I am seeing the following warnings in git head from zic.c:
zic.c:1505: warning: ignoring return value of ‘fwrite’, declared with
attribute warn_unused_result
zic.c:1514: warning: ignoring return value of ‘fwrite’, declared with
attribute warn_unused_result
zic.c:1752: warning: ignoring return value of ‘fwrite’, declared with
attribute warn_unused_result
zic.c:1753: warning: ignoring return value of ‘fwrite’, declared with
attribute warn_unused_result
zic.c:1754: warning: ignoring return value of ‘fwrite’, declared with
attribute warn_unused_result
zic.c:1755: warning: ignoring return value of ‘fwrite’, declared with
attribute warn_unused_result
zic.c:1756: warning: ignoring return value of ‘fwrite’, declared with
attribute warn_unused_result
zic.c:1757: warning: ignoring return value of ‘fwrite’, declared with
attribute warn_unused_result
zic.c:1758: warning: ignoring return value of ‘fwrite’, declared with
attribute warn_unused_result
zic.c:1759: warning: ignoring return value of ‘fwrite’, declared with
attribute warn_unused_result
zic.c:1760: warning: ignoring return value of ‘fwrite’, declared with
attribute warn_unused_result
zic.c:1772: warning: ignoring return value of ‘fwrite’, declared with
attribute warn_unused_result
zic.c:1785: warning: ignoring return value of ‘fwrite’, declared with
attribute warn_unused_result
Here is the first C line that generated the warning message:
(void) fwrite((void *) buf, (size_t) sizeof buf, (size_t) 1, fp);
Seems casting to void is not enough. Not sure why the error just
started appearing for me last week. I don't see any recent gcc updates.
This is gcc version 4.4.5-8 on Debian Squeeze.
However, the only place I see fwrite() cast to void is in zic.c, and I
see this code in pg_upgrade/utils.c:
/*
* There's nothing much we can do about it if fwrite fails, but some
* platforms declare fwrite with warn_unused_result. Do a little
* dance with casting to void to shut up the compiler in such cases.
*/
size_t rc;
rc = fwrite(message, strlen(message), 1, log_opts.internal);
/* if we are using OVERWRITE_MESSAGE, add newline to log file */
if (strchr(message, '\r') != NULL)
rc = fwrite("\n", 1, 1, log_opts.internal);
(void) rc;
which was added by this commit:
commit b98fd52a5516365e4a90d523cfed906eb7b3e67a
Author: Tom Lane <[email protected]>
Date: Wed Sep 5 14:36:47 2012 -0400
Silence -Wunused-result warning in contrib/pg_upgrade.
This is just neatnik-ism, but since we do it for comparable code in
elog.c,
we may as well do it here.
Should we give zic.c the same treatment?
--
Bruce Momjian <[email protected]> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers