Check fprintf return values rather than ferror

master
C. McEnroe 2021-01-10 22:00:40 -05:00
parent df280aa7d6
commit 0f7518226e
1 changed files with 6 additions and 6 deletions

12
log.c
View File

@ -109,15 +109,15 @@ void logFormat(uint id, const time_t *src, const char *format, ...) {
char buf[sizeof("0000-00-00T00:00:00+0000")]; char buf[sizeof("0000-00-00T00:00:00+0000")];
strftime(buf, sizeof(buf), "%FT%T%z", tm); strftime(buf, sizeof(buf), "%FT%T%z", tm);
fprintf(file, "[%s] ", buf); int n = fprintf(file, "[%s] ", buf);
if (ferror(file)) err(EX_IOERR, "%s", idNames[id]); if (n < 0) err(EX_IOERR, "%s", idNames[id]);
va_list ap; va_list ap;
va_start(ap, format); va_start(ap, format);
vfprintf(file, format, ap); n = vfprintf(file, format, ap);
va_end(ap); va_end(ap);
if (ferror(file)) err(EX_IOERR, "%s", idNames[id]); if (n < 0) err(EX_IOERR, "%s", idNames[id]);
fprintf(file, "\n"); n = fprintf(file, "\n");
if (ferror(file)) err(EX_IOERR, "%s", idNames[id]); if (n < 0) err(EX_IOERR, "%s", idNames[id]);
} }