summaryrefslogtreecommitdiffstats
path: root/hwclock
diff options
context:
space:
mode:
authorSami Kerola2012-04-04 19:59:35 +0200
committerSami Kerola2012-04-04 19:59:35 +0200
commitdb116df726f640699e500590d50200b9df6115a2 (patch)
tree098e93a0192da84a1b3e841803c426f58a237db2 /hwclock
parentlogin-utils: verify writing to streams was successful (diff)
downloadkernel-qcow2-util-linux-db116df726f640699e500590d50200b9df6115a2.tar.gz
kernel-qcow2-util-linux-db116df726f640699e500590d50200b9df6115a2.tar.xz
kernel-qcow2-util-linux-db116df726f640699e500590d50200b9df6115a2.zip
hwclock: verify writing to streams was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'hwclock')
-rw-r--r--hwclock/hwclock.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/hwclock/hwclock.c b/hwclock/hwclock.c
index 4da2dca79..3cedd1de3 100644
--- a/hwclock/hwclock.c
+++ b/hwclock/hwclock.c
@@ -72,6 +72,7 @@
#include "c.h"
#include "clock.h"
+#include "closestream.h"
#include "nls.h"
#include "pathnames.h"
#include "strutils.h"
@@ -164,7 +165,8 @@ static void write_date_to_file(struct tm *tm)
if ((fp = fopen(_PATH_LASTDATE, "w"))) {
fprintf(fp, "%02d.%02d.%04d\n", tm->tm_mday, tm->tm_mon + 1,
tm->tm_year + 1900);
- fclose(fp);
+ if (close_stream(fp) != 0)
+ warn(_("cannot write %s"), _PATH_LASTDATE);
} else
warn(_("cannot write %s"), _PATH_LASTDATE);
}
@@ -1026,7 +1028,7 @@ static void save_adjtime(const struct adjtime adjtime, const bool testing)
adj_file_name);
err = 1;
}
- if (fclose(adjfile) < 0) {
+ if (close_stream(adjfile) != 0) {
warn(_
("Could not update file with the clock adjustment "
"parameters (%s) in it"),
@@ -1521,6 +1523,7 @@ int main(int argc, char **argv)
#endif
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
+ atexit(close_stdout);
/* Set option defaults */
show = set = systohc = hctosys = systz = adjust = noadjfile = predict =