aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/support/murmur_hash.c
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2015-06-23 09:26:21 -0700
committerGravatar Craig Tiller <ctiller@google.com>2015-06-23 09:26:21 -0700
commit949b6ee7962aa01a6d3940380d1c3ecc85e85f4a (patch)
treed83f2d71923d2e2d3574ff1850500da69b2923fe /src/core/support/murmur_hash.c
parent624babfcd8f0aa26f74b2669c5c0d34ee8b7881a (diff)
parentf8fedc43d76f171b8f87bb65dc5d253e67db996f (diff)
Merge github.com:grpc/grpc into oops-i-split-it-again
Diffstat (limited to 'src/core/support/murmur_hash.c')
-rw-r--r--src/core/support/murmur_hash.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/core/support/murmur_hash.c b/src/core/support/murmur_hash.c
index cc84691508..37fdca82ba 100644
--- a/src/core/support/murmur_hash.c
+++ b/src/core/support/murmur_hash.c
@@ -48,7 +48,7 @@
gpr_uint32 gpr_murmur_hash3(const void *key, size_t len, gpr_uint32 seed) {
const gpr_uint8 *data = (const gpr_uint8 *)key;
- const int nblocks = len / 4;
+ const size_t nblocks = len / 4;
int i;
gpr_uint32 h1 = seed;
@@ -57,11 +57,11 @@ gpr_uint32 gpr_murmur_hash3(const void *key, size_t len, gpr_uint32 seed) {
const gpr_uint32 c1 = 0xcc9e2d51;
const gpr_uint32 c2 = 0x1b873593;
- const gpr_uint32 *blocks = (const uint32_t *)(data + nblocks * 4);
- const uint8_t *tail = (const uint8_t *)(data + nblocks * 4);
+ const gpr_uint32 *blocks = ((const gpr_uint32 *)key) + nblocks;
+ const gpr_uint8 *tail = (const gpr_uint8 *)(data + nblocks * 4);
/* body */
- for (i = -nblocks; i; i++) {
+ for (i = -(int)nblocks; i; i++) {
k1 = GETBLOCK32(blocks, i);
k1 *= c1;
@@ -78,9 +78,9 @@ gpr_uint32 gpr_murmur_hash3(const void *key, size_t len, gpr_uint32 seed) {
/* tail */
switch (len & 3) {
case 3:
- k1 ^= tail[2] << 16;
+ k1 ^= ((gpr_uint32)tail[2]) << 16;
case 2:
- k1 ^= tail[1] << 8;
+ k1 ^= ((gpr_uint32)tail[1]) << 8;
case 1:
k1 ^= tail[0];
k1 *= c1;
@@ -90,7 +90,7 @@ gpr_uint32 gpr_murmur_hash3(const void *key, size_t len, gpr_uint32 seed) {
};
/* finalization */
- h1 ^= len;
+ h1 ^= (gpr_uint32)len;
FMIX32(h1);
return h1;
}