aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2015-09-10 11:47:15 -0700
committerGravatar Craig Tiller <ctiller@google.com>2015-09-10 11:47:15 -0700
commit32ca48ce0b963949ff29d2dcd526b174679779aa (patch)
treee1203e29dbc0827fe4e9eed5737b3f1589d44f34 /test
parentbe947697d7c5edb1f67c9df5ef024e3eaf98e9e6 (diff)
Core compiles with -Wsign-conversion
Diffstat (limited to 'test')
-rw-r--r--test/core/channel/channel_args_test.c11
-rw-r--r--test/core/end2end/dualstack_socket_test.c4
-rw-r--r--test/core/end2end/no_server_test.c4
-rw-r--r--test/core/fling/client.c7
-rw-r--r--test/core/fling/fling_stream_test.c4
-rw-r--r--test/core/fling/fling_test.c2
-rw-r--r--test/core/fling/server.c2
-rw-r--r--test/core/httpcli/httpcli_test.c2
-rw-r--r--test/core/iomgr/alarm_heap_test.c65
-rw-r--r--test/core/iomgr/tcp_posix_test.c36
-rw-r--r--test/core/json/json_rewrite.c26
-rw-r--r--test/core/json/json_rewrite_test.c28
-rw-r--r--test/core/profiling/timers_test.c16
-rw-r--r--test/core/security/base64_test.c4
-rw-r--r--test/core/security/json_token_test.c11
-rw-r--r--test/core/support/murmur_hash_test.c4
-rw-r--r--test/core/support/slice_test.c10
-rw-r--r--test/core/support/stack_lockfree_test.c14
-rw-r--r--test/core/support/time_test.c18
-rw-r--r--test/core/surface/byte_buffer_reader_test.c8
-rw-r--r--test/core/surface/completion_queue_test.c8
-rw-r--r--test/core/surface/lame_client_test.c2
-rw-r--r--test/core/transport/chttp2/hpack_table_test.c4
-rw-r--r--test/core/transport/chttp2/stream_encoder_test.c10
-rw-r--r--test/core/transport/chttp2/stream_map_test.c6
-rw-r--r--test/core/transport/metadata_test.c12
26 files changed, 162 insertions, 156 deletions
diff --git a/test/core/channel/channel_args_test.c b/test/core/channel/channel_args_test.c
index 87f006acde..0b74dee41e 100644
--- a/test/core/channel/channel_args_test.c
+++ b/test/core/channel/channel_args_test.c
@@ -85,12 +85,13 @@ static void test_set_compression_algorithm(void) {
static void test_compression_algorithm_states(void) {
grpc_channel_args *ch_args, *ch_args_wo_gzip, *ch_args_wo_gzip_deflate;
- int states_bitset;
+ unsigned states_bitset;
size_t i;
ch_args = grpc_channel_args_copy_and_add(NULL, NULL, 0);
/* by default, all enabled */
- states_bitset = grpc_channel_args_compression_algorithm_get_states(ch_args);
+ states_bitset =
+ (unsigned)grpc_channel_args_compression_algorithm_get_states(ch_args);
for (i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) {
GPR_ASSERT(GPR_BITGET(states_bitset, i));
@@ -104,7 +105,7 @@ static void test_compression_algorithm_states(void) {
&ch_args_wo_gzip, GRPC_COMPRESS_DEFLATE, 0);
GPR_ASSERT(ch_args_wo_gzip == ch_args_wo_gzip_deflate);
- states_bitset = grpc_channel_args_compression_algorithm_get_states(
+ states_bitset = (unsigned)grpc_channel_args_compression_algorithm_get_states(
ch_args_wo_gzip_deflate);
for (i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) {
if (i == GRPC_COMPRESS_GZIP || i == GRPC_COMPRESS_DEFLATE) {
@@ -119,8 +120,8 @@ static void test_compression_algorithm_states(void) {
&ch_args_wo_gzip_deflate, GRPC_COMPRESS_GZIP, 1);
GPR_ASSERT(ch_args_wo_gzip == ch_args_wo_gzip_deflate);
- states_bitset =
- grpc_channel_args_compression_algorithm_get_states(ch_args_wo_gzip);
+ states_bitset = (unsigned)grpc_channel_args_compression_algorithm_get_states(
+ ch_args_wo_gzip);
for (i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) {
if (i == GRPC_COMPRESS_DEFLATE) {
GPR_ASSERT(GPR_BITGET(states_bitset, i) == 0);
diff --git a/test/core/end2end/dualstack_socket_test.c b/test/core/end2end/dualstack_socket_test.c
index fcc12952bf..2aee333d27 100644
--- a/test/core/end2end/dualstack_socket_test.c
+++ b/test/core/end2end/dualstack_socket_test.c
@@ -186,7 +186,7 @@ void test_connect(const char *server_host, const char *client_host, int port,
op->flags = 0;
op->reserved = NULL;
op++;
- error = grpc_call_start_batch(c, ops, op - ops, tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
GPR_ASSERT(GRPC_CALL_OK == error);
if (expect_ok) {
@@ -212,7 +212,7 @@ void test_connect(const char *server_host, const char *client_host, int port,
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
op++;
- error = grpc_call_start_batch(s, ops, op - ops, tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
GPR_ASSERT(GRPC_CALL_OK == error);
cq_expect_completion(cqv, tag(102), 1);
diff --git a/test/core/end2end/no_server_test.c b/test/core/end2end/no_server_test.c
index 619627ddd2..c391003141 100644
--- a/test/core/end2end/no_server_test.c
+++ b/test/core/end2end/no_server_test.c
@@ -79,8 +79,8 @@ int main(int argc, char **argv) {
op->flags = 0;
op->reserved = NULL;
op++;
- GPR_ASSERT(GRPC_CALL_OK ==
- grpc_call_start_batch(call, ops, op - ops, tag(1), NULL));
+ GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(
+ call, ops, (size_t)(op - ops), tag(1), NULL));
/* verify that all tags get completed */
cq_expect_completion(cqv, tag(1), 1);
cq_verify(cqv);
diff --git a/test/core/fling/client.c b/test/core/fling/client.c
index 54c9274510..ed80544e3c 100644
--- a/test/core/fling/client.c
+++ b/test/core/fling/client.c
@@ -92,8 +92,9 @@ static void step_ping_pong_request(void) {
call = grpc_channel_create_call(channel, NULL, GRPC_PROPAGATE_DEFAULTS, cq,
"/Reflector/reflectUnary", "localhost",
gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
- GPR_ASSERT(GRPC_CALL_OK ==
- grpc_call_start_batch(call, ops, op - ops, (void *)1, NULL));
+ GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call, ops,
+ (size_t)(op - ops),
+ (void *)1, NULL));
grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
grpc_call_destroy(call);
grpc_byte_buffer_destroy(response_payload_recv);
@@ -188,7 +189,7 @@ int main(int argc, char **argv) {
channel = grpc_insecure_channel_create(target, NULL, NULL);
cq = grpc_completion_queue_create(NULL);
- the_buffer = grpc_raw_byte_buffer_create(&slice, payload_size);
+ the_buffer = grpc_raw_byte_buffer_create(&slice, (size_t)payload_size);
histogram = gpr_histogram_create(0.01, 60e9);
sc.init();
diff --git a/test/core/fling/fling_stream_test.c b/test/core/fling/fling_stream_test.c
index 4d9253c0ad..78a73372aa 100644
--- a/test/core/fling/fling_stream_test.c
+++ b/test/core/fling/fling_stream_test.c
@@ -60,10 +60,10 @@ int main(int argc, char **argv) {
pid_t svr, cli;
/* seed rng with pid, so we don't end up with the same random numbers as a
concurrently running test binary */
- srand(getpid());
+ srand((unsigned)getpid());
/* figure out where we are */
if (lslash) {
- memcpy(root, me, lslash - me);
+ memcpy(root, me, (size_t)(lslash - me));
root[lslash - me] = 0;
} else {
strcpy(root, ".");
diff --git a/test/core/fling/fling_test.c b/test/core/fling/fling_test.c
index 29d9050704..cf43ecfd2d 100644
--- a/test/core/fling/fling_test.c
+++ b/test/core/fling/fling_test.c
@@ -51,7 +51,7 @@ int main(int argc, char **argv) {
gpr_subprocess *svr, *cli;
/* figure out where we are */
if (lslash) {
- memcpy(root, me, lslash - me);
+ memcpy(root, me, (size_t)(lslash - me));
root[lslash - me] = 0;
} else {
strcpy(root, ".");
diff --git a/test/core/fling/server.c b/test/core/fling/server.c
index 0430ff9ab7..64f9573084 100644
--- a/test/core/fling/server.c
+++ b/test/core/fling/server.c
@@ -123,7 +123,7 @@ static void handle_unary_method(void) {
op->data.recv_close_on_server.cancelled = &was_cancelled;
op++;
- error = grpc_call_start_batch(call, unary_ops, op - unary_ops,
+ error = grpc_call_start_batch(call, unary_ops, (size_t)(op - unary_ops),
tag(FLING_SERVER_BATCH_OPS_FOR_UNARY), NULL);
GPR_ASSERT(GRPC_CALL_OK == error);
}
diff --git a/test/core/httpcli/httpcli_test.c b/test/core/httpcli/httpcli_test.c
index 42b2661c0a..cf2b10c021 100644
--- a/test/core/httpcli/httpcli_test.c
+++ b/test/core/httpcli/httpcli_test.c
@@ -134,7 +134,7 @@ int main(int argc, char **argv) {
/* figure out where we are */
if (lslash) {
- memcpy(root, me, lslash - me);
+ memcpy(root, me, (size_t)(lslash - me));
root[lslash - me] = 0;
} else {
strcpy(root, ".");
diff --git a/test/core/iomgr/alarm_heap_test.c b/test/core/iomgr/alarm_heap_test.c
index 66b6e4cb64..13bf7e43f6 100644
--- a/test/core/iomgr/alarm_heap_test.c
+++ b/test/core/iomgr/alarm_heap_test.c
@@ -48,9 +48,9 @@ static gpr_timespec random_deadline(void) {
return ts;
}
-static grpc_alarm *create_test_elements(int num_elements) {
+static grpc_alarm *create_test_elements(size_t num_elements) {
grpc_alarm *elems = gpr_malloc(num_elements * sizeof(grpc_alarm));
- int i;
+ size_t i;
for (i = 0; i < num_elements; i++) {
elems[i].deadline = random_deadline();
}
@@ -63,24 +63,25 @@ static int cmp_elem(const void *a, const void *b) {
return i - j;
}
-static int *all_top(grpc_alarm_heap *pq, int *n) {
- int *vec = NULL;
- int *need_to_check_children;
- int num_need_to_check_children = 0;
+static size_t *all_top(grpc_alarm_heap *pq, size_t *n) {
+ size_t *vec = NULL;
+ size_t *need_to_check_children;
+ size_t num_need_to_check_children = 0;
*n = 0;
if (pq->alarm_count == 0) return vec;
- need_to_check_children = gpr_malloc(pq->alarm_count * sizeof(int));
+ need_to_check_children =
+ gpr_malloc(pq->alarm_count * sizeof(*need_to_check_children));
need_to_check_children[num_need_to_check_children++] = 0;
- vec = gpr_malloc(pq->alarm_count * sizeof(int));
+ vec = gpr_malloc(pq->alarm_count * sizeof(*vec));
while (num_need_to_check_children > 0) {
- int ind = need_to_check_children[0];
- int leftchild, rightchild;
+ size_t ind = need_to_check_children[0];
+ size_t leftchild, rightchild;
num_need_to_check_children--;
memmove(need_to_check_children, need_to_check_children + 1,
- num_need_to_check_children * sizeof(int));
+ num_need_to_check_children * sizeof(*need_to_check_children));
vec[(*n)++] = ind;
- leftchild = 1 + 2 * ind;
+ leftchild = 1u + 2u * ind;
if (leftchild < pq->alarm_count) {
if (gpr_time_cmp(pq->alarms[leftchild]->deadline,
pq->alarms[ind]->deadline) >= 0) {
@@ -101,13 +102,14 @@ static int *all_top(grpc_alarm_heap *pq, int *n) {
}
static void check_pq_top(grpc_alarm *elements, grpc_alarm_heap *pq,
- gpr_uint8 *inpq, int num_elements) {
+ gpr_uint8 *inpq, size_t num_elements) {
gpr_timespec max_deadline = gpr_inf_past(GPR_CLOCK_REALTIME);
- int *max_deadline_indices = gpr_malloc(num_elements * sizeof(int));
- int *top_elements;
- int num_max_deadline_indices = 0;
- int num_top_elements;
- int i;
+ size_t *max_deadline_indices =
+ gpr_malloc(num_elements * sizeof(*max_deadline_indices));
+ size_t *top_elements;
+ size_t num_max_deadline_indices = 0;
+ size_t num_top_elements;
+ size_t i;
for (i = 0; i < num_elements; ++i) {
if (inpq[i] && gpr_time_cmp(elements[i].deadline, max_deadline) >= 0) {
if (gpr_time_cmp(elements[i].deadline, max_deadline) > 0) {
@@ -117,7 +119,8 @@ static void check_pq_top(grpc_alarm *elements, grpc_alarm_heap *pq,
max_deadline_indices[num_max_deadline_indices++] = elements[i].heap_index;
}
}
- qsort(max_deadline_indices, num_max_deadline_indices, sizeof(int), cmp_elem);
+ qsort(max_deadline_indices, num_max_deadline_indices,
+ sizeof(*max_deadline_indices), cmp_elem);
top_elements = all_top(pq, &num_top_elements);
GPR_ASSERT(num_top_elements == num_max_deadline_indices);
for (i = 0; i < num_top_elements; i++) {
@@ -128,7 +131,7 @@ static void check_pq_top(grpc_alarm *elements, grpc_alarm_heap *pq,
}
static int contains(grpc_alarm_heap *pq, grpc_alarm *el) {
- int i;
+ size_t i;
for (i = 0; i < pq->alarm_count; i++) {
if (pq->alarms[i] == el) return 1;
}
@@ -136,10 +139,10 @@ static int contains(grpc_alarm_heap *pq, grpc_alarm *el) {
}
static void check_valid(grpc_alarm_heap *pq) {
- int i;
+ size_t i;
for (i = 0; i < pq->alarm_count; ++i) {
- int left_child = 1 + 2 * i;
- int right_child = left_child + 1;
+ size_t left_child = 1u + 2u * i;
+ size_t right_child = left_child + 1u;
if (left_child < pq->alarm_count) {
GPR_ASSERT(gpr_time_cmp(pq->alarms[i]->deadline,
pq->alarms[left_child]->deadline) >= 0);
@@ -153,9 +156,9 @@ static void check_valid(grpc_alarm_heap *pq) {
static void test1(void) {
grpc_alarm_heap pq;
- const int num_test_elements = 200;
- const int num_test_operations = 10000;
- int i;
+ const size_t num_test_elements = 200;
+ const size_t num_test_operations = 10000;
+ size_t i;
grpc_alarm *test_elements = create_test_elements(num_test_elements);
gpr_uint8 *inpq = gpr_malloc(num_test_elements);
@@ -182,7 +185,7 @@ static void test1(void) {
check_pq_top(test_elements, &pq, inpq, num_test_elements);
for (i = 0; i < num_test_operations; ++i) {
- int elem_num = rand() % num_test_elements;
+ size_t elem_num = (size_t)rand() % num_test_elements;
grpc_alarm *el = &test_elements[elem_num];
if (!inpq[elem_num]) { /* not in pq */
GPR_ASSERT(!contains(&pq, el));
@@ -209,11 +212,11 @@ static void test1(void) {
static void shrink_test(void) {
grpc_alarm_heap pq;
- int i;
- int expected_size;
+ size_t i;
+ size_t expected_size;
/* A large random number to allow for multiple shrinkages, at least 512. */
- const int num_elements = rand() % 2000 + 512;
+ const size_t num_elements = (size_t)rand() % 2000 + 512;
grpc_alarm_heap_init(&pq);
@@ -243,7 +246,7 @@ static void shrink_test(void) {
4 times the Size and not less than 2 times, but never goes below 16. */
expected_size = pq.alarm_count;
while (pq.alarm_count > 0) {
- const int which = rand() % pq.alarm_count;
+ const size_t which = (size_t)rand() % pq.alarm_count;
grpc_alarm *te = pq.alarms[which];
grpc_alarm_heap_remove(&pq, te);
gpr_free(te);
diff --git a/test/core/iomgr/tcp_posix_test.c b/test/core/iomgr/tcp_posix_test.c
index 8acaa433bb..b94f5987ca 100644
--- a/test/core/iomgr/tcp_posix_test.c
+++ b/test/core/iomgr/tcp_posix_test.c
@@ -105,7 +105,7 @@ static size_t fill_socket_partial(int fd, size_t bytes) {
do {
write_bytes = write(fd, buf, bytes - total_bytes);
if (write_bytes > 0) {
- total_bytes += write_bytes;
+ total_bytes += (size_t)write_bytes;
}
} while ((write_bytes >= 0 || errno == EINTR) && bytes > total_bytes);
@@ -116,15 +116,15 @@ static size_t fill_socket_partial(int fd, size_t bytes) {
struct read_socket_state {
grpc_endpoint *ep;
- ssize_t read_bytes;
- ssize_t target_read_bytes;
+ size_t read_bytes;
+ size_t target_read_bytes;
gpr_slice_buffer incoming;
grpc_iomgr_closure read_cb;
};
-static ssize_t count_slices(gpr_slice *slices, size_t nslices,
- int *current_data) {
- ssize_t num_bytes = 0;
+static size_t count_slices(gpr_slice *slices, size_t nslices,
+ int *current_data) {
+ size_t num_bytes = 0;
unsigned i, j;
unsigned char *buf;
for (i = 0; i < nslices; ++i) {
@@ -140,7 +140,7 @@ static ssize_t count_slices(gpr_slice *slices, size_t nslices,
static void read_cb(void *user_data, int success) {
struct read_socket_state *state = (struct read_socket_state *)user_data;
- ssize_t read_bytes;
+ size_t read_bytes;
int current_data;
GPR_ASSERT(success);
@@ -172,11 +172,11 @@ static void read_cb(void *user_data, int success) {
}
/* Write to a socket, then read from it using the grpc_tcp API. */
-static void read_test(ssize_t num_bytes, ssize_t slice_size) {
+static void read_test(size_t num_bytes, size_t slice_size) {
int sv[2];
grpc_endpoint *ep;
struct read_socket_state state;
- ssize_t written_bytes;
+ size_t written_bytes;
gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(20);
gpr_log(GPR_INFO, "Read test of size %d, slice size %d", num_bytes,
@@ -222,7 +222,7 @@ static void read_test(ssize_t num_bytes, ssize_t slice_size) {
/* Write to a socket until it fills up, then read from it using the grpc_tcp
API. */
-static void large_read_test(ssize_t slice_size) {
+static void large_read_test(size_t slice_size) {
int sv[2];
grpc_endpoint *ep;
struct read_socket_state state;
@@ -242,7 +242,7 @@ static void large_read_test(ssize_t slice_size) {
state.ep = ep;
state.read_bytes = 0;
- state.target_read_bytes = written_bytes;
+ state.target_read_bytes = (size_t)written_bytes;
gpr_slice_buffer_init(&state.incoming);
grpc_iomgr_closure_init(&state.read_cb, read_cb, &state);
@@ -275,11 +275,11 @@ struct write_socket_state {
int write_done;
};
-static gpr_slice *allocate_blocks(ssize_t num_bytes, ssize_t slice_size,
+static gpr_slice *allocate_blocks(size_t num_bytes, size_t slice_size,
size_t *num_blocks, int *current_data) {
- size_t nslices = num_bytes / slice_size + (num_bytes % slice_size ? 1 : 0);
+ size_t nslices = num_bytes / slice_size + (num_bytes % slice_size ? 1u : 0u);
gpr_slice *slices = gpr_malloc(sizeof(gpr_slice) * nslices);
- ssize_t num_bytes_left = num_bytes;
+ size_t num_bytes_left = num_bytes;
unsigned i, j;
unsigned char *buf;
*num_blocks = nslices;
@@ -334,7 +334,7 @@ void drain_socket_blocking(int fd, size_t num_bytes, size_t read_size) {
GPR_ASSERT(buf[i] == current);
current = (current + 1) % 256;
}
- bytes_left -= bytes_read;
+ bytes_left -= (size_t)bytes_read;
if (bytes_left == 0) break;
}
flags = fcntl(fd, F_GETFL, 0);
@@ -366,7 +366,7 @@ static ssize_t drain_socket(int fd) {
/* Write to a socket using the grpc_tcp API, then drain it directly.
Note that if the write does not complete immediately we need to drain the
socket in parallel with the read. */
-static void write_test(ssize_t num_bytes, ssize_t slice_size) {
+static void write_test(size_t num_bytes, size_t slice_size) {
int sv[2];
grpc_endpoint *ep;
struct write_socket_state state;
@@ -400,7 +400,7 @@ static void write_test(ssize_t num_bytes, ssize_t slice_size) {
case GRPC_ENDPOINT_DONE:
/* Write completed immediately */
read_bytes = drain_socket(sv[0]);
- GPR_ASSERT(read_bytes == num_bytes);
+ GPR_ASSERT((size_t)read_bytes == num_bytes);
break;
case GRPC_ENDPOINT_PENDING:
drain_socket_blocking(sv[0], num_bytes, num_bytes);
@@ -426,7 +426,7 @@ static void write_test(ssize_t num_bytes, ssize_t slice_size) {
}
void run_tests(void) {
- int i = 0;
+ size_t i = 0;
read_test(100, 8192);
read_test(10000, 8192);
diff --git a/test/core/json/json_rewrite.c b/test/core/json/json_rewrite.c
index 02f60a3163..561bf487b9 100644
--- a/test/core/json/json_rewrite.c
+++ b/test/core/json/json_rewrite.c
@@ -81,7 +81,7 @@ grpc_json_writer_vtable writer_vtable = {json_writer_output_char,
static void check_string(json_reader_userdata* state, size_t needed) {
if (state->free_space >= needed) return;
needed -= state->free_space;
- needed = (needed + 0xff) & ~0xff;
+ needed = (needed + 0xffu) & ~0xffu;
state->scratchpad = gpr_realloc(state->scratchpad, state->allocated + needed);
state->free_space += needed;
state->allocated += needed;
@@ -103,22 +103,22 @@ static void json_reader_string_add_utf32(void* userdata, gpr_uint32 c) {
if (c <= 0x7f) {
json_reader_string_add_char(userdata, c);
} else if (c <= 0x7ff) {
- int b1 = 0xc0 | ((c >> 6) & 0x1f);
- int b2 = 0x80 | (c & 0x3f);
+ gpr_uint32 b1 = 0xc0u | ((c >> 6u) & 0x1fu);
+ gpr_uint32 b2 = 0x80u | (c & 0x3fu);
json_reader_string_add_char(userdata, b1);
json_reader_string_add_char(userdata, b2);
- } else if (c <= 0xffff) {
- int b1 = 0xe0 | ((c >> 12) & 0x0f);
- int b2 = 0x80 | ((c >> 6) & 0x3f);
- int b3 = 0x80 | (c & 0x3f);
+ } else if (c <= 0xffffu) {
+ gpr_uint32 b1 = 0xe0u | ((c >> 12u) & 0x0fu);
+ gpr_uint32 b2 = 0x80u | ((c >> 6u) & 0x3fu);
+ gpr_uint32 b3 = 0x80u | (c & 0x3fu);
json_reader_string_add_char(userdata, b1);
json_reader_string_add_char(userdata, b2);
json_reader_string_add_char(userdata, b3);
- } else if (c <= 0x1fffff) {
- int b1 = 0xf0 | ((c >> 18) & 0x07);
- int b2 = 0x80 | ((c >> 12) & 0x3f);
- int b3 = 0x80 | ((c >> 6) & 0x3f);
- int b4 = 0x80 | (c & 0x3f);
+ } else if (c <= 0x1fffffu) {
+ gpr_uint32 b1 = 0xf0u | ((c >> 18u) & 0x07u);
+ gpr_uint32 b2 = 0x80u | ((c >> 12u) & 0x3fu);
+ gpr_uint32 b3 = 0x80u | ((c >> 6u) & 0x3fu);
+ gpr_uint32 b4 = 0x80u | (c & 0x3fu);
json_reader_string_add_char(userdata, b1);
json_reader_string_add_char(userdata, b2);
json_reader_string_add_char(userdata, b3);
@@ -132,7 +132,7 @@ static gpr_uint32 json_reader_read_char(void* userdata) {
r = fgetc(state->in);
if (r == EOF) r = GRPC_JSON_READ_CHAR_EOF;
- return r;
+ return (gpr_uint32)r;
}
static void json_reader_container_begins(void* userdata, grpc_json_type type) {
diff --git a/test/core/json/json_rewrite_test.c b/test/core/json/json_rewrite_test.c
index f5859322ea..7cf184950e 100644
--- a/test/core/json/json_rewrite_test.c
+++ b/test/core/json/json_rewrite_test.c
@@ -93,7 +93,7 @@ grpc_json_writer_vtable writer_vtable = {json_writer_output_char,
static void check_string(json_reader_userdata* state, size_t needed) {
if (state->free_space >= needed) return;
needed -= state->free_space;
- needed = (needed + 0xff) & ~0xff;
+ needed = (needed + 0xffu) & ~0xffu;
state->scratchpad = gpr_realloc(state->scratchpad, state->allocated + needed);
state->free_space += needed;
state->allocated += needed;
@@ -114,23 +114,23 @@ static void json_reader_string_add_char(void* userdata, gpr_uint32 c) {
static void json_reader_string_add_utf32(void* userdata, gpr_uint32 c) {
if (c <= 0x7f) {
json_reader_string_add_char(userdata, c);
- } else if (c <= 0x7ff) {
- int b1 = 0xc0 | ((c >> 6) & 0x1f);
- int b2 = 0x80 | (c & 0x3f);
+ } else if (c <= 0x7ffu) {
+ gpr_uint32 b1 = 0xc0u | ((c >> 6u) & 0x1fu);
+ gpr_uint32 b2 = 0x80u | (c & 0x3fu);
json_reader_string_add_char(userdata, b1);
json_reader_string_add_char(userdata, b2);
- } else if (c <= 0xffff) {
- int b1 = 0xe0 | ((c >> 12) & 0x0f);
- int b2 = 0x80 | ((c >> 6) & 0x3f);
- int b3 = 0x80 | (c & 0x3f);
+ } else if (c <= 0xffffu) {
+ gpr_uint32 b1 = 0xe0u | ((c >> 12u) & 0x0fu);
+ gpr_uint32 b2 = 0x80u | ((c >> 6u) & 0x3fu);
+ gpr_uint32 b3 = 0x80u | (c & 0x3fu);
json_reader_string_add_char(userdata, b1);
json_reader_string_add_char(userdata, b2);
json_reader_string_add_char(userdata, b3);
- } else if (c <= 0x1fffff) {
- int b1 = 0xf0 | ((c >> 18) & 0x07);
- int b2 = 0x80 | ((c >> 12) & 0x3f);
- int b3 = 0x80 | ((c >> 6) & 0x3f);
- int b4 = 0x80 | (c & 0x3f);
+ } else if (c <= 0x1fffffu) {
+ gpr_uint32 b1 = 0xf0u | ((c >> 18u) & 0x07u);
+ gpr_uint32 b2 = 0x80u | ((c >> 12u) & 0x3fu);
+ gpr_uint32 b3 = 0x80u | ((c >> 6u) & 0x3fu);
+ gpr_uint32 b4 = 0x80u | (c & 0x3fu);
json_reader_string_add_char(userdata, b1);
json_reader_string_add_char(userdata, b2);
json_reader_string_add_char(userdata, b3);
@@ -151,7 +151,7 @@ static gpr_uint32 json_reader_read_char(void* userdata) {
r = fgetc(state->in);
if (r == EOF) r = GRPC_JSON_READ_CHAR_EOF;
- return r;
+ return (gpr_uint32)r;
}
static void json_reader_container_begins(void* userdata, grpc_json_type type) {
diff --git a/test/core/profiling/timers_test.c b/test/core/profiling/timers_test.c
index 12b08c115e..b79cde64bd 100644
--- a/test/core/profiling/timers_test.c
+++ b/test/core/profiling/timers_test.c
@@ -35,22 +35,22 @@
#include <stdlib.h>
#include "test/core/util/test_config.h"
-void test_log_events(int num_seqs) {
- int start = 0;
- int *state;
+void test_log_events(size_t num_seqs) {
+ size_t start = 0;
+ size_t *state;
state = calloc(num_seqs, sizeof(state[0]));
while (start < num_seqs) {
- int i;
- int row;
+ size_t i;
+ size_t row;
if (state[start] == 3) { /* Already done with this posn */
start++;
continue;
}
- row = rand() % 10; /* how many in a row */
+ row = (size_t)rand() % 10; /* how many in a row */
for (i = start; (i < start + row) && (i < num_seqs); i++) {
- int j;
- int advance = 1 + rand() % 3; /* how many to advance by */
+ size_t j;
+ size_t advance = 1 + (size_t)rand() % 3; /* how many to advance by */
for (j = 0; j < advance; j++) {
switch (state[i]) {
case 0:
diff --git a/test/core/security/base64_test.c b/test/core/security/base64_test.c
index f8b7ebf554..6d49b6d1a1 100644
--- a/test/core/security/base64_test.c
+++ b/test/core/security/base64_test.c
@@ -70,7 +70,7 @@ static void test_full_range_encode_decode_b64(int url_safe, int multiline) {
size_t i;
char *b64;
gpr_slice orig_decoded;
- for (i = 0; i < sizeof(orig); i++) orig[i] = (char)i;
+ for (i = 0; i < sizeof(orig); i++) orig[i] = (gpr_uint8)i;
/* Try all the different paddings. */
for (i = 0; i < 3; i++) {
@@ -122,7 +122,7 @@ static void test_url_safe_unsafe_mismtach_failure(void) {
char *b64;
gpr_slice orig_decoded;
int url_safe = 1;
- for (i = 0; i < sizeof(orig); i++) orig[i] = (char)i;
+ for (i = 0; i < sizeof(orig); i++) orig[i] = (gpr_uint8)i;
b64 = grpc_base64_encode(orig, sizeof(orig), url_safe, 0);
orig_decoded = grpc_base64_decode(b64, !url_safe);
diff --git a/test/core/security/json_token_test.c b/test/core/security/json_token_test.c
index 0bac61eb54..740fd018b6 100644
--- a/test/core/security/json_token_test.c
+++ b/test/core/security/json_token_test.c
@@ -391,20 +391,21 @@ static void test_jwt_encode_and_sign(
char *jwt = jwt_encode_and_sign_func(&json_key);
const char *dot = strchr(jwt, '.');
GPR_ASSERT(dot != NULL);
- parsed_header = parse_json_part_from_jwt(jwt, dot - jwt, &scratchpad);
+ parsed_header =
+ parse_json_part_from_jwt(jwt, (size_t)(dot - jwt), &scratchpad);
GPR_ASSERT(parsed_header != NULL);
check_jwt_header(parsed_header);
- offset = dot - jwt + 1;
+ offset = (size_t)(dot - jwt) + 1;
grpc_json_destroy(parsed_header);
gpr_free(scratchpad);
dot = strchr(jwt + offset, '.');
GPR_ASSERT(dot != NULL);
- parsed_claim =
- parse_json_part_from_jwt(jwt + offset, dot - (jwt + offset), &scratchpad);
+ parsed_claim = parse_json_part_from_jwt(
+ jwt + offset, (size_t)(dot - (jwt + offset)), &scratchpad);
GPR_ASSERT(parsed_claim != NULL);
check_jwt_claim_func(parsed_claim);
- offset = dot - jwt + 1;
+ offset = (size_t)(dot - jwt) + 1;
grpc_json_destroy(parsed_claim);
gpr_free(scratchpad);
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 ");
diff --git a/test/core/surface/byte_buffer_reader_test.c b/test/core/surface/byte_buffer_reader_test.c
index d9c60e4212..560e0ac7b2 100644
--- a/test/core/surface/byte_buffer_reader_test.c
+++ b/test/core/surface/byte_buffer_reader_test.c
@@ -113,14 +113,14 @@ static void test_read_none_compressed_slice(void) {
}
static void read_compressed_slice(grpc_compression_algorithm algorithm,
- int input_size) {
+ size_t input_size) {
gpr_slice input_slice;
gpr_slice_buffer sliceb_in;
gpr_slice_buffer sliceb_out;
grpc_byte_buffer *buffer;
grpc_byte_buffer_reader reader;
gpr_slice read_slice;
- int read_count = 0;
+ size_t read_count = 0;
gpr_slice_buffer_init(&sliceb_in);
gpr_slice_buffer_init(&sliceb_out);
@@ -149,13 +149,13 @@ static void read_compressed_slice(grpc_compression_algorithm algorithm,
}
static void test_read_gzip_compressed_slice(void) {
- const int INPUT_SIZE = 2048;
+ const size_t INPUT_SIZE = 2048;
LOG_TEST("test_read_gzip_compressed_slice");
read_compressed_slice(GRPC_COMPRESS_GZIP, INPUT_SIZE);
}
static void test_read_deflate_compressed_slice(void) {
- const int INPUT_SIZE = 2048;
+ const size_t INPUT_SIZE = 2048;
LOG_TEST("test_read_deflate_compressed_slice");
read_compressed_slice(GRPC_COMPRESS_DEFLATE, INPUT_SIZE);
}
diff --git a/test/core/surface/completion_queue_test.c b/test/core/surface/completion_queue_test.c
index c382b2a5aa..0eeb5dac45 100644
--- a/test/core/surface/completion_queue_test.c
+++ b/test/core/surface/completion_queue_test.c
@@ -177,7 +177,7 @@ typedef struct test_thread_options {
gpr_event on_phase1_done;
gpr_event *phase2;
gpr_event on_finished;
- int events_triggered;
+ size_t events_triggered;
int id;
grpc_completion_queue *cc;
} test_thread_options;
@@ -251,14 +251,14 @@ static void consumer_thread(void *arg) {
}
}
-static void test_threading(int producers, int consumers) {
+static void test_threading(size_t producers, size_t consumers) {
test_thread_options *options =
gpr_malloc((producers + consumers) * sizeof(test_thread_options));
gpr_event phase1 = GPR_EVENT_INIT;
gpr_event phase2 = GPR_EVENT_INIT;
grpc_completion_queue *cc = grpc_completion_queue_create(NULL);
- int i;
- int total_consumed = 0;
+ size_t i;
+ size_t total_consumed = 0;
static int optid = 101;
gpr_log(GPR_INFO, "%s: %d producers, %d consumers", "test_threading",
diff --git a/test/core/surface/lame_client_test.c b/test/core/surface/lame_client_test.c
index 96434193c9..0d29bea555 100644
--- a/test/core/surface/lame_client_test.c
+++ b/test/core/surface/lame_client_test.c
@@ -82,7 +82,7 @@ int main(int argc, char **argv) {
op->flags = 0;
op->reserved = NULL;
op++;
- error = grpc_call_start_batch(call, ops, op - ops, tag(1), NULL);
+ error = grpc_call_start_batch(call, ops, (size_t)(op - ops), tag(1), NULL);
GPR_ASSERT(GRPC_CALL_OK == error);
/* the call should immediately fail */
diff --git a/test/core/transport/chttp2/hpack_table_test.c b/test/core/transport/chttp2/hpack_table_test.c
index 15b37d17b6..ec0a569371 100644
--- a/test/core/transport/chttp2/hpack_table_test.c
+++ b/test/core/transport/chttp2/hpack_table_test.c
@@ -49,8 +49,8 @@ static void assert_str(const grpc_chttp2_hptbl *tbl, grpc_mdstr *mdstr,
GPR_ASSERT(gpr_slice_str_cmp(mdstr->slice, str) == 0);
}
-static void assert_index(const grpc_chttp2_hptbl *tbl, int idx, const char *key,
- const char *value) {
+static void assert_index(const grpc_chttp2_hptbl *tbl, size_t idx,
+ const char *key, const char *value) {
grpc_mdelem *md = grpc_chttp2_hptbl_lookup(tbl, idx);
assert_str(tbl, md->key, key);
assert_str(tbl, md->value, value);
diff --git a/test/core/transport/chttp2/stream_encoder_test.c b/test/core/transport/chttp2/stream_encoder_test.c
index e6731ff195..4bb503b4e9 100644
--- a/test/core/transport/chttp2/stream_encoder_test.c
+++ b/test/core/transport/chttp2/stream_encoder_test.c
@@ -52,8 +52,8 @@ int g_failure = 0;
grpc_stream_op_buffer g_sopb;
void **to_delete = NULL;
-int num_to_delete = 0;
-int cap_to_delete = 0;
+size_t num_to_delete = 0;
+size_t cap_to_delete = 0;
static gpr_slice create_test_slice(size_t length) {
gpr_slice slice = gpr_slice_malloc(length);
@@ -126,8 +126,8 @@ static void test_small_data_framing(void) {
verify_sopb(10, 0, 5, "000005 0000 deadbeef 00000000ff");
}
-static void add_sopb_headers(int n, ...) {
- int i;
+static void add_sopb_headers(size_t n, ...) {
+ size_t i;
grpc_metadata_batch b;
va_list l;
grpc_linked_mdelem *e = gpr_malloc(sizeof(*e) * n);
@@ -336,7 +336,7 @@ static void run_test(void (*test)(), const char *name) {
}
int main(int argc, char **argv) {
- int i;
+ size_t i;
grpc_test_init(argc, argv);
TEST(test_small_data_framing);
TEST(test_basic_headers);
diff --git a/test/core/transport/chttp2/stream_map_test.c b/test/core/transport/chttp2/stream_map_test.c
index b0bb3a8904..72aaafd18d 100644
--- a/test/core/transport/chttp2/stream_map_test.c
+++ b/test/core/transport/chttp2/stream_map_test.c
@@ -203,9 +203,9 @@ static void test_periodic_compaction(size_t n) {
}
int main(int argc, char **argv) {
- int n = 1;
- int prev = 1;
- int tmp;
+ size_t n = 1;
+ size_t prev = 1;
+ size_t tmp;
grpc_test_init(argc, argv);
diff --git a/test/core/transport/metadata_test.c b/test/core/transport/metadata_test.c
index 4a4d4bcb8a..1861442bb1 100644
--- a/test/core/transport/metadata_test.c
+++ b/test/core/transport/metadata_test.c
@@ -177,11 +177,11 @@ static void test_spin_creating_the_same_thing(void) {
static void test_things_stick_around(void) {
grpc_mdctx *ctx;
- int i, j;
+ size_t i, j;
char *buffer;
- int nstrs = 1000;
+ size_t nstrs = 1000;
grpc_mdstr **strs = gpr_malloc(sizeof(grpc_mdstr *) * nstrs);
- int *shuf = gpr_malloc(sizeof(int) * nstrs);
+ size_t *shuf = gpr_malloc(sizeof(size_t) * nstrs);
grpc_mdstr *test;
LOG_TEST("test_things_stick_around");
@@ -201,9 +201,9 @@ static void test_things_stick_around(void) {
}
for (i = 0; i < nstrs; i++) {
- int p = rand() % nstrs;
- int q = rand() % nstrs;
- int temp = shuf[p];
+ size_t p = (size_t)rand() % nstrs;
+ size_t q = (size_t)rand() % nstrs;
+ size_t temp = shuf[p];
shuf[p] = shuf[q];
shuf[q] = temp;
}