From 9b9d8e479301106c9d6db74061fbd224958f810d Mon Sep 17 00:00:00 2001 From: michael Date: Tue, 4 Jun 2013 12:53:18 +0000 Subject: - motd.c:motd_cache(): do the stat() before fopen() + improve error reporting in case stat() failed git-svn-id: svn://svn.ircd-hybrid.org/svnroot/ircd-hybrid/branches/8.1.x@2191 82007160-df01-0410-b94d-b575c5fd34c7 --- src/motd.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/motd.c b/src/motd.c index 889d04e..21218e3 100644 --- a/src/motd.c +++ b/src/motd.c @@ -126,18 +126,19 @@ motd_cache(struct Motd *motd) } } - /* gotta read in the file, now */ - if ((file = fopen(motd->path, "r")) == NULL) + /* need the file's modification time */ + if (stat(motd->path, &sb) == -1) { - ilog(LOG_TYPE_IRCD, "Couldn't open \"%s\": %s", motd->path, + ilog(LOG_TYPE_IRCD, "Couldn't stat \"%s\": %s", motd->path, strerror(errno)); return 0; } - /* need the file's modification time */ - if (stat(motd->path, &sb) == -1) + /* gotta read in the file, now */ + if ((file = fopen(motd->path, "r")) == NULL) { - fclose(file); + ilog(LOG_TYPE_IRCD, "Couldn't open \"%s\": %s", motd->path, + strerror(errno)); return 0; } -- cgit