summaryrefslogtreecommitdiffstats
path: root/hash.c
diff options
context:
space:
mode:
authorRocco Rutte <pdmef@gmx.net>2008-07-02 10:06:10 +0200
committerRocco Rutte <pdmef@gmx.net>2008-07-02 10:06:10 +0200
commit80643307a082b5a3b7408040ce7d58d9f483a7bb (patch)
tree22dd2819f17120fba465ed8ff9f78dfcc2bcd2dc /hash.c
parent730fbc5c71c91b8ee9bd8601cf75888946a0ee7b (diff)
Use casts to avoid triggering integer overflow detection in hash function
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/hash.c b/hash.c
index 2c7e6dd7..d872f61d 100644
--- a/hash.c
+++ b/hash.c
@@ -30,7 +30,7 @@
int hash_string (const unsigned char *s, int n)
{
- int h = 0;
+ unsigned int h = 0;
#if 0
while (*s)
@@ -42,7 +42,7 @@ int hash_string (const unsigned char *s, int n)
h = (h >= 0) ? h : h + n;
#endif
- return (h % n);
+ return (signed) (h % n);
}
HASH *hash_create (int nelem)