Skip to content

Commit

Permalink
* nis/nis_subr.c: Some minor code cleanups.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulrich Drepper committed Jul 30, 2005
1 parent 29c21e4 commit 1ce359b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2005-07-30 Ulrich Drepper <drepper@redhat.com>

* nis/nis_subr.c: Some minor code cleanups.

2005-07-29 Ulrich Drepper <drepper@redhat.com>

* misc/bits/syslog.h: New file.
Expand Down
20 changes: 5 additions & 15 deletions nis/nis_subr.c
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 1ce359b

Please sign in to comment.