diff options
author | Eric Andersen <andersen@codepoet.org> | 2003-06-27 10:19:29 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2003-06-27 10:19:29 +0000 |
commit | 2e55dec21f3310e6868689fc1f4c4074ea3a35bb (patch) | |
tree | 77479d130301a86ca26009cf712dc0ebe3ddd340 /libc/pwd_grp/pwent.c | |
parent | ea3abe244d9ad2ec59d00b29152fc457571d2d37 (diff) |
Fixup errno handling
-Erik
Diffstat (limited to 'libc/pwd_grp/pwent.c')
-rw-r--r-- | libc/pwd_grp/pwent.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/libc/pwd_grp/pwent.c b/libc/pwd_grp/pwent.c index f79be7f33..f70a6e378 100644 --- a/libc/pwd_grp/pwent.c +++ b/libc/pwd_grp/pwent.c @@ -67,23 +67,27 @@ void endpwent(void) int getpwent_r (struct passwd *password, char *buff, size_t buflen, struct passwd **crap) { + int ret; LOCK; - if (pw_fd != -1 && __getpwent_r(password, buff, buflen, pw_fd) != -1) { + if (pw_fd != -1 && (ret=__getpwent_r(password, buff, buflen, pw_fd)) == 0) { UNLOCK; return 0; } UNLOCK; - return -1; + __set_errno(ret); + return ret; } struct passwd *getpwent(void) { + int ret; static char line_buff[PWD_BUFFER_SIZE]; static struct passwd pwd; - if (getpwent_r(&pwd, line_buff, sizeof(line_buff), NULL) != -1) { + if ((ret=getpwent_r(&pwd, line_buff, sizeof(line_buff), NULL)) == 0) { return &pwd; } + __set_errno(ret); return NULL; } |