From 119ae5514681e42839f83a4993021a222ec45daa Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 28 Oct 2009 10:24:09 +0100 Subject: [PATCH] fprintftime: avoid a warning about ignored fwrite return value * lib/strftime.c [FPRINTFTIME]: Include "ignore-value.h". (cpy) [FPRINTFTIME]: Ignore fwrite failure, even though technically, that is unsafe. * modules/fprintftime (Depends-on): Add ignore-value. --- ChangeLog | 6 ++++++ lib/strftime.c | 11 ++++++++++- modules/fprintftime | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 54a79e86e..ed3e6bd12 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2009-10-28 Jim Meyering + fprintftime: avoid a warning about ignored fwrite return value + * lib/strftime.c [FPRINTFTIME]: Include "ignore-value.h". + (cpy) [FPRINTFTIME]: Ignore fwrite failure, even though technically, + that is unsafe. + * modules/fprintftime (Depends-on): Add ignore-value. + exclude: avoid an unwarranted warning * lib/exclude.c (excluded_file_name): Initialize "rc" before switch. diff --git a/lib/strftime.c b/lib/strftime.c index fff5d38ea..7f06d6fda 100644 --- a/lib/strftime.c +++ b/lib/strftime.c @@ -31,6 +31,7 @@ # else # include "strftime.h" # endif +# include "ignore-value.h" #endif #include @@ -203,7 +204,15 @@ extern char *tzname[]; else if (to_uppcase) \ fwrite_uppcase (p, (s), _n); \ else \ - fwrite ((s), _n, 1, p)) + { \ + /* We are ignoring the value of fwrite here, in spite of the \ + fact that technically, that may not be valid: the fwrite \ + specification in POSIX 2008 defers to that of fputc, which \ + is intended to be consistent with the one from ISO C, \ + which permits failure due to ENOMEM *without* setting the \ + stream's error indicator. */ \ + ignore_value (fwrite ((s), _n, 1, p))); \ + } #else # define cpy(n, s) \ add ((n), \ diff --git a/modules/fprintftime b/modules/fprintftime index 4333a3137..87598eff1 100644 --- a/modules/fprintftime +++ b/modules/fprintftime @@ -7,6 +7,7 @@ lib/fprintftime.c m4/fprintftime.m4 Depends-on: +ignore-value strftime configure.ac: -- 2.11.0