diff options
Diffstat (limited to 'libc/misc')
-rw-r--r-- | libc/misc/hsearch_r.c | 17 | ||||
-rw-r--r-- | libc/misc/syslog.c | 7 |
2 files changed, 10 insertions, 14 deletions
diff --git a/libc/misc/hsearch_r.c b/libc/misc/hsearch_r.c index cb4d67466..c855a4184 100644 --- a/libc/misc/hsearch_r.c +++ b/libc/misc/hsearch_r.c @@ -1,4 +1,5 @@ -/* Copyright (C) 1993,1995-1997,2002,2005,2007 Free Software Foundation, Inc. +/* Copyright (C) 1993,1995-1997,2002,2005,2007,2008 + Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1993. @@ -154,18 +155,11 @@ hsearch_r (item, action, retval, htab) } /* First hash function: simply take the modul but prevent zero. */ - hval %= htab->size; - if (hval == 0) - ++hval; - - /* The first index tried. */ - idx = hval; + idx = hval % htab->size + 1; if (htab->table[idx].used) { /* Further action might be required according to the action value. */ - unsigned hval2; - if (htab->table[idx].used == hval && strcmp (item.key, htab->table[idx].entry.key) == 0) { @@ -174,7 +168,8 @@ hsearch_r (item, action, retval, htab) } /* Second hash function, as suggested in [Knuth] */ - hval2 = 1 + hval % (htab->size - 2); + unsigned int hval2 = 1 + hval % (htab->size - 2); + unsigned int first_idx = idx; do { @@ -186,7 +181,7 @@ hsearch_r (item, action, retval, htab) idx -= hval2; /* If we visited all entries leave the loop unsuccessfully. */ - if (idx == hval) + if (idx == first_idx) break; /* If entry is found use it. */ diff --git a/libc/misc/syslog.c b/libc/misc/syslog.c index 8f84faf75..90cd3bfa1 100644 --- a/libc/misc/syslog.c +++ b/libc/misc/syslog.c @@ -358,10 +358,11 @@ openlog_internal(const char *ident, int logstat, int logfac) # ifndef __ASSUME_SOCK_CLOEXEC if (__have_sock_cloexec == 0) __have_sock_cloexec - = (LogFile != -1 - || errno != EINVAL); + = ((LogFile != -1 + || errno != EINVAL) + ? 1 : -1); } -#endif +# endif #endif #ifndef __ASSUME_SOCK_CLOEXEC # ifdef SOCK_CLOEXEC |