Mercurial > hg > octave-lyh > gnulib-hg
changeset 5896:311a31a595bb
(getlogin_r): Don't set errno to 0 on return.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Sat, 28 May 2005 06:11:39 +0000 |
parents | 1640ff3cd5f5 |
children | 535cb354305c |
files | lib/getlogin_r.c |
diffstat | 1 files changed, 8 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/getlogin_r.c +++ b/lib/getlogin_r.c @@ -44,8 +44,15 @@ errno = 0; n = getlogin (); + + /* A system function like getlogin_r is never supposed to set errno + to zero, so make sure errno is nonzero here. ENOENT is a + reasonable errno value if getlogin returns NULL. */ + if (!errno) + errno = ENOENT; + if (!n) - return errno ? errno : ENOENT; + return errno; nlen = strlen (n); if (size <= nlen) return ERANGE;