This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] getlogin_r: return early when linux sentinel value is set
- From: Andreas Schwab <schwab at linux-m68k dot org>
- To: Jesse Hathaway <jesse at mbuki-mvuki dot org>
- Cc: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>, libc-alpha at sourceware dot org
- Date: Tue, 20 Mar 2018 19:30:23 +0100
- Subject: Re: [PATCH] getlogin_r: return early when linux sentinel value is set
- References: <CANSNSoWLXfsYq6kP0niyP8r25S=S1uTKN=+46xnC_SPLBmKXhQ@mail.gmail.com> <73b04097-ef36-b597-4f7c-2e73c6eb9fa3@linaro.org> <CANSNSoVxHOAM9XZx5ghighXLmXQzSvBfy4xp_FU8=_+U2ZXk8Q@mail.gmail.com>
On Mär 20 2018, Jesse Hathaway <jesse@mbuki-mvuki.org> wrote:
>> Also,
>> __getlogin_r_loginuid should set errno itself as for ERANGE instead
>> of just return its value (errno won't be set in this case and I think
>> it got it wrong for ENOMEM in this case).
>
> Would you be so kind as to explain this a little more to someone with
> very little C experience. I returned the errno value because the
> comment on the function indicates that is what the caller expects:
>
> /* Try to determine login name from /proc/self/loginuid and return 0
> if successful. If /proc/self/loginuid cannot be read return -1.
> Otherwise return the error number. */
>
> and getlogin when it calls __getlogin_r_loginuid, only checks the
> return value, and not the errno value
Depends on whether you want the linux __getlogin_r to fall back to the
generic __getlogin_r.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."