Bug 11959 - fwrite must not be declared with the warn_unused_result attribute
Summary: fwrite must not be declared with the warn_unused_result attribute
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: stdio (show other bugs)
Version: 2.13
: P2 normal
Target Milestone: ---
Assignee: Ulrich Drepper
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-30 20:29 UTC by jim@meyering.net
Modified: 2014-06-30 08:09 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments
remove fwrite's __wur attribute (667 bytes, patch)
2010-08-30 20:32 UTC, jim@meyering.net
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description jim@meyering.net 2010-08-30 20:29:38 UTC
The use of the warn_unused_result attribute in the declaration of fwrite is
undesirable, since it is perfectly legitimate to use fwrite without inspecting
its return value.  In that case, one can still detect failure via ferror.
That libc declares fwrite with this attribute causes inordinate trouble for
those who try to avoid gcc warnings about this attribute.

Patch below.
Comment 1 jim@meyering.net 2010-08-30 20:32:58 UTC
Created attachment 4956 [details]
remove fwrite's __wur attribute
Comment 2 Eric Blake 2010-08-30 20:46:01 UTC
This is particularly true since fputc is declared without __wur - consistency
demands that both or neither should have the attribute, and I strongly favor
neither based on the number of bug reports that have been falsely attributed to
gnulib as a result of glibc's header markup on fwrite.  For example:
http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/22751
Comment 3 Eric Blake 2010-08-30 21:11:04 UTC
See also this gcc bug:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25509
where the suggested hammer is to completely disable ALL warn_unused_result
checking in order to silence spurious warnings for fwrite().  I'd rather remove
the __wur from fwrite than turn off what would otherwise be a useful gcc feature
for functions where warning really does make sense.
Comment 4 Andreas Jaeger 2012-04-11 19:04:35 UTC
Thanks, your patch has been added to git.
Comment 5 Jackie Rosen 2014-02-16 19:42:48 UTC Comment hidden (spam)