From 04b5339fc736b776e9a9af30f4b55ade48203b39 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Mon, 17 Jun 2002 19:00:59 +0000 Subject: Shuffle the logic around a bit --- libc/pwd_grp/getgrgid.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'libc/pwd_grp/getgrgid.c') diff --git a/libc/pwd_grp/getgrgid.c b/libc/pwd_grp/getgrgid.c index 1eaed64c0..dc9176d39 100644 --- a/libc/pwd_grp/getgrgid.c +++ b/libc/pwd_grp/getgrgid.c @@ -26,18 +26,27 @@ struct group *getgrgid(const gid_t gid) { - struct group *group; - int grp_fd; + struct group *group; + int grp_fd; - if ((grp_fd = open(_PATH_GROUP, O_RDONLY)) < 0) - return NULL; + if ((grp_fd = open(_PATH_GROUP, O_RDONLY)) < 0) + return NULL; - while ((group = __getgrent(grp_fd)) != NULL) - if (group->gr_gid == gid) { - close(grp_fd); - return group; - } + while ((group = __getgrent(grp_fd)) != NULL) + if (group->gr_gid == gid) { + close(grp_fd); + return group; + } + + close(grp_fd); + return NULL; +} + +#if 0 +/* Search for an entry with a matching group ID. */ +int getgrgid_r (gid_t gid, struct group *resultbuf, char *buffer, + size_t buflen, struct group **result) +{ - close(grp_fd); - return NULL; } +#endif -- cgit v1.2.3