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/getspnam.c | |
parent | ea3abe244d9ad2ec59d00b29152fc457571d2d37 (diff) |
Fixup errno handling
-Erik
Diffstat (limited to 'libc/pwd_grp/getspnam.c')
-rw-r--r-- | libc/pwd_grp/getspnam.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/libc/pwd_grp/getspnam.c b/libc/pwd_grp/getspnam.c index 9d578f09a..6f3d3a128 100644 --- a/libc/pwd_grp/getspnam.c +++ b/libc/pwd_grp/getspnam.c @@ -40,34 +40,35 @@ int getspnam_r (const char *name, struct spwd *spwd, int spwd_fd; if (name == NULL) { - __set_errno(EINVAL); - return -1; + return EINVAL; } if ((spwd_fd = open(_PATH_SHADOW, O_RDONLY)) < 0) - return -1; + return errno; - while (__getspent_r(spwd, buff, buflen, spwd_fd) != -1) + while (__getspent_r(spwd, buff, buflen, spwd_fd) == 0) if (!strcmp(spwd->sp_namp, name)) { close(spwd_fd); return 0; } close(spwd_fd); - return -1; + return EINVAL; } struct spwd *getspnam(const char *name) { + int ret; static char line_buff[PWD_BUFFER_SIZE]; static struct spwd spwd; LOCK; - if (getspnam_r(name, &spwd, line_buff, sizeof(line_buff), NULL) != -1) { + if ((ret=getspnam_r(name, &spwd, line_buff, sizeof(line_buff), NULL)) == 0) { UNLOCK; return &spwd; } UNLOCK; + __set_errno(ret); return NULL; } |