On 2014/02/18 18:25, Ingo Schwarze wrote:
> 
> Yes, i guess that behaviour would conform to POSIX.  However, the way
> i read it, it is unspecified whether getpwnam_r() sets errno in
> addition to returning the error code.
> 
> So we have two options:
> 
>  a) leave the errno setting inside getpwnam_r(), as it is now
> 
>      - advantage: less code changes
>      - advantage: getpnam_r() also sets errno, as in the past
> 
>  b) move the errno setting to getpwnam() as proposed by kettenis@,
>     which would then look like (pseudocode):
> 
>       getpwnam(...) {
>               ret = getpwnam_r(...);
>               if (ret) {
>                       pw = NULL;
>                       errno = ret;
>               } /* else, pw may or may not be NULL */
>               return (pw);
>       }
> 
>       - disadvantage: more code changes in getpwnam_r()
>       - disadvantage: behaviour of getpwnam_r() changes
>       - advantage: code becomes simpler
>       - advantage: *maybe* a bit closer to POSIX spirit
> 
> I'd slightly favour option b), but could live with a), too.

The getgr* functions use a different method again, they have a separate
_gs function to do the actual lookup which is called by both the _r and
standard functions..

getgrgid_r etc. do preserve the state of errno, whether or not the call
was successful.

Reply via email to