Warnings from fwrite() in git head - Mailing list pgsql-hackers
| From | Bruce Momjian |
|---|---|
| Subject | Warnings from fwrite() in git head |
| Date | |
| Msg-id | 20121008155851.GD7460@momjian.us Whole thread Raw |
| Responses |
Re: Warnings from fwrite() in git head
Re: Warnings from fwrite() in git head |
| List | pgsql-hackers |
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_resultzic.c:1514: warning:
ignoringreturn value of ‘fwrite’, declared with attribute warn_unused_resultzic.c:1752: warning: ignoring return value
of‘fwrite’, declared with attribute warn_unused_resultzic.c:1753: warning: ignoring return value of ‘fwrite’, declared
withattribute warn_unused_resultzic.c:1754: warning: ignoring return value of ‘fwrite’, declared with attribute
warn_unused_resultzic.c:1755:warning: ignoring return value of ‘fwrite’, declared with attribute
warn_unused_resultzic.c:1756:warning: ignoring return value of ‘fwrite’, declared with attribute
warn_unused_resultzic.c:1757:warning: ignoring return value of ‘fwrite’, declared with attribute
warn_unused_resultzic.c:1758:warning: ignoring return value of ‘fwrite’, declared with attribute
warn_unused_resultzic.c:1759:warning: ignoring return value of ‘fwrite’, declared with attribute
warn_unused_resultzic.c:1760:warning: ignoring return value of ‘fwrite’, declared with attribute
warn_unused_resultzic.c:1772:warning: ignoring return value of ‘fwrite’, declared with attribute
warn_unused_resultzic.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
withwarn_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
newlineto log file */ if (strchr(message, '\r') != NULL) rc = fwrite("\n", 1, 1, log_opts.internal);
(void) rc;
which was added by this commit:
commit b98fd52a5516365e4a90d523cfed906eb7b3e67aAuthor: Tom Lane <tgl@sss.pgh.pa.us>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
comparablecode in elog.c, we may as well do it here.
Should we give zic.c the same treatment?
-- Bruce Momjian <bruce@momjian.us> http://momjian.us EnterpriseDB
http://enterprisedb.com
+ It's impossible for everything to be true. +
pgsql-hackers by date: