]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Cast unsigned chars to chars before passing to strlen.
authorTed Lemon <source@isc.org>
Mon, 12 Apr 1999 21:33:34 +0000 (21:33 +0000)
committerTed Lemon <source@isc.org>
Mon, 12 Apr 1999 21:33:34 +0000 (21:33 +0000)
common/hash.c

index 8fa51e69d9e0add0d837b5708034399a48eeb4b7..e8757fe92e15b03ceb87df15c66d5ab68e88bf5c 100644 (file)
@@ -22,7 +22,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: hash.c,v 1.13 1999/04/05 19:02:42 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: hash.c,v 1.14 1999/04/12 21:33:34 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -47,23 +47,12 @@ static INLINE int do_hash (name, len, size)
        register int accum = 0;
        register unsigned char *s = (unsigned char *)name;
        int i = len;
-       if (i) {
-               while (i--) {
-                       /* Add the character in... */
-                       accum += *s++;
-                       /* Add carry back in... */
-                       while (accum > 255) {
-                               accum = (accum & 255) + (accum >> 8);
-                       }
-               }
-       } else {
-               while (*s) {
-                       /* Add the character in... */
-                       accum += *s++;
-                       /* Add carry back in... */
-                       while (accum > 255) {
-                               accum = (accum & 255) + (accum >> 8);
-                       }
+       while (i--) {
+               /* Add the character in... */
+               accum += *s++;
+               /* Add carry back in... */
+               while (accum > 255) {
+                       accum = (accum & 255) + (accum >> 8);
                }
        }
        return accum % size;
@@ -82,7 +71,7 @@ void add_hash (table, name, len, pointer)
                return;
 
        if (!len)
-               len = strlen (name);
+               len = strlen ((char *)name);
 
        hashno = do_hash (name, len, table -> hash_count);
        bp = new_hash_bucket ("add_hash");
@@ -110,7 +99,7 @@ void delete_hash_entry (table, name, len)
                return;
 
        if (!len)
-               len = strlen (name);
+               len = strlen ((char *)name);
 
        hashno = do_hash (name, len, table -> hash_count);
 
@@ -144,7 +133,7 @@ unsigned char *hash_lookup (table, name, len)
        if (!table)
                return (unsigned char *)0;
        if (!len)
-               len = strlen (name);
+               len = strlen ((char *)name);
 
        hashno = do_hash (name, len, table -> hash_count);