diff options
author | Ulrich Drepper <drepper@redhat.com> | 2006-04-09 02:45:24 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2006-04-09 02:45:24 +0000 |
commit | ab9a9ff8a1db6e91ce2461069c709e68bd82d8eb (patch) | |
tree | e38d1cb8196af19131b1419b04025aed5c04ba03 /nis/nss_nis/nis-initgroups.c | |
parent | 7960f2a7040874c63196657fa25d6ddda778cc67 (diff) | |
download | glibc-ab9a9ff8a1db6e91ce2461069c709e68bd82d8eb.tar.gz glibc-ab9a9ff8a1db6e91ce2461069c709e68bd82d8eb.tar.xz glibc-ab9a9ff8a1db6e91ce2461069c709e68bd82d8eb.zip |
* nis/nss_nis/nis-alias.c: Optimize use of yperr2nss. Avoid calling
it for YPERR_SUCCESS. Minor cleanups. Add __builtin_expect. * nis/nss_nis/nis-ethers.c: Likewise. * nis/nss_nis/nis-grp.c: Likewise. * nis/nss_nis/nis-hosts.c: Likewise. * nis/nss_nis/nis-initgroups.c: Likewise. * nis/nss_nis/nis-netgrp.c: Likewise. * nis/nss_nis/nis-network.c: Likewise. * nis/nss_nis/nis-proto.c: Likewise. * nis/nss_nis/nis-publickey.c: Likewise. * nis/nss_nis/nis-pwd.c: Likewise. * nis/nss_nis/nis-rpc.c: Likewise. * nis/nss_nis/nis-service.c: Likewise. * nis/nss_nis/nis-spwd.c: Likewise.
Diffstat (limited to 'nis/nss_nis/nis-initgroups.c')
-rw-r--r-- | nis/nss_nis/nis-initgroups.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/nis/nss_nis/nis-initgroups.c b/nis/nss_nis/nis-initgroups.c index 33a9662b4c..863ac5405f 100644 --- a/nis/nss_nis/nis-initgroups.c +++ b/nis/nss_nis/nis-initgroups.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998-2000, 2002, 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 1998-2000,2002,2003,2004,2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk <kukuk@suse.de>, 1998. @@ -99,25 +99,23 @@ static enum nss_status internal_getgrent_r (struct group *grp, char *buffer, size_t buflen, int *errnop, intern_t *intern) { - struct parser_data *data = (void *) buffer; - int parse_res; - char *p; - if (intern->start == NULL) return NSS_STATUS_NOTFOUND; /* Get the next entry until we found a correct one. */ + int parse_res; do { if (intern->next == NULL) return NSS_STATUS_NOTFOUND; - p = strncpy (buffer, intern->next->val, buflen); + char *p = strncpy (buffer, intern->next->val, buflen); while (isspace (*p)) ++p; - parse_res = _nss_files_parse_grent (p, grp, data, buflen, errnop); - if (parse_res == -1) + parse_res = _nss_files_parse_grent (p, grp, (void *) buffer, buflen, + errnop); + if (__builtin_expect (parse_res == -1, 0)) return NSS_STATUS_TRYAGAIN; intern->next = intern->next->next; } @@ -166,13 +164,12 @@ initgroups_netid (uid_t uid, gid_t group, long int *start, long int *size, ssize_t keylen = snprintf (key, sizeof (key), "unix.%lu@%s", (unsigned long int) uid, domainname); - enum nss_status retval; char *result; int reslen; - retval = yperr2nss (yp_match (domainname, "netid.byname", key, keylen, - &result, &reslen)); - if (retval != NSS_STATUS_SUCCESS) - return retval; + int yperr = yp_match (domainname, "netid.byname", key, keylen, &result, + &reslen); + if (__builtin_expect (yperr != YPERR_SUCCESS, 0)) + return yperr2nss (yperr); /* Parse the result: following the colon is a comma separated list of group IDs. */ @@ -207,7 +204,6 @@ initgroups_netid (uid_t uid, gid_t group, long int *start, long int *size, if (*start == *size) { /* Need a bigger buffer. */ - gid_t *newgroups; long int newsize; if (limit > 0 && *size == limit) @@ -219,7 +215,7 @@ initgroups_netid (uid_t uid, gid_t group, long int *start, long int *size, else newsize = MIN (limit, 2 * *size); - newgroups = realloc (groups, newsize * sizeof (*groups)); + gid_t *newgroups = realloc (groups, newsize * sizeof (*groups)); if (newgroups == NULL) goto errout; *groupsp = groups = newgroups; |