diff options
Diffstat (limited to 'test')
70 files changed, 430 insertions, 353 deletions
diff --git a/test/build/empty.c b/test/build/empty.c new file mode 100644 index 0000000000..58e4698aee --- /dev/null +++ b/test/build/empty.c @@ -0,0 +1,34 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +int main(void) {} diff --git a/test/core/bad_client/bad_client.c b/test/core/bad_client/bad_client.c index 1d98879662..41ac83b7b7 100644 --- a/test/core/bad_client/bad_client.c +++ b/test/core/bad_client/bad_client.c @@ -145,6 +145,7 @@ void grpc_run_bad_client_test(grpc_bad_client_server_side_validator validator, gpr_event_wait(&a.done_write, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))); if (flags & GRPC_BAD_CLIENT_DISCONNECT) { + grpc_endpoint_shutdown(sfd.client); grpc_endpoint_destroy(sfd.client); sfd.client = NULL; } @@ -153,6 +154,7 @@ void grpc_run_bad_client_test(grpc_bad_client_server_side_validator validator, /* Shutdown */ if (sfd.client) { + grpc_endpoint_shutdown(sfd.client); grpc_endpoint_destroy(sfd.client); } grpc_server_shutdown_and_notify(a.server, a.cq, NULL); 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/client_config/lb_policies_test.c b/test/core/client_config/lb_policies_test.c index 18c675b9eb..eec0778cfe 100644 --- a/test/core/client_config/lb_policies_test.c +++ b/test/core/client_config/lb_policies_test.c @@ -86,15 +86,15 @@ static void test_spec_reset(test_spec *spec) { } } -static test_spec *test_spec_create(size_t num_iters, int num_servers) { +static test_spec *test_spec_create(size_t num_iters, size_t num_servers) { test_spec *spec; size_t i; spec = gpr_malloc(sizeof(test_spec)); spec->num_iters = num_iters; spec->num_servers = num_servers; - spec->kill_at = gpr_malloc(sizeof(int*) * num_iters); - spec->revive_at = gpr_malloc(sizeof(int*) * num_iters); + spec->kill_at = gpr_malloc(sizeof(int *) * num_iters); + spec->revive_at = gpr_malloc(sizeof(int *) * num_iters); for (i = 0; i < num_iters; i++) { spec->kill_at[i] = gpr_malloc(sizeof(int) * num_servers); spec->revive_at[i] = gpr_malloc(sizeof(int) * num_servers); @@ -130,19 +130,18 @@ static void drain_cq(grpc_completion_queue *cq) { } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void kill_server(const servers_fixture *f, int i) { +static void kill_server(const servers_fixture *f, size_t i) { gpr_log(GPR_INFO, "KILLING SERVER %d", i); GPR_ASSERT(f->servers[i] != NULL); grpc_server_shutdown_and_notify(f->servers[i], f->cq, tag(10000)); - GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(10000), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), - NULL) + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(10000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->servers[i]); f->servers[i] = NULL; } -static void revive_server(const servers_fixture *f, int i) { +static void revive_server(const servers_fixture *f, size_t i) { int got_port; gpr_log(GPR_INFO, "RAISE AGAIN SERVER %d", i); GPR_ASSERT(f->servers[i] == NULL); @@ -161,12 +160,13 @@ static servers_fixture *setup_servers(const char *server_host, size_t i; f->num_servers = num_servers; - f->server_calls = gpr_malloc(sizeof(grpc_call*) * num_servers); - f->request_metadata_recv = gpr_malloc(sizeof(grpc_metadata_array) * num_servers); + f->server_calls = gpr_malloc(sizeof(grpc_call *) * num_servers); + f->request_metadata_recv = + gpr_malloc(sizeof(grpc_metadata_array) * num_servers); /* Create servers. */ - ports = gpr_malloc(sizeof(int*) * num_servers); - f->servers = gpr_malloc(sizeof(grpc_server*) * num_servers); - f->servers_hostports = gpr_malloc(sizeof(char*) * num_servers); + ports = gpr_malloc(sizeof(int *) * num_servers); + f->servers = gpr_malloc(sizeof(grpc_server *) * num_servers); + f->servers_hostports = gpr_malloc(sizeof(char *) * num_servers); f->cq = grpc_completion_queue_create(NULL); for (i = 0; i < num_servers; i++) { ports[i] = grpc_pick_unused_port_or_die(); @@ -190,9 +190,8 @@ static void teardown_servers(servers_fixture *f) { for (i = 0; i < f->num_servers; i++) { if (f->servers[i] == NULL) continue; grpc_server_shutdown_and_notify(f->servers[i], f->cq, tag(10000)); - GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(10000), - GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), - NULL) + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(10000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->servers[i]); } @@ -234,7 +233,7 @@ int *perform_request(servers_fixture *f, grpc_channel *client, grpc_metadata_array trailing_metadata_recv; s_valid = gpr_malloc(sizeof(int) * f->num_servers); - call_details = gpr_malloc(sizeof(grpc_call_details) * f->num_servers); + call_details = gpr_malloc(sizeof(grpc_call_details) * f->num_servers); connection_sequence = gpr_malloc(sizeof(int) * spec->num_iters); /* Send a trivial request. */ @@ -292,16 +291,17 @@ int *perform_request(servers_fixture *f, grpc_channel *client, op->reserved = NULL; op++; GPR_ASSERT(GRPC_CALL_OK == - grpc_call_start_batch(c, ops, op - ops, tag(1), NULL)); + grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL)); /* "listen" on all servers */ for (i = 0; i < f->num_servers; i++) { grpc_metadata_array_init(&f->request_metadata_recv[i]); if (f->servers[i] != NULL) { - GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call( - f->servers[i], &f->server_calls[i], - &call_details[i], &f->request_metadata_recv[i], - f->cq, f->cq, tag(1000 + i))); + GPR_ASSERT(GRPC_CALL_OK == + grpc_server_request_call(f->servers[i], &f->server_calls[i], + &call_details[i], + &f->request_metadata_recv[i], f->cq, + f->cq, tag(1000 + (int)i))); } } @@ -341,14 +341,13 @@ int *perform_request(servers_fixture *f, grpc_channel *client, op->reserved = NULL; op++; GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(f->server_calls[s_idx], - ops, op - ops, tag(102), - NULL)); + ops, (size_t)(op - ops), + tag(102), NULL)); cq_expect_completion(cqv, tag(102), 1); cq_expect_completion(cqv, tag(1), 1); cq_verify(cqv); - GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details[s_idx].method, "/foo")); @@ -357,7 +356,7 @@ int *perform_request(servers_fixture *f, grpc_channel *client, } for (i = 0; i < f->num_servers; i++) { - if (s_valid[i] != 0){ + if (s_valid[i] != 0) { grpc_call_destroy(f->server_calls[i]); } grpc_metadata_array_destroy(&f->request_metadata_recv[i]); @@ -404,7 +403,8 @@ static void assert_channel_connectivity( } va_end(ap); if (i == num_accepted_conn_states) { - char **accepted_strs = gpr_malloc(sizeof(char*) * num_accepted_conn_states); + char **accepted_strs = + gpr_malloc(sizeof(char *) * num_accepted_conn_states); char *accepted_str_joined; va_start(ap, accepted_conn_states); for (i = 0; i < num_accepted_conn_states; i++) { @@ -476,7 +476,7 @@ static void verify_vanilla_round_robin(const servers_fixture *f, const size_t num_iters) { int *expected_connection_sequence; size_t i; - const int expected_seq_length = f->num_servers; + const size_t expected_seq_length = f->num_servers; /* verify conn. seq. expectation */ /* get the first sequence of "num_servers" elements */ @@ -507,7 +507,7 @@ static void verify_vanishing_floor_round_robin( const servers_fixture *f, grpc_channel *client, const int *actual_connection_sequence, const size_t num_iters) { int *expected_connection_sequence; - const int expected_seq_length = 2; + const size_t expected_seq_length = 2; size_t i; /* verify conn. seq. expectation */ @@ -522,13 +522,12 @@ static void verify_vanishing_floor_round_robin( expected_connection_sequence[0], actual_connection_sequence[0], 0); print_failed_expectations(expected_connection_sequence, actual_connection_sequence, expected_seq_length, - 1); + 1u); abort(); } GPR_ASSERT(actual_connection_sequence[1] == -1); - for (i = 2; i < num_iters; i++) { const int actual = actual_connection_sequence[i]; const int expected = expected_connection_sequence[i % expected_seq_length]; @@ -570,7 +569,7 @@ static void verify_partial_carnage_round_robin( const int *actual_connection_sequence, const size_t num_iters) { int *expected_connection_sequence; size_t i; - const int expected_seq_length = f->num_servers; + const size_t expected_seq_length = f->num_servers; /* verify conn. seq. expectation */ /* get the first sequence of "num_servers" elements */ @@ -578,7 +577,7 @@ static void verify_partial_carnage_round_robin( memcpy(expected_connection_sequence, actual_connection_sequence, sizeof(int) * expected_seq_length); - for (i = 0; i < num_iters/2; i++) { + for (i = 0; i < num_iters / 2; i++) { const int actual = actual_connection_sequence[i]; const int expected = expected_connection_sequence[i % expected_seq_length]; if (actual != expected) { @@ -609,7 +608,7 @@ static void verify_rebirth_round_robin(const servers_fixture *f, const size_t num_iters) { int *expected_connection_sequence; size_t i; - const int expected_seq_length = f->num_servers; + const size_t expected_seq_length = f->num_servers; /* verify conn. seq. expectation */ /* get the first sequence of "num_servers" elements */ @@ -643,7 +642,6 @@ static void verify_rebirth_round_robin(const servers_fixture *f, gpr_free(expected_connection_sequence); } - int main(int argc, char **argv) { test_spec *spec; size_t i; @@ -657,7 +655,7 @@ int main(int argc, char **argv) { spec = test_spec_create(NUM_ITERS, NUM_SERVERS); spec->verifier = verify_vanilla_round_robin; spec->description = "test_all_server_up"; - /*run_spec(spec);*/ + run_spec(spec); /* Kill all servers first thing in the morning */ test_spec_reset(spec); @@ -676,7 +674,7 @@ int main(int argc, char **argv) { for (i = 1; i < NUM_SERVERS - 1; i++) { spec->kill_at[1][i] = 1; } - /*run_spec(spec);*/ + run_spec(spec); /* Midway, kill all servers. */ test_spec_reset(spec); @@ -685,7 +683,7 @@ int main(int argc, char **argv) { for (i = 0; i < NUM_SERVERS; i++) { spec->kill_at[spec->num_iters / 2][i] = 1; } - /*run_spec(spec);*/ + run_spec(spec); /* After first iteration, kill all servers. On the third one, bring them all * back up. */ @@ -696,7 +694,7 @@ int main(int argc, char **argv) { spec->kill_at[1][i] = 1; spec->revive_at[3][i] = 1; } - /*run_spec(spec);*/ + run_spec(spec); test_spec_destroy(spec); diff --git a/test/core/compression/message_compress_test.c b/test/core/compression/message_compress_test.c index 495841c79f..98da6a1eaa 100644 --- a/test/core/compression/message_compress_test.c +++ b/test/core/compression/message_compress_test.c @@ -149,7 +149,7 @@ static gpr_slice create_test_value(test_value id) { static void test_bad_data(void) { gpr_slice_buffer input; gpr_slice_buffer output; - int i; + grpc_compression_algorithm i; gpr_slice_buffer_init(&input); gpr_slice_buffer_init(&output); diff --git a/test/core/end2end/dualstack_socket_test.c b/test/core/end2end/dualstack_socket_test.c index fcc12952bf..ec3fb65105 100644 --- a/test/core/end2end/dualstack_socket_test.c +++ b/test/core/end2end/dualstack_socket_test.c @@ -40,6 +40,7 @@ #include <grpc/support/string_util.h> #include "src/core/support/string.h" +#include "src/core/iomgr/resolve_address.h" #include "src/core/iomgr/socket_utils_posix.h" #include "test/core/end2end/cq_verifier.h" @@ -186,7 +187,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 +213,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); @@ -263,6 +264,15 @@ void test_connect(const char *server_host, const char *client_host, int port, gpr_free(details); } +int external_dns_works(const char *host) { + grpc_resolved_addresses *res = grpc_blocking_resolve_address(host, "80"); + if (res != NULL) { + gpr_free(res); + return 1; + } + return 0; +} + int main(int argc, char **argv) { int do_ipv6 = 1; @@ -308,6 +318,25 @@ int main(int argc, char **argv) { test_connect("::1", "ipv4:127.0.0.1", 0, 0); test_connect("127.0.0.1", "ipv6:[::1]", 0, 0); } + + if (!external_dns_works("loopback46.unittest.grpc.io")) { + gpr_log(GPR_INFO, "Skipping tests that depend on *.unittest.grpc.io."); + } else { + test_connect("loopback46.unittest.grpc.io", + "loopback4.unittest.grpc.io", 0, 1); + test_connect("loopback4.unittest.grpc.io", + "loopback46.unittest.grpc.io", 0, 1); + if (do_ipv6) { + test_connect("loopback46.unittest.grpc.io", + "loopback6.unittest.grpc.io", 0, 1); + test_connect("loopback6.unittest.grpc.io", + "loopback46.unittest.grpc.io", 0, 1); + test_connect("loopback4.unittest.grpc.io", + "loopback6.unittest.grpc.io", 0, 0); + test_connect("loopback6.unittest.grpc.io", + "loopback4.unittest.grpc.io", 0, 0); + } + } } grpc_shutdown(); 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/end2end/tests/bad_hostname.c b/test/core/end2end/tests/bad_hostname.c index 8f28fa1e63..93e2df1e43 100644 --- a/test/core/end2end/tests/bad_hostname.c +++ b/test/core/end2end/tests/bad_hostname.c @@ -146,7 +146,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { 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); cq_expect_completion(cqv, tag(1), 1); diff --git a/test/core/end2end/tests/binary_metadata.c b/test/core/end2end/tests/binary_metadata.c index 2345f94044..21e0bbcc49 100644 --- a/test/core/end2end/tests/binary_metadata.c +++ b/test/core/end2end/tests/binary_metadata.c @@ -191,7 +191,7 @@ static void test_request_response_with_metadata_and_payload( 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); error = @@ -213,7 +213,7 @@ static void test_request_response_with_metadata_and_payload( op->flags = 0; op->reserved = NULL; 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); @@ -237,7 +237,7 @@ static void test_request_response_with_metadata_and_payload( op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch(s, ops, op - ops, tag(103), NULL); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL); GPR_ASSERT(GRPC_CALL_OK == error); cq_expect_completion(cqv, tag(103), 1); diff --git a/test/core/end2end/tests/call_creds.c b/test/core/end2end/tests/call_creds.c index 75c5bba5bd..4e905aafc7 100644 --- a/test/core/end2end/tests/call_creds.c +++ b/test/core/end2end/tests/call_creds.c @@ -247,7 +247,7 @@ static void request_response_with_payload_and_call_creds( 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); error = @@ -280,7 +280,7 @@ static void request_response_with_payload_and_call_creds( op->flags = 0; op->reserved = NULL; 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); @@ -304,7 +304,7 @@ static void request_response_with_payload_and_call_creds( op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch(s, ops, op - ops, tag(103), NULL); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL); GPR_ASSERT(GRPC_CALL_OK == error); cq_expect_completion(cqv, tag(103), 1); @@ -464,7 +464,7 @@ static void test_request_with_server_rejecting_client_creds( 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(error == GRPC_CALL_OK); cq_expect_completion(cqv, tag(1), 1); diff --git a/test/core/end2end/tests/cancel_after_accept.c b/test/core/end2end/tests/cancel_after_accept.c index 313e0b05bd..10e62275ab 100644 --- a/test/core/end2end/tests/cancel_after_accept.c +++ b/test/core/end2end/tests/cancel_after_accept.c @@ -165,7 +165,7 @@ static void test_cancel_after_accept(grpc_end2end_test_config config, 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); error = grpc_server_request_call(f.server, &s, &call_details, @@ -195,7 +195,7 @@ static void test_cancel_after_accept(grpc_end2end_test_config config, op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch(s, ops, op - ops, tag(3), NULL); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(3), NULL); GPR_ASSERT(GRPC_CALL_OK == error); GPR_ASSERT(GRPC_CALL_OK == mode.initiate_cancel(c, NULL)); diff --git a/test/core/end2end/tests/cancel_after_client_done.c b/test/core/end2end/tests/cancel_after_client_done.c index 2430a6d218..4fed5be5f7 100644 --- a/test/core/end2end/tests/cancel_after_client_done.c +++ b/test/core/end2end/tests/cancel_after_client_done.c @@ -169,7 +169,7 @@ static void test_cancel_after_accept_and_writes_closed( 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); error = grpc_server_request_call(f.server, &s, &call_details, @@ -199,7 +199,7 @@ static void test_cancel_after_accept_and_writes_closed( op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch(s, ops, op - ops, tag(3), NULL); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(3), NULL); GPR_ASSERT(GRPC_CALL_OK == error); GPR_ASSERT(GRPC_CALL_OK == mode.initiate_cancel(c, NULL)); diff --git a/test/core/end2end/tests/cancel_after_invoke.c b/test/core/end2end/tests/cancel_after_invoke.c index 9991ee02f0..40595e4c7b 100644 --- a/test/core/end2end/tests/cancel_after_invoke.c +++ b/test/core/end2end/tests/cancel_after_invoke.c @@ -101,7 +101,7 @@ static void end_test(grpc_end2end_test_fixture *f) { /* Cancel after invoke, no payload */ static void test_cancel_after_invoke(grpc_end2end_test_config config, - cancellation_mode mode, int test_ops) { + cancellation_mode mode, size_t test_ops) { grpc_op ops[6]; grpc_op *op; grpc_call *c; diff --git a/test/core/end2end/tests/cancel_before_invoke.c b/test/core/end2end/tests/cancel_before_invoke.c index 8b582e0c42..c049e0c2d6 100644 --- a/test/core/end2end/tests/cancel_before_invoke.c +++ b/test/core/end2end/tests/cancel_before_invoke.c @@ -99,7 +99,7 @@ static void end_test(grpc_end2end_test_fixture *f) { /* Cancel before invoke */ static void test_cancel_before_invoke(grpc_end2end_test_config config, - int test_ops) { + size_t test_ops) { grpc_op ops[6]; grpc_op *op; grpc_call *c; @@ -189,7 +189,7 @@ static void test_cancel_before_invoke(grpc_end2end_test_config config, } void grpc_end2end_tests(grpc_end2end_test_config config) { - int i; + size_t i; for (i = 1; i <= 6; i++) { test_cancel_before_invoke(config, i); } diff --git a/test/core/end2end/tests/census_simple_request.c b/test/core/end2end/tests/census_simple_request.c index 36b9e92884..adf855ca60 100644 --- a/test/core/end2end/tests/census_simple_request.c +++ b/test/core/end2end/tests/census_simple_request.c @@ -145,7 +145,7 @@ static void test_body(grpc_end2end_test_fixture f) { 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); error = @@ -173,7 +173,7 @@ static void test_body(grpc_end2end_test_fixture f) { op->flags = 0; op->reserved = NULL; 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/tests/compressed_payload.c b/test/core/end2end/tests/compressed_payload.c index 299943c548..c50eaba8b2 100644 --- a/test/core/end2end/tests/compressed_payload.c +++ b/test/core/end2end/tests/compressed_payload.c @@ -186,7 +186,7 @@ static void request_with_payload_template( 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); error = @@ -215,7 +215,7 @@ static void request_with_payload_template( op->flags = 0; op->reserved = NULL; 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); @@ -234,7 +234,7 @@ static void request_with_payload_template( op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch(s, ops, op - ops, tag(103), NULL); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL); GPR_ASSERT(GRPC_CALL_OK == error); cq_expect_completion(cqv, tag(103), 1); diff --git a/test/core/end2end/tests/default_host.c b/test/core/end2end/tests/default_host.c index 57f65b834b..7b62505a9a 100644 --- a/test/core/end2end/tests/default_host.c +++ b/test/core/end2end/tests/default_host.c @@ -154,7 +154,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { 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(error == GRPC_CALL_OK); error = @@ -191,7 +191,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { op->flags = 0; op->reserved = NULL; 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(error == GRPC_CALL_OK); cq_expect_completion(cqv, tag(102), 1); diff --git a/test/core/end2end/tests/disappearing_server.c b/test/core/end2end/tests/disappearing_server.c index 09762705e3..de3ea16f66 100644 --- a/test/core/end2end/tests/disappearing_server.c +++ b/test/core/end2end/tests/disappearing_server.c @@ -131,7 +131,7 @@ static void do_request_and_shutdown_server(grpc_end2end_test_fixture *f, 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); error = @@ -163,7 +163,7 @@ static void do_request_and_shutdown_server(grpc_end2end_test_fixture *f, op->flags = 0; op->reserved = NULL; 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/tests/graceful_server_shutdown.c b/test/core/end2end/tests/graceful_server_shutdown.c index d4e7a1ac6d..df420a9846 100644 --- a/test/core/end2end/tests/graceful_server_shutdown.c +++ b/test/core/end2end/tests/graceful_server_shutdown.c @@ -146,7 +146,7 @@ static void test_early_server_shutdown_finishes_inflight_calls( 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); error = @@ -178,7 +178,7 @@ static void test_early_server_shutdown_finishes_inflight_calls( op->flags = 0; op->reserved = NULL; 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/tests/high_initial_seqno.c b/test/core/end2end/tests/high_initial_seqno.c index 0067bb4bef..44d6a60c10 100644 --- a/test/core/end2end/tests/high_initial_seqno.c +++ b/test/core/end2end/tests/high_initial_seqno.c @@ -149,7 +149,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { 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); error = @@ -177,7 +177,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { op->flags = 0; op->reserved = NULL; 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/tests/invoke_large_request.c b/test/core/end2end/tests/invoke_large_request.c index 7677084511..f79d146da1 100644 --- a/test/core/end2end/tests/invoke_large_request.c +++ b/test/core/end2end/tests/invoke_large_request.c @@ -171,7 +171,7 @@ static void test_invoke_large_request(grpc_end2end_test_config config) { 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); error = @@ -192,7 +192,7 @@ static void test_invoke_large_request(grpc_end2end_test_config config) { op->flags = 0; op->reserved = NULL; 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); @@ -216,7 +216,7 @@ static void test_invoke_large_request(grpc_end2end_test_config config) { op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch(s, ops, op - ops, tag(103), NULL); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL); GPR_ASSERT(GRPC_CALL_OK == error); cq_expect_completion(cqv, tag(103), 1); diff --git a/test/core/end2end/tests/large_metadata.c b/test/core/end2end/tests/large_metadata.c index 98e47aaf98..87529639a7 100644 --- a/test/core/end2end/tests/large_metadata.c +++ b/test/core/end2end/tests/large_metadata.c @@ -121,7 +121,7 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { char *details = NULL; size_t details_capacity = 0; int was_cancelled = 2; - const int large_size = 64 * 1024; + const size_t large_size = 64 * 1024; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr", deadline, NULL); @@ -167,7 +167,7 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { 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); error = @@ -188,7 +188,7 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { op->flags = 0; op->reserved = NULL; 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); @@ -207,7 +207,7 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch(s, ops, op - ops, tag(103), NULL); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL); GPR_ASSERT(GRPC_CALL_OK == error); cq_expect_completion(cqv, tag(103), 1); diff --git a/test/core/end2end/tests/max_concurrent_streams.c b/test/core/end2end/tests/max_concurrent_streams.c index 0ba620b851..87eb4dd451 100644 --- a/test/core/end2end/tests/max_concurrent_streams.c +++ b/test/core/end2end/tests/max_concurrent_streams.c @@ -147,7 +147,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { 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); error = @@ -175,7 +175,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { op->flags = 0; op->reserved = NULL; 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); @@ -280,7 +280,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch(c1, ops, op - ops, tag(301), NULL); + error = grpc_call_start_batch(c1, ops, (size_t)(op - ops), tag(301), NULL); GPR_ASSERT(GRPC_CALL_OK == error); op = ops; @@ -297,7 +297,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch(c1, ops, op - ops, tag(302), NULL); + error = grpc_call_start_batch(c1, ops, (size_t)(op - ops), tag(302), NULL); GPR_ASSERT(GRPC_CALL_OK == error); op = ops; @@ -310,7 +310,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch(c2, ops, op - ops, tag(401), NULL); + error = grpc_call_start_batch(c2, ops, (size_t)(op - ops), tag(401), NULL); GPR_ASSERT(GRPC_CALL_OK == error); op = ops; @@ -327,7 +327,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch(c2, ops, op - ops, tag(402), NULL); + error = grpc_call_start_batch(c2, ops, (size_t)(op - ops), tag(402), NULL); GPR_ASSERT(GRPC_CALL_OK == error); got_client_start = 0; @@ -372,7 +372,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch(s1, ops, op - ops, tag(102), NULL); + error = grpc_call_start_batch(s1, ops, (size_t)(op - ops), tag(102), NULL); GPR_ASSERT(GRPC_CALL_OK == error); cq_expect_completion(cqv, tag(102), 1); @@ -406,7 +406,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch(s2, ops, op - ops, tag(202), NULL); + error = grpc_call_start_batch(s2, ops, (size_t)(op - ops), tag(202), NULL); GPR_ASSERT(GRPC_CALL_OK == error); cq_expect_completion(cqv, tag(live_call + 2), 1); diff --git a/test/core/end2end/tests/max_message_length.c b/test/core/end2end/tests/max_message_length.c index 2b9560716f..782b9d0f26 100644 --- a/test/core/end2end/tests/max_message_length.c +++ b/test/core/end2end/tests/max_message_length.c @@ -167,7 +167,7 @@ static void test_max_message_length(grpc_end2end_test_config config) { 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); error = @@ -183,7 +183,7 @@ static void test_max_message_length(grpc_end2end_test_config config) { op->flags = 0; op->reserved = NULL; 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/tests/metadata.c b/test/core/end2end/tests/metadata.c index a4cc27896c..d0604cc6b6 100644 --- a/test/core/end2end/tests/metadata.c +++ b/test/core/end2end/tests/metadata.c @@ -175,7 +175,7 @@ static void test_request_response_with_metadata_and_payload( 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); error = @@ -197,7 +197,7 @@ static void test_request_response_with_metadata_and_payload( op->flags = 0; op->reserved = NULL; 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); @@ -221,7 +221,7 @@ static void test_request_response_with_metadata_and_payload( op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch(s, ops, op - ops, tag(103), NULL); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL); GPR_ASSERT(GRPC_CALL_OK == error); cq_expect_completion(cqv, tag(103), 1); diff --git a/test/core/end2end/tests/payload.c b/test/core/end2end/tests/payload.c index ff00ae6d9d..0b303268fc 100644 --- a/test/core/end2end/tests/payload.c +++ b/test/core/end2end/tests/payload.c @@ -164,7 +164,7 @@ static void request_response_with_payload(grpc_end2end_test_fixture f) { 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); error = @@ -185,7 +185,7 @@ static void request_response_with_payload(grpc_end2end_test_fixture f) { op->flags = 0; op->reserved = NULL; 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); @@ -209,7 +209,7 @@ static void request_response_with_payload(grpc_end2end_test_fixture f) { op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch(s, ops, op - ops, tag(103), NULL); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL); GPR_ASSERT(GRPC_CALL_OK == error); cq_expect_completion(cqv, tag(103), 1); diff --git a/test/core/end2end/tests/ping_pong_streaming.c b/test/core/end2end/tests/ping_pong_streaming.c index 43abda4d7f..39682d8bc5 100644 --- a/test/core/end2end/tests/ping_pong_streaming.c +++ b/test/core/end2end/tests/ping_pong_streaming.c @@ -154,7 +154,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, 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); error = @@ -175,7 +175,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch(s, ops, op - ops, tag(101), NULL); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(101), NULL); GPR_ASSERT(GRPC_CALL_OK == error); for (i = 0; i < messages; i++) { @@ -193,7 +193,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch(c, ops, op - ops, tag(2), NULL); + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), NULL); GPR_ASSERT(GRPC_CALL_OK == error); op = ops; @@ -202,7 +202,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, op->flags = 0; op->reserved = NULL; 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); cq_verify(cqv); @@ -213,7 +213,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch(s, ops, op - ops, tag(103), NULL); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL); GPR_ASSERT(GRPC_CALL_OK == error); cq_expect_completion(cqv, tag(103), 1); cq_expect_completion(cqv, tag(2), 1); @@ -233,7 +233,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch(c, ops, op - ops, tag(3), NULL); + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), NULL); GPR_ASSERT(GRPC_CALL_OK == error); op = ops; @@ -244,7 +244,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch(s, ops, op - ops, tag(104), NULL); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), NULL); GPR_ASSERT(GRPC_CALL_OK == error); cq_expect_completion(cqv, tag(1), 1); diff --git a/test/core/end2end/tests/registered_call.c b/test/core/end2end/tests/registered_call.c index eddce6ded4..b3156e0248 100644 --- a/test/core/end2end/tests/registered_call.c +++ b/test/core/end2end/tests/registered_call.c @@ -148,7 +148,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, void *rc) { 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); error = @@ -176,7 +176,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, void *rc) { op->flags = 0; op->reserved = NULL; 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/tests/request_with_flags.c b/test/core/end2end/tests/request_with_flags.c index eb2e5dc7e8..b9cdf5168c 100644 --- a/test/core/end2end/tests/request_with_flags.c +++ b/test/core/end2end/tests/request_with_flags.c @@ -160,7 +160,7 @@ static void test_invoke_request_with_flags( op->reserved = NULL; op++; expectation = call_start_batch_expected_result; - 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(expectation == error); if (expectation == GRPC_CALL_OK) { diff --git a/test/core/end2end/tests/request_with_payload.c b/test/core/end2end/tests/request_with_payload.c index 149dbaeb00..a323b43ab0 100644 --- a/test/core/end2end/tests/request_with_payload.c +++ b/test/core/end2end/tests/request_with_payload.c @@ -158,7 +158,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) { 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); GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call( @@ -178,7 +178,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) { op->flags = 0; op->reserved = NULL; 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); @@ -197,7 +197,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) { op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch(s, ops, op - ops, tag(103), NULL); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL); GPR_ASSERT(GRPC_CALL_OK == error); cq_expect_completion(cqv, tag(103), 1); diff --git a/test/core/end2end/tests/server_finishes_request.c b/test/core/end2end/tests/server_finishes_request.c index 8bacc6c730..bdc18a5e38 100644 --- a/test/core/end2end/tests/server_finishes_request.c +++ b/test/core/end2end/tests/server_finishes_request.c @@ -145,7 +145,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { 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); error = @@ -173,7 +173,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { op->flags = 0; op->reserved = NULL; 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/tests/shutdown_finishes_calls.c b/test/core/end2end/tests/shutdown_finishes_calls.c index 233bc9bee2..ad7def09a9 100644 --- a/test/core/end2end/tests/shutdown_finishes_calls.c +++ b/test/core/end2end/tests/shutdown_finishes_calls.c @@ -139,7 +139,7 @@ static void test_early_server_shutdown_finishes_inflight_calls( 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); error = @@ -155,7 +155,7 @@ static void test_early_server_shutdown_finishes_inflight_calls( op->flags = 0; op->reserved = NULL; 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); /* shutdown and destroy the server */ diff --git a/test/core/end2end/tests/simple_delayed_request.c b/test/core/end2end/tests/simple_delayed_request.c index 9133aacc35..14e0ac8f66 100644 --- a/test/core/end2end/tests/simple_delayed_request.c +++ b/test/core/end2end/tests/simple_delayed_request.c @@ -140,7 +140,7 @@ static void simple_delayed_request_body(grpc_end2end_test_config config, 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); config.init_server(f, server_args); @@ -170,7 +170,7 @@ static void simple_delayed_request_body(grpc_end2end_test_config config, op->flags = 0; op->reserved = NULL; 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/tests/simple_request.c b/test/core/end2end/tests/simple_request.c index 0f62d958ae..a874640837 100644 --- a/test/core/end2end/tests/simple_request.c +++ b/test/core/end2end/tests/simple_request.c @@ -155,7 +155,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { 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); error = @@ -192,7 +192,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { op->flags = 0; op->reserved = NULL; 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/tests/trailing_metadata.c b/test/core/end2end/tests/trailing_metadata.c index 8b764751f6..c040b9fac1 100644 --- a/test/core/end2end/tests/trailing_metadata.c +++ b/test/core/end2end/tests/trailing_metadata.c @@ -178,7 +178,7 @@ static void test_request_response_with_metadata_and_payload( 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); error = @@ -200,7 +200,7 @@ static void test_request_response_with_metadata_and_payload( op->flags = 0; op->reserved = NULL; 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); @@ -225,7 +225,7 @@ static void test_request_response_with_metadata_and_payload( op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch(s, ops, op - ops, tag(103), NULL); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL); GPR_ASSERT(GRPC_CALL_OK == error); cq_expect_completion(cqv, tag(103), 1); diff --git a/test/core/fling/client.c b/test/core/fling/client.c index 54c9274510..a53411c2f5 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); @@ -129,7 +130,7 @@ static void step_ping_pong_stream(void) { static double now(void) { gpr_timespec tv = gpr_now(GPR_CLOCK_REALTIME); - return 1e9 * tv.tv_sec + tv.tv_nsec; + return 1e9 * (double)tv.tv_sec + tv.tv_nsec; } typedef struct { @@ -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..5aace03520 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); } @@ -197,7 +197,7 @@ int main(int argc, char **argv) { grpc_test_init(1, fake_argv); grpc_init(); - srand(clock()); + srand((unsigned)clock()); cl = gpr_cmdline_create("fling server"); gpr_cmdline_add_string(cl, "bind", "Bind host:port", &addr); 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/endpoint_tests.c b/test/core/iomgr/endpoint_tests.c index 27123eb216..853b9a32c2 100644 --- a/test/core/iomgr/endpoint_tests.c +++ b/test/core/iomgr/endpoint_tests.c @@ -86,7 +86,7 @@ static grpc_endpoint_test_fixture begin_test(grpc_endpoint_test_config config, static void end_test(grpc_endpoint_test_config config) { config.clean_up(); } static gpr_slice *allocate_blocks(size_t num_bytes, size_t slice_size, - size_t *num_blocks, int *current_data) { + size_t *num_blocks, gpr_uint8 *current_data) { size_t nslices = num_bytes / slice_size + (num_bytes % slice_size ? 1 : 0); gpr_slice *slices = malloc(sizeof(gpr_slice) * nslices); size_t num_bytes_left = num_bytes; @@ -102,7 +102,7 @@ static gpr_slice *allocate_blocks(size_t num_bytes, size_t slice_size, buf = GPR_SLICE_START_PTR(slices[i]); for (j = 0; j < GPR_SLICE_LENGTH(slices[i]); ++j) { buf[j] = *current_data; - *current_data = (*current_data + 1) % 256; + (*current_data)++; } } GPR_ASSERT(num_bytes_left == 0); @@ -117,7 +117,7 @@ struct read_and_write_test_state { size_t current_write_size; size_t bytes_written; int current_read_data; - int current_write_data; + gpr_uint8 current_write_data; int read_done; int write_done; gpr_slice_buffer incoming; diff --git a/test/core/iomgr/fd_posix_test.c b/test/core/iomgr/fd_posix_test.c index 8bba87d61f..75959069c0 100644 --- a/test/core/iomgr/fd_posix_test.c +++ b/test/core/iomgr/fd_posix_test.c @@ -83,7 +83,8 @@ static void create_test_socket(int port, int *socket_fd, /* Use local address for test */ sin->sin_family = AF_INET; sin->sin_addr.s_addr = htonl(0x7f000001); - sin->sin_port = htons(port); + GPR_ASSERT(port >= 0 && port < 65536); + sin->sin_port = htons((gpr_uint16)port); } /* Dummy gRPC callback */ @@ -419,7 +420,7 @@ static void test_grpc_fd_change(void) { int flags; int sv[2]; char data; - int result; + ssize_t result; grpc_iomgr_closure first_closure; grpc_iomgr_closure second_closure; diff --git a/test/core/iomgr/tcp_posix_test.c b/test/core/iomgr/tcp_posix_test.c index 8acaa433bb..59c498edff 100644 --- a/test/core/iomgr/tcp_posix_test.c +++ b/test/core/iomgr/tcp_posix_test.c @@ -81,7 +81,7 @@ static ssize_t fill_socket(int fd) { int i; unsigned char buf[256]; for (i = 0; i < 256; ++i) { - buf[i] = i; + buf[i] = (gpr_uint8)i; } do { write_bytes = write(fd, buf, 256); @@ -99,13 +99,13 @@ static size_t fill_socket_partial(int fd, size_t bytes) { unsigned char *buf = malloc(bytes); unsigned i; for (i = 0; i < bytes; ++i) { - buf[i] = i % 256; + buf[i] = (gpr_uint8)(i % 256); } 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, - size_t *num_blocks, int *current_data) { - size_t nslices = num_bytes / slice_size + (num_bytes % slice_size ? 1 : 0); +static gpr_slice *allocate_blocks(size_t num_bytes, size_t slice_size, + size_t *num_blocks, gpr_uint8 *current_data) { + 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; @@ -291,7 +291,7 @@ static gpr_slice *allocate_blocks(ssize_t num_bytes, ssize_t slice_size, buf = GPR_SLICE_START_PTR(slices[i]); for (j = 0; j < GPR_SLICE_LENGTH(slices[i]); ++j) { buf[j] = *current_data; - *current_data = (*current_data + 1) % 256; + (*current_data)++; } } GPR_ASSERT(num_bytes_left == 0); @@ -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,14 +366,14 @@ 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; ssize_t read_bytes; size_t num_blocks; gpr_slice *slices; - int current_data = 0; + gpr_uint8 current_data = 0; gpr_slice_buffer outgoing; grpc_iomgr_closure write_done_closure; gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(20); @@ -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/iomgr/udp_server_test.c b/test/core/iomgr/udp_server_test.c index c91752b937..c4f1896ba6 100644 --- a/test/core/iomgr/udp_server_test.c +++ b/test/core/iomgr/udp_server_test.c @@ -53,13 +53,13 @@ static void on_connect(void *arg, grpc_endpoint *udp) {} static void on_read(int fd, grpc_udp_server_cb new_transport_cb, void *cb_arg) { char read_buffer[512]; - int byte_count; + ssize_t byte_count; gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset)); byte_count = recv(fd, read_buffer, sizeof(read_buffer), 0); g_number_of_reads++; - g_number_of_bytes_read += byte_count; + g_number_of_bytes_read += (int)byte_count; grpc_pollset_kick(&g_pollset, NULL); gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset)); diff --git a/test/core/json/json_rewrite.c b/test/core/json/json_rewrite.c index 02f60a3163..82cc4090f3 100644 --- a/test/core/json/json_rewrite.c +++ b/test/core/json/json_rewrite.c @@ -34,8 +34,9 @@ #include <stdio.h> #include <stdlib.h> -#include <grpc/support/cmdline.h> #include <grpc/support/alloc.h> +#include <grpc/support/cmdline.h> +#include <grpc/support/log.h> #include "src/core/json/json_reader.h" #include "src/core/json/json_writer.h" @@ -81,7 +82,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; @@ -96,29 +97,30 @@ static void json_reader_string_clear(void* userdata) { static void json_reader_string_add_char(void* userdata, gpr_uint32 c) { json_reader_userdata* state = userdata; check_string(state, 1); - state->scratchpad[state->string_len++] = c; + GPR_ASSERT(c < 256); + state->scratchpad[state->string_len++] = (char)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); + 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 +134,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..d26ef53b2d 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; @@ -108,29 +108,30 @@ static void json_reader_string_clear(void* userdata) { static void json_reader_string_add_char(void* userdata, gpr_uint32 c) { json_reader_userdata* state = userdata; check_string(state, 1); - state->scratchpad[state->string_len++] = c; + GPR_ASSERT(c <= 256); + state->scratchpad[state->string_len++] = (char)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 +152,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..1762486776 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)); @@ -57,8 +57,8 @@ static void verification_test(hash_func hash, gpr_uint32 expected) { the seed */ for (i = 0; i < 256; i++) { - key[i] = (uint8_t)i; - hashes[i] = hash(key, i, 256 - i); + key[i] = (gpr_uint8)i; + hashes[i] = hash(key, i, (gpr_uint32)(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..1d202f0618 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); @@ -116,7 +116,7 @@ static void test_slice_sub_works(unsigned length) { beginning of the slice. */ slice = gpr_slice_malloc(length); for (i = 0; i < length; i++) { - GPR_SLICE_START_PTR(slice)[i] = i; + GPR_SLICE_START_PTR(slice)[i] = (gpr_uint8)i; } /* Ensure that for all subsets length is correct and that we start on the @@ -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); @@ -155,7 +155,7 @@ static void test_slice_split_head_works(int length) { beginning of the slice. */ slice = gpr_slice_malloc(length); for (i = 0; i < length; i++) { - GPR_SLICE_START_PTR(slice)[i] = i; + GPR_SLICE_START_PTR(slice)[i] = (gpr_uint8)i; } /* Ensure that for all subsets length is correct and that we start on the @@ -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); @@ -183,7 +183,7 @@ static void test_slice_split_tail_works(int length) { beginning of the slice. */ slice = gpr_slice_malloc(length); for (i = 0; i < length; i++) { - GPR_SLICE_START_PTR(slice)[i] = i; + GPR_SLICE_START_PTR(slice)[i] = (gpr_uint8)i; } /* Ensure that for all subsets length is correct and that we start on the diff --git a/test/core/support/stack_lockfree_test.c b/test/core/support/stack_lockfree_test.c index 02ec3154d5..0f49e6fa52 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)); + GPR_ASSERT(gpr_stack_lockfree_push(stack, (int)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]; @@ -118,7 +118,7 @@ static void test_mt_sized(int size, int nth) { stack = gpr_stack_lockfree_create(size); for (i = 0; i < nth; i++) { args[i].stack = stack; - args[i].stack_size = size; + args[i].stack_size = (int)size; args[i].nthreads = nth; args[i].rank = i; args[i].sum = 0; @@ -137,7 +137,8 @@ static void test_mt_sized(int size, int nth) { } static void test_mt() { - int size, nth; + size_t size; + int 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..aa3e273a6c 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, gpr_uint32 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..71db98c69e 100644 --- a/test/core/transport/chttp2/stream_encoder_test.c +++ b/test/core/transport/chttp2/stream_encoder_test.c @@ -52,14 +52,14 @@ 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); size_t i; for (i = 0; i < length; i++) { - GPR_SLICE_START_PTR(slice)[i] = i; + GPR_SLICE_START_PTR(slice)[i] = (gpr_uint8)i; } return slice; } @@ -75,8 +75,8 @@ static void verify_sopb(size_t window_available, int eof, gpr_slice_buffer_init(&output); grpc_sopb_init(&encops); GPR_ASSERT(expect_window_used == - grpc_chttp2_preencode(g_sopb.ops, &g_sopb.nops, window_available, - &encops)); + grpc_chttp2_preencode(g_sopb.ops, &g_sopb.nops, + (gpr_uint32)window_available, &encops)); grpc_chttp2_encode(encops.ops, encops.nops, eof, 0xdeadbeef, &g_compressor, &output); encops.nops = 0; @@ -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); @@ -196,10 +196,10 @@ static void test_basic_headers(void) { } static void encode_int_to_str(int i, char *p) { - p[0] = 'a' + i % 26; + p[0] = (char)('a' + i % 26); i /= 26; GPR_ASSERT(i < 26); - p[1] = 'a' + i; + p[1] = (char)('a' + i); p[2] = 0; } @@ -246,7 +246,7 @@ static void randstr(char *p, int bufsz) { int i; int len = 1 + rand() % bufsz; for (i = 0; i < len; i++) { - p[i] = 'a' + rand() % 26; + p[i] = (char)('a' + rand() % 26); } p[len] = 0; } @@ -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..81fb80f84f 100644 --- a/test/core/transport/chttp2/stream_map_test.c +++ b/test/core/transport/chttp2/stream_map_test.c @@ -82,9 +82,9 @@ static void test_double_deletion(void) { } /* test add & lookup */ -static void test_basic_add_find(size_t n) { +static void test_basic_add_find(gpr_uint32 n) { grpc_chttp2_stream_map map; - size_t i; + gpr_uint32 i; size_t got; LOG_TEST("test_basic_add_find"); @@ -107,15 +107,15 @@ static void test_basic_add_find(size_t n) { /* verify that for_each gets the right values during test_delete_evens_XXX */ static void verify_for_each(void *user_data, gpr_uint32 stream_id, void *ptr) { - size_t *for_each_check = user_data; + gpr_uint32 *for_each_check = user_data; GPR_ASSERT(ptr); GPR_ASSERT(*for_each_check == stream_id); *for_each_check += 2; } -static void check_delete_evens(grpc_chttp2_stream_map *map, size_t n) { - size_t for_each_check = 1; - size_t i; +static void check_delete_evens(grpc_chttp2_stream_map *map, gpr_uint32 n) { + gpr_uint32 for_each_check = 1; + gpr_uint32 i; size_t got; GPR_ASSERT(NULL == grpc_chttp2_stream_map_find(map, 0)); @@ -139,9 +139,9 @@ static void check_delete_evens(grpc_chttp2_stream_map *map, size_t n) { /* add a bunch of keys, delete the even ones, and make sure the map is consistent */ -static void test_delete_evens_sweep(size_t n) { +static void test_delete_evens_sweep(gpr_uint32 n) { grpc_chttp2_stream_map map; - size_t i; + gpr_uint32 i; LOG_TEST("test_delete_evens_sweep"); gpr_log(GPR_INFO, "n = %d", n); @@ -152,7 +152,8 @@ static void test_delete_evens_sweep(size_t n) { } for (i = 1; i <= n; i++) { if ((i & 1) == 0) { - GPR_ASSERT((void *)i == grpc_chttp2_stream_map_delete(&map, i)); + GPR_ASSERT((void *)(gpr_uintptr)i == + grpc_chttp2_stream_map_delete(&map, i)); } } check_delete_evens(&map, n); @@ -161,9 +162,9 @@ static void test_delete_evens_sweep(size_t n) { /* add a bunch of keys, delete the even ones immediately, and make sure the map is consistent */ -static void test_delete_evens_incremental(size_t n) { +static void test_delete_evens_incremental(gpr_uint32 n) { grpc_chttp2_stream_map map; - size_t i; + gpr_uint32 i; LOG_TEST("test_delete_evens_incremental"); gpr_log(GPR_INFO, "n = %d", n); @@ -181,10 +182,10 @@ static void test_delete_evens_incremental(size_t n) { /* add a bunch of keys, delete old ones after some time, ensure the backing array does not grow */ -static void test_periodic_compaction(size_t n) { +static void test_periodic_compaction(gpr_uint32 n) { grpc_chttp2_stream_map map; - size_t i; - size_t del; + gpr_uint32 i; + gpr_uint32 del; LOG_TEST("test_periodic_compaction"); gpr_log(GPR_INFO, "n = %d", n); @@ -192,10 +193,11 @@ static void test_periodic_compaction(size_t n) { grpc_chttp2_stream_map_init(&map, 16); GPR_ASSERT(map.capacity == 16); for (i = 1; i <= n; i++) { - grpc_chttp2_stream_map_add(&map, i, (void *)i); + grpc_chttp2_stream_map_add(&map, i, (void *)(gpr_uintptr)i); if (i > 8) { del = i - 8; - GPR_ASSERT((void *)del == grpc_chttp2_stream_map_delete(&map, del)); + GPR_ASSERT((void *)(gpr_uintptr)del == + grpc_chttp2_stream_map_delete(&map, del)); } } GPR_ASSERT(map.capacity == 16); @@ -203,9 +205,9 @@ static void test_periodic_compaction(size_t n) { } int main(int argc, char **argv) { - int n = 1; - int prev = 1; - int tmp; + gpr_uint32 n = 1; + gpr_uint32 prev = 1; + gpr_uint32 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; } diff --git a/test/core/util/parse_hexstring.c b/test/core/util/parse_hexstring.c index bf5bc84b48..eced3173d1 100644 --- a/test/core/util/parse_hexstring.c +++ b/test/core/util/parse_hexstring.c @@ -35,7 +35,7 @@ #include <grpc/support/log.h> gpr_slice parse_hexstring(const char *hexstring) { - int nibbles = 0; + size_t nibbles = 0; const char *p = 0; gpr_uint8 *out; gpr_uint8 temp; @@ -54,10 +54,10 @@ gpr_slice parse_hexstring(const char *hexstring) { temp = 0; for (p = hexstring; *p; p++) { if (*p >= '0' && *p <= '9') { - temp = (temp << 4) | (*p - '0'); + temp = (gpr_uint8)(temp << 4) | (gpr_uint8)(*p - '0'); nibbles++; } else if (*p >= 'a' && *p <= 'f') { - temp = (temp << 4) | (*p - 'a' + 10); + temp = (gpr_uint8)(temp << 4) | (gpr_uint8)(*p - 'a' + 10); nibbles++; } if (nibbles == 2) { diff --git a/test/core/util/port_posix.c b/test/core/util/port_posix.c index 4781d334e2..be45bae496 100644 --- a/test/core/util/port_posix.c +++ b/test/core/util/port_posix.c @@ -102,7 +102,7 @@ static int is_port_available(int *port, int is_tcp) { /* Try binding to port */ addr.sin_family = AF_INET; addr.sin_addr.s_addr = INADDR_ANY; - addr.sin_port = htons(*port); + addr.sin_port = htons((gpr_uint16)*port); if (bind(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) { gpr_log(GPR_DEBUG, "bind(port=%d) failed: %s", *port, strerror(errno)); close(fd); diff --git a/test/core/util/reconnect_server.c b/test/core/util/reconnect_server.c index 61535cc5c0..71fb69b54f 100644 --- a/test/core/util/reconnect_server.c +++ b/test/core/util/reconnect_server.c @@ -81,7 +81,8 @@ static void on_connect(void *arg, grpc_endpoint *tcp) { } else { if (last_colon == NULL) { gpr_log(GPR_ERROR, "peer does not contain a ':'"); - } else if (strncmp(server->peer, peer, last_colon - peer) != 0) { + } else if (strncmp(server->peer, peer, (size_t)(last_colon - peer)) != + 0) { gpr_log(GPR_ERROR, "mismatched peer! %s vs %s", server->peer, peer); } gpr_free(peer); @@ -115,7 +116,7 @@ void reconnect_server_start(reconnect_server *server, int port) { int port_added; addr.sin_family = AF_INET; - addr.sin_port = htons(port); + addr.sin_port = htons((gpr_uint16)port); memset(&addr.sin_addr, 0, sizeof(addr.sin_addr)); server->tcp_server = grpc_tcp_server_create(); diff --git a/test/core/util/test_config.c b/test/core/util/test_config.c index 685bdff530..f5d5cdb57c 100644 --- a/test/core/util/test_config.c +++ b/test/core/util/test_config.c @@ -42,12 +42,12 @@ double g_fixture_slowdown_factor = 1.0; #if GPR_GETPID_IN_UNISTD_H #include <unistd.h> -static int seed(void) { return getpid(); } +static unsigned seed(void) { return (unsigned)getpid(); } #endif #if GPR_GETPID_IN_PROCESS_H #include <process.h> -static int seed(void) { return _getpid(); } +static unsigned seed(void) { return _getpid(); } #endif #if GPR_WINDOWS_CRASH_HANDLER diff --git a/test/core/util/test_config.h b/test/core/util/test_config.h index ccef8620c1..15b71747fb 100644 --- a/test/core/util/test_config.h +++ b/test/core/util/test_config.h @@ -54,15 +54,17 @@ extern double g_fixture_slowdown_factor; (GRPC_TEST_SLOWDOWN_BUILD_FACTOR * GRPC_TEST_SLOWDOWN_MACHINE_FACTOR * \ g_fixture_slowdown_factor) -#define GRPC_TIMEOUT_SECONDS_TO_DEADLINE(x) \ - gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), \ - gpr_time_from_millis(GRPC_TEST_SLOWDOWN_FACTOR * 1e3 * (x), \ - GPR_TIMESPAN)) +#define GRPC_TIMEOUT_SECONDS_TO_DEADLINE(x) \ + gpr_time_add( \ + gpr_now(GPR_CLOCK_MONOTONIC), \ + gpr_time_from_millis((long)(GRPC_TEST_SLOWDOWN_FACTOR * 1e3 * (x)), \ + GPR_TIMESPAN)) -#define GRPC_TIMEOUT_MILLIS_TO_DEADLINE(x) \ - gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), \ - gpr_time_from_micros(GRPC_TEST_SLOWDOWN_FACTOR * 1e3 * (x), \ - GPR_TIMESPAN)) +#define GRPC_TIMEOUT_MILLIS_TO_DEADLINE(x) \ + gpr_time_add( \ + gpr_now(GPR_CLOCK_MONOTONIC), \ + gpr_time_from_micros((long)(GRPC_TEST_SLOWDOWN_FACTOR * 1e3 * (x)), \ + GPR_TIMESPAN)) #ifndef GRPC_TEST_CUSTOM_PICK_PORT #define GRPC_TEST_PICK_PORT diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc index 20fe1c515f..ba44a918db 100644 --- a/test/cpp/interop/client.cc +++ b/test/cpp/interop/client.cc @@ -120,11 +120,10 @@ int main(int argc, char** argv) { grpc::string json_key = GetServiceAccountJsonKey(); client.DoJwtTokenCreds(json_key); } else if (FLAGS_test_case == "oauth2_auth_token") { - grpc::string json_key = GetServiceAccountJsonKey(); - client.DoOauth2AuthToken(json_key, FLAGS_oauth_scope); + client.DoOauth2AuthToken(FLAGS_default_service_account, FLAGS_oauth_scope); } else if (FLAGS_test_case == "per_rpc_creds") { grpc::string json_key = GetServiceAccountJsonKey(); - client.DoPerRpcCreds(json_key, FLAGS_oauth_scope); + client.DoPerRpcCreds(json_key); } else if (FLAGS_test_case == "status_code_and_message") { client.DoStatusWithMessage(); } else if (FLAGS_test_case == "all") { @@ -143,8 +142,9 @@ int main(int argc, char** argv) { if (FLAGS_enable_ssl) { grpc::string json_key = GetServiceAccountJsonKey(); client.DoJwtTokenCreds(json_key); - client.DoOauth2AuthToken(json_key, FLAGS_oauth_scope); - client.DoPerRpcCreds(json_key, FLAGS_oauth_scope); + client.DoOauth2AuthToken( + FLAGS_default_service_account, FLAGS_oauth_scope); + client.DoPerRpcCreds(json_key); } // compute_engine_creds only runs in GCE. } else { diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc index 48ccf06da9..8124cae67a 100644 --- a/test/cpp/interop/interop_client.cc +++ b/test/cpp/interop/interop_client.cc @@ -196,36 +196,33 @@ void InteropClient::DoOauth2AuthToken(const grpc::string& username, AssertOkOrPrintErrorStatus(s); GPR_ASSERT(!response.username().empty()); GPR_ASSERT(!response.oauth_scope().empty()); - GPR_ASSERT(username.find(response.username()) != grpc::string::npos); + GPR_ASSERT(username == response.username()); const char* oauth_scope_str = response.oauth_scope().c_str(); GPR_ASSERT(oauth_scope.find(oauth_scope_str) != grpc::string::npos); gpr_log(GPR_INFO, "Unary with oauth2 access token credentials done."); } -void InteropClient::DoPerRpcCreds(const grpc::string& username, - const grpc::string& oauth_scope) { +void InteropClient::DoPerRpcCreds(const grpc::string& json_key) { gpr_log(GPR_INFO, - "Sending a unary rpc with per-rpc raw oauth2 access token ..."); + "Sending a unary rpc with per-rpc JWT access token ..."); SimpleRequest request; SimpleResponse response; request.set_fill_username(true); - request.set_fill_oauth_scope(true); std::unique_ptr<TestService::Stub> stub(TestService::NewStub(channel_)); ClientContext context; - grpc::string access_token = GetOauth2AccessToken(); - std::shared_ptr<Credentials> creds = AccessTokenCredentials(access_token); + std::chrono::seconds token_lifetime = std::chrono::hours(1); + std::shared_ptr<Credentials> creds = + ServiceAccountJWTAccessCredentials(json_key, token_lifetime.count()); + context.set_credentials(creds); Status s = stub->UnaryCall(&context, request, &response); AssertOkOrPrintErrorStatus(s); GPR_ASSERT(!response.username().empty()); - GPR_ASSERT(!response.oauth_scope().empty()); - GPR_ASSERT(username.find(response.username()) != grpc::string::npos); - const char* oauth_scope_str = response.oauth_scope().c_str(); - GPR_ASSERT(oauth_scope.find(oauth_scope_str) != grpc::string::npos); - gpr_log(GPR_INFO, "Unary with per-rpc oauth2 access token done."); + GPR_ASSERT(json_key.find(response.username()) != grpc::string::npos); + gpr_log(GPR_INFO, "Unary with per-rpc JWT access token done."); } void InteropClient::DoJwtTokenCreds(const grpc::string& username) { diff --git a/test/cpp/interop/interop_client.h b/test/cpp/interop/interop_client.h index 5a085c4c02..7bcb58571e 100644 --- a/test/cpp/interop/interop_client.h +++ b/test/cpp/interop/interop_client.h @@ -68,12 +68,11 @@ class InteropClient { void DoJwtTokenCreds(const grpc::string& username); void DoComputeEngineCreds(const grpc::string& default_service_account, const grpc::string& oauth_scope); - // username is a string containing the user email + // username the GCE default service account email void DoOauth2AuthToken(const grpc::string& username, const grpc::string& oauth_scope); // username is a string containing the user email - void DoPerRpcCreds(const grpc::string& username, - const grpc::string& oauth_scope); + void DoPerRpcCreds(const grpc::string& json_key); private: void PerformLargeUnary(SimpleRequest* request, SimpleResponse* response); diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc index 0ed2048d4a..516598a0e2 100644 --- a/test/cpp/qps/server_async.cc +++ b/test/cpp/qps/server_async.cc @@ -98,7 +98,9 @@ class AsyncQpsServerTest : public Server { } } ~AsyncQpsServerTest() { - server_->Shutdown(); + auto deadline = std::chrono::system_clock::now() + + std::chrono::seconds(10); + server_->Shutdown(deadline); for (auto ss = shutdown_state_.begin(); ss != shutdown_state_.end(); ++ss) { (*ss)->set_shutdown(); } |