diff options
author | June McEnroe <june@causal.agency> | 2021-01-10 22:00:40 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2021-01-10 22:00:40 -0500 |
commit | 0f7518226e64112794a780dba03dc47e894fa451 (patch) | |
tree | cac59f2226323b7954da917c594339ce0e5f63aa /log.c | |
parent | Sandbox with unveil(2) on OpenBSD in restricted mode (diff) | |
download | catgirl-0f7518226e64112794a780dba03dc47e894fa451.tar.gz catgirl-0f7518226e64112794a780dba03dc47e894fa451.zip |
Check fprintf return values rather than ferror
Diffstat (limited to 'log.c')
-rw-r--r-- | log.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/log.c b/log.c index c114c41..11edb52 100644 --- a/log.c +++ b/log.c @@ -109,15 +109,15 @@ void logFormat(uint id, const time_t *src, const char *format, ...) { char buf[sizeof("0000-00-00T00:00:00+0000")]; strftime(buf, sizeof(buf), "%FT%T%z", tm); - fprintf(file, "[%s] ", buf); - if (ferror(file)) err(EX_IOERR, "%s", idNames[id]); + int n = fprintf(file, "[%s] ", buf); + if (n < 0) err(EX_IOERR, "%s", idNames[id]); va_list ap; va_start(ap, format); - vfprintf(file, format, ap); + n = vfprintf(file, format, 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"); - if (ferror(file)) err(EX_IOERR, "%s", idNames[id]); + n = fprintf(file, "\n"); + if (n < 0) err(EX_IOERR, "%s", idNames[id]); } |