diff options
author | Craig Tiller <ctiller@google.com> | 2015-09-10 11:47:15 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2015-09-10 11:47:15 -0700 |
commit | 32ca48ce0b963949ff29d2dcd526b174679779aa (patch) | |
tree | e1203e29dbc0827fe4e9eed5737b3f1589d44f34 /test/core/support | |
parent | be947697d7c5edb1f67c9df5ef024e3eaf98e9e6 (diff) |
Core compiles with -Wsign-conversion
Diffstat (limited to 'test/core/support')
-rw-r--r-- | test/core/support/murmur_hash_test.c | 4 | ||||
-rw-r--r-- | test/core/support/slice_test.c | 10 | ||||
-rw-r--r-- | test/core/support/stack_lockfree_test.c | 14 | ||||
-rw-r--r-- | test/core/support/time_test.c | 18 |
4 files changed, 23 insertions, 23 deletions
diff --git a/test/core/support/murmur_hash_test.c b/test/core/support/murmur_hash_test.c index 2462abf7de..1e5279f462 100644 --- a/test/core/support/murmur_hash_test.c +++ b/test/core/support/murmur_hash_test.c @@ -48,7 +48,7 @@ static void verification_test(hash_func hash, gpr_uint32 expected) { gpr_uint8 key[256]; gpr_uint32 hashes[256]; gpr_uint32 final = 0; - int i; + size_t i; memset(key, 0, sizeof(key)); memset(hashes, 0, sizeof(hashes)); @@ -58,7 +58,7 @@ static void verification_test(hash_func hash, gpr_uint32 expected) { for (i = 0; i < 256; i++) { key[i] = (uint8_t)i; - hashes[i] = hash(key, i, 256 - i); + hashes[i] = hash(key, i, 256u - i); } /* Then hash the result array */ diff --git a/test/core/support/slice_test.c b/test/core/support/slice_test.c index 3ca87427dd..a84ad50cf3 100644 --- a/test/core/support/slice_test.c +++ b/test/core/support/slice_test.c @@ -66,7 +66,7 @@ static void test_slice_malloc_returns_something_sensible(void) { } /* We must be able to write to every byte of the data */ for (i = 0; i < length; i++) { - GPR_SLICE_START_PTR(slice)[i] = (char)i; + GPR_SLICE_START_PTR(slice)[i] = (gpr_uint8)i; } /* And finally we must succeed in destroying the slice */ gpr_slice_unref(slice); @@ -143,10 +143,10 @@ static void check_head_tail(gpr_slice slice, gpr_slice head, gpr_slice tail) { GPR_SLICE_START_PTR(tail), GPR_SLICE_LENGTH(tail))); } -static void test_slice_split_head_works(int length) { +static void test_slice_split_head_works(size_t length) { gpr_slice slice; gpr_slice head, tail; - int i; + size_t i; LOG_TEST_NAME("test_slice_split_head_works"); gpr_log(GPR_INFO, "length=%d", length); @@ -171,10 +171,10 @@ static void test_slice_split_head_works(int length) { gpr_slice_unref(slice); } -static void test_slice_split_tail_works(int length) { +static void test_slice_split_tail_works(size_t length) { gpr_slice slice; gpr_slice head, tail; - int i; + size_t i; LOG_TEST_NAME("test_slice_split_tail_works"); gpr_log(GPR_INFO, "length=%d", length); diff --git a/test/core/support/stack_lockfree_test.c b/test/core/support/stack_lockfree_test.c index 02ec3154d5..4a2a0532d8 100644 --- a/test/core/support/stack_lockfree_test.c +++ b/test/core/support/stack_lockfree_test.c @@ -46,9 +46,10 @@ #define MAX_THREADS 32 -static void test_serial_sized(int size) { +static void test_serial_sized(size_t size) { gpr_stack_lockfree *stack = gpr_stack_lockfree_create(size); - int i; + size_t i; + size_t j; /* First try popping empty */ GPR_ASSERT(gpr_stack_lockfree_pop(stack) == -1); @@ -60,12 +61,11 @@ static void test_serial_sized(int size) { /* Now add repeatedly more items and check them */ for (i = 1; i < size; i *= 2) { - int j; for (j = 0; j <= i; j++) { GPR_ASSERT(gpr_stack_lockfree_push(stack, j) == (j == 0)); } for (j = 0; j <= i; j++) { - GPR_ASSERT(gpr_stack_lockfree_pop(stack) == i - j); + GPR_ASSERT(gpr_stack_lockfree_pop(stack) == (int)(i - j)); } GPR_ASSERT(gpr_stack_lockfree_pop(stack) == -1); } @@ -74,7 +74,7 @@ static void test_serial_sized(int size) { } static void test_serial() { - int i; + size_t i; for (i = 128; i < MAX_STACK_SIZE; i *= 2) { test_serial_sized(i); } @@ -107,7 +107,7 @@ static void test_mt_body(void *v) { } } -static void test_mt_sized(int size, int nth) { +static void test_mt_sized(size_t size, int nth) { gpr_stack_lockfree *stack; struct test_arg args[MAX_THREADS]; gpr_thd_id thds[MAX_THREADS]; @@ -137,7 +137,7 @@ static void test_mt_sized(int size, int nth) { } static void test_mt() { - int size, nth; + size_t size, nth; for (nth = 1; nth < MAX_THREADS; nth++) { for (size = 128; size < MAX_STACK_SIZE; size *= 2) { test_mt_sized(size, nth); diff --git a/test/core/support/time_test.c b/test/core/support/time_test.c index 594863c278..ce35edd83c 100644 --- a/test/core/support/time_test.c +++ b/test/core/support/time_test.c @@ -43,14 +43,14 @@ #include <grpc/support/time.h> #include "test/core/util/test_config.h" -static void to_fp(void *arg, const char *buf, int len) { +static void to_fp(void *arg, const char *buf, size_t len) { fwrite(buf, 1, len, (FILE *)arg); } /* Convert gpr_uintmax x to ascii base b (2..16), and write with (*writer)(arg, ...), zero padding to "chars" digits). */ static void u_to_s(gpr_uintmax x, unsigned base, int chars, - void (*writer)(void *arg, const char *buf, int len), + void (*writer)(void *arg, const char *buf, size_t len), void *arg) { char buf[64]; char *p = buf + sizeof(buf); @@ -59,25 +59,25 @@ static void u_to_s(gpr_uintmax x, unsigned base, int chars, x /= base; chars--; } while (x != 0 || chars > 0); - (*writer)(arg, p, buf + sizeof(buf) - p); + (*writer)(arg, p, (size_t)(buf + sizeof(buf) - p)); } /* Convert gpr_intmax x to ascii base b (2..16), and write with (*writer)(arg, ...), zero padding to "chars" digits). */ static void i_to_s(gpr_intmax x, unsigned base, int chars, - void (*writer)(void *arg, const char *buf, int len), + void (*writer)(void *arg, const char *buf, size_t len), void *arg) { if (x < 0) { (*writer)(arg, "-", 1); - u_to_s(-x, base, chars - 1, writer, arg); + u_to_s((gpr_uintmax)-x, base, chars - 1, writer, arg); } else { - u_to_s(x, base, chars, writer, arg); + u_to_s((gpr_uintmax)x, base, chars, writer, arg); } } /* Convert ts to ascii, and write with (*writer)(arg, ...). */ static void ts_to_s(gpr_timespec t, - void (*writer)(void *arg, const char *buf, int len), + void (*writer)(void *arg, const char *buf, size_t len), void *arg) { if (t.tv_sec < 0 && t.tv_nsec != 0) { t.tv_sec++; @@ -96,7 +96,7 @@ static void test_values(void) { x = gpr_inf_future(GPR_CLOCK_REALTIME); fprintf(stderr, "far future "); - u_to_s(x.tv_sec, 16, 16, &to_fp, stderr); + i_to_s(x.tv_sec, 16, 16, &to_fp, stderr); fprintf(stderr, "\n"); GPR_ASSERT(x.tv_sec >= INT_MAX); fprintf(stderr, "far future "); @@ -105,7 +105,7 @@ static void test_values(void) { x = gpr_inf_past(GPR_CLOCK_REALTIME); fprintf(stderr, "far past "); - u_to_s(x.tv_sec, 16, 16, &to_fp, stderr); + i_to_s(x.tv_sec, 16, 16, &to_fp, stderr); fprintf(stderr, "\n"); GPR_ASSERT(x.tv_sec <= INT_MIN); fprintf(stderr, "far past "); |