From 5e71d7aff16a95bf621c7c3451b3a295b1f9b0b3 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Fri, 19 Jun 2015 12:24:44 -0700 Subject: [PATCH 1/6] Silenced conversion warnings in src/core/support --- src/core/support/cmdline.c | 6 +++--- src/core/support/cpu_linux.c | 6 +++--- src/core/support/file.c | 3 ++- src/core/support/histogram.c | 6 +++--- src/core/support/host_port.c | 4 ++-- src/core/support/murmur_hash.c | 14 +++++++------- src/core/support/slice.c | 28 +++++++++++++++------------- src/core/support/slice_buffer.c | 8 ++++---- src/core/support/string.c | 6 +++--- src/core/support/subprocess_posix.c | 4 ++-- src/core/support/time.c | 16 ++++++++-------- src/core/support/time_posix.c | 2 +- 12 files changed, 53 insertions(+), 50 deletions(-) diff --git a/src/core/support/cmdline.c b/src/core/support/cmdline.c index 4baad85040c..45a3182f73a 100644 --- a/src/core/support/cmdline.c +++ b/src/core/support/cmdline.c @@ -228,7 +228,7 @@ static void value_state(gpr_cmdline *cl, char *arg) { cl->cur_arg->name); print_usage_and_die(cl); } - *(int *)cl->cur_arg->value = intval; + *(int *)cl->cur_arg->value = (int)intval; break; case ARGTYPE_BOOL: if (0 == strcmp(arg, "1") || 0 == strcmp(arg, "true")) { @@ -287,8 +287,8 @@ static void normal_state(gpr_cmdline *cl, char *arg) { eq = strchr(arg, '='); if (eq != NULL) { /* copy the string into a temp buffer and extract the name */ - tmp = arg_name = gpr_malloc(eq - arg + 1); - memcpy(arg_name, arg, eq - arg); + tmp = arg_name = gpr_malloc((size_t)(eq - arg + 1)); + memcpy(arg_name, arg, (size_t)(eq - arg)); arg_name[eq - arg] = 0; } else { arg_name = arg; diff --git a/src/core/support/cpu_linux.c b/src/core/support/cpu_linux.c index 37e840d4cf9..a748d43cf05 100644 --- a/src/core/support/cpu_linux.c +++ b/src/core/support/cpu_linux.c @@ -48,10 +48,10 @@ #include #include -static int ncpus = 0; +static unsigned ncpus = 0; static void init_num_cpus() { - ncpus = sysconf(_SC_NPROCESSORS_ONLN); + ncpus = (unsigned)sysconf(_SC_NPROCESSORS_ONLN); if (ncpus < 1) { gpr_log(GPR_ERROR, "Cannot determine number of CPUs: assuming 1"); ncpus = 1; @@ -70,7 +70,7 @@ unsigned gpr_cpu_current_cpu(void) { gpr_log(GPR_ERROR, "Error determining current CPU: %s\n", strerror(errno)); return 0; } - return cpu; + return (unsigned)cpu; } #endif /* GPR_CPU_LINUX */ diff --git a/src/core/support/file.c b/src/core/support/file.c index 8ce7a67fb1e..c1361d8a9e3 100644 --- a/src/core/support/file.c +++ b/src/core/support/file.c @@ -58,7 +58,8 @@ gpr_slice gpr_load_file(const char *filename, int add_null_terminator, goto end; } fseek(file, 0, SEEK_END); - contents_size = ftell(file); + /* Converting to size_t on the assumption that it will not fail */ + contents_size = (size_t)ftell(file); fseek(file, 0, SEEK_SET); contents = gpr_malloc(contents_size + (add_null_terminator ? 1 : 0)); bytes_read = fread(contents, 1, contents_size, file); diff --git a/src/core/support/histogram.c b/src/core/support/histogram.c index 673affde713..2f1adcf5119 100644 --- a/src/core/support/histogram.c +++ b/src/core/support/histogram.c @@ -189,12 +189,12 @@ static double threshold_for_count_below(gpr_histogram *h, double count_below) { break; } } - return (bucket_start(h, lower_idx) + bucket_start(h, upper_idx)) / 2.0; + return (bucket_start(h, (double)lower_idx) + bucket_start(h, (double)upper_idx)) / 2.0; } else { /* treat values as uniform throughout the bucket, and find where this value should lie */ - lower_bound = bucket_start(h, lower_idx); - upper_bound = bucket_start(h, lower_idx + 1); + lower_bound = bucket_start(h, (double)lower_idx); + upper_bound = bucket_start(h, (double)(lower_idx + 1)); return GPR_CLAMP(upper_bound - (upper_bound - lower_bound) * (count_so_far - count_below) / h->buckets[lower_idx], diff --git a/src/core/support/host_port.c b/src/core/support/host_port.c index 53669f063b7..0906ebc2a37 100644 --- a/src/core/support/host_port.c +++ b/src/core/support/host_port.c @@ -76,7 +76,7 @@ void gpr_split_host_port(const char *name, char **host, char **port) { return; } host_start = name + 1; - host_len = rbracket - host_start; + host_len = (size_t)(rbracket - host_start); if (memchr(host_start, ':', host_len) == NULL) { /* Require all bracketed hosts to contain a colon, because a hostname or IPv4 address should never use brackets. */ @@ -87,7 +87,7 @@ void gpr_split_host_port(const char *name, char **host, char **port) { if (colon != NULL && strchr(colon + 1, ':') == NULL) { /* Exactly 1 colon. Split into host:port. */ host_start = name; - host_len = colon - name; + host_len = (size_t)(colon - name); port_start = colon + 1; } else { /* 0 or 2+ colons. Bare hostname or IPv6 litearal. */ diff --git a/src/core/support/murmur_hash.c b/src/core/support/murmur_hash.c index cc84691508f..e875ba72283 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; } diff --git a/src/core/support/slice.c b/src/core/support/slice.c index 4cff029286c..a2d62fc1e53 100644 --- a/src/core/support/slice.c +++ b/src/core/support/slice.c @@ -194,7 +194,7 @@ gpr_slice gpr_slice_malloc(size_t length) { } else { /* small slice: just inline the data */ slice.refcount = NULL; - slice.data.inlined.length = length; + slice.data.inlined.length = (gpr_uint8)length; } return slice; } @@ -202,11 +202,11 @@ gpr_slice gpr_slice_malloc(size_t length) { gpr_slice gpr_slice_sub_no_ref(gpr_slice source, size_t begin, size_t end) { gpr_slice subset; + GPR_ASSERT(end >= begin); + if (source.refcount) { /* Enforce preconditions */ - GPR_ASSERT(source.data.refcounted.length >= begin); GPR_ASSERT(source.data.refcounted.length >= end); - GPR_ASSERT(end >= begin); /* Build the result */ subset.refcount = source.refcount; @@ -214,8 +214,10 @@ gpr_slice gpr_slice_sub_no_ref(gpr_slice source, size_t begin, size_t end) { subset.data.refcounted.bytes = source.data.refcounted.bytes + begin; subset.data.refcounted.length = end - begin; } else { + /* Enforce preconditions */ + GPR_ASSERT(source.data.inlined.length >= end); subset.refcount = NULL; - subset.data.inlined.length = end - begin; + subset.data.inlined.length = (gpr_uint8)(end - begin); memcpy(subset.data.inlined.bytes, source.data.inlined.bytes + begin, end - begin); } @@ -227,7 +229,7 @@ gpr_slice gpr_slice_sub(gpr_slice source, size_t begin, size_t end) { if (end - begin <= sizeof(subset.data.inlined.bytes)) { subset.refcount = NULL; - subset.data.inlined.length = end - begin; + subset.data.inlined.length = (gpr_uint8)(end - begin); memcpy(subset.data.inlined.bytes, GPR_SLICE_START_PTR(source) + begin, end - begin); } else { @@ -245,17 +247,17 @@ gpr_slice gpr_slice_split_tail(gpr_slice *source, size_t split) { /* inlined data, copy it out */ GPR_ASSERT(source->data.inlined.length >= split); tail.refcount = NULL; - tail.data.inlined.length = source->data.inlined.length - split; + tail.data.inlined.length = (gpr_uint8)(source->data.inlined.length - split); memcpy(tail.data.inlined.bytes, source->data.inlined.bytes + split, tail.data.inlined.length); - source->data.inlined.length = split; + source->data.inlined.length = (gpr_uint8)split; } else { size_t tail_length = source->data.refcounted.length - split; GPR_ASSERT(source->data.refcounted.length >= split); if (tail_length < sizeof(tail.data.inlined.bytes)) { /* Copy out the bytes - it'll be cheaper than refcounting */ tail.refcount = NULL; - tail.data.inlined.length = tail_length; + tail.data.inlined.length = (gpr_uint8)tail_length; memcpy(tail.data.inlined.bytes, source->data.refcounted.bytes + split, tail_length); } else { @@ -280,16 +282,16 @@ gpr_slice gpr_slice_split_head(gpr_slice *source, size_t split) { GPR_ASSERT(source->data.inlined.length >= split); head.refcount = NULL; - head.data.inlined.length = split; + head.data.inlined.length = (gpr_uint8)split; memcpy(head.data.inlined.bytes, source->data.inlined.bytes, split); - source->data.inlined.length -= split; + source->data.inlined.length = (gpr_uint8)(source->data.inlined.length - split); memmove(source->data.inlined.bytes, source->data.inlined.bytes + split, source->data.inlined.length); } else if (split < sizeof(head.data.inlined.bytes)) { GPR_ASSERT(source->data.refcounted.length >= split); head.refcount = NULL; - head.data.inlined.length = split; + head.data.inlined.length = (gpr_uint8)split; memcpy(head.data.inlined.bytes, source->data.refcounted.bytes, split); source->data.refcounted.bytes += split; source->data.refcounted.length -= split; @@ -311,7 +313,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 = GPR_SLICE_LENGTH(a) - GPR_SLICE_LENGTH(b); + int d = (int)(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)); @@ -319,7 +321,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 = GPR_SLICE_LENGTH(a) - b_length; + int d = (int)(GPR_SLICE_LENGTH(a) - b_length); if (d != 0) return d; return memcmp(GPR_SLICE_START_PTR(a), b, b_length); } diff --git a/src/core/support/slice_buffer.c b/src/core/support/slice_buffer.c index 91b5d8c98b2..7e25d99774c 100644 --- a/src/core/support/slice_buffer.c +++ b/src/core/support/slice_buffer.c @@ -81,7 +81,7 @@ gpr_uint8 *gpr_slice_buffer_tiny_add(gpr_slice_buffer *sb, unsigned n) { if ((back->data.inlined.length + n) > sizeof(back->data.inlined.bytes)) goto add_new; out = back->data.inlined.bytes + back->data.inlined.length; - back->data.inlined.length += n; + back->data.inlined.length = (gpr_uint8)(back->data.inlined.length + n); return out; add_new: @@ -89,7 +89,7 @@ add_new: back = &sb->slices[sb->count]; sb->count++; back->refcount = NULL; - back->data.inlined.length = n; + back->data.inlined.length = (gpr_uint8)n; return back->data.inlined.bytes; } @@ -116,7 +116,7 @@ void gpr_slice_buffer_add(gpr_slice_buffer *sb, gpr_slice s) { GPR_SLICE_INLINED_SIZE) { memcpy(back->data.inlined.bytes + back->data.inlined.length, s.data.inlined.bytes, s.data.inlined.length); - back->data.inlined.length += s.data.inlined.length; + back->data.inlined.length = (gpr_uint8)(back->data.inlined.length + s.data.inlined.length); } else { size_t cp1 = GPR_SLICE_INLINED_SIZE - back->data.inlined.length; memcpy(back->data.inlined.bytes + back->data.inlined.length, @@ -126,7 +126,7 @@ void gpr_slice_buffer_add(gpr_slice_buffer *sb, gpr_slice s) { back = &sb->slices[n]; sb->count = n + 1; back->refcount = NULL; - back->data.inlined.length = s.data.inlined.length - cp1; + back->data.inlined.length = (gpr_uint8)(s.data.inlined.length - cp1); memcpy(back->data.inlined.bytes, s.data.inlined.bytes + cp1, s.data.inlined.length - cp1); } diff --git a/src/core/support/string.c b/src/core/support/string.c index bfd7ce1590d..6a80ccc8411 100644 --- a/src/core/support/string.c +++ b/src/core/support/string.c @@ -94,7 +94,7 @@ char *gpr_hexdump(const char *buf, size_t len, gpr_uint32 flags) { if (len) hexout_append(&out, ' '); hexout_append(&out, '\''); for (cur = beg; cur != end; ++cur) { - hexout_append(&out, isprint(*cur) ? *cur : '.'); + hexout_append(&out, isprint(*cur) ? *(char*)cur : '.'); } hexout_append(&out, '\''); } @@ -113,7 +113,7 @@ int gpr_parse_bytes_to_uint32(const char *buf, size_t len, gpr_uint32 *result) { for (i = 0; i < len; i++) { if (buf[i] < '0' || buf[i] > '9') return 0; /* bad char */ - new = 10 * out + (buf[i] - '0'); + new = 10 * out + (gpr_uint32)(buf[i] - '0'); if (new < out) return 0; /* overflow */ out = new; } @@ -143,7 +143,7 @@ int gpr_ltoa(long value, char *string) { if (neg) value = -value; while (value) { - string[i++] = '0' + value % 10; + string[i++] = (char)('0' + value % 10); value /= 10; } if (neg) string[i++] = '-'; diff --git a/src/core/support/subprocess_posix.c b/src/core/support/subprocess_posix.c index b4631fa0edb..171054e4da6 100644 --- a/src/core/support/subprocess_posix.c +++ b/src/core/support/subprocess_posix.c @@ -66,8 +66,8 @@ gpr_subprocess *gpr_subprocess_create(int argc, const char **argv) { if (pid == -1) { return NULL; } else if (pid == 0) { - exec_args = gpr_malloc((argc + 1) * sizeof(char *)); - memcpy(exec_args, argv, argc * sizeof(char *)); + exec_args = gpr_malloc(((size_t)argc + 1) * sizeof(char *)); + memcpy(exec_args, argv, (size_t)argc * sizeof(char *)); exec_args[argc] = NULL; execv(exec_args[0], exec_args); /* if we reach here, an error has occurred */ diff --git a/src/core/support/time.c b/src/core/support/time.c index 7dbf95059f5..d47b08b2664 100644 --- a/src/core/support/time.c +++ b/src/core/support/time.c @@ -86,11 +86,11 @@ gpr_timespec gpr_time_from_nanos(long ns) { result = gpr_inf_past; } else if (ns >= 0) { result.tv_sec = ns / GPR_NS_PER_SEC; - result.tv_nsec = ns - result.tv_sec * GPR_NS_PER_SEC; + result.tv_nsec = (int)(ns - result.tv_sec * GPR_NS_PER_SEC); } else { /* Calculation carefully formulated to avoid any possible under/overflow. */ result.tv_sec = (-(999999999 - (ns + GPR_NS_PER_SEC)) / GPR_NS_PER_SEC) - 1; - result.tv_nsec = ns - result.tv_sec * GPR_NS_PER_SEC; + result.tv_nsec = (int)(ns - result.tv_sec * GPR_NS_PER_SEC); } return result; } @@ -103,11 +103,11 @@ gpr_timespec gpr_time_from_micros(long us) { result = gpr_inf_past; } else if (us >= 0) { result.tv_sec = us / 1000000; - result.tv_nsec = (us - result.tv_sec * 1000000) * 1000; + result.tv_nsec = (int)((us - result.tv_sec * 1000000) * 1000); } else { /* Calculation carefully formulated to avoid any possible under/overflow. */ result.tv_sec = (-(999999 - (us + 1000000)) / 1000000) - 1; - result.tv_nsec = (us - result.tv_sec * 1000000) * 1000; + result.tv_nsec = (int)((us - result.tv_sec * 1000000) * 1000); } return result; } @@ -120,11 +120,11 @@ gpr_timespec gpr_time_from_millis(long ms) { result = gpr_inf_past; } else if (ms >= 0) { result.tv_sec = ms / 1000; - result.tv_nsec = (ms - result.tv_sec * 1000) * 1000000; + result.tv_nsec = (int)((ms - result.tv_sec * 1000) * 1000000); } else { /* Calculation carefully formulated to avoid any possible under/overflow. */ result.tv_sec = (-(999 - (ms + 1000)) / 1000) - 1; - result.tv_nsec = (ms - result.tv_sec * 1000) * 1000000; + result.tv_nsec = (int)((ms - result.tv_sec * 1000) * 1000000); } return result; } @@ -245,10 +245,10 @@ gpr_int32 gpr_time_to_millis(gpr_timespec t) { care?) */ return -2147483647; } else { - return t.tv_sec * GPR_MS_PER_SEC + t.tv_nsec / GPR_NS_PER_MS; + return (gpr_int32)(t.tv_sec * GPR_MS_PER_SEC + t.tv_nsec / GPR_NS_PER_MS); } } double gpr_timespec_to_micros(gpr_timespec t) { - return t.tv_sec * GPR_US_PER_SEC + t.tv_nsec * 1e-3; + return (double)t.tv_sec * GPR_US_PER_SEC + t.tv_nsec * 1e-3; } diff --git a/src/core/support/time_posix.c b/src/core/support/time_posix.c index 3675f1eb229..afb58ef2313 100644 --- a/src/core/support/time_posix.c +++ b/src/core/support/time_posix.c @@ -51,7 +51,7 @@ static struct timespec timespec_from_gpr(gpr_timespec gts) { static gpr_timespec gpr_from_timespec(struct timespec ts) { gpr_timespec rv; rv.tv_sec = ts.tv_sec; - rv.tv_nsec = ts.tv_nsec; + rv.tv_nsec = (int)ts.tv_nsec; return rv; } From 04a0395670322d5a7c08aafdf54b7a44ce9e78e3 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Fri, 19 Jun 2015 16:20:50 -0700 Subject: [PATCH 2/6] Added casts to a macro --- include/grpc/support/slice.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/grpc/support/slice.h b/include/grpc/support/slice.h index 3ee103bfb9c..19415865cf8 100644 --- a/include/grpc/support/slice.h +++ b/include/grpc/support/slice.h @@ -97,8 +97,8 @@ typedef struct gpr_slice { ((slice).refcount ? (slice).data.refcounted.length \ : (slice).data.inlined.length) #define GPR_SLICE_SET_LENGTH(slice, newlen) \ - ((slice).refcount ? ((slice).data.refcounted.length = (newlen)) \ - : ((slice).data.inlined.length = (newlen))) + ((slice).refcount ? ((slice).data.refcounted.length = (size_t)(newlen)) \ + : ((slice).data.inlined.length = (gpr_uint8)(newlen))) #define GPR_SLICE_END_PTR(slice) \ GPR_SLICE_START_PTR(slice) + GPR_SLICE_LENGTH(slice) #define GPR_SLICE_IS_EMPTY(slice) (GPR_SLICE_LENGTH(slice) == 0) From 5912fb5ca084dd044217af5ea915c84104fff212 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Mon, 22 Jun 2015 13:50:34 -0700 Subject: [PATCH 3/6] Reverted incorrect type change --- src/core/support/cpu_linux.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/support/cpu_linux.c b/src/core/support/cpu_linux.c index a748d43cf05..b59d013e92c 100644 --- a/src/core/support/cpu_linux.c +++ b/src/core/support/cpu_linux.c @@ -48,10 +48,11 @@ #include #include -static unsigned ncpus = 0; +static int ncpus = 0; static void init_num_cpus() { - ncpus = (unsigned)sysconf(_SC_NPROCESSORS_ONLN); + // This must be signed. sysconf returns -1 when the number can't be determined + ncpus = (int)sysconf(_SC_NPROCESSORS_ONLN); if (ncpus < 1) { gpr_log(GPR_ERROR, "Cannot determine number of CPUs: assuming 1"); ncpus = 1; @@ -61,7 +62,7 @@ static void init_num_cpus() { unsigned gpr_cpu_num_cores(void) { static gpr_once once = GPR_ONCE_INIT; gpr_once_init(&once, init_num_cpus); - return ncpus; + return (unsigned)ncpus; } unsigned gpr_cpu_current_cpu(void) { From d1873b0128ea37c5dcf1cc42f05ba9083b07f944 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Mon, 22 Jun 2015 14:12:58 -0700 Subject: [PATCH 4/6] Fixed incorrect comment format --- src/core/support/cpu_linux.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/support/cpu_linux.c b/src/core/support/cpu_linux.c index b59d013e92c..282d4daab1c 100644 --- a/src/core/support/cpu_linux.c +++ b/src/core/support/cpu_linux.c @@ -51,7 +51,8 @@ static int ncpus = 0; static void init_num_cpus() { - // This must be signed. sysconf returns -1 when the number can't be determined + /* This must be signed. sysconf returns -1 when the number cannot be + determined */ ncpus = (int)sysconf(_SC_NPROCESSORS_ONLN); if (ncpus < 1) { gpr_log(GPR_ERROR, "Cannot determine number of CPUs: assuming 1"); From 154cb407a803c77b76fd3c14e9f5b329ceb2912d Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Mon, 22 Jun 2015 14:48:25 -0700 Subject: [PATCH 5/6] Made requested fixes --- src/core/support/murmur_hash.c | 4 ++-- src/core/support/slice.c | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/core/support/murmur_hash.c b/src/core/support/murmur_hash.c index e875ba72283..37fdca82ba0 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 a2d62fc1e53..5a3dbe17362 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); } From 84976a70ce07f13c959e8630b5c10d4fbbace4d8 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Mon, 22 Jun 2015 15:07:23 -0700 Subject: [PATCH 6/6] Reverted slice.c changes --- src/core/support/slice.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/core/support/slice.c b/src/core/support/slice.c index 5a3dbe17362..a2d62fc1e53 100644 --- a/src/core/support/slice.c +++ b/src/core/support/slice.c @@ -31,8 +31,6 @@ * */ -#include - #include #include #include @@ -315,7 +313,7 @@ gpr_slice gpr_slice_split_head(gpr_slice *source, size_t split) { } int gpr_slice_cmp(gpr_slice a, gpr_slice b) { - ssize_t d = (ssize_t)(GPR_SLICE_LENGTH(a) - GPR_SLICE_LENGTH(b)); + int d = (int)(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)); @@ -323,7 +321,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); - ssize_t d = (ssize_t)(GPR_SLICE_LENGTH(a) - b_length); + int d = (int)(GPR_SLICE_LENGTH(a) - b_length); if (d != 0) return d; return memcmp(GPR_SLICE_START_PTR(a), b, b_length); }