[tz] [PROPOSED PATCH 2/3] zdump: check more consistently for output errors
Paul Eggert
eggert at cs.ucla.edu
Thu Aug 21 01:27:58 UTC 2014
That can be slightly simplified by the attached further patch, since
zdump's close_file function always has a null 2nd argument.
-------------- next part --------------
diff --git a/zdump.c b/zdump.c
index e9a42fd..a9d3831 100644
--- a/zdump.c
+++ b/zdump.c
@@ -309,14 +309,12 @@ abbrok(const char *const abbrp, const char *const zone)
}
static void
-close_file(FILE *stream, char const *name)
+close_file(FILE *stream)
{
char const *e = (ferror(stream) ? _("I/O error")
: fclose(stream) != 0 ? strerror(errno) : NULL);
if (e) {
fprintf(stderr, "%s: ", progname);
- if (name)
- fprintf(stderr, "%s: ", name);
fprintf(stderr, "%s\n", e);
exit(EXIT_FAILURE);
}
@@ -331,7 +329,7 @@ _("%s: usage: %s [--version] [--help] [-{vV}] [-{ct} [lo,]hi] zonename ...\n"
"Report bugs to %s.\n"),
progname, progname, REPORT_BUGS_TO);
if (status == EXIT_SUCCESS)
- close_file(stream, NULL);
+ close_file(stream);
exit(status);
}
@@ -525,7 +523,7 @@ main(int argc, char *argv[])
show(argv[i], t, TRUE);
}
}
- close_file(stdout, NULL);
+ close_file(stdout);
if (errout && (ferror(stderr) || fclose(stderr) != 0))
return EXIT_FAILURE;
return EXIT_SUCCESS;
More information about the tz
mailing list