aboutsummaryrefslogtreecommitdiff
path: root/nis
diff options
context:
space:
mode:
Diffstat (limited to 'nis')
-rw-r--r--nis/nss_nis/nis-alias.c52
-rw-r--r--nis/nss_nis/nis-ethers.c75
-rw-r--r--nis/nss_nis/nis-grp.c96
-rw-r--r--nis/nss_nis/nis-hosts.c122
-rw-r--r--nis/nss_nis/nis-initgroups.c26
-rw-r--r--nis/nss_nis/nis-netgrp.c12
-rw-r--r--nis/nss_nis/nis-network.c115
-rw-r--r--nis/nss_nis/nis-proto.c60
-rw-r--r--nis/nss_nis/nis-publickey.c75
-rw-r--r--nis/nss_nis/nis-pwd.c119
-rw-r--r--nis/nss_nis/nis-rpc.c55
-rw-r--r--nis/nss_nis/nis-service.c103
-rw-r--r--nis/nss_nis/nis-spwd.c64
13 files changed, 486 insertions, 488 deletions
diff --git a/nis/nss_nis/nis-alias.c b/nis/nss_nis/nis-alias.c
index 1da999be2f..9286e36ba6 100644
--- a/nis/nss_nis/nis-alias.c
+++ b/nis/nss_nis/nis-alias.c
@@ -125,52 +125,53 @@ internal_nis_getaliasent_r (struct aliasent *alias, char *buffer,
size_t buflen, int *errnop)
{
char *domain;
- char *result;
- int len;
- char *outkey;
- int keylen;
- char *p;
- int parse_res;
- if (yp_get_default_domain (&domain))
+ if (__builtin_expect (yp_get_default_domain (&domain), 0))
return NSS_STATUS_UNAVAIL;
alias->alias_local = 0;
/* Get the next entry until we found a correct one. */
+ int parse_res;
do
{
- enum nss_status retval;
+ char *result;
+ int len;
+ char *outkey;
+ int keylen;
+ int yperr;
if (new_start)
- retval = yperr2nss (yp_first (domain, "mail.aliases",
- &outkey, &keylen, &result, &len));
+ yperr = yp_first (domain, "mail.aliases", &outkey, &keylen, &result,
+ &len);
else
- retval = yperr2nss ( yp_next (domain, "mail.aliases", oldkey,
- oldkeylen, &outkey, &keylen,
- &result, &len));
- if (retval != NSS_STATUS_SUCCESS)
+ yperr = yp_next (domain, "mail.aliases", oldkey, oldkeylen, &outkey,
+ &keylen, &result, &len);
+
+ if (__builtin_expect (yperr != YPERR_SUCCESS, 0))
{
+ enum nss_status retval = yperr2nss (yperr);
+
if (retval == NSS_STATUS_TRYAGAIN)
*errnop = errno;
return retval;
}
- if ((size_t) (len + 1) > buflen)
+ if (__builtin_expect ((size_t) (len + 1) > buflen, 0))
{
free (result);
*errnop = ERANGE;
return NSS_STATUS_TRYAGAIN;
}
- p = strncpy (buffer, result, len);
+ char *p = strncpy (buffer, result, len);
buffer[len] = '\0';
while (isspace (*p))
++p;
free (result);
- parse_res = _nss_nis_parse_aliasent (outkey, p, alias, buffer, buflen,
- errnop);
- if (parse_res == -1)
+ parse_res = _nss_nis_parse_aliasent (outkey, p, alias, buffer,
+ buflen, errnop);
+ if (__builtin_expect (parse_res == -1, 0))
{
free (outkey);
*errnop = ERANGE;
@@ -216,7 +217,7 @@ _nss_nis_getaliasbyname_r (const char *name, struct aliasent *alias,
char name2[namlen + 1];
char *domain;
- if (yp_get_default_domain (&domain))
+ if (__builtin_expect (yp_get_default_domain (&domain), 0))
return NSS_STATUS_UNAVAIL;
/* Convert name to lowercase. */
@@ -227,17 +228,18 @@ _nss_nis_getaliasbyname_r (const char *name, struct aliasent *alias,
char *result;
int len;
- enum nss_status retval = yperr2nss (yp_match (domain, "mail.aliases", name2,
- namlen, &result, &len));
+ int yperr = yp_match (domain, "mail.aliases", name2, namlen, &result, &len);
- if (retval != NSS_STATUS_SUCCESS)
+ if (__builtin_expect (yperr != YPERR_SUCCESS, 0))
{
+ enum nss_status retval = yperr2nss (yperr);
+
if (retval == NSS_STATUS_TRYAGAIN)
*errnop = errno;
return retval;
}
- if ((size_t) (len + 1) > buflen)
+ if (__builtin_expect ((size_t) (len + 1) > buflen, 0))
{
free (result);
*errnop = ERANGE;
@@ -253,7 +255,7 @@ _nss_nis_getaliasbyname_r (const char *name, struct aliasent *alias,
alias->alias_local = 0;
int parse_res = _nss_nis_parse_aliasent (name, p, alias, buffer, buflen,
errnop);
- if (parse_res < 1)
+ if (__builtin_expect (parse_res < 1, 0))
{
if (parse_res == -1)
return NSS_STATUS_TRYAGAIN;
diff --git a/nis/nss_nis/nis-ethers.c b/nis/nss_nis/nis-ethers.c
index def4c22510..a3064282ab 100644
--- a/nis/nss_nis/nis-ethers.c
+++ b/nis/nss_nis/nis-ethers.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996-2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2003, 2004, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@suse.de>, 1996.
@@ -182,45 +182,46 @@ enum nss_status
_nss_nis_gethostton_r (const char *name, struct etherent *eth,
char *buffer, size_t buflen, int *errnop)
{
- struct parser_data *data = (void *) buffer;
- enum nss_status retval;
- char *domain, *result, *p;
- int len, parse_res;
-
if (name == NULL)
{
*errnop = EINVAL;
return NSS_STATUS_UNAVAIL;
}
- if (yp_get_default_domain (&domain))
+ char *domain;
+ if (__builtin_expect (yp_get_default_domain (&domain), 0))
return NSS_STATUS_UNAVAIL;
- retval = yperr2nss (yp_match (domain, "ethers.byname", name,
- strlen (name), &result, &len));
+ char *result;
+ int len;
+ int yperr = yp_match (domain, "ethers.byname", name, strlen (name), &result,
+ &len);
- if (retval != NSS_STATUS_SUCCESS)
+ if (__builtin_expect (yperr != YPERR_SUCCESS, 0))
{
+ enum nss_status retval = yperr2nss (yperr);
+
if (retval == NSS_STATUS_TRYAGAIN)
*errnop = errno;
return retval;
}
- if ((size_t) (len + 1) > buflen)
+ if (__builtin_expect ((size_t) (len + 1) > buflen, 0))
{
free (result);
*errnop = ERANGE;
return NSS_STATUS_TRYAGAIN;
}
- p = strncpy (buffer, result, len);
+ char *p = strncpy (buffer, result, len);
buffer[len] = '\0';
while (isspace (*p))
++p;
free (result);
- parse_res = _nss_files_parse_etherent (p, eth, data, buflen, errnop);
- if (parse_res < 1)
+ int parse_res = _nss_files_parse_etherent (p, eth, (void *) buffer, buflen,
+ errnop);
+ if (__builtin_expect (parse_res < 1, 0))
{
if (parse_res == -1)
return NSS_STATUS_TRYAGAIN;
@@ -234,54 +235,54 @@ enum nss_status
_nss_nis_getntohost_r (const struct ether_addr *addr, struct etherent *eth,
char *buffer, size_t buflen, int *errnop)
{
- struct parser_data *data = (void *) buffer;
- enum nss_status retval;
- char *domain, *result, *p;
- int len, nlen, parse_res;
- char buf[33];
-
if (addr == NULL)
{
*errnop = EINVAL;
return NSS_STATUS_UNAVAIL;
}
- if (yp_get_default_domain (&domain))
+ char *domain;
+ if (__builtin_expect (yp_get_default_domain (&domain), 0))
return NSS_STATUS_UNAVAIL;
- nlen = sprintf (buf, "%x:%x:%x:%x:%x:%x",
- (int) addr->ether_addr_octet[0],
- (int) addr->ether_addr_octet[1],
- (int) addr->ether_addr_octet[2],
- (int) addr->ether_addr_octet[3],
- (int) addr->ether_addr_octet[4],
- (int) addr->ether_addr_octet[5]);
-
- retval = yperr2nss (yp_match (domain, "ethers.byaddr", buf,
- nlen, &result, &len));
-
- if (retval != NSS_STATUS_SUCCESS)
+ char buf[33];
+ int nlen = snprintf (buf, sizeof (buf), "%x:%x:%x:%x:%x:%x",
+ (int) addr->ether_addr_octet[0],
+ (int) addr->ether_addr_octet[1],
+ (int) addr->ether_addr_octet[2],
+ (int) addr->ether_addr_octet[3],
+ (int) addr->ether_addr_octet[4],
+ (int) addr->ether_addr_octet[5]);
+
+ char *result;
+ int len;
+ int yperr = yp_match (domain, "ethers.byaddr", buf, nlen, &result, &len);
+
+ if (__builtin_expect (yperr != YPERR_SUCCESS, 0))
{
+ enum nss_status retval = yperr2nss (yperr);
+
if (retval == NSS_STATUS_TRYAGAIN)
*errnop = errno;
return retval;
}
- if ((size_t) (len + 1) > buflen)
+ if (__builtin_expect ((size_t) (len + 1) > buflen, 0))
{
free (result);
*errnop = ERANGE;
return NSS_STATUS_TRYAGAIN;
}
- p = strncpy (buffer, result, len);
+ char *p = strncpy (buffer, result, len);
buffer[len] = '\0';
while (isspace (*p))
++p;
free (result);
- parse_res = _nss_files_parse_etherent (p, eth, data, buflen, errnop);
- if (parse_res < 1)
+ int parse_res = _nss_files_parse_etherent (p, eth, (void *) buffer, buflen,
+ errnop);
+ if (__builtin_expect (parse_res < 1, 0))
{
if (parse_res == -1)
return NSS_STATUS_TRYAGAIN;
diff --git a/nis/nss_nis/nis-grp.c b/nis/nss_nis/nis-grp.c
index 8be7332515..68f3ced992 100644
--- a/nis/nss_nis/nis-grp.c
+++ b/nis/nss_nis/nis-grp.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996-1999, 2001-2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 1996-1999, 2001-2003, 2004, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@suse.de>, 1996.
@@ -71,49 +71,52 @@ static enum nss_status
internal_nis_getgrent_r (struct group *grp, char *buffer, size_t buflen,
int *errnop)
{
- struct parser_data *data = (void *) buffer;
- char *domain, *result, *outkey;
- int len, keylen, parse_res;
-
- if (yp_get_default_domain (&domain))
+ char *domain;
+ if (__builtin_expect (yp_get_default_domain (&domain), 0))
return NSS_STATUS_UNAVAIL;
/* Get the next entry until we found a correct one. */
+ int parse_res;
do
{
- enum nss_status retval;
- char *p;
+ char *result;
+ char *outkey;
+ int len;
+ int keylen;
+ int yperr;
if (new_start)
- retval = yperr2nss (yp_first (domain, "group.byname",
- &outkey, &keylen, &result, &len));
+ yperr = yp_first (domain, "group.byname", &outkey, &keylen, &result,
+ &len);
else
- retval = yperr2nss ( yp_next (domain, "group.byname",
- oldkey, oldkeylen,
- &outkey, &keylen, &result, &len));
+ yperr = yp_next (domain, "group.byname", oldkey, oldkeylen, &outkey,
+ &keylen, &result, &len);
- if (retval != NSS_STATUS_SUCCESS)
+ if (__builtin_expect (yperr != YPERR_SUCCESS, 0))
{
+ enum nss_status retval = yperr2nss (yperr);
+
if (retval == NSS_STATUS_TRYAGAIN)
*errnop = errno;
return retval;
}
- if ((size_t) (len + 1) > buflen)
+ if (__builtin_expect ((size_t) (len + 1) > buflen, 0))
{
free (result);
*errnop = ERANGE;
return NSS_STATUS_TRYAGAIN;
}
- p = strncpy (buffer, result, len);
+ char *p = strncpy (buffer, result, len);
buffer[len] = '\0';
while (isspace (*p))
++p;
free (result);
- 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))
{
free (outkey);
*errnop = ERANGE;
@@ -149,45 +152,46 @@ enum nss_status
_nss_nis_getgrnam_r (const char *name, struct group *grp,
char *buffer, size_t buflen, int *errnop)
{
- struct parser_data *data = (void *) buffer;
- enum nss_status retval;
- char *domain, *result, *p;
- int len, parse_res;
-
if (name == NULL)
{
*errnop = EINVAL;
return NSS_STATUS_UNAVAIL;
}
- if (yp_get_default_domain (&domain))
+ char *domain;
+ if (__builtin_expect (yp_get_default_domain (&domain), 0))
return NSS_STATUS_UNAVAIL;
- retval = yperr2nss (yp_match (domain, "group.byname", name,
- strlen (name), &result, &len));
+ char *result;
+ int len;
+ int yperr = yp_match (domain, "group.byname", name, strlen (name), &result,
+ &len);
- if (retval != NSS_STATUS_SUCCESS)
+ if (__builtin_expect (yperr != YPERR_SUCCESS, 0))
{
+ enum nss_status retval = yperr2nss (yperr);
+
if (retval == NSS_STATUS_TRYAGAIN)
*errnop = errno;
return retval;
}
- if ((size_t) (len + 1) > buflen)
+ if (__builtin_expect ((size_t) (len + 1) > buflen, 0))
{
free (result);
*errnop = ERANGE;
return NSS_STATUS_TRYAGAIN;
}
- p = strncpy (buffer, result, len);
+ char *p = strncpy (buffer, result, len);
buffer[len] = '\0';
while (isspace (*p))
++p;
free (result);
- parse_res = _nss_files_parse_grent (p, grp, data, buflen, errnop);
- if (parse_res < 1)
+ int parse_res = _nss_files_parse_grent (p, grp, (void *) buffer, buflen,
+ errnop);
+ if (__builtin_expect (parse_res < 1, 0))
{
if (parse_res == -1)
return NSS_STATUS_TRYAGAIN;
@@ -201,42 +205,42 @@ enum nss_status
_nss_nis_getgrgid_r (gid_t gid, struct group *grp,
char *buffer, size_t buflen, int *errnop)
{
- struct parser_data *data = (void *) buffer;
- enum nss_status retval;
- char *domain, *result, *p;
- int len, nlen, parse_res;
- char buf[32];
-
- if (yp_get_default_domain (&domain))
+ char *domain;
+ if (__builtin_expect (yp_get_default_domain (&domain), 0))
return NSS_STATUS_UNAVAIL;
- nlen = sprintf (buf, "%lu", (unsigned long int) gid);
+ char buf[32];
+ int nlen = sprintf (buf, "%lu", (unsigned long int) gid);
- retval = yperr2nss (yp_match (domain, "group.bygid", buf,
- nlen, &result, &len));
+ char *result;
+ int len;
+ int yperr = yp_match (domain, "group.bygid", buf, nlen, &result, &len);
- if (retval != NSS_STATUS_SUCCESS)
+ if (__builtin_expect (yperr != YPERR_SUCCESS, 0))
{
+ enum nss_status retval = yperr2nss (yperr);
+
if (retval == NSS_STATUS_TRYAGAIN)
*errnop = errno;
return retval;
}
- if ((size_t) (len + 1) > buflen)
+ if (__builtin_expect ((size_t) (len + 1) > buflen, 0))
{
free (result);
*errnop = ERANGE;
return NSS_STATUS_TRYAGAIN;
}
- p = strncpy (buffer, result, len);
+ char *p = strncpy (buffer, result, len);
buffer[len] = '\0';
while (isspace (*p))
++p;
free (result);
- parse_res = _nss_files_parse_grent (p, grp, data, buflen, errnop);
- if (parse_res < 1)
+ int parse_res = _nss_files_parse_grent (p, grp, (void *) buffer, buflen,
+ errnop);
+ if (__builtin_expect (parse_res < 1, 0))
{
if (parse_res == -1)
return NSS_STATUS_TRYAGAIN;
diff --git a/nis/nss_nis/nis-hosts.c b/nis/nss_nis/nis-hosts.c
index 58a9064f14..4fa0361681 100644
--- a/nis/nss_nis/nis-hosts.c
+++ b/nis/nss_nis/nis-hosts.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996-2000, 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2000, 2002, 2003, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@suse.de>, 1996.
@@ -131,17 +131,11 @@ internal_nis_gethostent_r (struct hostent *host, char *buffer,
int af, int flags)
{
char *domain;
- char *result;
- int len, parse_res;
- char *outkey;
- int keylen;
- struct parser_data *data = (void *) buffer;
- size_t linebuflen = buffer + buflen - data->linebuffer;
-
- if (yp_get_default_domain (&domain))
+ if (__builtin_expect (yp_get_default_domain (&domain), 0))
return NSS_STATUS_UNAVAIL;
- if (buflen < sizeof *data + 1)
+ struct parser_data *data = (void *) buffer;
+ if (__builtin_expect (buflen < sizeof *data + 1, 0))
{
*errnop = ERANGE;
*h_errnop = NETDB_INTERNAL;
@@ -149,21 +143,26 @@ internal_nis_gethostent_r (struct hostent *host, char *buffer,
}
/* Get the next entry until we found a correct one. */
+ const size_t linebuflen = buffer + buflen - data->linebuffer;
+ int parse_res;
do
{
- enum nss_status retval;
- char *p;
-
+ char *result;
+ int len;
+ char *outkey;
+ int keylen;
+ int yperr;
if (new_start)
- retval = yperr2nss (yp_first (domain, "hosts.byname",
- &outkey, &keylen, &result, &len));
+ yperr = yp_first (domain, "hosts.byname", &outkey, &keylen, &result,
+ &len);
else
- retval = yperr2nss ( yp_next (domain, "hosts.byname",
- oldkey, oldkeylen,
- &outkey, &keylen, &result, &len));
+ yperr = yp_next (domain, "hosts.byname", oldkey, oldkeylen, &outkey,
+ &keylen, &result, &len);
- if (retval != NSS_STATUS_SUCCESS)
+ if (__builtin_expect (yperr != YPERR_SUCCESS, 0))
{
+ enum nss_status retval = yperr2nss (yperr);
+
switch (retval)
{
case NSS_STATUS_TRYAGAIN:
@@ -180,7 +179,7 @@ internal_nis_gethostent_r (struct hostent *host, char *buffer,
return retval;
}
- if ((size_t) (len + 1) > linebuflen)
+ if (__builtin_expect ((size_t) (len + 1) > linebuflen, 0))
{
free (result);
*h_errnop = NETDB_INTERNAL;
@@ -188,14 +187,14 @@ internal_nis_gethostent_r (struct hostent *host, char *buffer,
return NSS_STATUS_TRYAGAIN;
}
- p = strncpy (data->linebuffer, result, len);
+ char *p = strncpy (data->linebuffer, result, len);
data->linebuffer[len] = '\0';
while (isspace (*p))
++p;
free (result);
parse_res = parse_line (p, host, data, buflen, errnop, af, flags);
- if (parse_res == -1)
+ if (__builtin_expect (parse_res == -1, 0))
{
free (outkey);
*h_errnop = NETDB_INTERNAL;
@@ -235,11 +234,7 @@ internal_gethostbyname2_r (const char *name, int af, struct hostent *host,
char *buffer, size_t buflen, int *errnop,
int *h_errnop, int flags)
{
- enum nss_status retval;
- char *domain, *result, *p;
- int len, parse_res;
struct parser_data *data = (void *) buffer;
- size_t linebuflen = buffer + buflen - data->linebuffer;
if (name == NULL)
{
@@ -247,6 +242,7 @@ internal_gethostbyname2_r (const char *name, int af, struct hostent *host,
return NSS_STATUS_UNAVAIL;
}
+ char *domain;
if (yp_get_default_domain (&domain))
return NSS_STATUS_UNAVAIL;
@@ -256,24 +252,24 @@ internal_gethostbyname2_r (const char *name, int af, struct hostent *host,
*errnop = ERANGE;
return NSS_STATUS_TRYAGAIN;
}
- else
- {
- /* Convert name to lowercase. */
- size_t namlen = strlen (name);
- char name2[namlen + 1];
- size_t i;
- for (i = 0; i < namlen; ++i)
- name2[i] = tolower (name[i]);
- name2[i] = '\0';
+ /* Convert name to lowercase. */
+ size_t namlen = strlen (name);
+ char name2[namlen + 1];
+ size_t i;
- retval = yperr2nss (yp_match (domain, "hosts.byname", name2,
- namlen, &result, &len));
+ for (i = 0; i < namlen; ++i)
+ name2[i] = tolower (name[i]);
+ name2[i] = '\0';
- }
+ char *result;
+ int len;
+ int yperr = yp_match (domain, "hosts.byname", name2, namlen, &result, &len);
- if (retval != NSS_STATUS_SUCCESS)
+ if (__builtin_expect (yperr != YPERR_SUCCESS, 0))
{
+ enum nss_status retval = yperr2nss (yperr);
+
if (retval == NSS_STATUS_TRYAGAIN)
{
*h_errnop = TRY_AGAIN;
@@ -284,7 +280,8 @@ internal_gethostbyname2_r (const char *name, int af, struct hostent *host,
return retval;
}
- if ((size_t) (len + 1) > linebuflen)
+ const size_t linebuflen = buffer + buflen - data->linebuffer;
+ if (__builtin_expect ((size_t) (len + 1) > linebuflen, 0))
{
free (result);
*h_errnop = NETDB_INTERNAL;
@@ -292,15 +289,15 @@ internal_gethostbyname2_r (const char *name, int af, struct hostent *host,
return NSS_STATUS_TRYAGAIN;
}
- p = strncpy (data->linebuffer, result, len);
+ char *p = strncpy (data->linebuffer, result, len);
data->linebuffer[len] = '\0';
while (isspace (*p))
++p;
free (result);
- parse_res = parse_line (p, host, data, buflen, errnop, af, flags);
+ int parse_res = parse_line (p, host, data, buflen, errnop, af, flags);
- if (parse_res < 1 || host->h_addrtype != af)
+ if (__builtin_expect (parse_res < 1 || host->h_addrtype != af, 0))
{
if (parse_res == -1)
{
@@ -351,42 +348,42 @@ _nss_nis_gethostbyaddr_r (const void *addr, socklen_t addrlen, int af,
struct hostent *host, char *buffer, size_t buflen,
int *errnop, int *h_errnop)
{
- enum nss_status retval;
- char *domain, *result, *p;
- int len, parse_res;
- char *buf;
- struct parser_data *data = (void *) buffer;
- size_t linebuflen = buffer + buflen - data->linebuffer;
-
- if (yp_get_default_domain (&domain))
+ char *domain;
+ if (__builtin_expect (yp_get_default_domain (&domain), 0))
return NSS_STATUS_UNAVAIL;
- if (buflen < sizeof *data + 1)
+ struct parser_data *data = (void *) buffer;
+ if (__builtin_expect (buflen < sizeof *data + 1, 0))
{
*errnop = ERANGE;
*h_errnop = NETDB_INTERNAL;
return NSS_STATUS_TRYAGAIN;
}
- buf = inet_ntoa (*(const struct in_addr *) addr);
+ char *buf = inet_ntoa (*(const struct in_addr *) addr);
- retval = yperr2nss (yp_match (domain, "hosts.byaddr", buf,
- strlen (buf), &result, &len));
+ char *result;
+ int len;
+ int yperr = yp_match (domain, "hosts.byaddr", buf, strlen (buf), &result,
+ &len);
- if (retval != NSS_STATUS_SUCCESS)
+ if (__builtin_expect (yperr != YPERR_SUCCESS, 0))
{
+ enum nss_status retval = yperr2nss (yperr);
+
if (retval == NSS_STATUS_TRYAGAIN)
{
*h_errnop = TRY_AGAIN;
*errnop = errno;
}
- if (retval == NSS_STATUS_NOTFOUND)
+ else if (retval == NSS_STATUS_NOTFOUND)
*h_errnop = HOST_NOT_FOUND;
return retval;
}
- if ((size_t) (len + 1) > linebuflen)
+ const size_t linebuflen = buffer + buflen - data->linebuffer;
+ if (__builtin_expect ((size_t) (len + 1) > linebuflen, 0))
{
free (result);
*errnop = ERANGE;
@@ -394,15 +391,16 @@ _nss_nis_gethostbyaddr_r (const void *addr, socklen_t addrlen, int af,
return NSS_STATUS_TRYAGAIN;
}
- p = strncpy (data->linebuffer, result, len);
+ char *p = strncpy (data->linebuffer, result, len);
data->linebuffer[len] = '\0';
while (isspace (*p))
++p;
free (result);
- parse_res = parse_line (p, host, data, buflen, errnop, af,
- ((_res.options & RES_USE_INET6) ? AI_V4MAPPED : 0));
- if (parse_res < 1)
+ int parse_res = parse_line (p, host, data, buflen, errnop, af,
+ ((_res.options & RES_USE_INET6)
+ ? AI_V4MAPPED : 0));
+ if (__builtin_expect (parse_res < 1, 0))
{
if (parse_res == -1)
{
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;
diff --git a/nis/nss_nis/nis-netgrp.c b/nis/nss_nis/nis-netgrp.c
index 049bd8cdb4..5a88b72d9c 100644
--- a/nis/nss_nis/nis-netgrp.c
+++ b/nis/nss_nis/nis-netgrp.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996,1997,1999,2000,2002,2003,2004,2005
+/* Copyright (C) 1996,1997,1999,2000,2002,2003,2004,2005,2006
Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@suse.de>, 1996.
@@ -47,24 +47,25 @@ internal_nis_endnetgrent (struct __netgrent *netgrp)
netgrp->cursor = NULL;
}
+
enum nss_status
_nss_nis_setnetgrent (const char *group, struct __netgrent *netgrp)
{
- char *domain;
int len;
enum nss_status status;
status = NSS_STATUS_SUCCESS;
- if (group == NULL || group[0] == '\0')
+ if (__builtin_expect (group == NULL || group[0] == '\0', 0))
return NSS_STATUS_UNAVAIL;
- if (yp_get_default_domain (&domain))
+ char *domain;
+ if (__builtin_expect (yp_get_default_domain (&domain), 0))
return NSS_STATUS_UNAVAIL;
status = yperr2nss (yp_match (domain, "netgroup", group, strlen (group),
&netgrp->data, &len));
- if (status == NSS_STATUS_SUCCESS)
+ if (__builtin_expect (status == NSS_STATUS_SUCCESS, 1))
{
/* Our implementation of yp_match already allocates a buffer
which is one byte larger than the value in LEN specifies
@@ -90,6 +91,7 @@ _nss_nis_endnetgrent (struct __netgrent *netgrp)
return NSS_STATUS_SUCCESS;
}
+
enum nss_status
_nss_nis_getnetgrent_r (struct __netgrent *result, char *buffer, size_t buflen,
int *errnop)
diff --git a/nis/nss_nis/nis-network.c b/nis/nss_nis/nis-network.c
index ed8439c814..9b02302e0b 100644
--- a/nis/nss_nis/nis-network.c
+++ b/nis/nss_nis/nis-network.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996-2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2003, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996.
@@ -73,28 +73,32 @@ internal_nis_getnetent_r (struct netent *net, char *buffer, size_t buflen,
int *errnop, int *herrnop)
{
struct parser_data *data = (void *) buffer;
- char *domain, *result, *outkey;
- int len, keylen, parse_res;
- if (yp_get_default_domain (&domain))
+ char *domain;
+ if (__builtin_expect (yp_get_default_domain (&domain), 0))
return NSS_STATUS_UNAVAIL;
/* Get the next entry until we found a correct one. */
+ int parse_res;
do
{
- enum nss_status retval;
- char *p;
+ char *result;
+ char *outkey;
+ int len;
+ int keylen;
+ int yperr;
if (new_start)
- retval = yperr2nss (yp_first (domain, "networks.byname",
- &outkey, &keylen, &result, &len));
+ yperr = yp_first (domain, "networks.byname", &outkey, &keylen, &result,
+ &len);
else
- retval = yperr2nss ( yp_next (domain, "networks.byname",
- oldkey, oldkeylen,
- &outkey, &keylen, &result, &len));
+ yperr = yp_next (domain, "networks.byname", oldkey, oldkeylen, &outkey,
+ &keylen, &result, &len);
- if (retval != NSS_STATUS_SUCCESS)
+ if (__builtin_expect (yperr != YPERR_SUCCESS, 0))
{
+ enum nss_status retval = yperr2nss (yperr);
+
if (retval == NSS_STATUS_TRYAGAIN)
{
*herrnop = NETDB_INTERNAL;
@@ -103,7 +107,7 @@ internal_nis_getnetent_r (struct netent *net, char *buffer, size_t buflen,
return retval;
}
- if ((size_t) (len + 1) > buflen)
+ if (__builtin_expect ((size_t) (len + 1) > buflen, 0))
{
free (result);
*errnop = ERANGE;
@@ -111,14 +115,14 @@ internal_nis_getnetent_r (struct netent *net, char *buffer, size_t buflen,
return NSS_STATUS_TRYAGAIN;
}
- p = strncpy (buffer, result, len);
+ char *p = strncpy (buffer, result, len);
buffer[len] = '\0';
while (isspace (*p))
++p;
free (result);
parse_res = _nss_files_parse_netent (p, net, data, buflen, errnop);
- if (parse_res == -1)
+ if (__builtin_expect (parse_res == -1, 0))
{
free (outkey);
*herrnop = NETDB_INTERNAL;
@@ -155,11 +159,6 @@ enum nss_status
_nss_nis_getnetbyname_r (const char *name, struct netent *net, char *buffer,
size_t buflen, int *errnop, int *herrnop)
{
- enum nss_status retval;
- struct parser_data *data = (void *) buffer;
- char *domain, *result, *p;
- int len, parse_res;
-
if (name == NULL)
{
*errnop = EINVAL;
@@ -167,33 +166,36 @@ _nss_nis_getnetbyname_r (const char *name, struct netent *net, char *buffer,
return NSS_STATUS_UNAVAIL;
}
- if (yp_get_default_domain (&domain))
+ char *domain;
+ if (__builtin_expect (yp_get_default_domain (&domain), 0))
return NSS_STATUS_UNAVAIL;
+ struct parser_data *data = (void *) buffer;
if (buflen < sizeof *data + 1)
{
*herrnop = NETDB_INTERNAL;
*errnop = ERANGE;
return NSS_STATUS_TRYAGAIN;
}
- else
- {
- /* Convert name to lowercase. */
- size_t namlen = strlen (name);
- char name2[namlen + 1];
- size_t i;
- for (i = 0; i < namlen; ++i)
- name2[i] = _tolower (name[i]);
- name2[i] = '\0';
+ /* Convert name to lowercase. */
+ size_t namlen = strlen (name);
+ char name2[namlen + 1];
+ size_t i;
- retval = yperr2nss (yp_match (domain, "networks.byname", name2,
- namlen, &result, &len));
- }
+ for (i = 0; i < namlen; ++i)
+ name2[i] = _tolower (name[i]);
+ name2[i] = '\0';
+ char *result;
+ int len;
+ int yperr = yp_match (domain, "networks.byname", name2, namlen, &result,
+ &len);
- if (retval != NSS_STATUS_SUCCESS)
+ if (__builtin_expect (yperr != YPERR_SUCCESS, 0))
{
+ enum nss_status retval = yperr2nss (yperr);
+
if (retval == NSS_STATUS_TRYAGAIN)
{
*errnop = errno;
@@ -202,7 +204,7 @@ _nss_nis_getnetbyname_r (const char *name, struct netent *net, char *buffer,
return retval;
}
- if ((size_t) (len + 1) > buflen)
+ if (__builtin_expect ((size_t) (len + 1) > buflen, 0))
{
free (result);
*errnop = ERANGE;
@@ -210,15 +212,15 @@ _nss_nis_getnetbyname_r (const char *name, struct netent *net, char *buffer,
return NSS_STATUS_TRYAGAIN;
}
- p = strncpy (buffer, result, len);
+ char *p = strncpy (buffer, result, len);
buffer[len] = '\0';
while (isspace (*p))
++p;
free (result);
- parse_res = _nss_files_parse_netent (p, net, data, buflen, errnop);
+ int parse_res = _nss_files_parse_netent (p, net, data, buflen, errnop);
- if (parse_res < 1)
+ if (__builtin_expect (parse_res < 1, 0))
{
*herrnop = NETDB_INTERNAL;
if (parse_res == -1)
@@ -235,32 +237,26 @@ _nss_nis_getnetbyaddr_r (uint32_t addr, int type, struct netent *net,
char *buffer, size_t buflen, int *errnop,
int *herrnop)
{
- struct parser_data *data = (void *) buffer;
char *domain;
- char *result;
- int len;
- char buf[256];
- int blen;
- struct in_addr in;
- char *p;
-
- if (yp_get_default_domain (&domain))
+ if (__builtin_expect (yp_get_default_domain (&domain), 0))
return NSS_STATUS_UNAVAIL;
- in = inet_makeaddr (addr, 0);
- strcpy (buf, inet_ntoa (in));
- blen = strlen (buf);
+ struct in_addr in = inet_makeaddr (addr, 0);
+ char *buf = inet_ntoa (in);
+ size_t blen = strlen (buf);
while (1)
{
- enum nss_status retval;
- int parse_res;
+ char *result;
+ int len;
- retval = yperr2nss (yp_match (domain, "networks.byaddr", buf,
- strlen (buf), &result, &len));
+ int yperr = yp_match (domain, "networks.byaddr", buf, blen, &result,
+ &len);
- if (retval != NSS_STATUS_SUCCESS)
+ if (__builtin_expect (yperr != YPERR_SUCCESS, 0))
{
+ enum nss_status retval = yperr2nss (yperr);
+
if (retval == NSS_STATUS_NOTFOUND)
{
if (buf[blen - 2] == '.' && buf[blen - 1] == '0')
@@ -282,7 +278,7 @@ _nss_nis_getnetbyaddr_r (uint32_t addr, int type, struct netent *net,
}
}
- if ((size_t) (len + 1) > buflen)
+ if (__builtin_expect ((size_t) (len + 1) > buflen, 0))
{
free (result);
*errnop = ERANGE;
@@ -290,15 +286,16 @@ _nss_nis_getnetbyaddr_r (uint32_t addr, int type, struct netent *net,
return NSS_STATUS_TRYAGAIN;
}
- p = strncpy (buffer, result, len);
+ char *p = strncpy (buffer, result, len);
buffer[len] = '\0';
while (isspace (*p))
++p;
free (result);
- parse_res = _nss_files_parse_netent (p, net, data, buflen, errnop);
+ int parse_res = _nss_files_parse_netent (p, net, (void *) buffer,
+ buflen, errnop);
- if (parse_res < 1)
+ if (__builtin_expect (parse_res < 1, 0))
{
*herrnop = NETDB_INTERNAL;
if (parse_res == -1)
diff --git a/nis/nss_nis/nis-proto.c b/nis/nss_nis/nis-proto.c
index f1069283ab..1480a928b5 100644
--- a/nis/nss_nis/nis-proto.c
+++ b/nis/nss_nis/nis-proto.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996-1998, 2000-2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 1996-1998, 2000-2004, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@suse.de>, 1996.
@@ -179,45 +179,46 @@ enum nss_status
_nss_nis_getprotobyname_r (const char *name, struct protoent *proto,
char *buffer, size_t buflen, int *errnop)
{
- struct parser_data *data = (void *) buffer;
- enum nss_status retval;
- char *domain, *result, *p;
- int len, parse_res;
-
if (name == NULL)
{
*errnop = EINVAL;
return NSS_STATUS_UNAVAIL;
}
- if (yp_get_default_domain (&domain))
+ char *domain;
+ if (__builtin_expect (yp_get_default_domain (&domain), 0))
return NSS_STATUS_UNAVAIL;
- retval = yperr2nss (yp_match (domain, "protocols.byname", name,
- strlen (name), &result, &len));
+ char *result;
+ int len;
+ int yperr = yp_match (domain, "protocols.byname", name, strlen (name),
+ &result, &len);
- if (retval != NSS_STATUS_SUCCESS)
+ if (__builtin_expect (yperr != YPERR_SUCCESS, 0))
{
+ enum nss_status retval = yperr2nss (yperr);
+
if (retval == NSS_STATUS_TRYAGAIN)
*errnop = errno;
return retval;
}
- if ((size_t) (len + 1) > buflen)
+ if (__builtin_expect ((size_t) (len + 1) > buflen, 0))
{
free (result);
*errnop = ERANGE;
return NSS_STATUS_TRYAGAIN;
}
- p = strncpy (buffer, result, len);
+ char *p = strncpy (buffer, result, len);
buffer[len] = '\0';
while (isspace (*p))
++p;
free (result);
- parse_res = _nss_files_parse_protoent (p, proto, data, buflen, errnop);
- if (parse_res < 1)
+ int parse_res = _nss_files_parse_protoent (p, proto, (void *) buffer, buflen,
+ errnop);
+ if (__builtin_expect (parse_res < 1, 0))
{
if (parse_res == -1)
return NSS_STATUS_TRYAGAIN;
@@ -231,42 +232,43 @@ enum nss_status
_nss_nis_getprotobynumber_r (int number, struct protoent *proto,
char *buffer, size_t buflen, int *errnop)
{
- struct parser_data *data = (void *) buffer;
- enum nss_status retval;
- char *domain, *result, *p;
- int len, nlen, parse_res;
- char buf[32];
-
- if (yp_get_default_domain (&domain))
+ char *domain;
+ if (__builtin_expect (yp_get_default_domain (&domain), 0))
return NSS_STATUS_UNAVAIL;
- nlen = sprintf (buf, "%d", number);
+ char buf[32];
+ int nlen = snprintf (buf, sizeof (buf), "%d", number);
- retval = yperr2nss (yp_match (domain, "protocols.bynumber", buf,
- nlen, &result, &len));
+ char *result;
+ int len;
+ int yperr = yp_match (domain, "protocols.bynumber", buf, nlen, &result,
+ &len);
- if (retval != NSS_STATUS_SUCCESS)
+ if (__builtin_expect (yperr != YPERR_SUCCESS, 0))
{
+ enum nss_status retval = yperr2nss (yperr);
+
if (retval == NSS_STATUS_TRYAGAIN)
*errnop = errno;
return retval;
}
- if ((size_t) (len + 1) > buflen)
+ if (__builtin_expect ((size_t) (len + 1) > buflen, 0))
{
free (result);
*errnop = ERANGE;
return NSS_STATUS_TRYAGAIN;
}
- p = strncpy (buffer, result, len);
+ char *p = strncpy (buffer, result, len);
buffer[len] = '\0';
while (isspace (*p))
++p;
free (result);
- parse_res = _nss_files_parse_protoent (p, proto, data, buflen, errnop);
- if (parse_res < 1)
+ int parse_res = _nss_files_parse_protoent (p, proto, (void *) buffer, buflen,
+ errnop);
+ if (__builtin_expect (parse_res < 1, 0))
{
if (parse_res == -1)
return NSS_STATUS_TRYAGAIN;
diff --git a/nis/nss_nis/nis-publickey.c b/nis/nss_nis/nis-publickey.c
index f82db192a6..f58eb154ad 100644
--- a/nis/nss_nis/nis-publickey.c
+++ b/nis/nss_nis/nis-publickey.c
@@ -36,10 +36,6 @@ extern int xdecrypt (char *, char *);
enum nss_status
_nss_nis_getpublickey (const char *netname, char *pkey, int *errnop)
{
- enum nss_status retval;
- char *domain, *result;
- int len;
-
pkey[0] = 0;
if (netname == NULL)
@@ -48,19 +44,23 @@ _nss_nis_getpublickey (const char *netname, char *pkey, int *errnop)
return NSS_STATUS_UNAVAIL;
}
- domain = strchr (netname, '@');
- if (!domain)
+ char *domain = strchr (netname, '@');
+ if (domain == NULL)
{
*errnop = EINVAL;
return NSS_STATUS_UNAVAIL;
}
++domain;
- retval = yperr2nss (yp_match (domain, "publickey.byname", netname,
- strlen (netname), &result, &len));
+ char *result;
+ int len;
+ int yperr = yp_match (domain, "publickey.byname", netname, strlen (netname),
+ &result, &len);
- if (retval != NSS_STATUS_SUCCESS)
+ if (__builtin_expect (yperr != YPERR_SUCCESS, 0))
{
+ enum nss_status retval = yperr2nss (yperr);
+
if (retval == NSS_STATUS_TRYAGAIN)
*errnop = errno;
return retval;
@@ -82,11 +82,6 @@ enum nss_status
_nss_nis_getsecretkey (const char *netname, char *skey, char *passwd,
int *errnop)
{
- enum nss_status retval;
- char buf[2 * (HEXKEYBYTES + 1)];
- char *domain, *result;
- int len;
-
skey[0] = 0;
if (netname == NULL || passwd == NULL)
@@ -95,19 +90,23 @@ _nss_nis_getsecretkey (const char *netname, char *skey, char *passwd,
return NSS_STATUS_UNAVAIL;
}
- domain = strchr (netname, '@');
- if (!domain)
+ char *domain = strchr (netname, '@');
+ if (domain == NULL)
{
*errnop = EINVAL;
return NSS_STATUS_UNAVAIL;
}
++domain;
- retval = yperr2nss (yp_match (domain, "publickey.byname", netname,
- strlen (netname), &result, &len));
+ char *result;
+ int len;
+ int yperr = yp_match (domain, "publickey.byname", netname, strlen (netname),
+ &result, &len);
- if (retval != NSS_STATUS_SUCCESS)
+ if (__builtin_expect (yperr != YPERR_SUCCESS, 0))
{
+ enum nss_status retval = yperr2nss (yperr);
+
if (retval == NSS_STATUS_TRYAGAIN)
*errnop = errno;
return retval;
@@ -118,6 +117,8 @@ _nss_nis_getsecretkey (const char *netname, char *skey, char *passwd,
char *p = strchr (result, ':');
if (p != NULL)
{
+ char buf[2 * (HEXKEYBYTES + 1)];
+
++p;
strncpy (buf, p, 2 * (HEXKEYBYTES + 1));
buf[2 * HEXKEYBYTES + 1] = '\0';
@@ -195,13 +196,8 @@ enum nss_status
_nss_nis_netname2user (char netname[MAXNETNAMELEN + 1], uid_t *uidp,
gid_t *gidp, int *gidlenp, gid_t *gidlist, int *errnop)
{
- char *domain;
- int yperr;
- char *lookup;
- int len;
-
- domain = strchr (netname, '@');
- if (!domain)
+ char *domain = strchr (netname, '@');
+ if (domain == NULL)
{
*errnop = EINVAL;
return NSS_STATUS_UNAVAIL;
@@ -209,9 +205,10 @@ _nss_nis_netname2user (char netname[MAXNETNAMELEN + 1], uid_t *uidp,
/* Point past the '@' character */
++domain;
- lookup = NULL;
- yperr = yp_match (domain, "netid.byname", netname, strlen (netname),
- &lookup, &len);
+ char *lookup = NULL;
+ int len;
+ int yperr = yp_match (domain, "netid.byname", netname, strlen (netname),
+ &lookup, &len);
switch (yperr)
{
case YPERR_SUCCESS:
@@ -224,17 +221,15 @@ _nss_nis_netname2user (char netname[MAXNETNAMELEN + 1], uid_t *uidp,
return NSS_STATUS_UNAVAIL;
}
- if (lookup)
- {
- enum nss_status err;
-
- lookup[len] = '\0';
- err = parse_netid_str (lookup, uidp, gidp, gidlenp, gidlist);
- free (lookup);
- return err;
- }
- else
+ if (lookup == NULL)
return NSS_STATUS_NOTFOUND;
- return NSS_STATUS_SUCCESS;
+
+ lookup[len] = '\0';
+
+ enum nss_status err = parse_netid_str (lookup, uidp, gidp, gidlenp, gidlist);
+
+ free (lookup);
+
+ return err;
}
diff --git a/nis/nss_nis/nis-pwd.c b/nis/nss_nis/nis-pwd.c
index 0f56ced014..457574a49b 100644
--- a/nis/nss_nis/nis-pwd.c
+++ b/nis/nss_nis/nis-pwd.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996-1998, 2001, 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 1996-1998,2001,2002,2003,2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996.
@@ -71,31 +71,31 @@ static enum nss_status
internal_nis_getpwent_r (struct passwd *pwd, char *buffer, size_t buflen,
int *errnop)
{
- struct parser_data *data = (void *) buffer;
char *domain;
- int parse_res;
-
- if (yp_get_default_domain (&domain))
+ if (__builtin_expect (yp_get_default_domain (&domain), 0))
return NSS_STATUS_UNAVAIL;
/* Get the next entry until we found a correct one. */
+ int parse_res;
do
{
- enum nss_status retval;
- char *result, *outkey, *result2, *p;
- int len, keylen, len2;
- size_t namelen;
+ char *result;
+ char *outkey;
+ int len;
+ int keylen;
+ int yperr;
if (new_start)
- retval = yperr2nss (yp_first (domain, "passwd.byname",
- &outkey, &keylen, &result, &len));
+ yperr = yp_first (domain, "passwd.byname", &outkey, &keylen, &result,
+ &len);
else
- retval = yperr2nss ( yp_next (domain, "passwd.byname",
- oldkey, oldkeylen,
- &outkey, &keylen, &result, &len));
+ yperr = yp_next (domain, "passwd.byname", oldkey, oldkeylen, &outkey,
+ &keylen, &result, &len);
- if (retval != NSS_STATUS_SUCCESS)
+ if (__builtin_expect (yperr != YPERR_SUCCESS, 0))
{
+ enum nss_status retval = yperr2nss (yperr);
+
if (retval == NSS_STATUS_TRYAGAIN)
*errnop = errno;
return retval;
@@ -103,7 +103,10 @@ internal_nis_getpwent_r (struct passwd *pwd, char *buffer, size_t buflen,
/* Check for adjunct style secret passwords. They can be
recognized by a password starting with "##". */
- p = strchr (result, ':');
+ char *p = strchr (result, ':');
+ size_t namelen;
+ char *result2;
+ int len2;
if (p != NULL /* This better should be true in all cases. */
&& p[1] == '#' && p[2] == '#'
&& (namelen = p - result,
@@ -128,7 +131,8 @@ internal_nis_getpwent_r (struct passwd *pwd, char *buffer, size_t buflen,
}
restlen = len - (p - result);
- if ((size_t) (namelen + (endp - encrypted) + restlen + 2) > buflen)
+ if (__builtin_expect ((size_t) (namelen + (endp - encrypted)
+ + restlen + 2) > buflen, 0))
{
free (result2);
free (result);
@@ -147,7 +151,7 @@ internal_nis_getpwent_r (struct passwd *pwd, char *buffer, size_t buflen,
else
{
non_adjunct:
- if ((size_t) (len + 1) > buflen)
+ if (__builtin_expect ((size_t) (len + 1) > buflen, 0))
{
free (result);
*errnop = ERANGE;
@@ -162,8 +166,9 @@ internal_nis_getpwent_r (struct passwd *pwd, char *buffer, size_t buflen,
++p;
free (result);
- parse_res = _nss_files_parse_pwent (p, pwd, data, buflen, errnop);
- if (parse_res == -1)
+ parse_res = _nss_files_parse_pwent (p, pwd, (void *) buffer, buflen,
+ errnop);
+ if (__builtin_expect (parse_res == -1, 0))
{
free (outkey);
*errnop = ERANGE;
@@ -199,28 +204,26 @@ enum nss_status
_nss_nis_getpwnam_r (const char *name, struct passwd *pwd,
char *buffer, size_t buflen, int *errnop)
{
- struct parser_data *data = (void *) buffer;
- enum nss_status retval;
- char *domain, *result, *result2, *p;
- int len, len2, parse_res;
- size_t namelen;
-
if (name == NULL)
{
*errnop = EINVAL;
return NSS_STATUS_UNAVAIL;
}
- if (yp_get_default_domain (&domain))
+ char *domain;
+ if (__builtin_expect (yp_get_default_domain (&domain), 0))
return NSS_STATUS_UNAVAIL;
- namelen = strlen (name);
+ size_t namelen = strlen (name);
- retval = yperr2nss (yp_match (domain, "passwd.byname", name,
- namelen, &result, &len));
+ char *result;
+ int len;
+ int yperr = yp_match (domain, "passwd.byname", name, namelen, &result, &len);
- if (retval != NSS_STATUS_SUCCESS)
+ if (__builtin_expect (yperr != YPERR_SUCCESS, 0))
{
+ enum nss_status retval = yperr2nss (yperr);
+
if (retval == NSS_STATUS_TRYAGAIN)
*errnop = errno;
return retval;
@@ -228,7 +231,9 @@ _nss_nis_getpwnam_r (const char *name, struct passwd *pwd,
/* Check for adjunct style secret passwords. They can be recognized
by a password starting with "##". */
- p = strchr (result, ':');
+ char *result2;
+ int len2;
+ char *p = strchr (result, ':');
if (p != NULL /* This better should be true in all cases. */
&& p[1] == '#' && p[2] == '#'
&& yp_match (domain, "passwd.adjunct.byname", name, namelen,
@@ -238,7 +243,6 @@ _nss_nis_getpwnam_r (const char *name, struct passwd *pwd,
therein into original result. */
char *encrypted = strchr (result2, ':');
char *endp;
- size_t restlen;
if (encrypted == NULL
|| (endp = strchr (++encrypted, ':')) == NULL
@@ -251,8 +255,9 @@ _nss_nis_getpwnam_r (const char *name, struct passwd *pwd,
goto non_adjunct;
}
- restlen = len - (p - result);
- if ((size_t) (namelen + (endp - encrypted) + restlen + 2) > buflen)
+ size_t restlen = len - (p - result);
+ if (__builtin_expect ((size_t) (namelen + (endp - encrypted)
+ + restlen + 2) > buflen, 0))
{
free (result2);
free (result);
@@ -271,7 +276,7 @@ _nss_nis_getpwnam_r (const char *name, struct passwd *pwd,
else
{
non_adjunct:
- if ((size_t) (len + 1) > buflen)
+ if (__builtin_expect ((size_t) (len + 1) > buflen, 0))
{
free (result);
*errnop = ERANGE;
@@ -286,8 +291,9 @@ _nss_nis_getpwnam_r (const char *name, struct passwd *pwd,
++p;
free (result);
- parse_res = _nss_files_parse_pwent (p, pwd, data, buflen, errnop);
- if (parse_res < 1)
+ int parse_res = _nss_files_parse_pwent (p, pwd, (void *) buffer, buflen,
+ errnop);
+ if (__builtin_expect (parse_res < 1, 0))
{
if (parse_res == -1)
return NSS_STATUS_TRYAGAIN;
@@ -302,23 +308,21 @@ enum nss_status
_nss_nis_getpwuid_r (uid_t uid, struct passwd *pwd,
char *buffer, size_t buflen, int *errnop)
{
- struct parser_data *data = (void *) buffer;
- enum nss_status retval;
- char *domain, *result, *p, *result2;
- int len, nlen, parse_res, len2;
- char buf[32];
- size_t namelen;
-
- if (yp_get_default_domain (&domain))
+ char *domain;
+ if (__builtin_expect (yp_get_default_domain (&domain), 0))
return NSS_STATUS_UNAVAIL;
- nlen = sprintf (buf, "%lu", (unsigned long int) uid);
+ char buf[32];
+ int nlen = snprintf (buf, sizeof (buf), "%lu", (unsigned long int) uid);
- retval = yperr2nss (yp_match (domain, "passwd.byuid", buf,
- nlen, &result, &len));
+ char *result;
+ int len;
+ int yperr = yp_match (domain, "passwd.byuid", buf, nlen, &result, &len);
- if (retval != NSS_STATUS_SUCCESS)
+ if (__builtin_expect (yperr != YPERR_SUCCESS, 0))
{
+ enum nss_status retval = yperr2nss (yperr);
+
if (retval == NSS_STATUS_TRYAGAIN)
*errnop = errno;
return retval;
@@ -326,7 +330,10 @@ _nss_nis_getpwuid_r (uid_t uid, struct passwd *pwd,
/* Check for adjunct style secret passwords. They can be recognized
by a password starting with "##". */
- p = strchr (result, ':');
+ char *result2;
+ int len2;
+ size_t namelen;
+ char *p = strchr (result, ':');
if (p != NULL /* This better should be true in all cases. */
&& p[1] == '#' && p[2] == '#'
&& (namelen = p - result,
@@ -351,7 +358,8 @@ _nss_nis_getpwuid_r (uid_t uid, struct passwd *pwd,
}
restlen = len - (p - result);
- if ((size_t) (namelen + (endp - encrypted) + restlen + 2) > buflen)
+ if (__builtin_expect ((size_t) (namelen + (endp - encrypted)
+ + restlen + 2) > buflen, 0))
{
free (result2);
free (result);
@@ -370,7 +378,7 @@ _nss_nis_getpwuid_r (uid_t uid, struct passwd *pwd,
else
{
non_adjunct:
- if ((size_t) (len + 1) > buflen)
+ if (__builtin_expect ((size_t) (len + 1) > buflen, 0))
{
free (result);
*errnop = ERANGE;
@@ -385,8 +393,9 @@ _nss_nis_getpwuid_r (uid_t uid, struct passwd *pwd,
++p;
free (result);
- parse_res = _nss_files_parse_pwent (p, pwd, data, buflen, errnop);
- if (parse_res < 1)
+ int parse_res = _nss_files_parse_pwent (p, pwd, (void *) buffer, buflen,
+ errnop);
+ if (__builtin_expect (parse_res < 1, 0))
{
if (parse_res == -1)
return NSS_STATUS_TRYAGAIN;
diff --git a/nis/nss_nis/nis-rpc.c b/nis/nss_nis/nis-rpc.c
index d1ab94371a..162f3572bf 100644
--- a/nis/nss_nis/nis-rpc.c
+++ b/nis/nss_nis/nis-rpc.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1996-1998,2000,2002,2003,2004 Free Software Foundation, Inc.
+/* Copyright (C) 1996-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>, 1996.
@@ -54,7 +55,7 @@ static int
saveit (int instatus, char *inkey, int inkeylen, char *inval,
int invallen, char *indata)
{
- intern_t *intern = (intern_t *)indata;
+ intern_t *intern = (intern_t *) indata;
if (instatus != YP_TRUE)
return 1;
@@ -158,7 +159,7 @@ internal_nis_getrpcent_r (struct rpcent *rpc, char *buffer, size_t buflen,
++p;
parse_res = _nss_files_parse_rpcent (p, rpc, pdata, buflen, errnop);
- if (parse_res == -1)
+ if (__builtin_expect (parse_res == -1, 0))
return NSS_STATUS_TRYAGAIN;
data->next = data->next->next;
}
@@ -186,21 +187,18 @@ enum nss_status
_nss_nis_getrpcbyname_r (const char *name, struct rpcent *rpc,
char *buffer, size_t buflen, int *errnop)
{
- intern_t data = {NULL, NULL};
- enum nss_status status;
- int found;
-
if (name == NULL)
{
*errnop = EINVAL;
return NSS_STATUS_UNAVAIL;
}
- status = internal_nis_setrpcent (&data);
- if (status != NSS_STATUS_SUCCESS)
+ intern_t data = { NULL, NULL };
+ enum nss_status status = internal_nis_setrpcent (&data);
+ if (__builtin_expect (status != NSS_STATUS_SUCCESS, 0))
return status;
- found = 0;
+ int found = 0;
while (!found &&
((status = internal_nis_getrpcent_r (rpc, buffer, buflen, errnop,
&data)) == NSS_STATUS_SUCCESS))
@@ -226,53 +224,52 @@ _nss_nis_getrpcbyname_r (const char *name, struct rpcent *rpc,
internal_nis_endrpcent (&data);
- if (!found && status == NSS_STATUS_SUCCESS)
+ if (__builtin_expect (!found && status == NSS_STATUS_SUCCESS, 0))
return NSS_STATUS_NOTFOUND;
- else
- return status;
+
+ return status;
}
enum nss_status
_nss_nis_getrpcbynumber_r (int number, struct rpcent *rpc,
char *buffer, size_t buflen, int *errnop)
{
- struct parser_data *data = (void *) buffer;
- enum nss_status retval;
- char *domain, *result, *p;
- int len, nlen, parse_res;
- char buf[32];
-
- if (yp_get_default_domain (&domain))
+ char *domain;
+ if (__builtin_expect (yp_get_default_domain (&domain), 0))
return NSS_STATUS_UNAVAIL;
- nlen = sprintf (buf, "%d", number);
+ char buf[32];
+ int nlen = snprintf (buf, sizeof (buf), "%d", number);
- retval = yperr2nss (yp_match (domain, "rpc.bynumber", buf,
- nlen, &result, &len));
+ char *result;
+ int len;
+ int yperr = yp_match (domain, "rpc.bynumber", buf, nlen, &result, &len);
- if (retval != NSS_STATUS_SUCCESS)
+ if (__builtin_expect (yperr != YPERR_SUCCESS, 0))
{
+ enum nss_status retval = yperr2nss (yperr);
+
if (retval == NSS_STATUS_TRYAGAIN)
*errnop = errno;
return retval;
}
- if ((size_t) (len + 1) > buflen)
+ if (__builtin_expect ((size_t) (len + 1) > buflen, 0))
{
free (result);
*errnop = ERANGE;
return NSS_STATUS_TRYAGAIN;
}
- p = strncpy (buffer, result, len);
+ char *p = strncpy (buffer, result, len);
buffer[len] = '\0';
while (isspace (*p))
++p;
free (result);
- parse_res = _nss_files_parse_rpcent (p, rpc, data, buflen, errnop);
-
- if (parse_res < 1)
+ int parse_res = _nss_files_parse_rpcent (p, rpc, (void *) buffer, buflen,
+ errnop);
+ if (__builtin_expect (parse_res < 1, 0))
{
if (parse_res == -1)
return NSS_STATUS_TRYAGAIN;
diff --git a/nis/nss_nis/nis-service.c b/nis/nss_nis/nis-service.c
index 1e879d04e3..51b668a90e 100644
--- a/nis/nss_nis/nis-service.c
+++ b/nis/nss_nis/nis-service.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996-2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2004, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@suse.de>, 1996.
@@ -98,29 +98,26 @@ dosearch (int instatus, char *inkey, int inkeylen, char *inval,
{
struct search_t *req = (struct search_t *) indata;
- if (instatus != YP_TRUE)
+ if (__builtin_expect (instatus != YP_TRUE, 0))
return 1;
if (inkey && inkeylen > 0 && inval && invallen > 0)
{
- struct parser_data *pdata = (void *) req->buffer;
- int parse_res;
- char *p;
-
- if ((size_t) (invallen + 1) > req->buflen)
+ if (__builtin_expect ((size_t) (invallen + 1) > req->buflen, 0))
{
*req->errnop = ERANGE;
req->status = NSS_STATUS_TRYAGAIN;
return 1;
}
- p = strncpy (req->buffer, inval, invallen);
+ char *p = strncpy (req->buffer, inval, invallen);
req->buffer[invallen] = '\0';
while (isspace (*p))
++p;
- parse_res = _nss_files_parse_servent (p, req->serv, pdata, req->buflen,
- req->errnop);
+ int parse_res = _nss_files_parse_servent (p, req->serv,
+ (void *) req->buffer,
+ req->buflen, req->errnop);
if (parse_res == -1)
{
req->status = NSS_STATUS_TRYAGAIN;
@@ -237,7 +234,7 @@ internal_nis_getservent_r (struct servent *serv, char *buffer,
++p;
parse_res = _nss_files_parse_servent (p, serv, pdata, buflen, errnop);
- if (parse_res == -1)
+ if (__builtin_expect (parse_res == -1, 0))
return NSS_STATUS_TRYAGAIN;
data->next = data->next->next;
}
@@ -266,60 +263,56 @@ _nss_nis_getservbyname_r (const char *name, const char *protocol,
struct servent *serv, char *buffer, size_t buflen,
int *errnop)
{
- enum nss_status status;
- char *domain;
-
if (name == NULL)
{
*errnop = EINVAL;
return NSS_STATUS_UNAVAIL;
}
- if (yp_get_default_domain (&domain))
+ char *domain;
+ if (__builtin_expect (yp_get_default_domain (&domain), 0))
return NSS_STATUS_UNAVAIL;
/* If the protocol is given, we could try if our NIS server knows
about services.byservicename map. If yes, we only need one query. */
- char key[strlen (name) + (protocol ? strlen (protocol) : 0) + 2];
- char *cp, *result;
- size_t keylen, len;
- int int_len;
+ size_t keylen = strlen (name) + 1 + (protocol ? strlen (protocol) : 0);
+ char key[keylen + 1];
/* key is: "name/proto" */
- cp = stpcpy (key, name);
- if (protocol)
+ char *cp = stpcpy (key, name);
+ if (protocol != NULL)
{
*cp++ = '/';
strcpy (cp, protocol);
}
- keylen = strlen (key);
- status = yperr2nss (yp_match (domain, "services.byservicename", key,
- keylen, &result, &int_len));
- len = int_len;
+
+ char *result;
+ int int_len;
+ enum nss_status status = yperr2nss (yp_match (domain,
+ "services.byservicename", key,
+ keylen, &result, &int_len));
+ size_t len = int_len;
/* If we found the key, it's ok and parse the result. If not,
fall through and parse the complete table. */
- if (status == NSS_STATUS_SUCCESS)
+ if (__builtin_expect (status == NSS_STATUS_SUCCESS, 1))
{
- struct parser_data *pdata = (void *) buffer;
- int parse_res;
- char *p;
-
- if ((size_t) (len + 1) > buflen)
+ if (__builtin_expect ((size_t) (len + 1) > buflen, 0))
{
free (result);
*errnop = ERANGE;
return NSS_STATUS_TRYAGAIN;
}
- p = strncpy (buffer, result, len);
+ char *p = strncpy (buffer, result, len);
buffer[len] = '\0';
while (isspace (*p))
++p;
free (result);
- parse_res = _nss_files_parse_servent (p, serv, pdata,
- buflen, errnop);
- if (parse_res < 0)
+
+ int parse_res = _nss_files_parse_servent (p, serv, (void *) buffer,
+ buflen, errnop);
+ if (__builtin_expect (parse_res < 0, 0))
{
if (parse_res == -1)
return NSS_STATUS_TRYAGAIN;
@@ -360,10 +353,8 @@ _nss_nis_getservbyport_r (int port, const char *protocol,
struct servent *serv, char *buffer,
size_t buflen, int *errnop)
{
- enum nss_status status;
char *domain;
-
- if (yp_get_default_domain (&domain))
+ if (__builtin_expect (yp_get_default_domain (&domain), 0))
return NSS_STATUS_UNAVAIL;
/* If the protocol is given, we only need one query.
@@ -372,48 +363,45 @@ _nss_nis_getservbyport_r (int port, const char *protocol,
const char *proto = protocol != NULL ? protocol : "tcp";
do
{
+ /* key is: "port/proto" */
char key[sizeof (int) * 3 + strlen (proto) + 2];
+ size_t keylen = snprintf (key, sizeof (key), "%d/%s", ntohs (port),
+ proto);
+
char *result;
- size_t keylen, len;
int int_len;
-
- /* key is: "port/proto" */
- keylen = snprintf (key, sizeof (key), "%d/%s", ntohs (port), proto);
- status = yperr2nss (yp_match (domain, "services.byname", key,
- keylen, &result, &int_len));
- len = int_len;
+ enum nss_status status = yperr2nss (yp_match (domain, "services.byname",
+ key, keylen, &result,
+ &int_len));
+ size_t len = int_len;
/* If we found the key, it's ok and parse the result. If not,
fall through and parse the complete table. */
if (status == NSS_STATUS_SUCCESS)
{
- struct parser_data *pdata = (void *) buffer;
- int parse_res;
- char *p;
-
- if ((size_t) (len + 1) > buflen)
+ if (__builtin_expect ((size_t) (len + 1) > buflen, 0))
{
free (result);
*errnop = ERANGE;
return NSS_STATUS_TRYAGAIN;
}
- p = strncpy (buffer, result, len);
+ char *p = strncpy (buffer, result, len);
buffer[len] = '\0';
while (isspace (*p))
++p;
free (result);
- parse_res = _nss_files_parse_servent (p, serv, pdata,
- buflen, errnop);
- if (parse_res < 0)
+ int parse_res = _nss_files_parse_servent (p, serv, (void *) buffer,
+ buflen, errnop);
+ if (__builtin_expect (parse_res < 0, 0))
{
if (parse_res == -1)
return NSS_STATUS_TRYAGAIN;
else
return NSS_STATUS_NOTFOUND;
}
- else
- return NSS_STATUS_SUCCESS;
+
+ return NSS_STATUS_SUCCESS;
}
}
while (protocol == NULL && (proto[0] == 't' ? (proto = "udp") : NULL));
@@ -434,7 +422,8 @@ _nss_nis_getservbyport_r (int port, const char *protocol,
req.buflen = buflen;
req.errnop = errnop;
req.status = NSS_STATUS_NOTFOUND;
- status = yperr2nss (yp_all (domain, "services.byname", &ypcb));
+ enum nss_status status = yperr2nss (yp_all (domain, "services.byname",
+ &ypcb));
if (status != NSS_STATUS_SUCCESS)
return status;
diff --git a/nis/nss_nis/nis-spwd.c b/nis/nss_nis/nis-spwd.c
index 99a9ed5f48..820bfb25e5 100644
--- a/nis/nss_nis/nis-spwd.c
+++ b/nis/nss_nis/nis-spwd.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996-1998, 2001, 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 1996-1998,2001,2002,2003,2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996.
@@ -69,48 +69,53 @@ internal_nis_getspent_r (struct spwd *sp, char *buffer, size_t buflen,
int *errnop)
{
struct parser_data *data = (void *) buffer;
- char *domain, *result, *outkey;
- int len, keylen, parse_res;
- if (yp_get_default_domain (&domain))
+ char *domain;
+ if (__builtin_expect (yp_get_default_domain (&domain), 0))
return NSS_STATUS_UNAVAIL;
/* Get the next entry until we found a correct one. */
+ int parse_res;
do
{
- enum nss_status retval;
- char *p;
+ char *result;
+ char *outkey;
+ int len;
+ int keylen;
+ int yperr;
if (new_start)
- retval = yperr2nss (yp_first (domain, "shadow.byname",
- &outkey, &keylen, &result, &len));
+ yperr = yp_first (domain, "shadow.byname", &outkey, &keylen, &result,
+ &len);
else
- retval = yperr2nss ( yp_next (domain, "shadow.byname",
- oldkey, oldkeylen,
- &outkey, &keylen, &result, &len));
+ yperr = yp_next (domain, "shadow.byname", oldkey, oldkeylen, &outkey,
+ &keylen, &result, &len);
- if (retval != NSS_STATUS_SUCCESS)
+ if (__builtin_expect (yperr != YPERR_SUCCESS, 0))
{
+ enum nss_status retval = yperr2nss (yperr);
+
if (retval == NSS_STATUS_TRYAGAIN)
*errnop = errno;
return retval;
}
- if ((size_t) (len + 1) > buflen)
+ if (__builtin_expect ((size_t) (len + 1) > buflen, 0))
{
free (result);
*errnop = ERANGE;
return NSS_STATUS_TRYAGAIN;
}
- p = strncpy (buffer, result, len);
+ char *p = strncpy (buffer, result, len);
buffer[len] = '\0';
while (isspace (*p))
++p;
free (result);
- parse_res = _nss_files_parse_spent (p, sp, data, buflen, errnop);
- if (parse_res == -1)
+ parse_res = _nss_files_parse_spent (p, sp, (void *) buffer, buflen,
+ errnop);
+ if (__builtin_expect (parse_res == -1, 0))
{
free (outkey);
*errnop = ERANGE;
@@ -146,45 +151,46 @@ enum nss_status
_nss_nis_getspnam_r (const char *name, struct spwd *sp,
char *buffer, size_t buflen, int *errnop)
{
- struct parser_data *data = (void *) buffer;
- enum nss_status retval;
- char *domain, *result, *p;
- int len, parse_res;
-
if (name == NULL)
{
*errnop = EINVAL;
return NSS_STATUS_UNAVAIL;
}
- if (yp_get_default_domain (&domain))
+ char *domain;
+ if (__builtin_expect (yp_get_default_domain (&domain), 0))
return NSS_STATUS_UNAVAIL;
- retval = yperr2nss (yp_match (domain, "shadow.byname", name,
- strlen (name), &result, &len));
+ char *result;
+ int len;
+ int yperr = yp_match (domain, "shadow.byname", name, strlen (name), &result,
+ &len);
- if (retval != NSS_STATUS_SUCCESS)
+ if (__builtin_expect (yperr != YPERR_SUCCESS, 0))
{
+ enum nss_status retval = yperr2nss (yperr);
+
if (retval == NSS_STATUS_TRYAGAIN)
*errnop = errno;
return retval;
}
- if ((size_t) (len + 1) > buflen)
+ if (__builtin_expect ((size_t) (len + 1) > buflen, 0))
{
free (result);
*errnop = ERANGE;
return NSS_STATUS_TRYAGAIN;
}
- p = strncpy (buffer, result, len);
+ char *p = strncpy (buffer, result, len);
buffer[len] = '\0';
while (isspace (*p))
++p;
free (result);
- parse_res = _nss_files_parse_spent (p, sp, data, buflen, errnop);
- if (parse_res < 1)
+ int parse_res = _nss_files_parse_spent (p, sp, (void *) buffer, buflen,
+ errnop);
+ if (__builtin_expect (parse_res < 1, 0))
{
if (parse_res == -1)
return NSS_STATUS_TRYAGAIN;