[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: failure to build due to ignoring fwrite() result
From: |
Eric Blake |
Subject: |
Re: failure to build due to ignoring fwrite() result |
Date: |
Mon, 30 Aug 2010 14:04:29 -0600 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.8) Gecko/20100806 Fedora/3.1.2-1.fc13 Mnenhy/0.8.3 Thunderbird/3.1.2 |
On 08/30/2010 01:52 PM, Jim Meyering wrote:
fwrite is an exception in that its value really is ignorable,
if you know what you're doing. Hence, the warn_unused_result
attribute on its declaration is the problem, not gcc, and not
the ignore-value module.
Agreed. Do we have an open bugzilla against glibc for this yet?
The solution here could be to make gnulib provide a better declaration of
fwrite: one without the offending attribute. Deprecating ignore-value or
somehow disabling all warn_unused_result attributes would be overkill --
no reason to throw the baby out with the bathwater.
In fact, I think that gnulib could do something like:
static inline int
rpl_fwrite(...)
{
return fwrite(...);
}
#define fwrite rpl_fwrite
to work around broken glibc headers.
In fact, I'm leaning towards the idea of doing that workaround only if
the close-out (or close-in) modules are in use, so that you still get
the warning if you aren't using the preferred gnulib idiom for making
ignored fwrites safe. That is, the gnulib idiom is that you add:
atexit(close_stdout);
to main(), as the guarantee that all possible code paths will safely
detect fwrite() and fflush() failures via ferror(), so that nowhere else
in the program needs to bother with the return values of intermediate
steps on FILE*.
--
Eric Blake address@hidden +1-801-349-2682
Libvirt virtualization library http://libvirt.org
- Re: failure to build due to ignoring fwrite() result, (continued)
Re: failure to build due to ignoring fwrite() result, Paul Eggert, 2010/08/30
- Re: failure to build due to ignoring fwrite() result, Ralf Wildenhues, 2010/08/30
- Re: failure to build due to ignoring fwrite() result, Jim Meyering, 2010/08/30
- Re: failure to build due to ignoring fwrite() result, Bruce Korb, 2010/08/30
- Re: failure to build due to ignoring fwrite() result, Eric Blake, 2010/08/30
- Re: failure to build due to ignoring fwrite() result, Eric Blake, 2010/08/30
- Re: failure to build due to ignoring fwrite() result, Jim Meyering, 2010/08/30
Re: failure to build due to ignoring fwrite() result,
Eric Blake <=
Re: failure to build due to ignoring fwrite() result, Paul Eggert, 2010/08/30
Re: failure to build due to ignoring fwrite() result, Eric Blake, 2010/08/30
Re: failure to build due to ignoring fwrite() result, Jim Meyering, 2010/08/30
Re: failure to build due to ignoring fwrite() result, Bruce Korb, 2010/08/30
Re: failure to build due to ignoring fwrite() result, Bruno Haible, 2010/08/30
Re: failure to build due to ignoring fwrite() result, Karl Berry, 2010/08/30
Re: failure to build due to ignoring fwrite() result, Paul Eggert, 2010/08/30
Re: failure to build due to ignoring fwrite() result, Bruno Haible, 2010/08/30
Re: failure to build due to ignoring fwrite() result, Bruce Korb, 2010/08/30
Re: failure to build due to ignoring fwrite() result, Paolo Bonzini, 2010/08/31