On Tue, Oct 28, 2003 at 04:17:53PM -0500, Wakko Warner wrote:
>> It does not override the errno. It *pre-sets* the errno to zero,
>> because strtoul does not set it in the case when it succeeds.
>
> Actually, does any system call set errno if it succeeds? I've read
> some man pages on linux calls and from what I can tell they only set
> errno on error.
>
Hang on, no system call/library routine
should set errno if it succeeds. The
value returned indicates if there was an error.
IF an error is indicated by the return
value then errno may be set.
You should never look at errno unless the value returned
by the system call indicated that it had an error.
From man 2 intro (solaris)
This section describes all of the system calls. Most of
these calls return one or more error conditions. An error
condition is indicated by an otherwise impossible return
value. This is almost always -1 or the null pointer; the
individual descriptions specify the details. An error
number is also made available in the external variable
errno, which is not cleared on successful calls, so it
should be tested only after an error has been indicated.
Regards,
pdg
--
See mail headers for contact information.