[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Switch on compiler hardening defaults

On Sun, Nov 01, 2009 at 08:10:44PM +0100, Samuel Thibault wrote:
> Ben Hutchings, le Sun 01 Nov 2009 19:06:59 +0000, a écrit :
> > On Sun, 2009-11-01 at 19:53 +0100, Matthias Klose wrote:
> > > there are some functions in glibc which are questionably declared with the "warn 
> > > about unused result" attribute (fwrite*).  This seems to force a programming 
> > > style which not everybody agrees with (having to check the return value after 
> > > each operation instead of checking errno later).
> > In general you cannot rely on checking errno because it is not defined
> > whether a successful operation clears it.
> But you can clear it by hand before calling them.

No, you can't. The value of errno is only defined after a failed call.
It is undefined after a sucessfull call. You can see it as a special
return value.


It is a human characteristic to love little animals, especially if
they're attractive in some way.
		-- McCoy, "The Trouble with Tribbles", stardate 4525.6

Reply to: