> Date: Tue, 18 Feb 2014 17:01:24 +0100
> From: Ingo Schwarze <[email protected]>
>
> > So: we need to
> >  - clear errno in the success and "no match" cases,
> 
> This is incorrect and shouldn't be done.
> When no error occurs, errno has to stay as it is.

Indeed.  POSIX explicitly says:

  "No function in this volume of POSIX.1-2008 shall set errno to zero."

The standard is slightly ambiguous on what getpwnam_r() should do, but
the way I read it, it should not touch errno at all.  So it should
save errno at the start of the function, and restore it just before
return.

Reply via email to