From 80643307a082b5a3b7408040ce7d58d9f483a7bb Mon Sep 17 00:00:00 2001 From: Rocco Rutte Date: Wed, 2 Jul 2008 10:06:10 +0200 Subject: [PATCH] Use casts to avoid triggering integer overflow detection in hash function --- hash.c | 4 ++-- 1 file 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) -- 2.40.0