[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: commit: ldap/libraries/liblber io.c

Howard Chu writes:
> What are you talking about, re: spurious error codes? System calls
> only set errno when they fail.

No.  From POSIX, IEEE Std 1003.1 of 2004, susv3/functions/errno.html:
   "The value of errno should only be examined when it is indicated to
   be valid by a function's return value. (...)  The setting of errno
   after a successful call to a function is unspecified unless the
   description of that function specifies that errno shall not be
As for non-POSIX, I have no idea.

The C standard is a bit gentler for its own functions.  From C99 7.5p3:
     "The value of errno may be set to nonzero by a library function
     call whether or not there is an error, provided the use of errno is
     not documented in the description of the function in this
     International Standard."
Thus e.g. strtol() cannot set a spurious errno because its description
says when to set errno = ERANGE.