POSIX prohibits any library function from setting errno to 0.
Correct my previous commit and add a comment to the manpage indicating that the user must set errno to 0 if they wish to distinguish "no such user" from "error". Pointed out by: Jacques Vidrine (nectar@)
This commit is contained in:
parent
3030b19f2c
commit
5edb850fbe
@ -185,9 +185,13 @@ return a valid pointer to a passwd structure on success
|
||||
or
|
||||
.Dv NULL
|
||||
if the entry is not found or if an error occurs.
|
||||
In the latter case,
|
||||
If an error does occur,
|
||||
.Va errno
|
||||
will be set.
|
||||
Note that programs must explicitly set
|
||||
.Va errno
|
||||
to zero before calling any of these functions if they need to
|
||||
distinguish between a non-existent entry and an error.
|
||||
The functions
|
||||
.Fn getpwent_r ,
|
||||
.Fn getpwnam_r ,
|
||||
|
@ -388,7 +388,7 @@ getpw(int (*fn)(union key, struct passwd *, char *, size_t, struct passwd **),
|
||||
return (NULL);
|
||||
}
|
||||
} while (res == NULL && rv == ERANGE);
|
||||
if (res == NULL)
|
||||
if (rv != 0)
|
||||
errno = rv;
|
||||
return (res);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user