From: Brian Aker Date: Tue, 20 Jul 2010 00:31:05 +0000 (-0700) Subject: Merge in cast fix for H algo X-Git-Tag: 0.44~18 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=bf6025dd72490837e51cfa3d2d703eb7cdade2db;p=m6w6%2Flibmemcached Merge in cast fix for H algo --- diff --git a/libhashkit/hsieh.c b/libhashkit/hsieh.c index c688add6..ba46ed2c 100644 --- a/libhashkit/hsieh.c +++ b/libhashkit/hsieh.c @@ -43,16 +43,18 @@ uint32_t hashkit_hsieh(const char *key, size_t key_length, void *context __attri { case 3: hash += get16bits (key); hash ^= hash << 16; - hash ^= key[sizeof (uint16_t)] << 18; + hash ^= (uint32_t)key[sizeof (uint16_t)] << 18; hash += hash >> 11; break; case 2: hash += get16bits (key); hash ^= hash << 11; hash += hash >> 17; break; - case 1: hash += *key; + case 1: hash += (unsigned char)(*key); hash ^= hash << 10; hash += hash >> 1; + default: + break; } /* Force "avalanching" of final 127 bits */