summaryrefslogtreecommitdiff
path: root/libc/pwd_grp/fgetpwent.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc/pwd_grp/fgetpwent.c')
-rw-r--r--libc/pwd_grp/fgetpwent.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/libc/pwd_grp/fgetpwent.c b/libc/pwd_grp/fgetpwent.c
index 5ca08d3b0..8917c29d0 100644
--- a/libc/pwd_grp/fgetpwent.c
+++ b/libc/pwd_grp/fgetpwent.c
@@ -37,22 +37,23 @@ int fgetpwent_r (FILE *file, struct passwd *password,
char *buff, size_t buflen, struct passwd **crap)
{
if (file == NULL) {
- __set_errno(EINTR);
- return -1;
+ return EINTR;
}
return(__getpwent_r(password, buff, buflen, fileno(file)));
}
struct passwd *fgetpwent(FILE * file)
{
+ int ret;
static char line_buff[PWD_BUFFER_SIZE];
static struct passwd pwd;
LOCK;
- if (fgetpwent_r(file, &pwd, line_buff, sizeof(line_buff), NULL) != -1) {
+ if ((ret=fgetpwent_r(file, &pwd, line_buff, sizeof(line_buff), NULL)) == 0) {
UNLOCK;
return &pwd;
}
UNLOCK;
+ __set_errno(ret);
return NULL;
}