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.
2006-04-08 Ulrich Drepper <drepper@redhat.com>
+ * 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.
+
* nis/nis_ping.c: Remove unnecessary conditionals before
nis_freeresult calls.
* nis/nis_ismember.c: Likewise.
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;
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. */
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;
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;
-/* 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.
_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;
_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;
-/* 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.
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;
_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;
_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;
-/* 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.
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;
}
/* 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:
return retval;
}
- if ((size_t) (len + 1) > linebuflen)
+ if (__builtin_expect ((size_t) (len + 1) > linebuflen, 0))
{
free (result);
*h_errnop = NETDB_INTERNAL;
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;
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)
{
return NSS_STATUS_UNAVAIL;
}
+ char *domain;
if (yp_get_default_domain (&domain))
return NSS_STATUS_UNAVAIL;
*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;
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;
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)
{
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;
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)
{
-/* 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.
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;
}
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. */
if (*start == *size)
{
/* Need a bigger buffer. */
- gid_t *newgroups;
long int newsize;
if (limit > 0 && *size == limit)
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;
-/* 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.
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
return NSS_STATUS_SUCCESS;
}
+
enum nss_status
_nss_nis_getnetgrent_r (struct __netgrent *result, char *buffer, size_t buflen,
int *errnop)
-/* 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.
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;
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_netent (p, net, data, buflen, errnop);
- if (parse_res == -1)
+ if (__builtin_expect (parse_res == -1, 0))
{
free (outkey);
*herrnop = NETDB_INTERNAL;
_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;
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;
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_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)
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')
}
}
- 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_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)
-/* 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.
_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;
_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;
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)
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;
_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)
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;
char *p = strchr (result, ':');
if (p != NULL)
{
+ char buf[2 * (HEXKEYBYTES + 1)];
+
++p;
strncpy (buf, p, 2 * (HEXKEYBYTES + 1));
buf[2 * HEXKEYBYTES + 1] = '\0';
_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;
/* 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:
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;
}
-/* 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.
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;
/* 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,
}
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);
else
{
non_adjunct:
- if ((size_t) (len + 1) > buflen)
+ if (__builtin_expect ((size_t) (len + 1) > buflen, 0))
{
free (result);
*errnop = ERANGE;
++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;
_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;
/* 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,
therein into original result. */
char *encrypted = strchr (result2, ':');
char *endp;
- size_t restlen;
if (encrypted == NULL
|| (endp = strchr (++encrypted, ':')) == NULL
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);
else
{
non_adjunct:
- if ((size_t) (len + 1) > buflen)
+ if (__builtin_expect ((size_t) (len + 1) > buflen, 0))
{
free (result);
*errnop = ERANGE;
++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;
_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;
/* 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,
}
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);
else
{
non_adjunct:
- if ((size_t) (len + 1) > buflen)
+ if (__builtin_expect ((size_t) (len + 1) > buflen, 0))
{
free (result);
*errnop = ERANGE;
++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;
-/* 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.
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;
++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;
}
_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))
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;
-/* 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.
{
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;
++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;
}
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;
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.
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));
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;
-/* 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.
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;
_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;
2006-04-08 Ulrich Drepper <drepper@redhat.com>
+ * sysdeps/unix/sysv/linux/i386/lowlevellock.h: Remove branch predicion
+ suffix for conditional jumps.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_trywait.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/libc-lowlevellock.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/pthread_barrier_wait.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_timedwait.S: Likewise.
+ * sysdeps/unix/sysv/linux/i386/i486/sem_wait.S: Likewise.
+
* init.c (sigcancel_handler): Compare with correct PID even if the
thread is in the middle of a fork call.
(sighandler_setxid): Likewise.
#ifndef UP
# define LOCK \
cmpl $0, %gs:MULTIPLE_THREADS_OFFSET; \
- je,pt 0f; \
+ je 0f; \
lock; \
0:
#endif
xchgl %eax, (%ebx) /* NB: lock is implied */
testl %eax, %eax
- jnz,pn 1b
+ jnz 1b
popl %esi
popl %ebx
#else
cmpl %edx, CURR_EVENT(%ebx)
#endif
- je,pn 8b
+ je 8b
/* Increment LEFT. If this brings the count back to the
initial count unlock the object. */
xaddl %edx, LEFT(%ebx)
subl $1, %ecx
cmpl %ecx, %edx
- jne,pt 10f
+ jne 10f
/* Release the mutex. We cannot release the lock before
waking the waiting threads since otherwise a new thread might
xaddl %edx, LEFT(%ebx)
subl $1, %ecx
cmpl %ecx, %edx
- jne,pt 5f
+ jne 5f
/* Release the mutex. We cannot release the lock before
waking the waiting threads since otherwise a new thread might
movl (%ecx), %eax
2: testl %eax, %eax
- je,pn 1f
+ je 1f
leal -1(%eax), %edx
LOCK
cmpxchgl %edx, (%ecx)
- jne,pn 2b
+ jne 2b
xorl %eax, %eax
ret
call __pthread_disable_asynccancel
testl %esi, %esi
- je,pt 9f
+ je 9f
cmpl $-EWOULDBLOCK, %esi
jne 3f
leal -1(%eax), %ecx
LOCK
cmpxchgl %ecx, (%ebx)
- jne,pn 8b
+ jne 8b
addl $12, %esp
cfi_adjust_cfa_offset(-12)
leal -1(%eax), %edx
LOCK
cmpxchgl %edx, (%ecx)
- jne,pn 2b
+ jne 2b
xorl %eax, %eax
ret
leal -1(%eax), %edx
LOCK
cmpxchgl %edx, (%ebx)
- jne,pn 2b
+ jne 2b
xorl %eax, %eax
movl 4(%esp), %esi
# define lll_trylock(futex) \
({ unsigned char ret; \
__asm __volatile ("cmpl $0, %%gs:%P5\n\t" \
- "je,pt 0f\n\t" \
+ "je 0f\n\t" \
"lock\n" \
"0:\tcmpxchgl %2, %1; setne %0" \
: "=a" (ret), "=m" (futex) \
# define lll_lock(futex) \
(void) ({ int ignore1, ignore2; \
__asm __volatile ("cmpl $0, %%gs:%P6\n\t" \
- "je,pt 0f\n\t" \
+ "je 0f\n\t" \
"lock\n" \
"0:\tcmpxchgl %1, %2\n\t" \
"jnz _L_mutex_lock_%=\n\t" \
# define lll_unlock(futex) \
(void) ({ int ignore; \
__asm __volatile ("cmpl $0, %%gs:%P3\n\t" \
- "je,pt 0f\n\t" \
+ "je 0f\n\t" \
"lock\n" \
"0:\tsubl $1,%0\n\t" \
"jne _L_mutex_unlock_%=\n\t" \
"1:\tmovl %1, %%eax\n\t" \
LLL_ENTER_KERNEL \
"cmpl $0, (%%ebx)\n\t" \
- "jne,pn 1b\n\t" \
+ "jne 1b\n\t" \
LLL_EBX_LOAD \
: "=&a" (__ignore) \
: "i" (SYS_futex), LLL_EBX_REG (&tid), "S" (0), \