BUG/MEDIUM: backend: Update hash to use unsigned int throughout
When we were generating a hash, it was done using an unsigned long. When the hash was used
to select a backend, it was sent as an unsigned int. This made it difficult to predict which
backend would be selected.
This patch updates get_hash, and the hash methods to use an unsigned int, to remain consistent
throughout the codebase.
This fix should be backported to 1.5 and probably in part to 1.4.
diff --git a/src/hash.c b/src/hash.c
index 034685e..aa236cb 100644
--- a/src/hash.c
+++ b/src/hash.c
@@ -17,7 +17,7 @@
#include <common/hash.h>
-unsigned long hash_wt6(const char *key, int len)
+unsigned int hash_wt6(const char *key, int len)
{
unsigned h0 = 0xa53c965aUL;
unsigned h1 = 0x5ca6953aUL;
@@ -44,9 +44,9 @@
return h0 ^ h1;
}
-unsigned long hash_djb2(const char *key, int len)
+unsigned int hash_djb2(const char *key, int len)
{
- unsigned long hash = 5381;
+ unsigned int hash = 5381;
/* the hash unrolled eight times */
for (; len >= 8; len -= 8) {
@@ -72,9 +72,9 @@
return hash;
}
-unsigned long hash_sdbm(const char *key, int len)
+unsigned int hash_sdbm(const char *key, int len)
{
- unsigned long hash = 0;
+ unsigned int hash = 0;
int c;
while (len--) {