about summary refs log tree commit diff
path: root/nis/nis_subr.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2005-07-30 19:37:11 +0000
committerUlrich Drepper <drepper@redhat.com>2005-07-30 19:37:11 +0000
commit1ce359b0fc6ee2f371be84f17e98cf99932c4eff (patch)
tree5a995df43d615efc649b96fe927416407b770970 /nis/nis_subr.c
parent29c21e490099c35fb3e35c2c493b6b480b211e72 (diff)
downloadglibc-1ce359b0fc6ee2f371be84f17e98cf99932c4eff.tar.gz
glibc-1ce359b0fc6ee2f371be84f17e98cf99932c4eff.tar.xz
glibc-1ce359b0fc6ee2f371be84f17e98cf99932c4eff.zip
* nis/nis_subr.c: Some minor code cleanups.
Diffstat (limited to 'nis/nis_subr.c')
-rw-r--r--nis/nis_subr.c20
1 files changed, 5 insertions, 15 deletions
diff --git a/nis/nis_subr.c b/nis/nis_subr.c
index 4c4ef8b5b4..5838e30e88 100644
--- a/nis/nis_subr.c
+++ b/nis/nis_subr.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 1997, 1999, 2000, 2004 Free Software Foundation, Inc.
+/* Copyright (c) 1997, 1999, 2000, 2004, 2005 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
 
@@ -39,22 +39,13 @@ nis_leaf_of_r (const_nis_name name, char *buffer, size_t buflen)
   while (name[i] != '.' && name[i] != '\0')
     i++;
 
-  if (i > buflen - 1)
+  if (__builtin_expect (i > buflen - 1, 0))
     {
       __set_errno (ERANGE);
       return NULL;
     }
 
-  if (i > 0)
-    {
-      if ((size_t)i >= buflen)
-	{
-	  __set_errno (ERANGE);
-	  return NULL;
-	}
-
-      *((char *) __mempcpy (buffer, name, i)) = '\0';
-    }
+  *((char *) __mempcpy (buffer, name, i)) = '\0';
 
   return buffer;
 }
@@ -98,13 +89,12 @@ nis_name_of_r (const_nis_name name, char *buffer, size_t buflen)
 }
 libnsl_hidden_def (nis_name_of_r)
 
-static int
+static int __always_inline
 count_dots (const_nis_name str)
 {
   int count = 0;
-  size_t l = strlen (str);
 
-  for (size_t i = 0; i < l; ++i)
+  for (size_t i = 0; str[i] != '\0'; ++i)
     if (str[i] == '.')
       ++count;