[PATCH 0/3] Fix wrong assumption about errno

Carlos O'Donell carlos@redhat.com
Fri Dec 22 16:57:00 GMT 2017


On 12/22/2017 08:39 AM, Zack Weinberg wrote:
> Well, Carlos is right that it is _usually_ wrong to check errno to
> decide if something failed.  Maybe something in the middle:
> 
> | The initial value of @code{errno} at program startup is zero.  In many
> | cases, when a library function encounters an error, it will set
> | @code{errno} to a non-zero value to indicate what specific error
> | condition occurred.  The documentation for each function lists the
> | error conditions that are possible for that function.  Not all library
> | functions use this mechanism; some return an error code directly,
> | instead.
> |
> | @strong{Warning:} Many library functions may set @code{errno} to some
> | meaningless non-zero value even if they did not encounter any errors,
> | and even if they return error codes directly.  Therefore, it is
> | usually incorrect to check @emph{whether} an error occurred by
> | inspecting the value of @code{errno}.  The proper way to check for
> | error is documented for each function.
 
Zack, This language is better than what we have, thank you for that.

Aurelien, Are you able to merge this in to the manual?

-- 
Cheers,
Carlos.



More information about the Libc-alpha mailing list