From c617db9065afa51100199d9ac4561feee4279291 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Wed, 12 Jun 2002 23:27:00 +0000 Subject: Silence warnings, clean things up. -Erik --- libc/pwd_grp/getpwuid.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'libc/pwd_grp/getpwuid.c') diff --git a/libc/pwd_grp/getpwuid.c b/libc/pwd_grp/getpwuid.c index 4d6d60ee8..ff3637abe 100644 --- a/libc/pwd_grp/getpwuid.c +++ b/libc/pwd_grp/getpwuid.c @@ -21,37 +21,34 @@ #include #include #include -#include #include #include "config.h" -#define PWD_BUFFER_SIZE 256 - -/* file descriptor for the password file currently open */ -static char line_buff[PWD_BUFFER_SIZE]; -static struct passwd pwd; - int getpwuid_r (uid_t uid, struct passwd *password, char *buff, size_t buflen, struct passwd **crap) { - int passwd_fd; + int passwd_fd; - if ((passwd_fd = open(_PATH_PASSWD, O_RDONLY)) < 0) - return -1; + if ((passwd_fd = open(_PATH_PASSWD, O_RDONLY)) < 0) + return -1; - while (__getpwent_r(password, buff, buflen, passwd_fd) != -1) - if (password->pw_uid == uid) { - close(passwd_fd); - return 0; - } + while (__getpwent_r(password, buff, buflen, passwd_fd) != -1) + if (password->pw_uid == uid) { + close(passwd_fd); + return 0; + } - close(passwd_fd); - return -1; + close(passwd_fd); + return -1; } struct passwd *getpwuid(uid_t uid) { - if (getpwuid_r(uid, &pwd, line_buff, PWD_BUFFER_SIZE, NULL) != -1) { + /* file descriptor for the password file currently open */ + static char line_buff[PWD_BUFFER_SIZE]; + static struct passwd pwd; + + if (getpwuid_r(uid, &pwd, line_buff, sizeof(line_buff), NULL) != -1) { return &pwd; } return NULL; -- cgit v1.2.3