aboutsummaryrefslogtreecommitdiff
path: root/nis/nss_nis/nis-service.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2006-04-28 21:08:22 +0000
committerUlrich Drepper <drepper@redhat.com>2006-04-28 21:08:22 +0000
commit4eaa9bb48b319803544909a085651fc6ff4a9ea1 (patch)
tree82576e0a3da147dbad681d17ef6bb3aec4f0ba0d /nis/nss_nis/nis-service.c
parentee821689eb2a2db7d303d4e3efa7ef54f502c854 (diff)
downloadglibc-4eaa9bb48b319803544909a085651fc6ff4a9ea1.tar
glibc-4eaa9bb48b319803544909a085651fc6ff4a9ea1.tar.gz
glibc-4eaa9bb48b319803544909a085651fc6ff4a9ea1.tar.bz2
glibc-4eaa9bb48b319803544909a085651fc6ff4a9ea1.zip
* nis/nss-default.c (vars): Add SETENT_BATCH_READ.
* nis/nss: Document SETENT_BATCH_READ. * nis/libnsl.h: Define NSS_FLAG_SETENT_BATCH_READ. * nis/nss_nis/nis-service.c (saveit): Don't add NUL byte if the string is already NUL terminated. (internal_nis_endservent): No need to return anything. Change callers. (internal_nis_setservent): One more initialization. * nis/nss_nis/nis-pwd.c: Support SETENT_BATCH_READ option. * nis/nss_nis/nis-grp.c: Likewise. * nis/nss-default.c (init): Rewrite parser to get the variables
Diffstat (limited to 'nis/nss_nis/nis-service.c')
-rw-r--r--nis/nss_nis/nis-service.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/nis/nss_nis/nis-service.c b/nis/nss_nis/nis-service.c
index f5d886fc90..f705ff77cf 100644
--- a/nis/nss_nis/nis-service.c
+++ b/nis/nss_nis/nis-service.c
@@ -110,9 +110,13 @@ saveit (int instatus, char *inkey, int inkeylen, char *inval,
intern.offset = 0;
}
- *((char *) mempcpy (&bucket->mem[intern.offset], inval, invallen))
- = '\0';
- intern.offset += invallen + 1;
+ char *p = mempcpy (&bucket->mem[intern.offset], inval, invallen);
+ if (__builtin_expect (p[-1] != '\0', 0))
+ {
+ *p = '\0';
+ ++invallen;
+ }
+ intern.offset += invallen;
}
return 0;
@@ -177,7 +181,7 @@ dosearch (int instatus, char *inkey, int inkeylen, char *inval,
return 0;
}
-static enum nss_status
+static void
internal_nis_endservent (void)
{
struct response_t *curr = intern.next;
@@ -190,22 +194,18 @@ internal_nis_endservent (void)
}
intern.next = intern.start = NULL;
-
- return NSS_STATUS_SUCCESS;
}
enum nss_status
_nss_nis_endservent (void)
{
- enum nss_status status;
-
__libc_lock_lock (lock);
- status = internal_nis_endservent ();
+ internal_nis_endservent ();
__libc_lock_unlock (lock);
- return status;
+ return NSS_STATUS_SUCCESS;
}
static enum nss_status
@@ -218,16 +218,18 @@ internal_nis_setservent (void)
if (yp_get_default_domain (&domainname))
return NSS_STATUS_UNAVAIL;
- (void) internal_nis_endservent ();
+ internal_nis_endservent ();
ypcb.foreach = saveit;
ypcb.data = NULL;
status = yperr2nss (yp_all (domainname, "services.byname", &ypcb));
/* Mark the last buffer as full. */
- intern.next->size = intern.offset;
+ if (intern.next != NULL)
+ intern.next->size = intern.offset;
intern.next = intern.start;
+ intern.offset = 0;
return status;
}
@@ -262,7 +264,7 @@ internal_nis_getservent_r (struct servent *serv, char *buffer,
{
struct response_t *bucket = intern.next;
- if (intern.offset >= bucket->size)
+ if (__builtin_expect (intern.offset >= bucket->size, 0))
{
if (bucket->next == NULL)
return NSS_STATUS_NOTFOUND;