From 2e55dec21f3310e6868689fc1f4c4074ea3a35bb Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Fri, 27 Jun 2003 10:19:29 +0000 Subject: Fixup errno handling -Erik --- libc/pwd_grp/spent.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'libc/pwd_grp/spent.c') diff --git a/libc/pwd_grp/spent.c b/libc/pwd_grp/spent.c index d1b8ca07c..b281072f4 100644 --- a/libc/pwd_grp/spent.c +++ b/libc/pwd_grp/spent.c @@ -64,26 +64,29 @@ void endspent(void) int getspent_r (struct spwd *spwd, char *buff, size_t buflen, struct spwd **crap) { + int ret; LOCK; - if (spwd_fd != -1 && __getspent_r(spwd, buff, buflen, spwd_fd) != -1) { + if (spwd_fd != -1 && (ret=__getspent_r(spwd, buff, buflen, spwd_fd)) == 0) { UNLOCK; return 0; } UNLOCK; - return -1; + return ret; } struct spwd *getspent(void) { + int ret; static char line_buff[PWD_BUFFER_SIZE]; static struct spwd spwd; LOCK; - if (getspent_r(&spwd, line_buff, sizeof(line_buff), NULL) != -1) { + if ((ret=getspent_r(&spwd, line_buff, sizeof(line_buff), NULL)) == 0) { UNLOCK; return &spwd; } UNLOCK; + __set_errno(ret); return NULL; } -- cgit v1.2.3