From 5e71d7aff16a95bf621c7c3451b3a295b1f9b0b3 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Fri, 19 Jun 2015 12:24:44 -0700 Subject: Silenced conversion warnings in src/core/support --- src/core/support/murmur_hash.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/core/support/murmur_hash.c') diff --git a/src/core/support/murmur_hash.c b/src/core/support/murmur_hash.c index cc84691508..e875ba7228 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; } -- cgit v1.2.3 From 154cb407a803c77b76fd3c14e9f5b329ceb2912d Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Mon, 22 Jun 2015 14:48:25 -0700 Subject: Made requested fixes --- src/core/support/murmur_hash.c | 4 ++-- src/core/support/slice.c | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src/core/support/murmur_hash.c') diff --git a/src/core/support/murmur_hash.c b/src/core/support/murmur_hash.c index e875ba7228..37fdca82ba 100644 --- a/src/core/support/murmur_hash.c +++ b/src/core/support/murmur_hash.c @@ -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 ^= (gpr_uint32)(tail[2] << 16); + k1 ^= ((gpr_uint32)tail[2]) << 16; case 2: - k1 ^= (gpr_uint32)(tail[1] << 8); + k1 ^= ((gpr_uint32)tail[1]) << 8; case 1: k1 ^= tail[0]; k1 *= c1; diff --git a/src/core/support/slice.c b/src/core/support/slice.c index a2d62fc1e5..5a3dbe1736 100644 --- a/src/core/support/slice.c +++ b/src/core/support/slice.c @@ -31,6 +31,8 @@ * */ +#include + #include #include #include @@ -313,7 +315,7 @@ gpr_slice gpr_slice_split_head(gpr_slice *source, size_t split) { } int gpr_slice_cmp(gpr_slice a, gpr_slice b) { - int d = (int)(GPR_SLICE_LENGTH(a) - GPR_SLICE_LENGTH(b)); + ssize_t d = (ssize_t)(GPR_SLICE_LENGTH(a) - GPR_SLICE_LENGTH(b)); if (d != 0) return d; return memcmp(GPR_SLICE_START_PTR(a), GPR_SLICE_START_PTR(b), GPR_SLICE_LENGTH(a)); @@ -321,7 +323,7 @@ int gpr_slice_cmp(gpr_slice a, gpr_slice b) { int gpr_slice_str_cmp(gpr_slice a, const char *b) { size_t b_length = strlen(b); - int d = (int)(GPR_SLICE_LENGTH(a) - b_length); + ssize_t d = (ssize_t)(GPR_SLICE_LENGTH(a) - b_length); if (d != 0) return d; return memcmp(GPR_SLICE_START_PTR(a), b, b_length); } -- cgit v1.2.3