diff options
author | Craig Tiller <ctiller@google.com> | 2017-11-08 09:42:32 -0800 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2017-11-08 09:42:32 -0800 |
commit | 660d4aa2d281dbfbc6c3a3e3349b3e4b6a444285 (patch) | |
tree | 592cecc1d6670bb12b9af81c19cd3cb98cc0eeef /test/core/iomgr | |
parent | 48d26966646e910f7dd63d428ef831178ca9315e (diff) | |
parent | d9da7387b8057f3bd99a417a5ee905377bce9296 (diff) |
Merge github.com:grpc/grpc into tfix2
Diffstat (limited to 'test/core/iomgr')
-rw-r--r-- | test/core/iomgr/BUILD | 84 | ||||
-rw-r--r-- | test/core/iomgr/combiner_test.cc (renamed from test/core/iomgr/combiner_test.c) | 37 | ||||
-rw-r--r-- | test/core/iomgr/endpoint_pair_test.cc (renamed from test/core/iomgr/endpoint_pair_test.c) | 23 | ||||
-rw-r--r-- | test/core/iomgr/endpoint_tests.cc (renamed from test/core/iomgr/endpoint_tests.c) | 64 | ||||
-rw-r--r-- | test/core/iomgr/endpoint_tests.h | 8 | ||||
-rw-r--r-- | test/core/iomgr/error_test.cc (renamed from test/core/iomgr/error_test.c) | 0 | ||||
-rw-r--r-- | test/core/iomgr/ev_epollsig_linux_test.cc (renamed from test/core/iomgr/ev_epollsig_linux_test.c) | 77 | ||||
-rw-r--r-- | test/core/iomgr/fd_conservation_posix_test.cc (renamed from test/core/iomgr/fd_conservation_posix_test.c) | 4 | ||||
-rw-r--r-- | test/core/iomgr/fd_posix_test.cc (renamed from test/core/iomgr/fd_posix_test.c) | 120 | ||||
-rw-r--r-- | test/core/iomgr/load_file_test.cc (renamed from test/core/iomgr/load_file_test.c) | 34 | ||||
-rw-r--r-- | test/core/iomgr/pollset_set_test.cc (renamed from test/core/iomgr/pollset_set_test.c) | 59 | ||||
-rw-r--r-- | test/core/iomgr/resolve_address_posix_test.cc (renamed from test/core/iomgr/resolve_address_posix_test.c) | 43 | ||||
-rw-r--r-- | test/core/iomgr/resolve_address_test.cc (renamed from test/core/iomgr/resolve_address_test.c) | 47 | ||||
-rw-r--r-- | test/core/iomgr/resource_quota_test.cc (renamed from test/core/iomgr/resource_quota_test.c) | 128 | ||||
-rw-r--r-- | test/core/iomgr/sockaddr_utils_test.cc (renamed from test/core/iomgr/sockaddr_utils_test.c) | 48 | ||||
-rw-r--r-- | test/core/iomgr/socket_utils_test.cc (renamed from test/core/iomgr/socket_utils_test.c) | 30 | ||||
-rw-r--r-- | test/core/iomgr/tcp_client_posix_test.cc (renamed from test/core/iomgr/tcp_client_posix_test.c) | 43 | ||||
-rw-r--r-- | test/core/iomgr/tcp_client_uv_test.cc (renamed from test/core/iomgr/tcp_client_uv_test.c) | 57 | ||||
-rw-r--r-- | test/core/iomgr/tcp_posix_test.cc (renamed from test/core/iomgr/tcp_posix_test.c) | 123 | ||||
-rw-r--r-- | test/core/iomgr/tcp_server_posix_test.cc (renamed from test/core/iomgr/tcp_server_posix_test.c) | 107 | ||||
-rw-r--r-- | test/core/iomgr/tcp_server_uv_test.cc (renamed from test/core/iomgr/tcp_server_uv_test.c) | 92 | ||||
-rw-r--r-- | test/core/iomgr/time_averaged_stats_test.cc (renamed from test/core/iomgr/time_averaged_stats_test.c) | 2 | ||||
-rw-r--r-- | test/core/iomgr/timer_heap_test.cc (renamed from test/core/iomgr/timer_heap_test.c) | 41 | ||||
-rw-r--r-- | test/core/iomgr/timer_list_test.cc (renamed from test/core/iomgr/timer_list_test.c) | 32 | ||||
-rw-r--r-- | test/core/iomgr/udp_server_test.cc (renamed from test/core/iomgr/udp_server_test.c) | 83 | ||||
-rw-r--r-- | test/core/iomgr/wakeup_fd_cv_test.cc (renamed from test/core/iomgr/wakeup_fd_cv_test.c) | 12 |
26 files changed, 712 insertions, 686 deletions
diff --git a/test/core/iomgr/BUILD b/test/core/iomgr/BUILD index 7620d1de21..41e2607646 100644 --- a/test/core/iomgr/BUILD +++ b/test/core/iomgr/BUILD @@ -22,9 +22,9 @@ grpc_package(name = "test/core/iomgr", visibility = "public") # Useful for third grpc_cc_library( name = "endpoint_tests", - srcs = ["endpoint_tests.c"], + srcs = ["endpoint_tests.cc"], hdrs = ["endpoint_tests.h"], - language = "C", + language = "C++", visibility = ["//test:__subpackages__"], deps = [ "//:gpr", @@ -36,8 +36,8 @@ grpc_cc_library( grpc_cc_test( name = "combiner_test", - srcs = ["combiner_test.c"], - language = "C", + srcs = ["combiner_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -48,8 +48,8 @@ grpc_cc_test( grpc_cc_test( name = "endpoint_pair_test", - srcs = ["endpoint_pair_test.c"], - language = "C", + srcs = ["endpoint_pair_test.cc"], + language = "C++", deps = [ ":endpoint_tests", "//:gpr", @@ -61,20 +61,20 @@ grpc_cc_test( grpc_cc_test( name = "ev_epollsig_linux_test", - srcs = ["ev_epollsig_linux_test.c"], + srcs = ["ev_epollsig_linux_test.cc"], deps = [ "//:gpr", "//:grpc", "//test/core/util:gpr_test_util", "//test/core/util:grpc_test_util", ], - language = "C", + language = "C++", ) grpc_cc_test( name = "fd_conservation_posix_test", - srcs = ["fd_conservation_posix_test.c"], - language = "C", + srcs = ["fd_conservation_posix_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -85,8 +85,8 @@ grpc_cc_test( grpc_cc_test( name = "fd_posix_test", - srcs = ["fd_posix_test.c"], - language = "C", + srcs = ["fd_posix_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -97,8 +97,8 @@ grpc_cc_test( grpc_cc_test( name = "load_file_test", - srcs = ["load_file_test.c"], - language = "C", + srcs = ["load_file_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -109,8 +109,8 @@ grpc_cc_test( grpc_cc_test( name = "pollset_set_test", - srcs = ["pollset_set_test.c"], - language = "C", + srcs = ["pollset_set_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -121,8 +121,8 @@ grpc_cc_test( grpc_cc_test( name = "resolve_address_posix_test", - srcs = ["resolve_address_posix_test.c"], - language = "C", + srcs = ["resolve_address_posix_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -133,8 +133,8 @@ grpc_cc_test( grpc_cc_test( name = "resolve_address_test", - srcs = ["resolve_address_test.c"], - language = "C", + srcs = ["resolve_address_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -145,8 +145,8 @@ grpc_cc_test( grpc_cc_test( name = "resource_quota_test", - srcs = ["resource_quota_test.c"], - language = "C", + srcs = ["resource_quota_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -157,8 +157,8 @@ grpc_cc_test( grpc_cc_test( name = "sockaddr_utils_test", - srcs = ["sockaddr_utils_test.c"], - language = "C", + srcs = ["sockaddr_utils_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -169,8 +169,8 @@ grpc_cc_test( grpc_cc_test( name = "socket_utils_test", - srcs = ["socket_utils_test.c"], - language = "C", + srcs = ["socket_utils_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -181,8 +181,8 @@ grpc_cc_test( grpc_cc_test( name = "tcp_client_posix_test", - srcs = ["tcp_client_posix_test.c"], - language = "C", + srcs = ["tcp_client_posix_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -193,8 +193,8 @@ grpc_cc_test( grpc_cc_test( name = "tcp_posix_test", - srcs = ["tcp_posix_test.c"], - language = "C", + srcs = ["tcp_posix_test.cc"], + language = "C++", deps = [ ":endpoint_tests", "//:gpr", @@ -206,8 +206,8 @@ grpc_cc_test( grpc_cc_test( name = "tcp_server_posix_test", - srcs = ["tcp_server_posix_test.c"], - language = "C", + srcs = ["tcp_server_posix_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -218,8 +218,8 @@ grpc_cc_test( grpc_cc_test( name = "time_averaged_stats_test", - srcs = ["time_averaged_stats_test.c"], - language = "C", + srcs = ["time_averaged_stats_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -230,8 +230,8 @@ grpc_cc_test( grpc_cc_test( name = "timer_heap_test", - srcs = ["timer_heap_test.c"], - language = "C", + srcs = ["timer_heap_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -242,8 +242,8 @@ grpc_cc_test( grpc_cc_test( name = "timer_list_test", - srcs = ["timer_list_test.c"], - language = "C", + srcs = ["timer_list_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -254,8 +254,8 @@ grpc_cc_test( grpc_cc_test( name = "udp_server_test", - srcs = ["udp_server_test.c"], - language = "C", + srcs = ["udp_server_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", @@ -266,8 +266,8 @@ grpc_cc_test( grpc_cc_test( name = "wakeup_fd_cv_test", - srcs = ["wakeup_fd_cv_test.c"], - language = "C", + srcs = ["wakeup_fd_cv_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", diff --git a/test/core/iomgr/combiner_test.c b/test/core/iomgr/combiner_test.cc index 38f512de0e..5a825368f7 100644 --- a/test/core/iomgr/combiner_test.c +++ b/test/core/iomgr/combiner_test.cc @@ -33,15 +33,15 @@ static void test_no_op(void) { grpc_exec_ctx_finish(&exec_ctx); } -static void set_event_to_true(grpc_exec_ctx *exec_ctx, void *value, - grpc_error *error) { - gpr_event_set(value, (void *)1); +static void set_event_to_true(grpc_exec_ctx* exec_ctx, void* value, + grpc_error* error) { + gpr_event_set(static_cast<gpr_event*>(value), (void*)1); } static void test_execute_one(void) { gpr_log(GPR_DEBUG, "test_execute_one"); - grpc_combiner *lock = grpc_combiner_create(); + grpc_combiner* lock = grpc_combiner_create(); gpr_event done; gpr_event_init(&done); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -58,29 +58,29 @@ static void test_execute_one(void) { typedef struct { size_t ctr; - grpc_combiner *lock; + grpc_combiner* lock; gpr_event done; } thd_args; typedef struct { - size_t *ctr; + size_t* ctr; size_t value; } ex_args; -static void check_one(grpc_exec_ctx *exec_ctx, void *a, grpc_error *error) { - ex_args *args = a; +static void check_one(grpc_exec_ctx* exec_ctx, void* a, grpc_error* error) { + ex_args* args = static_cast<ex_args*>(a); GPR_ASSERT(*args->ctr == args->value - 1); *args->ctr = args->value; gpr_free(a); } -static void execute_many_loop(void *a) { - thd_args *args = a; +static void execute_many_loop(void* a) { + thd_args* args = static_cast<thd_args*>(a); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; size_t n = 1; for (size_t i = 0; i < 10; i++) { for (size_t j = 0; j < 10000; j++) { - ex_args *c = gpr_malloc(sizeof(*c)); + ex_args* c = static_cast<ex_args*>(gpr_malloc(sizeof(*c))); c->ctr = &args->ctr; c->value = n++; GRPC_CLOSURE_SCHED(&exec_ctx, @@ -103,7 +103,7 @@ static void execute_many_loop(void *a) { static void test_execute_many(void) { gpr_log(GPR_DEBUG, "test_execute_many"); - grpc_combiner *lock = grpc_combiner_create(); + grpc_combiner* lock = grpc_combiner_create(); gpr_thd_id thds[100]; thd_args ta[GPR_ARRAY_SIZE(thds)]; for (size_t i = 0; i < GPR_ARRAY_SIZE(thds); i++) { @@ -126,21 +126,22 @@ static void test_execute_many(void) { static gpr_event got_in_finally; -static void in_finally(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { - gpr_event_set(&got_in_finally, (void *)1); +static void in_finally(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { + gpr_event_set(&got_in_finally, (void*)1); } -static void add_finally(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { +static void add_finally(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { GRPC_CLOSURE_SCHED(exec_ctx, GRPC_CLOSURE_CREATE(in_finally, arg, - grpc_combiner_finally_scheduler(arg)), + grpc_combiner_finally_scheduler( + static_cast<grpc_combiner*>(arg))), GRPC_ERROR_NONE); } static void test_execute_finally(void) { gpr_log(GPR_DEBUG, "test_execute_finally"); - grpc_combiner *lock = grpc_combiner_create(); + grpc_combiner* lock = grpc_combiner_create(); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; gpr_event_init(&got_in_finally); GRPC_CLOSURE_SCHED( @@ -154,7 +155,7 @@ static void test_execute_finally(void) { grpc_exec_ctx_finish(&exec_ctx); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); grpc_init(); test_no_op(); diff --git a/test/core/iomgr/endpoint_pair_test.c b/test/core/iomgr/endpoint_pair_test.cc index f2ce3d0d12..30a0cb5924 100644 --- a/test/core/iomgr/endpoint_pair_test.c +++ b/test/core/iomgr/endpoint_pair_test.cc @@ -25,8 +25,8 @@ #include "test/core/iomgr/endpoint_tests.h" #include "test/core/util/test_config.h" -static gpr_mu *g_mu; -static grpc_pollset *g_pollset; +static gpr_mu* g_mu; +static grpc_pollset* g_pollset; static void clean_up(void) {} @@ -34,10 +34,11 @@ static grpc_endpoint_test_fixture create_fixture_endpoint_pair( size_t slice_size) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_endpoint_test_fixture f; - grpc_arg a[] = {{.key = GRPC_ARG_TCP_READ_CHUNK_SIZE, - .type = GRPC_ARG_INTEGER, - .value.integer = (int)slice_size}}; - grpc_channel_args args = {.num_args = GPR_ARRAY_SIZE(a), .args = a}; + grpc_arg a[1]; + a[0].key = const_cast<char*>(GRPC_ARG_TCP_READ_CHUNK_SIZE); + a[0].type = GRPC_ARG_INTEGER; + a[0].value.integer = (int)slice_size; + grpc_channel_args args = {GPR_ARRAY_SIZE(a), a}; grpc_endpoint_pair p = grpc_iomgr_create_endpoint_pair("test", &args); f.client_ep = p.client; @@ -53,17 +54,17 @@ static grpc_endpoint_test_config configs[] = { {"tcp/tcp_socketpair", create_fixture_endpoint_pair, clean_up}, }; -static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, - grpc_error *error) { - grpc_pollset_destroy(exec_ctx, p); +static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p, + grpc_error* error) { + grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p)); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_closure destroyed; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_test_init(argc, argv); grpc_init(); - g_pollset = gpr_zalloc(grpc_pollset_size()); + g_pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size())); grpc_pollset_init(g_pollset, &g_mu); grpc_endpoint_tests(configs[0], g_pollset, g_mu); GRPC_CLOSURE_INIT(&destroyed, destroy_pollset, g_pollset, diff --git a/test/core/iomgr/endpoint_tests.c b/test/core/iomgr/endpoint_tests.cc index 61e901f645..8e859ba909 100644 --- a/test/core/iomgr/endpoint_tests.c +++ b/test/core/iomgr/endpoint_tests.cc @@ -46,14 +46,14 @@ */ -static gpr_mu *g_mu; -static grpc_pollset *g_pollset; +static gpr_mu* g_mu; +static grpc_pollset* g_pollset; -size_t count_slices(grpc_slice *slices, size_t nslices, int *current_data) { +size_t count_slices(grpc_slice* slices, size_t nslices, int* current_data) { size_t num_bytes = 0; size_t i; size_t j; - unsigned char *buf; + unsigned char* buf; for (i = 0; i < nslices; ++i) { buf = GRPC_SLICE_START_PTR(slices[i]); for (j = 0; j < GRPC_SLICE_LENGTH(slices[i]); ++j) { @@ -66,7 +66,7 @@ size_t count_slices(grpc_slice *slices, size_t nslices, int *current_data) { } static grpc_endpoint_test_fixture begin_test(grpc_endpoint_test_config config, - const char *test_name, + const char* test_name, size_t slice_size) { gpr_log(GPR_INFO, "%s/%s", test_name, config.name); return config.create_fixture(slice_size); @@ -74,14 +74,14 @@ 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 grpc_slice *allocate_blocks(size_t num_bytes, size_t slice_size, - size_t *num_blocks, uint8_t *current_data) { +static grpc_slice* allocate_blocks(size_t num_bytes, size_t slice_size, + size_t* num_blocks, uint8_t* current_data) { size_t nslices = num_bytes / slice_size + (num_bytes % slice_size ? 1 : 0); - grpc_slice *slices = (grpc_slice *)gpr_malloc(sizeof(grpc_slice) * nslices); + grpc_slice* slices = (grpc_slice*)gpr_malloc(sizeof(grpc_slice) * nslices); size_t num_bytes_left = num_bytes; size_t i; size_t j; - unsigned char *buf; + unsigned char* buf; *num_blocks = nslices; for (i = 0; i < nslices; ++i) { @@ -99,8 +99,8 @@ static grpc_slice *allocate_blocks(size_t num_bytes, size_t slice_size, } struct read_and_write_test_state { - grpc_endpoint *read_ep; - grpc_endpoint *write_ep; + grpc_endpoint* read_ep; + grpc_endpoint* write_ep; size_t target_bytes; size_t bytes_read; size_t current_write_size; @@ -115,10 +115,10 @@ struct read_and_write_test_state { grpc_closure done_write; }; -static void read_and_write_test_read_handler(grpc_exec_ctx *exec_ctx, - void *data, grpc_error *error) { - struct read_and_write_test_state *state = - (struct read_and_write_test_state *)data; +static void read_and_write_test_read_handler(grpc_exec_ctx* exec_ctx, + void* data, grpc_error* error) { + struct read_and_write_test_state* state = + (struct read_and_write_test_state*)data; state->bytes_read += count_slices( state->incoming.slices, state->incoming.count, &state->current_read_data); @@ -135,11 +135,11 @@ static void read_and_write_test_read_handler(grpc_exec_ctx *exec_ctx, } } -static void read_and_write_test_write_handler(grpc_exec_ctx *exec_ctx, - void *data, grpc_error *error) { - struct read_and_write_test_state *state = - (struct read_and_write_test_state *)data; - grpc_slice *slices = NULL; +static void read_and_write_test_write_handler(grpc_exec_ctx* exec_ctx, + void* data, grpc_error* error) { + struct read_and_write_test_state* state = + (struct read_and_write_test_state*)data; + grpc_slice* slices = NULL; size_t nslices; if (error == GRPC_ERROR_NONE) { @@ -181,15 +181,17 @@ static void read_and_write_test(grpc_endpoint_test_config config, grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_millis deadline = grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(20)); - gpr_log(GPR_DEBUG, "num_bytes=%" PRIuPTR " write_size=%" PRIuPTR - " slice_size=%" PRIuPTR " shutdown=%d", + gpr_log(GPR_DEBUG, + "num_bytes=%" PRIuPTR " write_size=%" PRIuPTR " slice_size=%" PRIuPTR + " shutdown=%d", num_bytes, write_size, slice_size, shutdown); if (shutdown) { gpr_log(GPR_INFO, "Start read and write shutdown test"); } else { - gpr_log(GPR_INFO, "Start read and write test with %" PRIuPTR - " bytes, slice size %" PRIuPTR, + gpr_log(GPR_INFO, + "Start read and write test with %" PRIuPTR + " bytes, slice size %" PRIuPTR, num_bytes, slice_size); } @@ -235,7 +237,7 @@ static void read_and_write_test(grpc_endpoint_test_config config, gpr_mu_lock(g_mu); while (!state.read_done || !state.write_done) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; GPR_ASSERT(grpc_exec_ctx_now(&exec_ctx) < deadline); GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", @@ -252,16 +254,16 @@ static void read_and_write_test(grpc_endpoint_test_config config, grpc_exec_ctx_finish(&exec_ctx); } -static void inc_on_failure(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { +static void inc_on_failure(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { gpr_mu_lock(g_mu); - *(int *)arg += (error != GRPC_ERROR_NONE); + *(int*)arg += (error != GRPC_ERROR_NONE); GPR_ASSERT( GRPC_LOG_IF_ERROR("kick", grpc_pollset_kick(exec_ctx, g_pollset, NULL))); gpr_mu_unlock(g_mu); } -static void wait_for_fail_count(grpc_exec_ctx *exec_ctx, int *fail_count, +static void wait_for_fail_count(grpc_exec_ctx* exec_ctx, int* fail_count, int want_fail_count) { grpc_exec_ctx_flush(exec_ctx); gpr_mu_lock(g_mu); @@ -269,7 +271,7 @@ static void wait_for_fail_count(grpc_exec_ctx *exec_ctx, int *fail_count, grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(10)); while (grpc_exec_ctx_now(exec_ctx) < deadline && *fail_count < want_fail_count) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(exec_ctx, g_pollset, &worker, deadline))); @@ -319,7 +321,7 @@ static void multiple_shutdown_test(grpc_endpoint_test_config config) { } void grpc_endpoint_tests(grpc_endpoint_test_config config, - grpc_pollset *pollset, gpr_mu *mu) { + grpc_pollset* pollset, gpr_mu* mu) { size_t i; g_pollset = pollset; g_mu = mu; diff --git a/test/core/iomgr/endpoint_tests.h b/test/core/iomgr/endpoint_tests.h index def29d3224..227eeb997c 100644 --- a/test/core/iomgr/endpoint_tests.h +++ b/test/core/iomgr/endpoint_tests.h @@ -27,17 +27,17 @@ typedef struct grpc_endpoint_test_config grpc_endpoint_test_config; typedef struct grpc_endpoint_test_fixture grpc_endpoint_test_fixture; struct grpc_endpoint_test_fixture { - grpc_endpoint *client_ep; - grpc_endpoint *server_ep; + grpc_endpoint* client_ep; + grpc_endpoint* server_ep; }; struct grpc_endpoint_test_config { - const char *name; + const char* name; grpc_endpoint_test_fixture (*create_fixture)(size_t slice_size); void (*clean_up)(); }; void grpc_endpoint_tests(grpc_endpoint_test_config config, - grpc_pollset *pollset, gpr_mu *mu); + grpc_pollset* pollset, gpr_mu* mu); #endif /* GRPC_TEST_CORE_IOMGR_ENDPOINT_TESTS_H */ diff --git a/test/core/iomgr/error_test.c b/test/core/iomgr/error_test.cc index 51f8af1957..51f8af1957 100644 --- a/test/core/iomgr/error_test.c +++ b/test/core/iomgr/error_test.cc diff --git a/test/core/iomgr/ev_epollsig_linux_test.c b/test/core/iomgr/ev_epollsig_linux_test.cc index 37aadacd49..3ee607d97e 100644 --- a/test/core/iomgr/ev_epollsig_linux_test.c +++ b/test/core/iomgr/ev_epollsig_linux_test.cc @@ -36,17 +36,17 @@ #include "test/core/util/test_config.h" typedef struct test_pollset { - grpc_pollset *pollset; - gpr_mu *mu; + grpc_pollset* pollset; + gpr_mu* mu; } test_pollset; typedef struct test_fd { int inner_fd; - grpc_fd *fd; + grpc_fd* fd; } test_fd; /* num_fds should be an even number */ -static void test_fd_init(test_fd *tfds, int *fds, int num_fds) { +static void test_fd_init(test_fd* tfds, int* fds, int num_fds) { int i; int r; @@ -70,7 +70,7 @@ static void test_fd_init(test_fd *tfds, int *fds, int num_fds) { } } -static void test_fd_cleanup(grpc_exec_ctx *exec_ctx, test_fd *tfds, +static void test_fd_cleanup(grpc_exec_ctx* exec_ctx, test_fd* tfds, int num_fds) { int release_fd; int i; @@ -89,21 +89,22 @@ static void test_fd_cleanup(grpc_exec_ctx *exec_ctx, test_fd *tfds, } } -static void test_pollset_init(test_pollset *pollsets, int num_pollsets) { +static void test_pollset_init(test_pollset* pollsets, int num_pollsets) { int i; for (i = 0; i < num_pollsets; i++) { - pollsets[i].pollset = gpr_zalloc(grpc_pollset_size()); + pollsets[i].pollset = + static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size())); grpc_pollset_init(pollsets[i].pollset, &pollsets[i].mu); } } -static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, - grpc_error *error) { - grpc_pollset_destroy(exec_ctx, p); +static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p, + grpc_error* error) { + grpc_pollset_destroy(exec_ctx, (grpc_pollset*)p); } -static void test_pollset_cleanup(grpc_exec_ctx *exec_ctx, - test_pollset *pollsets, int num_pollsets) { +static void test_pollset_cleanup(grpc_exec_ctx* exec_ctx, + test_pollset* pollsets, int num_pollsets) { grpc_closure destroyed; int i; @@ -117,16 +118,16 @@ static void test_pollset_cleanup(grpc_exec_ctx *exec_ctx, } } -/* - * Cases to test: - * case 1) Polling islands of both fd and pollset are NULL - * case 2) Polling island of fd is NULL but that of pollset is not-NULL - * case 3) Polling island of fd is not-NULL but that of pollset is NULL - * case 4) Polling islands of both fd and pollset are not-NULL and: - * case 4.1) Polling islands of fd and pollset are equal - * case 4.2) Polling islands of fd and pollset are NOT-equal (This results - * in a merge) - * */ + /* + * Cases to test: + * case 1) Polling islands of both fd and pollset are NULL + * case 2) Polling island of fd is NULL but that of pollset is not-NULL + * case 3) Polling island of fd is not-NULL but that of pollset is NULL + * case 4) Polling islands of both fd and pollset are not-NULL and: + * case 4.1) Polling islands of fd and pollset are equal + * case 4.2) Polling islands of fd and pollset are NOT-equal (This results + * in a merge) + * */ #define NUM_FDS 8 #define NUM_POLLSETS 4 @@ -136,7 +137,7 @@ static void test_add_fd_to_pollset() { test_fd tfds[NUM_FDS]; int fds[NUM_FDS]; test_pollset pollsets[NUM_POLLSETS]; - void *expected_pi = NULL; + void* expected_pi = NULL; int i; test_fd_init(tfds, fds, NUM_FDS); @@ -221,21 +222,21 @@ static void test_add_fd_to_pollset() { #undef NUM_POLLSETS typedef struct threading_shared { - gpr_mu *mu; - grpc_pollset *pollset; - grpc_wakeup_fd *wakeup_fd; - grpc_fd *wakeup_desc; + gpr_mu* mu; + grpc_pollset* pollset; + grpc_wakeup_fd* wakeup_fd; + grpc_fd* wakeup_desc; grpc_closure on_wakeup; int wakeups; } threading_shared; static __thread int thread_wakeups = 0; -static void test_threading_loop(void *arg) { - threading_shared *shared = arg; +static void test_threading_loop(void* arg) { + threading_shared* shared = static_cast<threading_shared*>(arg); while (thread_wakeups < 1000000) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_pollset_worker *worker; + grpc_pollset_worker* worker; gpr_mu_lock(shared->mu); GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, shared->pollset, &worker, @@ -245,9 +246,9 @@ static void test_threading_loop(void *arg) { } } -static void test_threading_wakeup(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { - threading_shared *shared = arg; +static void test_threading_wakeup(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { + threading_shared* shared = static_cast<threading_shared*>(arg); ++shared->wakeups; ++thread_wakeups; if (error == GRPC_ERROR_NONE) { @@ -261,7 +262,7 @@ static void test_threading_wakeup(grpc_exec_ctx *exec_ctx, void *arg, static void test_threading(void) { threading_shared shared; - shared.pollset = gpr_zalloc(grpc_pollset_size()); + shared.pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size())); grpc_pollset_init(shared.pollset, &shared.mu); gpr_thd_id thds[10]; @@ -304,8 +305,8 @@ static void test_threading(void) { gpr_free(shared.pollset); } -int main(int argc, char **argv) { - const char *poll_strategy = NULL; +int main(int argc, char** argv) { + const char* poll_strategy = NULL; grpc_test_init(argc, argv); grpc_init(); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -325,6 +326,6 @@ int main(int argc, char **argv) { grpc_shutdown(); return 0; } -#else /* defined(GRPC_LINUX_EPOLL) */ -int main(int argc, char **argv) { return 0; } +#else /* defined(GRPC_LINUX_EPOLL) */ +int main(int argc, char** argv) { return 0; } #endif /* !defined(GRPC_LINUX_EPOLL) */ diff --git a/test/core/iomgr/fd_conservation_posix_test.c b/test/core/iomgr/fd_conservation_posix_test.cc index d29b1e8e41..b76c247fb8 100644 --- a/test/core/iomgr/fd_conservation_posix_test.c +++ b/test/core/iomgr/fd_conservation_posix_test.cc @@ -24,7 +24,7 @@ #include "src/core/lib/iomgr/iomgr.h" #include "test/core/util/test_config.h" -int main(int argc, char **argv) { +int main(int argc, char** argv) { int i; struct rlimit rlim; grpc_endpoint_pair p; @@ -38,7 +38,7 @@ int main(int argc, char **argv) { of descriptors */ rlim.rlim_cur = rlim.rlim_max = 10; GPR_ASSERT(0 == setrlimit(RLIMIT_NOFILE, &rlim)); - grpc_resource_quota *resource_quota = + grpc_resource_quota* resource_quota = grpc_resource_quota_create("fd_conservation_posix_test"); for (i = 0; i < 100; i++) { diff --git a/test/core/iomgr/fd_posix_test.c b/test/core/iomgr/fd_posix_test.cc index 1c62f34d3e..c70187ce91 100644 --- a/test/core/iomgr/fd_posix_test.c +++ b/test/core/iomgr/fd_posix_test.cc @@ -46,8 +46,8 @@ #include "src/core/lib/iomgr/socket_utils_posix.h" #include "test/core/util/test_config.h" -static gpr_mu *g_mu; -static grpc_pollset *g_pollset; +static gpr_mu* g_mu; +static grpc_pollset* g_pollset; /* buffer size used to send and receive data. 1024 is the minimal value to set TCP send and receive buffer. */ @@ -56,8 +56,8 @@ static grpc_pollset *g_pollset; /* Create a test socket with the right properties for testing. port is the TCP port to listen or connect to. Return a socket FD and sockaddr_in. */ -static void create_test_socket(int port, int *socket_fd, - struct sockaddr_in *sin) { +static void create_test_socket(int port, int* socket_fd, + struct sockaddr_in* sin) { int fd; int one = 1; int buffer_size_bytes = BUF_SIZE; @@ -82,20 +82,20 @@ static void create_test_socket(int port, int *socket_fd, } /* Dummy gRPC callback */ -void no_op_cb(void *arg, int success) {} +void no_op_cb(void* arg, int success) {} /* =======An upload server to test notify_on_read=========== The server simply reads and counts a stream of bytes. */ /* An upload server. */ typedef struct { - grpc_fd *em_fd; /* listening fd */ + grpc_fd* em_fd; /* listening fd */ ssize_t read_bytes_total; /* total number of received bytes */ int done; /* set to 1 when a server finishes serving */ grpc_closure listen_closure; } server; -static void server_init(server *sv) { +static void server_init(server* sv) { sv->read_bytes_total = 0; sv->done = 0; } @@ -103,18 +103,18 @@ static void server_init(server *sv) { /* An upload session. Created when a new upload request arrives in the server. */ typedef struct { - server *sv; /* not owned by a single session */ - grpc_fd *em_fd; /* fd to read upload bytes */ + server* sv; /* not owned by a single session */ + grpc_fd* em_fd; /* fd to read upload bytes */ char read_buf[BUF_SIZE]; /* buffer to store upload bytes */ grpc_closure session_read_closure; } session; /* Called when an upload session can be safely shutdown. Close session FD and start to shutdown listen FD. */ -static void session_shutdown_cb(grpc_exec_ctx *exec_ctx, void *arg, /*session */ +static void session_shutdown_cb(grpc_exec_ctx* exec_ctx, void* arg, /*session */ bool success) { - session *se = arg; - server *sv = se->sv; + session* se = static_cast<session*>(arg); + server* sv = se->sv; grpc_fd_orphan(exec_ctx, se->em_fd, NULL, NULL, false /* already_closed */, "a"); gpr_free(se); @@ -124,9 +124,9 @@ static void session_shutdown_cb(grpc_exec_ctx *exec_ctx, void *arg, /*session */ } /* Called when data become readable in a session. */ -static void session_read_cb(grpc_exec_ctx *exec_ctx, void *arg, /*session */ - grpc_error *error) { - session *se = arg; +static void session_read_cb(grpc_exec_ctx* exec_ctx, void* arg, /*session */ + grpc_error* error) { + session* se = static_cast<session*>(arg); int fd = grpc_fd_wrapped_fd(se->em_fd); ssize_t read_once = 0; @@ -169,9 +169,9 @@ static void session_read_cb(grpc_exec_ctx *exec_ctx, void *arg, /*session */ /* Called when the listen FD can be safely shutdown. Close listen FD and signal that server can be shutdown. */ -static void listen_shutdown_cb(grpc_exec_ctx *exec_ctx, void *arg /*server */, +static void listen_shutdown_cb(grpc_exec_ctx* exec_ctx, void* arg /*server */, int success) { - server *sv = arg; + server* sv = static_cast<server*>(arg); grpc_fd_orphan(exec_ctx, sv->em_fd, NULL, NULL, false /* already_closed */, "b"); @@ -184,27 +184,27 @@ static void listen_shutdown_cb(grpc_exec_ctx *exec_ctx, void *arg /*server */, } /* Called when a new TCP connection request arrives in the listening port. */ -static void listen_cb(grpc_exec_ctx *exec_ctx, void *arg, /*=sv_arg*/ - grpc_error *error) { - server *sv = arg; +static void listen_cb(grpc_exec_ctx* exec_ctx, void* arg, /*=sv_arg*/ + grpc_error* error) { + server* sv = static_cast<server*>(arg); int fd; int flags; - session *se; + session* se; struct sockaddr_storage ss; socklen_t slen = sizeof(ss); - grpc_fd *listen_em_fd = sv->em_fd; + grpc_fd* listen_em_fd = sv->em_fd; if (error != GRPC_ERROR_NONE) { listen_shutdown_cb(exec_ctx, arg, 1); return; } - fd = accept(grpc_fd_wrapped_fd(listen_em_fd), (struct sockaddr *)&ss, &slen); + fd = accept(grpc_fd_wrapped_fd(listen_em_fd), (struct sockaddr*)&ss, &slen); GPR_ASSERT(fd >= 0); GPR_ASSERT(fd < FD_SETSIZE); flags = fcntl(fd, F_GETFL, 0); fcntl(fd, F_SETFL, flags | O_NONBLOCK); - se = gpr_malloc(sizeof(*se)); + se = static_cast<session*>(gpr_malloc(sizeof(*se))); se->sv = sv; se->em_fd = grpc_fd_create(fd, "listener"); grpc_pollset_add_fd(exec_ctx, g_pollset, se->em_fd); @@ -222,7 +222,7 @@ static void listen_cb(grpc_exec_ctx *exec_ctx, void *arg, /*=sv_arg*/ listen_cb() is registered to be interested in reading from listen_fd. When connection request arrives, listen_cb() is called to accept the connection request. */ -static int server_start(grpc_exec_ctx *exec_ctx, server *sv) { +static int server_start(grpc_exec_ctx* exec_ctx, server* sv) { int port = 0; int fd; struct sockaddr_in sin; @@ -230,8 +230,8 @@ static int server_start(grpc_exec_ctx *exec_ctx, server *sv) { create_test_socket(port, &fd, &sin); addr_len = sizeof(sin); - GPR_ASSERT(bind(fd, (struct sockaddr *)&sin, addr_len) == 0); - GPR_ASSERT(getsockname(fd, (struct sockaddr *)&sin, &addr_len) == 0); + GPR_ASSERT(bind(fd, (struct sockaddr*)&sin, addr_len) == 0); + GPR_ASSERT(getsockname(fd, (struct sockaddr*)&sin, &addr_len) == 0); port = ntohs(sin.sin_port); GPR_ASSERT(listen(fd, MAX_NUM_FD) == 0); @@ -246,11 +246,11 @@ static int server_start(grpc_exec_ctx *exec_ctx, server *sv) { } /* Wait and shutdown a sever. */ -static void server_wait_and_shutdown(server *sv) { +static void server_wait_and_shutdown(server* sv) { gpr_mu_lock(g_mu); while (!sv->done) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, GRPC_MILLIS_INF_FUTURE))); @@ -270,7 +270,7 @@ static void server_wait_and_shutdown(server *sv) { /* An upload client. */ typedef struct { - grpc_fd *em_fd; + grpc_fd* em_fd; char write_buf[CLIENT_WRITE_BUF_SIZE]; ssize_t write_bytes_total; /* Number of times that the client fills up the write buffer and calls @@ -281,7 +281,7 @@ typedef struct { grpc_closure write_closure; } client; -static void client_init(client *cl) { +static void client_init(client* cl) { memset(cl->write_buf, 0, sizeof(cl->write_buf)); cl->write_bytes_total = 0; cl->client_write_cnt = 0; @@ -289,9 +289,9 @@ static void client_init(client *cl) { } /* Called when a client upload session is ready to shutdown. */ -static void client_session_shutdown_cb(grpc_exec_ctx *exec_ctx, - void *arg /*client */, int success) { - client *cl = arg; +static void client_session_shutdown_cb(grpc_exec_ctx* exec_ctx, + void* arg /*client */, int success) { + client* cl = static_cast<client*>(arg); grpc_fd_orphan(exec_ctx, cl->em_fd, NULL, NULL, false /* already_closed */, "c"); cl->done = 1; @@ -300,9 +300,9 @@ static void client_session_shutdown_cb(grpc_exec_ctx *exec_ctx, } /* Write as much as possible, then register notify_on_write. */ -static void client_session_write(grpc_exec_ctx *exec_ctx, void *arg, /*client */ - grpc_error *error) { - client *cl = arg; +static void client_session_write(grpc_exec_ctx* exec_ctx, void* arg, /*client */ + grpc_error* error) { + client* cl = static_cast<client*>(arg); int fd = grpc_fd_wrapped_fd(cl->em_fd); ssize_t write_once = 0; @@ -336,11 +336,11 @@ static void client_session_write(grpc_exec_ctx *exec_ctx, void *arg, /*client */ } /* Start a client to send a stream of bytes. */ -static void client_start(grpc_exec_ctx *exec_ctx, client *cl, int port) { +static void client_start(grpc_exec_ctx* exec_ctx, client* cl, int port) { int fd; struct sockaddr_in sin; create_test_socket(port, &fd, &sin); - if (connect(fd, (struct sockaddr *)&sin, sizeof(sin)) == -1) { + if (connect(fd, (struct sockaddr*)&sin, sizeof(sin)) == -1) { if (errno == EINPROGRESS) { struct pollfd pfd; pfd.fd = fd; @@ -363,10 +363,10 @@ static void client_start(grpc_exec_ctx *exec_ctx, client *cl, int port) { } /* Wait for the signal to shutdown a client. */ -static void client_wait_and_shutdown(client *cl) { +static void client_wait_and_shutdown(client* cl) { gpr_mu_lock(g_mu); while (!cl->done) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, @@ -402,14 +402,14 @@ typedef struct fd_change_data { grpc_iomgr_cb_func cb_that_ran; } fd_change_data; -void init_change_data(fd_change_data *fdc) { fdc->cb_that_ran = NULL; } +void init_change_data(fd_change_data* fdc) { fdc->cb_that_ran = NULL; } -void destroy_change_data(fd_change_data *fdc) {} +void destroy_change_data(fd_change_data* fdc) {} -static void first_read_callback(grpc_exec_ctx *exec_ctx, - void *arg /* fd_change_data */, - grpc_error *error) { - fd_change_data *fdc = arg; +static void first_read_callback(grpc_exec_ctx* exec_ctx, + void* arg /* fd_change_data */, + grpc_error* error) { + fd_change_data* fdc = static_cast<fd_change_data*>(arg); gpr_mu_lock(g_mu); fdc->cb_that_ran = first_read_callback; @@ -418,10 +418,10 @@ static void first_read_callback(grpc_exec_ctx *exec_ctx, gpr_mu_unlock(g_mu); } -static void second_read_callback(grpc_exec_ctx *exec_ctx, - void *arg /* fd_change_data */, - grpc_error *error) { - fd_change_data *fdc = arg; +static void second_read_callback(grpc_exec_ctx* exec_ctx, + void* arg /* fd_change_data */, + grpc_error* error) { + fd_change_data* fdc = static_cast<fd_change_data*>(arg); gpr_mu_lock(g_mu); fdc->cb_that_ran = second_read_callback; @@ -435,7 +435,7 @@ static void second_read_callback(grpc_exec_ctx *exec_ctx, point is to have two different function pointers and two different data pointers and make sure that changing both really works. */ static void test_grpc_fd_change(void) { - grpc_fd *em_fd; + grpc_fd* em_fd; fd_change_data a, b; int flags; int sv[2]; @@ -471,7 +471,7 @@ static void test_grpc_fd_change(void) { /* And now wait for it to run. */ gpr_mu_lock(g_mu); while (a.cb_that_ran == NULL) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, GRPC_MILLIS_INF_FUTURE))); @@ -495,7 +495,7 @@ static void test_grpc_fd_change(void) { gpr_mu_lock(g_mu); while (b.cb_that_ran == NULL) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, GRPC_MILLIS_INF_FUTURE))); @@ -514,17 +514,17 @@ static void test_grpc_fd_change(void) { close(sv[1]); } -static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, - grpc_error *error) { - grpc_pollset_destroy(exec_ctx, p); +static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p, + grpc_error* error) { + grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p)); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_closure destroyed; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_test_init(argc, argv); grpc_init(); - g_pollset = gpr_zalloc(grpc_pollset_size()); + g_pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size())); grpc_pollset_init(g_pollset, &g_mu); test_grpc_fd(); test_grpc_fd_change(); @@ -540,6 +540,6 @@ int main(int argc, char **argv) { #else /* GRPC_POSIX_SOCKET */ -int main(int argc, char **argv) { return 1; } +int main(int argc, char** argv) { return 1; } #endif /* GRPC_POSIX_SOCKET */ diff --git a/test/core/iomgr/load_file_test.c b/test/core/iomgr/load_file_test.cc index 537c3430b1..2c9e7c33f4 100644 --- a/test/core/iomgr/load_file_test.c +++ b/test/core/iomgr/load_file_test.cc @@ -33,11 +33,11 @@ static const char prefix[] = "file_test"; static void test_load_empty_file(void) { - FILE *tmp = NULL; + FILE* tmp = NULL; grpc_slice slice; grpc_slice slice_with_null_term; - grpc_error *error; - char *tmp_name; + grpc_error* error; + char* tmp_name; LOG_TEST_NAME("test_load_empty_file"); @@ -62,10 +62,10 @@ static void test_load_empty_file(void) { } static void test_load_failure(void) { - FILE *tmp = NULL; + FILE* tmp = NULL; grpc_slice slice; - grpc_error *error; - char *tmp_name; + grpc_error* error; + char* tmp_name; LOG_TEST_NAME("test_load_failure"); @@ -84,12 +84,12 @@ static void test_load_failure(void) { } static void test_load_small_file(void) { - FILE *tmp = NULL; + FILE* tmp = NULL; grpc_slice slice; grpc_slice slice_with_null_term; - grpc_error *error; - char *tmp_name; - const char *blah = "blah"; + grpc_error* error; + char* tmp_name; + const char* blah = "blah"; LOG_TEST_NAME("test_load_small_file"); @@ -107,7 +107,7 @@ static void test_load_small_file(void) { error = grpc_load_file(tmp_name, 1, &slice_with_null_term); GPR_ASSERT(error == GRPC_ERROR_NONE); GPR_ASSERT(GRPC_SLICE_LENGTH(slice_with_null_term) == (strlen(blah) + 1)); - GPR_ASSERT(strcmp((const char *)GRPC_SLICE_START_PTR(slice_with_null_term), + GPR_ASSERT(strcmp((const char*)GRPC_SLICE_START_PTR(slice_with_null_term), blah) == 0); remove(tmp_name); @@ -117,13 +117,13 @@ static void test_load_small_file(void) { } static void test_load_big_file(void) { - FILE *tmp = NULL; + FILE* tmp = NULL; grpc_slice slice; - grpc_error *error; - char *tmp_name; + grpc_error* error; + char* tmp_name; static const size_t buffer_size = 124631; - unsigned char *buffer = gpr_malloc(buffer_size); - unsigned char *current; + unsigned char* buffer = static_cast<unsigned char*>(gpr_malloc(buffer_size)); + unsigned char* current; size_t i; LOG_TEST_NAME("test_load_big_file"); @@ -150,7 +150,7 @@ static void test_load_big_file(void) { gpr_free(buffer); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); test_load_empty_file(); test_load_failure(); diff --git a/test/core/iomgr/pollset_set_test.c b/test/core/iomgr/pollset_set_test.cc index cddc146ce0..8d0198cace 100644 --- a/test/core/iomgr/pollset_set_test.c +++ b/test/core/iomgr/pollset_set_test.cc @@ -37,16 +37,18 @@ * test_pollset_set */ -typedef struct test_pollset_set { grpc_pollset_set *pss; } test_pollset_set; +typedef struct test_pollset_set { + grpc_pollset_set* pss; +} test_pollset_set; -void init_test_pollset_sets(test_pollset_set *pollset_sets, const int num_pss) { +void init_test_pollset_sets(test_pollset_set* pollset_sets, const int num_pss) { for (int i = 0; i < num_pss; i++) { pollset_sets[i].pss = grpc_pollset_set_create(); } } -void cleanup_test_pollset_sets(grpc_exec_ctx *exec_ctx, - test_pollset_set *pollset_sets, +void cleanup_test_pollset_sets(grpc_exec_ctx* exec_ctx, + test_pollset_set* pollset_sets, const int num_pss) { for (int i = 0; i < num_pss; i++) { grpc_pollset_set_destroy(exec_ctx, pollset_sets[i].pss); @@ -59,24 +61,25 @@ void cleanup_test_pollset_sets(grpc_exec_ctx *exec_ctx, */ typedef struct test_pollset { - grpc_pollset *ps; - gpr_mu *mu; + grpc_pollset* ps; + gpr_mu* mu; } test_pollset; -static void init_test_pollsets(test_pollset *pollsets, const int num_pollsets) { +static void init_test_pollsets(test_pollset* pollsets, const int num_pollsets) { for (int i = 0; i < num_pollsets; i++) { - pollsets[i].ps = gpr_zalloc(grpc_pollset_size()); + pollsets[i].ps = + static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size())); grpc_pollset_init(pollsets[i].ps, &pollsets[i].mu); } } -static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, - grpc_error *error) { - grpc_pollset_destroy(exec_ctx, p); +static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p, + grpc_error* error) { + grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p)); } -static void cleanup_test_pollsets(grpc_exec_ctx *exec_ctx, - test_pollset *pollsets, +static void cleanup_test_pollsets(grpc_exec_ctx* exec_ctx, + test_pollset* pollsets, const int num_pollsets) { grpc_closure destroyed; for (int i = 0; i < num_pollsets; i++) { @@ -95,18 +98,18 @@ static void cleanup_test_pollsets(grpc_exec_ctx *exec_ctx, */ typedef struct test_fd { - grpc_fd *fd; + grpc_fd* fd; grpc_wakeup_fd wakeup_fd; bool is_on_readable_called; /* Is on_readable closure is called ? */ grpc_closure on_readable; /* Closure to call when this fd is readable */ } test_fd; -void on_readable(grpc_exec_ctx *exec_ctx, void *tfd, grpc_error *error) { - ((test_fd *)tfd)->is_on_readable_called = true; +void on_readable(grpc_exec_ctx* exec_ctx, void* tfd, grpc_error* error) { + ((test_fd*)tfd)->is_on_readable_called = true; } -static void reset_test_fd(grpc_exec_ctx *exec_ctx, test_fd *tfd) { +static void reset_test_fd(grpc_exec_ctx* exec_ctx, test_fd* tfd) { tfd->is_on_readable_called = false; GRPC_CLOSURE_INIT(&tfd->on_readable, on_readable, tfd, @@ -114,7 +117,7 @@ static void reset_test_fd(grpc_exec_ctx *exec_ctx, test_fd *tfd) { grpc_fd_notify_on_read(exec_ctx, tfd->fd, &tfd->on_readable); } -static void init_test_fds(grpc_exec_ctx *exec_ctx, test_fd *tfds, +static void init_test_fds(grpc_exec_ctx* exec_ctx, test_fd* tfds, const int num_fds) { for (int i = 0; i < num_fds; i++) { GPR_ASSERT(GRPC_ERROR_NONE == grpc_wakeup_fd_init(&tfds[i].wakeup_fd)); @@ -124,7 +127,7 @@ static void init_test_fds(grpc_exec_ctx *exec_ctx, test_fd *tfds, } } -static void cleanup_test_fds(grpc_exec_ctx *exec_ctx, test_fd *tfds, +static void cleanup_test_fds(grpc_exec_ctx* exec_ctx, test_fd* tfds, const int num_fds) { int release_fd; @@ -146,13 +149,13 @@ static void cleanup_test_fds(grpc_exec_ctx *exec_ctx, test_fd *tfds, } } -static void make_test_fds_readable(test_fd *tfds, const int num_fds) { +static void make_test_fds_readable(test_fd* tfds, const int num_fds) { for (int i = 0; i < num_fds; i++) { GPR_ASSERT(GRPC_ERROR_NONE == grpc_wakeup_fd_wakeup(&tfds[i].wakeup_fd)); } } -static void verify_readable_and_reset(grpc_exec_ctx *exec_ctx, test_fd *tfds, +static void verify_readable_and_reset(grpc_exec_ctx* exec_ctx, test_fd* tfds, const int num_fds) { for (int i = 0; i < num_fds; i++) { /* Verify that the on_readable callback was called */ @@ -203,7 +206,7 @@ static void pollset_set_test_basic() { * +---> FD9 (Added after PS2 is added to PSS0) */ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_pollset_worker *worker; + grpc_pollset_worker* worker; grpc_millis deadline; test_fd tfds[10]; @@ -308,7 +311,7 @@ void pollset_set_test_dup_fds() { * +---> FD1 */ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_pollset_worker *worker; + grpc_pollset_worker* worker; grpc_millis deadline; test_fd tfds[3]; @@ -381,7 +384,7 @@ void pollset_set_test_empty_pollset() { * +---> FD2 */ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_pollset_worker *worker; + grpc_pollset_worker* worker; grpc_millis deadline; test_fd tfds[3]; @@ -430,11 +433,11 @@ void pollset_set_test_empty_pollset() { grpc_exec_ctx_finish(&exec_ctx); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_test_init(argc, argv); grpc_init(); - const char *poll_strategy = grpc_get_poll_strategy_name(); + const char* poll_strategy = grpc_get_poll_strategy_name(); if (poll_strategy != NULL && (strcmp(poll_strategy, "epollsig") == 0 || @@ -453,6 +456,6 @@ int main(int argc, char **argv) { grpc_shutdown(); return 0; } -#else /* defined(GRPC_LINUX_EPOLL) */ -int main(int argc, char **argv) { return 0; } +#else /* defined(GRPC_LINUX_EPOLL) */ +int main(int argc, char** argv) { return 0; } #endif /* !defined(GRPC_LINUX_EPOLL) */ diff --git a/test/core/iomgr/resolve_address_posix_test.c b/test/core/iomgr/resolve_address_posix_test.cc index cb9d6080fb..ba89fc8ad5 100644 --- a/test/core/iomgr/resolve_address_posix_test.c +++ b/test/core/iomgr/resolve_address_posix_test.cc @@ -39,25 +39,25 @@ static gpr_timespec test_deadline(void) { typedef struct args_struct { gpr_event ev; - grpc_resolved_addresses *addrs; + grpc_resolved_addresses* addrs; gpr_atm done_atm; - gpr_mu *mu; - grpc_pollset *pollset; - grpc_pollset_set *pollset_set; + gpr_mu* mu; + grpc_pollset* pollset; + grpc_pollset_set* pollset_set; } args_struct; -static void do_nothing(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {} +static void do_nothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {} -void args_init(grpc_exec_ctx *exec_ctx, args_struct *args) { +void args_init(grpc_exec_ctx* exec_ctx, args_struct* args) { gpr_event_init(&args->ev); - args->pollset = gpr_zalloc(grpc_pollset_size()); + args->pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size())); grpc_pollset_init(args->pollset, &args->mu); args->pollset_set = grpc_pollset_set_create(); grpc_pollset_set_add_pollset(exec_ctx, args->pollset_set, args->pollset); args->addrs = NULL; } -void args_finish(grpc_exec_ctx *exec_ctx, args_struct *args) { +void args_finish(grpc_exec_ctx* exec_ctx, args_struct* args) { GPR_ASSERT(gpr_event_wait(&args->ev, test_deadline())); grpc_resolved_addresses_destroy(args->addrs); grpc_pollset_set_del_pollset(exec_ctx, args->pollset_set, args->pollset); @@ -77,8 +77,8 @@ static grpc_millis n_sec_deadline(int seconds) { grpc_timeout_seconds_to_deadline(seconds)); } -static void actually_poll(void *argsp) { - args_struct *args = argsp; +static void actually_poll(void* argsp) { + args_struct* args = static_cast<args_struct*>(argsp); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_millis deadline = n_sec_deadline(10); while (true) { @@ -89,7 +89,7 @@ static void actually_poll(void *argsp) { grpc_millis time_left = deadline - grpc_exec_ctx_now(&exec_ctx); gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRIdPTR, done, time_left); GPR_ASSERT(time_left >= 0); - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; gpr_mu_lock(args->mu); GRPC_LOG_IF_ERROR("pollset_work", grpc_pollset_work(&exec_ctx, args->pollset, &worker, @@ -97,27 +97,27 @@ static void actually_poll(void *argsp) { gpr_mu_unlock(args->mu); grpc_exec_ctx_flush(&exec_ctx); } - gpr_event_set(&args->ev, (void *)1); + gpr_event_set(&args->ev, (void*)1); grpc_exec_ctx_finish(&exec_ctx); } -static void poll_pollset_until_request_done(args_struct *args) { +static void poll_pollset_until_request_done(args_struct* args) { gpr_atm_rel_store(&args->done_atm, 0); gpr_thd_id id; gpr_thd_new(&id, actually_poll, args, NULL); } -static void must_succeed(grpc_exec_ctx *exec_ctx, void *argsp, - grpc_error *err) { - args_struct *args = argsp; +static void must_succeed(grpc_exec_ctx* exec_ctx, void* argsp, + grpc_error* err) { + args_struct* args = static_cast<args_struct*>(argsp); GPR_ASSERT(err == GRPC_ERROR_NONE); GPR_ASSERT(args->addrs != NULL); GPR_ASSERT(args->addrs->naddrs > 0); gpr_atm_rel_store(&args->done_atm, 1); } -static void must_fail(grpc_exec_ctx *exec_ctx, void *argsp, grpc_error *err) { - args_struct *args = argsp; +static void must_fail(grpc_exec_ctx* exec_ctx, void* argsp, grpc_error* err) { + args_struct* args = static_cast<args_struct*>(argsp); GPR_ASSERT(err != GRPC_ERROR_NONE); gpr_atm_rel_store(&args->done_atm, 1); } @@ -141,8 +141,9 @@ static void test_unix_socket_path_name_too_long(void) { args_init(&exec_ctx, &args); const char prefix[] = "unix:/path/name"; size_t path_name_length = - GPR_ARRAY_SIZE(((struct sockaddr_un *)0)->sun_path) + 6; - char *path_name = gpr_malloc(sizeof(char) * path_name_length); + GPR_ARRAY_SIZE(((struct sockaddr_un*)0)->sun_path) + 6; + char* path_name = + static_cast<char*>(gpr_malloc(sizeof(char) * path_name_length)); memset(path_name, 'a', path_name_length); memcpy(path_name, prefix, strlen(prefix) - 1); path_name[path_name_length - 1] = '\0'; @@ -157,7 +158,7 @@ static void test_unix_socket_path_name_too_long(void) { grpc_exec_ctx_finish(&exec_ctx); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); grpc_init(); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; diff --git a/test/core/iomgr/resolve_address_test.c b/test/core/iomgr/resolve_address_test.cc index 178bbbb95f..0aa3e5f0f0 100644 --- a/test/core/iomgr/resolve_address_test.c +++ b/test/core/iomgr/resolve_address_test.cc @@ -32,18 +32,18 @@ static gpr_timespec test_deadline(void) { typedef struct args_struct { gpr_event ev; - grpc_resolved_addresses *addrs; + grpc_resolved_addresses* addrs; gpr_atm done_atm; - gpr_mu *mu; - grpc_pollset *pollset; - grpc_pollset_set *pollset_set; + gpr_mu* mu; + grpc_pollset* pollset; + grpc_pollset_set* pollset_set; } args_struct; -static void do_nothing(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {} +static void do_nothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {} -void args_init(grpc_exec_ctx *exec_ctx, args_struct *args) { +void args_init(grpc_exec_ctx* exec_ctx, args_struct* args) { gpr_event_init(&args->ev); - args->pollset = gpr_zalloc(grpc_pollset_size()); + args->pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size())); grpc_pollset_init(args->pollset, &args->mu); args->pollset_set = grpc_pollset_set_create(); grpc_pollset_set_add_pollset(exec_ctx, args->pollset_set, args->pollset); @@ -51,7 +51,7 @@ void args_init(grpc_exec_ctx *exec_ctx, args_struct *args) { gpr_atm_rel_store(&args->done_atm, 0); } -void args_finish(grpc_exec_ctx *exec_ctx, args_struct *args) { +void args_finish(grpc_exec_ctx* exec_ctx, args_struct* args) { GPR_ASSERT(gpr_event_wait(&args->ev, test_deadline())); grpc_resolved_addresses_destroy(args->addrs); grpc_pollset_set_del_pollset(exec_ctx, args->pollset_set, args->pollset); @@ -73,7 +73,7 @@ static grpc_millis n_sec_deadline(int seconds) { grpc_timeout_seconds_to_deadline(seconds)); } -static void poll_pollset_until_request_done(args_struct *args) { +static void poll_pollset_until_request_done(args_struct* args) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_millis deadline = n_sec_deadline(10); while (true) { @@ -84,7 +84,7 @@ static void poll_pollset_until_request_done(args_struct *args) { grpc_millis time_left = deadline - grpc_exec_ctx_now(&exec_ctx); gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRIdPTR, done, time_left); GPR_ASSERT(time_left >= 0); - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; gpr_mu_lock(args->mu); GRPC_LOG_IF_ERROR("pollset_work", grpc_pollset_work(&exec_ctx, args->pollset, &worker, @@ -92,13 +92,13 @@ static void poll_pollset_until_request_done(args_struct *args) { gpr_mu_unlock(args->mu); grpc_exec_ctx_flush(&exec_ctx); } - gpr_event_set(&args->ev, (void *)1); + gpr_event_set(&args->ev, (void*)1); grpc_exec_ctx_finish(&exec_ctx); } -static void must_succeed(grpc_exec_ctx *exec_ctx, void *argsp, - grpc_error *err) { - args_struct *args = argsp; +static void must_succeed(grpc_exec_ctx* exec_ctx, void* argsp, + grpc_error* err) { + args_struct* args = static_cast<args_struct*>(argsp); GPR_ASSERT(err == GRPC_ERROR_NONE); GPR_ASSERT(args->addrs != NULL); GPR_ASSERT(args->addrs->naddrs > 0); @@ -109,8 +109,8 @@ static void must_succeed(grpc_exec_ctx *exec_ctx, void *argsp, gpr_mu_unlock(args->mu); } -static void must_fail(grpc_exec_ctx *exec_ctx, void *argsp, grpc_error *err) { - args_struct *args = argsp; +static void must_fail(grpc_exec_ctx* exec_ctx, void* argsp, grpc_error* err) { + args_struct* args = static_cast<args_struct*>(argsp); GPR_ASSERT(err != GRPC_ERROR_NONE); gpr_atm_rel_store(&args->done_atm, 1); gpr_mu_lock(args->mu); @@ -190,8 +190,10 @@ static void test_ipv6_with_port(void) { } static void test_ipv6_without_port(void) { - const char *const kCases[] = { - "2001:db8::1", "2001:db8::1.2.3.4", "[2001:db8::1]", + const char* const kCases[] = { + "2001:db8::1", + "2001:db8::1.2.3.4", + "[2001:db8::1]", }; unsigned i; for (i = 0; i < sizeof(kCases) / sizeof(*kCases); i++) { @@ -210,8 +212,9 @@ static void test_ipv6_without_port(void) { } static void test_invalid_ip_addresses(void) { - const char *const kCases[] = { - "293.283.1238.3:1", "[2001:db8::11111]:1", + const char* const kCases[] = { + "293.283.1238.3:1", + "[2001:db8::11111]:1", }; unsigned i; for (i = 0; i < sizeof(kCases) / sizeof(*kCases); i++) { @@ -230,7 +233,7 @@ static void test_invalid_ip_addresses(void) { } static void test_unparseable_hostports(void) { - const char *const kCases[] = { + const char* const kCases[] = { "[", "[::1", "[::1]bad", "[1.2.3.4]", "[localhost]", "[localhost]:1", }; unsigned i; @@ -249,7 +252,7 @@ static void test_unparseable_hostports(void) { } } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); grpc_init(); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; diff --git a/test/core/iomgr/resource_quota_test.c b/test/core/iomgr/resource_quota_test.cc index b588f3d120..8a2faaed02 100644 --- a/test/core/iomgr/resource_quota_test.c +++ b/test/core/iomgr/resource_quota_test.cc @@ -27,14 +27,14 @@ gpr_mu g_mu; gpr_cv g_cv; -static void inc_int_cb(grpc_exec_ctx *exec_ctx, void *a, grpc_error *error) { +static void inc_int_cb(grpc_exec_ctx* exec_ctx, void* a, grpc_error* error) { gpr_mu_lock(&g_mu); - ++*(int *)a; + ++*(int*)a; gpr_cv_signal(&g_cv); gpr_mu_unlock(&g_mu); } -static void assert_counter_becomes(int *ctr, int value) { +static void assert_counter_becomes(int* ctr, int value) { gpr_mu_lock(&g_mu); gpr_timespec deadline = grpc_timeout_seconds_to_deadline(5); while (*ctr != value) { @@ -43,47 +43,49 @@ static void assert_counter_becomes(int *ctr, int value) { gpr_mu_unlock(&g_mu); } -static void set_event_cb(grpc_exec_ctx *exec_ctx, void *a, grpc_error *error) { - gpr_event_set((gpr_event *)a, (void *)1); +static void set_event_cb(grpc_exec_ctx* exec_ctx, void* a, grpc_error* error) { + gpr_event_set((gpr_event*)a, (void*)1); } -grpc_closure *set_event(gpr_event *ev) { +grpc_closure* set_event(gpr_event* ev) { return GRPC_CLOSURE_CREATE(set_event_cb, ev, grpc_schedule_on_exec_ctx); } typedef struct { size_t size; - grpc_resource_user *resource_user; - grpc_closure *then; + grpc_resource_user* resource_user; + grpc_closure* then; } reclaimer_args; -static void reclaimer_cb(grpc_exec_ctx *exec_ctx, void *args, - grpc_error *error) { + +static void reclaimer_cb(grpc_exec_ctx* exec_ctx, void* args, + grpc_error* error) { GPR_ASSERT(error == GRPC_ERROR_NONE); - reclaimer_args *a = args; + reclaimer_args* a = static_cast<reclaimer_args*>(args); grpc_resource_user_free(exec_ctx, a->resource_user, a->size); grpc_resource_user_finish_reclamation(exec_ctx, a->resource_user); GRPC_CLOSURE_RUN(exec_ctx, a->then, GRPC_ERROR_NONE); gpr_free(a); } -grpc_closure *make_reclaimer(grpc_resource_user *resource_user, size_t size, - grpc_closure *then) { - reclaimer_args *a = gpr_malloc(sizeof(*a)); + +grpc_closure* make_reclaimer(grpc_resource_user* resource_user, size_t size, + grpc_closure* then) { + reclaimer_args* a = static_cast<reclaimer_args*>(gpr_malloc(sizeof(*a))); a->size = size; a->resource_user = resource_user; a->then = then; return GRPC_CLOSURE_CREATE(reclaimer_cb, a, grpc_schedule_on_exec_ctx); } -static void unused_reclaimer_cb(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { +static void unused_reclaimer_cb(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { GPR_ASSERT(error == GRPC_ERROR_CANCELLED); - GRPC_CLOSURE_RUN(exec_ctx, arg, GRPC_ERROR_NONE); + GRPC_CLOSURE_RUN(exec_ctx, static_cast<grpc_closure*>(arg), GRPC_ERROR_NONE); } -grpc_closure *make_unused_reclaimer(grpc_closure *then) { +grpc_closure* make_unused_reclaimer(grpc_closure* then) { return GRPC_CLOSURE_CREATE(unused_reclaimer_cb, then, grpc_schedule_on_exec_ctx); } -static void destroy_user(grpc_resource_user *usr) { +static void destroy_user(grpc_resource_user* usr) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_resource_user_unref(&exec_ctx, usr); grpc_exec_ctx_finish(&exec_ctx); @@ -96,7 +98,7 @@ static void test_no_op(void) { static void test_resize_then_destroy(void) { gpr_log(GPR_INFO, "** test_resize_then_destroy **"); - grpc_resource_quota *q = + grpc_resource_quota* q = grpc_resource_quota_create("test_resize_then_destroy"); grpc_resource_quota_resize(q, 1024 * 1024); grpc_resource_quota_unref(q); @@ -104,19 +106,19 @@ static void test_resize_then_destroy(void) { static void test_resource_user_no_op(void) { gpr_log(GPR_INFO, "** test_resource_user_no_op **"); - grpc_resource_quota *q = + grpc_resource_quota* q = grpc_resource_quota_create("test_resource_user_no_op"); - grpc_resource_user *usr = grpc_resource_user_create(q, "usr"); + grpc_resource_user* usr = grpc_resource_user_create(q, "usr"); grpc_resource_quota_unref(q); destroy_user(usr); } static void test_instant_alloc_then_free(void) { gpr_log(GPR_INFO, "** test_instant_alloc_then_free **"); - grpc_resource_quota *q = + grpc_resource_quota* q = grpc_resource_quota_create("test_instant_alloc_then_free"); grpc_resource_quota_resize(q, 1024 * 1024); - grpc_resource_user *usr = grpc_resource_user_create(q, "usr"); + grpc_resource_user* usr = grpc_resource_user_create(q, "usr"); { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_resource_user_alloc(&exec_ctx, usr, 1024, NULL); @@ -133,10 +135,10 @@ static void test_instant_alloc_then_free(void) { static void test_instant_alloc_free_pair(void) { gpr_log(GPR_INFO, "** test_instant_alloc_free_pair **"); - grpc_resource_quota *q = + grpc_resource_quota* q = grpc_resource_quota_create("test_instant_alloc_free_pair"); grpc_resource_quota_resize(q, 1024 * 1024); - grpc_resource_user *usr = grpc_resource_user_create(q, "usr"); + grpc_resource_user* usr = grpc_resource_user_create(q, "usr"); { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_resource_user_alloc(&exec_ctx, usr, 1024, NULL); @@ -149,10 +151,10 @@ static void test_instant_alloc_free_pair(void) { static void test_simple_async_alloc(void) { gpr_log(GPR_INFO, "** test_simple_async_alloc **"); - grpc_resource_quota *q = + grpc_resource_quota* q = grpc_resource_quota_create("test_simple_async_alloc"); grpc_resource_quota_resize(q, 1024 * 1024); - grpc_resource_user *usr = grpc_resource_user_create(q, "usr"); + grpc_resource_user* usr = grpc_resource_user_create(q, "usr"); { gpr_event ev; gpr_event_init(&ev); @@ -173,10 +175,10 @@ static void test_simple_async_alloc(void) { static void test_async_alloc_blocked_by_size(void) { gpr_log(GPR_INFO, "** test_async_alloc_blocked_by_size **"); - grpc_resource_quota *q = + grpc_resource_quota* q = grpc_resource_quota_create("test_async_alloc_blocked_by_size"); grpc_resource_quota_resize(q, 1); - grpc_resource_user *usr = grpc_resource_user_create(q, "usr"); + grpc_resource_user* usr = grpc_resource_user_create(q, "usr"); gpr_event ev; gpr_event_init(&ev); { @@ -200,10 +202,10 @@ static void test_async_alloc_blocked_by_size(void) { static void test_scavenge(void) { gpr_log(GPR_INFO, "** test_scavenge **"); - grpc_resource_quota *q = grpc_resource_quota_create("test_scavenge"); + grpc_resource_quota* q = grpc_resource_quota_create("test_scavenge"); grpc_resource_quota_resize(q, 1024); - grpc_resource_user *usr1 = grpc_resource_user_create(q, "usr1"); - grpc_resource_user *usr2 = grpc_resource_user_create(q, "usr2"); + grpc_resource_user* usr1 = grpc_resource_user_create(q, "usr1"); + grpc_resource_user* usr2 = grpc_resource_user_create(q, "usr2"); { gpr_event ev; gpr_event_init(&ev); @@ -241,10 +243,10 @@ static void test_scavenge(void) { static void test_scavenge_blocked(void) { gpr_log(GPR_INFO, "** test_scavenge_blocked **"); - grpc_resource_quota *q = grpc_resource_quota_create("test_scavenge_blocked"); + grpc_resource_quota* q = grpc_resource_quota_create("test_scavenge_blocked"); grpc_resource_quota_resize(q, 1024); - grpc_resource_user *usr1 = grpc_resource_user_create(q, "usr1"); - grpc_resource_user *usr2 = grpc_resource_user_create(q, "usr2"); + grpc_resource_user* usr1 = grpc_resource_user_create(q, "usr1"); + grpc_resource_user* usr2 = grpc_resource_user_create(q, "usr2"); gpr_event ev; { gpr_event_init(&ev); @@ -283,10 +285,10 @@ static void test_scavenge_blocked(void) { static void test_blocked_until_scheduled_reclaim(void) { gpr_log(GPR_INFO, "** test_blocked_until_scheduled_reclaim **"); - grpc_resource_quota *q = + grpc_resource_quota* q = grpc_resource_quota_create("test_blocked_until_scheduled_reclaim"); grpc_resource_quota_resize(q, 1024); - grpc_resource_user *usr = grpc_resource_user_create(q, "usr"); + grpc_resource_user* usr = grpc_resource_user_create(q, "usr"); { gpr_event ev; gpr_event_init(&ev); @@ -329,11 +331,11 @@ static void test_blocked_until_scheduled_reclaim(void) { static void test_blocked_until_scheduled_reclaim_and_scavenge(void) { gpr_log(GPR_INFO, "** test_blocked_until_scheduled_reclaim_and_scavenge **"); - grpc_resource_quota *q = grpc_resource_quota_create( + grpc_resource_quota* q = grpc_resource_quota_create( "test_blocked_until_scheduled_reclaim_and_scavenge"); grpc_resource_quota_resize(q, 1024); - grpc_resource_user *usr1 = grpc_resource_user_create(q, "usr1"); - grpc_resource_user *usr2 = grpc_resource_user_create(q, "usr2"); + grpc_resource_user* usr1 = grpc_resource_user_create(q, "usr1"); + grpc_resource_user* usr2 = grpc_resource_user_create(q, "usr2"); { gpr_event ev; gpr_event_init(&ev); @@ -377,10 +379,10 @@ static void test_blocked_until_scheduled_reclaim_and_scavenge(void) { static void test_blocked_until_scheduled_destructive_reclaim(void) { gpr_log(GPR_INFO, "** test_blocked_until_scheduled_destructive_reclaim **"); - grpc_resource_quota *q = grpc_resource_quota_create( + grpc_resource_quota* q = grpc_resource_quota_create( "test_blocked_until_scheduled_destructive_reclaim"); grpc_resource_quota_resize(q, 1024); - grpc_resource_user *usr = grpc_resource_user_create(q, "usr"); + grpc_resource_user* usr = grpc_resource_user_create(q, "usr"); { gpr_event ev; gpr_event_init(&ev); @@ -423,10 +425,10 @@ static void test_blocked_until_scheduled_destructive_reclaim(void) { static void test_unused_reclaim_is_cancelled(void) { gpr_log(GPR_INFO, "** test_unused_reclaim_is_cancelled **"); - grpc_resource_quota *q = + grpc_resource_quota* q = grpc_resource_quota_create("test_unused_reclaim_is_cancelled"); grpc_resource_quota_resize(q, 1024); - grpc_resource_user *usr = grpc_resource_user_create(q, "usr"); + grpc_resource_user* usr = grpc_resource_user_create(q, "usr"); gpr_event benign_done; gpr_event_init(&benign_done); gpr_event destructive_done; @@ -456,10 +458,10 @@ static void test_unused_reclaim_is_cancelled(void) { static void test_benign_reclaim_is_preferred(void) { gpr_log(GPR_INFO, "** test_benign_reclaim_is_preferred **"); - grpc_resource_quota *q = + grpc_resource_quota* q = grpc_resource_quota_create("test_benign_reclaim_is_preferred"); grpc_resource_quota_resize(q, 1024); - grpc_resource_user *usr = grpc_resource_user_create(q, "usr"); + grpc_resource_user* usr = grpc_resource_user_create(q, "usr"); gpr_event benign_done; gpr_event_init(&benign_done); gpr_event destructive_done; @@ -519,10 +521,10 @@ static void test_benign_reclaim_is_preferred(void) { static void test_multiple_reclaims_can_be_triggered(void) { gpr_log(GPR_INFO, "** test_multiple_reclaims_can_be_triggered **"); - grpc_resource_quota *q = + grpc_resource_quota* q = grpc_resource_quota_create("test_multiple_reclaims_can_be_triggered"); grpc_resource_quota_resize(q, 1024); - grpc_resource_user *usr = grpc_resource_user_create(q, "usr"); + grpc_resource_user* usr = grpc_resource_user_create(q, "usr"); gpr_event benign_done; gpr_event_init(&benign_done); gpr_event destructive_done; @@ -583,10 +585,10 @@ static void test_multiple_reclaims_can_be_triggered(void) { static void test_resource_user_stays_allocated_until_memory_released(void) { gpr_log(GPR_INFO, "** test_resource_user_stays_allocated_until_memory_released **"); - grpc_resource_quota *q = grpc_resource_quota_create( + grpc_resource_quota* q = grpc_resource_quota_create( "test_resource_user_stays_allocated_until_memory_released"); grpc_resource_quota_resize(q, 1024 * 1024); - grpc_resource_user *usr = grpc_resource_user_create(q, "usr"); + grpc_resource_user* usr = grpc_resource_user_create(q, "usr"); { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_resource_user_alloc(&exec_ctx, usr, 1024, NULL); @@ -612,12 +614,12 @@ test_resource_user_stays_allocated_and_reclaimers_unrun_until_memory_released( "** " "test_resource_user_stays_allocated_and_reclaimers_unrun_until_" "memory_released **"); - grpc_resource_quota *q = grpc_resource_quota_create( + grpc_resource_quota* q = grpc_resource_quota_create( "test_resource_user_stays_allocated_and_reclaimers_unrun_until_memory_" "released"); grpc_resource_quota_resize(q, 1024); for (int i = 0; i < 10; i++) { - grpc_resource_user *usr = grpc_resource_user_create(q, "usr"); + grpc_resource_user* usr = grpc_resource_user_create(q, "usr"); gpr_event reclaimer_cancelled; gpr_event_init(&reclaimer_cancelled); { @@ -663,10 +665,10 @@ test_resource_user_stays_allocated_and_reclaimers_unrun_until_memory_released( static void test_reclaimers_can_be_posted_repeatedly(void) { gpr_log(GPR_INFO, "** test_reclaimers_can_be_posted_repeatedly **"); - grpc_resource_quota *q = + grpc_resource_quota* q = grpc_resource_quota_create("test_reclaimers_can_be_posted_repeatedly"); grpc_resource_quota_resize(q, 1024); - grpc_resource_user *usr = grpc_resource_user_create(q, "usr"); + grpc_resource_user* usr = grpc_resource_user_create(q, "usr"); { gpr_event allocated; gpr_event_init(&allocated); @@ -713,10 +715,10 @@ static void test_reclaimers_can_be_posted_repeatedly(void) { static void test_one_slice(void) { gpr_log(GPR_INFO, "** test_one_slice **"); - grpc_resource_quota *q = grpc_resource_quota_create("test_one_slice"); + grpc_resource_quota* q = grpc_resource_quota_create("test_one_slice"); grpc_resource_quota_resize(q, 1024); - grpc_resource_user *usr = grpc_resource_user_create(q, "usr"); + grpc_resource_user* usr = grpc_resource_user_create(q, "usr"); grpc_resource_user_slice_allocator alloc; int num_allocs = 0; @@ -745,11 +747,11 @@ static void test_one_slice(void) { static void test_one_slice_deleted_late(void) { gpr_log(GPR_INFO, "** test_one_slice_deleted_late **"); - grpc_resource_quota *q = + grpc_resource_quota* q = grpc_resource_quota_create("test_one_slice_deleted_late"); grpc_resource_quota_resize(q, 1024); - grpc_resource_user *usr = grpc_resource_user_create(q, "usr"); + grpc_resource_user* usr = grpc_resource_user_create(q, "usr"); grpc_resource_user_slice_allocator alloc; int num_allocs = 0; @@ -782,18 +784,18 @@ static void test_one_slice_deleted_late(void) { static void test_resize_to_zero(void) { gpr_log(GPR_INFO, "** test_resize_to_zero **"); - grpc_resource_quota *q = grpc_resource_quota_create("test_resize_to_zero"); + grpc_resource_quota* q = grpc_resource_quota_create("test_resize_to_zero"); grpc_resource_quota_resize(q, 0); grpc_resource_quota_unref(q); } static void test_negative_rq_free_pool(void) { gpr_log(GPR_INFO, "** test_negative_rq_free_pool **"); - grpc_resource_quota *q = + grpc_resource_quota* q = grpc_resource_quota_create("test_negative_rq_free_pool"); grpc_resource_quota_resize(q, 1024); - grpc_resource_user *usr = grpc_resource_user_create(q, "usr"); + grpc_resource_user* usr = grpc_resource_user_create(q, "usr"); grpc_resource_user_slice_allocator alloc; int num_allocs = 0; @@ -830,7 +832,7 @@ static void test_negative_rq_free_pool(void) { } } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); grpc_init(); gpr_mu_init(&g_mu); diff --git a/test/core/iomgr/sockaddr_utils_test.c b/test/core/iomgr/sockaddr_utils_test.cc index e4a4ddaa99..40f2157ba3 100644 --- a/test/core/iomgr/sockaddr_utils_test.c +++ b/test/core/iomgr/sockaddr_utils_test.cc @@ -20,8 +20,8 @@ using that endpoint. Because of various transitive includes in uv.h, including windows.h on Windows, uv.h must be included before other system headers. Therefore, sockaddr.h must always be included first */ -#include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/iomgr/sockaddr_utils.h" +#include "src/core/lib/iomgr/sockaddr.h" #include <errno.h> #include <string.h> @@ -31,9 +31,9 @@ #include <grpc/support/port_platform.h> #include "test/core/util/test_config.h" -static grpc_resolved_address make_addr4(const uint8_t *data, size_t data_len) { +static grpc_resolved_address make_addr4(const uint8_t* data, size_t data_len) { grpc_resolved_address resolved_addr4; - struct sockaddr_in *addr4 = (struct sockaddr_in *)resolved_addr4.addr; + struct sockaddr_in* addr4 = (struct sockaddr_in*)resolved_addr4.addr; memset(&resolved_addr4, 0, sizeof(resolved_addr4)); addr4->sin_family = AF_INET; GPR_ASSERT(data_len == sizeof(addr4->sin_addr.s_addr)); @@ -43,9 +43,9 @@ static grpc_resolved_address make_addr4(const uint8_t *data, size_t data_len) { return resolved_addr4; } -static grpc_resolved_address make_addr6(const uint8_t *data, size_t data_len) { +static grpc_resolved_address make_addr6(const uint8_t* data, size_t data_len) { grpc_resolved_address resolved_addr6; - struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)resolved_addr6.addr; + struct sockaddr_in6* addr6 = (struct sockaddr_in6*)resolved_addr6.addr; memset(&resolved_addr6, 0, sizeof(resolved_addr6)); addr6->sin6_family = AF_INET6; GPR_ASSERT(data_len == sizeof(addr6->sin6_addr.s6_addr)); @@ -55,8 +55,8 @@ static grpc_resolved_address make_addr6(const uint8_t *data, size_t data_len) { return resolved_addr6; } -static void set_addr6_scope_id(grpc_resolved_address *addr, uint32_t scope_id) { - struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)addr->addr; +static void set_addr6_scope_id(grpc_resolved_address* addr, uint32_t scope_id) { + struct sockaddr_in6* addr6 = (struct sockaddr_in6*)addr->addr; GPR_ASSERT(addr6->sin6_family == AF_INET6); addr6->sin6_scope_id = scope_id; } @@ -128,9 +128,9 @@ static void test_sockaddr_is_wildcard(void) { grpc_resolved_address wild6; grpc_resolved_address wild_mapped; grpc_resolved_address dummy; - struct sockaddr_in *wild4_addr; - struct sockaddr_in6 *wild6_addr; - struct sockaddr_in6 *wild_mapped_addr; + struct sockaddr_in* wild4_addr; + struct sockaddr_in6* wild6_addr; + struct sockaddr_in6* wild_mapped_addr; int port; gpr_log(GPR_INFO, "%s", "test_sockaddr_is_wildcard"); @@ -143,7 +143,7 @@ static void test_sockaddr_is_wildcard(void) { port = -1; GPR_ASSERT(grpc_sockaddr_is_wildcard(&wild4, &port)); GPR_ASSERT(port == 555); - wild4_addr = (struct sockaddr_in *)&wild4.addr; + wild4_addr = (struct sockaddr_in*)&wild4.addr; memset(&wild4_addr->sin_addr.s_addr, 0xbd, 1); GPR_ASSERT(!grpc_sockaddr_is_wildcard(&wild4, &port)); @@ -151,7 +151,7 @@ static void test_sockaddr_is_wildcard(void) { port = -1; GPR_ASSERT(grpc_sockaddr_is_wildcard(&wild6, &port)); GPR_ASSERT(port == 555); - wild6_addr = (struct sockaddr_in6 *)&wild6.addr; + wild6_addr = (struct sockaddr_in6*)&wild6.addr; memset(&wild6_addr->sin6_addr.s6_addr, 0xbd, 1); GPR_ASSERT(!grpc_sockaddr_is_wildcard(&wild6, &port)); @@ -159,7 +159,7 @@ static void test_sockaddr_is_wildcard(void) { port = -1; GPR_ASSERT(grpc_sockaddr_is_wildcard(&wild_mapped, &port)); GPR_ASSERT(port == 555); - wild_mapped_addr = (struct sockaddr_in6 *)&wild_mapped.addr; + wild_mapped_addr = (struct sockaddr_in6*)&wild_mapped.addr; memset(&wild_mapped_addr->sin6_addr.s6_addr, 0xbd, 1); GPR_ASSERT(!grpc_sockaddr_is_wildcard(&wild_mapped, &port)); @@ -170,10 +170,10 @@ static void test_sockaddr_is_wildcard(void) { GPR_ASSERT(port == -1); } -static void expect_sockaddr_str(const char *expected, - grpc_resolved_address *addr, int normalize) { +static void expect_sockaddr_str(const char* expected, + grpc_resolved_address* addr, int normalize) { int result; - char *str; + char* str; gpr_log(GPR_INFO, " expect_sockaddr_str(%s)", expected); result = grpc_sockaddr_to_string(&str, addr, normalize); GPR_ASSERT(str != NULL); @@ -183,9 +183,9 @@ static void expect_sockaddr_str(const char *expected, gpr_free(str); } -static void expect_sockaddr_uri(const char *expected, - grpc_resolved_address *addr) { - char *str; +static void expect_sockaddr_uri(const char* expected, + grpc_resolved_address* addr) { + char* str; gpr_log(GPR_INFO, " expect_sockaddr_uri(%s)", expected); str = grpc_sockaddr_to_uri(addr); GPR_ASSERT(str != NULL); @@ -197,7 +197,7 @@ static void test_sockaddr_to_string(void) { grpc_resolved_address input4; grpc_resolved_address input6; grpc_resolved_address dummy; - struct sockaddr *dummy_addr; + struct sockaddr* dummy_addr; gpr_log(GPR_INFO, "%s", "test_sockaddr_to_string"); @@ -234,7 +234,7 @@ static void test_sockaddr_to_string(void) { expect_sockaddr_uri("ipv6:[::fffe:c000:263]:12345", &input6); memset(&dummy, 0, sizeof(dummy)); - dummy_addr = (struct sockaddr *)dummy.addr; + dummy_addr = (struct sockaddr*)dummy.addr; dummy_addr->sa_family = 123; expect_sockaddr_str("(sockaddr family=123)", &dummy, 0); expect_sockaddr_str("(sockaddr family=123)", &dummy, 1); @@ -245,7 +245,7 @@ static void test_sockaddr_set_get_port(void) { grpc_resolved_address input4; grpc_resolved_address input6; grpc_resolved_address dummy; - struct sockaddr *dummy_addr; + struct sockaddr* dummy_addr; gpr_log(GPR_DEBUG, "test_sockaddr_set_get_port"); @@ -260,13 +260,13 @@ static void test_sockaddr_set_get_port(void) { GPR_ASSERT(grpc_sockaddr_get_port(&input6) == 54321); memset(&dummy, 0, sizeof(dummy)); - dummy_addr = (struct sockaddr *)dummy.addr; + dummy_addr = (struct sockaddr*)dummy.addr; dummy_addr->sa_family = 123; GPR_ASSERT(grpc_sockaddr_get_port(&dummy) == 0); GPR_ASSERT(grpc_sockaddr_set_port(&dummy, 1234) == 0); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); test_sockaddr_is_v4mapped(); diff --git a/test/core/iomgr/socket_utils_test.c b/test/core/iomgr/socket_utils_test.cc index 30f0c943dc..49c6f799e7 100644 --- a/test/core/iomgr/socket_utils_test.c +++ b/test/core/iomgr/socket_utils_test.cc @@ -39,10 +39,10 @@ struct test_socket_mutator { int option_value; }; -static bool mutate_fd(int fd, grpc_socket_mutator *mutator) { +static bool mutate_fd(int fd, grpc_socket_mutator* mutator) { int newval; socklen_t intlen = sizeof(newval); - struct test_socket_mutator *m = (struct test_socket_mutator *)mutator; + struct test_socket_mutator* m = (struct test_socket_mutator*)mutator; if (0 != setsockopt(fd, IPPROTO_IP, IP_TOS, &m->option_value, sizeof(m->option_value))) { @@ -57,24 +57,24 @@ static bool mutate_fd(int fd, grpc_socket_mutator *mutator) { return true; } -static void destroy_test_mutator(grpc_socket_mutator *mutator) { - struct test_socket_mutator *m = (struct test_socket_mutator *)mutator; +static void destroy_test_mutator(grpc_socket_mutator* mutator) { + struct test_socket_mutator* m = (struct test_socket_mutator*)mutator; gpr_free(m); } -static int compare_test_mutator(grpc_socket_mutator *a, - grpc_socket_mutator *b) { - struct test_socket_mutator *ma = (struct test_socket_mutator *)a; - struct test_socket_mutator *mb = (struct test_socket_mutator *)b; +static int compare_test_mutator(grpc_socket_mutator* a, + grpc_socket_mutator* b) { + struct test_socket_mutator* ma = (struct test_socket_mutator*)a; + struct test_socket_mutator* mb = (struct test_socket_mutator*)b; return GPR_ICMP(ma->option_value, mb->option_value); } static const grpc_socket_mutator_vtable mutator_vtable = { mutate_fd, compare_test_mutator, destroy_test_mutator}; -int main(int argc, char **argv) { +int main(int argc, char** argv) { int sock; - grpc_error *err; + grpc_error* err; grpc_test_init(argc, argv); sock = socket(PF_INET, SOCK_STREAM, 0); @@ -103,20 +103,20 @@ int main(int argc, char **argv) { mutator.option_value = IPTOS_LOWDELAY; GPR_ASSERT(GRPC_LOG_IF_ERROR( "set_socket_with_mutator", - grpc_set_socket_with_mutator(sock, (grpc_socket_mutator *)&mutator))); + grpc_set_socket_with_mutator(sock, (grpc_socket_mutator*)&mutator))); mutator.option_value = IPTOS_THROUGHPUT; GPR_ASSERT(GRPC_LOG_IF_ERROR( "set_socket_with_mutator", - grpc_set_socket_with_mutator(sock, (grpc_socket_mutator *)&mutator))); + grpc_set_socket_with_mutator(sock, (grpc_socket_mutator*)&mutator))); mutator.option_value = IPTOS_RELIABILITY; GPR_ASSERT(GRPC_LOG_IF_ERROR( "set_socket_with_mutator", - grpc_set_socket_with_mutator(sock, (grpc_socket_mutator *)&mutator))); + grpc_set_socket_with_mutator(sock, (grpc_socket_mutator*)&mutator))); mutator.option_value = -1; - err = grpc_set_socket_with_mutator(sock, (grpc_socket_mutator *)&mutator); + err = grpc_set_socket_with_mutator(sock, (grpc_socket_mutator*)&mutator); GPR_ASSERT(err != GRPC_ERROR_NONE); GRPC_ERROR_UNREF(err); @@ -127,6 +127,6 @@ int main(int argc, char **argv) { #else /* GRPC_POSIX_SOCKET */ -int main(int argc, char **argv) { return 1; } +int main(int argc, char** argv) { return 1; } #endif /* GRPC_POSIX_SOCKET */ diff --git a/test/core/iomgr/tcp_client_posix_test.c b/test/core/iomgr/tcp_client_posix_test.cc index b8b76d1c42..206fa5de01 100644 --- a/test/core/iomgr/tcp_client_posix_test.c +++ b/test/core/iomgr/tcp_client_posix_test.cc @@ -40,11 +40,11 @@ #include "src/core/lib/iomgr/timer.h" #include "test/core/util/test_config.h" -static grpc_pollset_set *g_pollset_set; -static gpr_mu *g_mu; -static grpc_pollset *g_pollset; +static grpc_pollset_set* g_pollset_set; +static gpr_mu* g_mu; +static grpc_pollset* g_pollset; static int g_connections_complete = 0; -static grpc_endpoint *g_connecting = NULL; +static grpc_endpoint* g_connecting = NULL; static grpc_millis test_deadline(void) { return grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(10)); @@ -60,8 +60,8 @@ static void finish_connection() { gpr_mu_unlock(g_mu); } -static void must_succeed(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { +static void must_succeed(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { GPR_ASSERT(g_connecting != NULL); GPR_ASSERT(error == GRPC_ERROR_NONE); grpc_endpoint_shutdown( @@ -72,7 +72,7 @@ static void must_succeed(grpc_exec_ctx *exec_ctx, void *arg, finish_connection(); } -static void must_fail(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { +static void must_fail(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { GPR_ASSERT(g_connecting == NULL); GPR_ASSERT(error != GRPC_ERROR_NONE); finish_connection(); @@ -80,7 +80,7 @@ static void must_fail(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { void test_succeeds(void) { grpc_resolved_address resolved_addr; - struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr; + struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr; int svr_fd; int r; int connections_complete_before; @@ -97,7 +97,7 @@ void test_succeeds(void) { svr_fd = socket(AF_INET, SOCK_STREAM, 0); GPR_ASSERT(svr_fd >= 0); GPR_ASSERT( - 0 == bind(svr_fd, (struct sockaddr *)addr, (socklen_t)resolved_addr.len)); + 0 == bind(svr_fd, (struct sockaddr*)addr, (socklen_t)resolved_addr.len)); GPR_ASSERT(0 == listen(svr_fd, 1)); gpr_mu_lock(g_mu); @@ -105,8 +105,8 @@ void test_succeeds(void) { gpr_mu_unlock(g_mu); /* connect to it */ - GPR_ASSERT(getsockname(svr_fd, (struct sockaddr *)addr, - (socklen_t *)&resolved_addr.len) == 0); + GPR_ASSERT(getsockname(svr_fd, (struct sockaddr*)addr, + (socklen_t*)&resolved_addr.len) == 0); GRPC_CLOSURE_INIT(&done, must_succeed, NULL, grpc_schedule_on_exec_ctx); grpc_tcp_client_connect(&exec_ctx, &done, &g_connecting, g_pollset_set, NULL, &resolved_addr, GRPC_MILLIS_INF_FUTURE); @@ -114,8 +114,7 @@ void test_succeeds(void) { /* await the connection */ do { resolved_addr.len = sizeof(addr); - r = accept(svr_fd, (struct sockaddr *)addr, - (socklen_t *)&resolved_addr.len); + r = accept(svr_fd, (struct sockaddr*)addr, (socklen_t*)&resolved_addr.len); } while (r == -1 && errno == EINTR); GPR_ASSERT(r >= 0); close(r); @@ -123,7 +122,7 @@ void test_succeeds(void) { gpr_mu_lock(g_mu); while (g_connections_complete == connections_complete_before) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, @@ -141,7 +140,7 @@ void test_succeeds(void) { void test_fails(void) { grpc_resolved_address resolved_addr; - struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr; + struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr; int connections_complete_before; grpc_closure done; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -165,7 +164,7 @@ void test_fails(void) { /* wait for the connection callback to finish */ while (g_connections_complete == connections_complete_before) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; grpc_millis polling_deadline = test_deadline(); switch (grpc_timer_check(&exec_ctx, &polling_deadline)) { case GRPC_TIMERS_FIRED: @@ -188,18 +187,18 @@ void test_fails(void) { grpc_exec_ctx_finish(&exec_ctx); } -static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, - grpc_error *error) { - grpc_pollset_destroy(exec_ctx, p); +static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p, + grpc_error* error) { + grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p)); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_closure destroyed; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_test_init(argc, argv); grpc_init(); g_pollset_set = grpc_pollset_set_create(); - g_pollset = gpr_zalloc(grpc_pollset_size()); + g_pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size())); grpc_pollset_init(g_pollset, &g_mu); grpc_pollset_set_add_pollset(&exec_ctx, g_pollset_set, g_pollset); grpc_exec_ctx_finish(&exec_ctx); @@ -218,6 +217,6 @@ int main(int argc, char **argv) { #else /* GRPC_POSIX_SOCKET */ -int main(int argc, char **argv) { return 1; } +int main(int argc, char** argv) { return 1; } #endif /* GRPC_POSIX_SOCKET */ diff --git a/test/core/iomgr/tcp_client_uv_test.c b/test/core/iomgr/tcp_client_uv_test.cc index edfccbe867..101d7bf6b5 100644 --- a/test/core/iomgr/tcp_client_uv_test.c +++ b/test/core/iomgr/tcp_client_uv_test.cc @@ -37,16 +37,16 @@ #include "src/core/lib/iomgr/timer.h" #include "test/core/util/test_config.h" -static gpr_mu *g_mu; -static grpc_pollset *g_pollset; +static gpr_mu* g_mu; +static grpc_pollset* g_pollset; static int g_connections_complete = 0; -static grpc_endpoint *g_connecting = NULL; +static grpc_endpoint* g_connecting = NULL; static grpc_millis test_deadline(void) { return grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(10)); } -static void finish_connection(grpc_exec_ctx *exec_ctx) { +static void finish_connection(grpc_exec_ctx* exec_ctx) { gpr_mu_lock(g_mu); g_connections_complete++; GPR_ASSERT(GRPC_LOG_IF_ERROR("pollset_kick", @@ -54,8 +54,8 @@ static void finish_connection(grpc_exec_ctx *exec_ctx) { gpr_mu_unlock(g_mu); } -static void must_succeed(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { +static void must_succeed(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { GPR_ASSERT(g_connecting != NULL); GPR_ASSERT(error == GRPC_ERROR_NONE); grpc_endpoint_shutdown( @@ -66,26 +66,27 @@ static void must_succeed(grpc_exec_ctx *exec_ctx, void *arg, finish_connection(exec_ctx); } -static void must_fail(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { +static void must_fail(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { GPR_ASSERT(g_connecting == NULL); GPR_ASSERT(error != GRPC_ERROR_NONE); finish_connection(exec_ctx); } -static void close_cb(uv_handle_t *handle) { gpr_free(handle); } +static void close_cb(uv_handle_t* handle) { gpr_free(handle); } -static void connection_cb(uv_stream_t *server, int status) { - uv_tcp_t *client_handle = gpr_malloc(sizeof(uv_tcp_t)); +static void connection_cb(uv_stream_t* server, int status) { + uv_tcp_t* client_handle = + static_cast<uv_tcp_t*>(gpr_malloc(sizeof(uv_tcp_t))); GPR_ASSERT(0 == status); GPR_ASSERT(0 == uv_tcp_init(uv_default_loop(), client_handle)); - GPR_ASSERT(0 == uv_accept(server, (uv_stream_t *)client_handle)); - uv_close((uv_handle_t *)client_handle, close_cb); + GPR_ASSERT(0 == uv_accept(server, (uv_stream_t*)client_handle)); + uv_close((uv_handle_t*)client_handle, close_cb); } void test_succeeds(void) { grpc_resolved_address resolved_addr; - struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr; - uv_tcp_t *svr_handle = gpr_malloc(sizeof(uv_tcp_t)); + struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr; + uv_tcp_t* svr_handle = static_cast<uv_tcp_t*>(gpr_malloc(sizeof(uv_tcp_t))); int connections_complete_before; grpc_closure done; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -98,16 +99,16 @@ void test_succeeds(void) { /* create a dummy server */ GPR_ASSERT(0 == uv_tcp_init(uv_default_loop(), svr_handle)); - GPR_ASSERT(0 == uv_tcp_bind(svr_handle, (struct sockaddr *)addr, 0)); - GPR_ASSERT(0 == uv_listen((uv_stream_t *)svr_handle, 1, connection_cb)); + GPR_ASSERT(0 == uv_tcp_bind(svr_handle, (struct sockaddr*)addr, 0)); + GPR_ASSERT(0 == uv_listen((uv_stream_t*)svr_handle, 1, connection_cb)); gpr_mu_lock(g_mu); connections_complete_before = g_connections_complete; gpr_mu_unlock(g_mu); /* connect to it */ - GPR_ASSERT(uv_tcp_getsockname(svr_handle, (struct sockaddr *)addr, - (int *)&resolved_addr.len) == 0); + GPR_ASSERT(uv_tcp_getsockname(svr_handle, (struct sockaddr*)addr, + (int*)&resolved_addr.len) == 0); GRPC_CLOSURE_INIT(&done, must_succeed, NULL, grpc_schedule_on_exec_ctx); grpc_tcp_client_connect(&exec_ctx, &done, &g_connecting, NULL, NULL, &resolved_addr, GRPC_MILLIS_INF_FUTURE); @@ -115,7 +116,7 @@ void test_succeeds(void) { gpr_mu_lock(g_mu); while (g_connections_complete == connections_complete_before) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, @@ -127,7 +128,7 @@ void test_succeeds(void) { } // This will get cleaned up when the pollset runs again or gets shutdown - uv_close((uv_handle_t *)svr_handle, close_cb); + uv_close((uv_handle_t*)svr_handle, close_cb); gpr_mu_unlock(g_mu); @@ -136,7 +137,7 @@ void test_succeeds(void) { void test_fails(void) { grpc_resolved_address resolved_addr; - struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr; + struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr; int connections_complete_before; grpc_closure done; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -160,7 +161,7 @@ void test_fails(void) { /* wait for the connection callback to finish */ while (g_connections_complete == connections_complete_before) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); grpc_millis polling_deadline = test_deadline(); switch (grpc_timer_check(&exec_ctx, &polling_deadline)) { @@ -184,17 +185,17 @@ void test_fails(void) { grpc_exec_ctx_finish(&exec_ctx); } -static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, - grpc_error *error) { - grpc_pollset_destroy(exec_ctx, p); +static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p, + grpc_error* error) { + grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p)); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_closure destroyed; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_test_init(argc, argv); grpc_init(); - g_pollset = gpr_malloc(grpc_pollset_size()); + g_pollset = static_cast<grpc_pollset*>(gpr_malloc(grpc_pollset_size())); grpc_pollset_init(g_pollset, &g_mu); grpc_exec_ctx_finish(&exec_ctx); test_succeeds(); @@ -211,6 +212,6 @@ int main(int argc, char **argv) { #else /* GRPC_UV */ -int main(int argc, char **argv) { return 1; } +int main(int argc, char** argv) { return 1; } #endif /* GRPC_UV */ diff --git a/test/core/iomgr/tcp_posix_test.c b/test/core/iomgr/tcp_posix_test.cc index 6501160c6f..51ab0bfc6a 100644 --- a/test/core/iomgr/tcp_posix_test.c +++ b/test/core/iomgr/tcp_posix_test.cc @@ -40,8 +40,8 @@ #include "test/core/iomgr/endpoint_tests.h" #include "test/core/util/test_config.h" -static gpr_mu *g_mu; -static grpc_pollset *g_pollset; +static gpr_mu* g_mu; +static grpc_pollset* g_pollset; /* General test notes: @@ -89,7 +89,7 @@ static ssize_t fill_socket(int fd) { static size_t fill_socket_partial(int fd, size_t bytes) { ssize_t write_bytes; size_t total_bytes = 0; - unsigned char *buf = (unsigned char *)gpr_malloc(bytes); + unsigned char* buf = (unsigned char*)gpr_malloc(bytes); unsigned i; for (i = 0; i < bytes; ++i) { buf[i] = (uint8_t)(i % 256); @@ -108,18 +108,18 @@ static size_t fill_socket_partial(int fd, size_t bytes) { } struct read_socket_state { - grpc_endpoint *ep; + grpc_endpoint* ep; size_t read_bytes; size_t target_read_bytes; grpc_slice_buffer incoming; grpc_closure read_cb; }; -static size_t count_slices(grpc_slice *slices, size_t nslices, - int *current_data) { +static size_t count_slices(grpc_slice* slices, size_t nslices, + int* current_data) { size_t num_bytes = 0; unsigned i, j; - unsigned char *buf; + unsigned char* buf; for (i = 0; i < nslices; ++i) { buf = GRPC_SLICE_START_PTR(slices[i]); for (j = 0; j < GRPC_SLICE_LENGTH(slices[i]); ++j) { @@ -131,9 +131,9 @@ static size_t count_slices(grpc_slice *slices, size_t nslices, return num_bytes; } -static void read_cb(grpc_exec_ctx *exec_ctx, void *user_data, - grpc_error *error) { - struct read_socket_state *state = (struct read_socket_state *)user_data; +static void read_cb(grpc_exec_ctx* exec_ctx, void* user_data, + grpc_error* error) { + struct read_socket_state* state = (struct read_socket_state*)user_data; size_t read_bytes; int current_data; @@ -159,7 +159,7 @@ static void read_cb(grpc_exec_ctx *exec_ctx, void *user_data, /* Write to a socket, then read from it using the grpc_tcp API. */ static void read_test(size_t num_bytes, size_t slice_size) { int sv[2]; - grpc_endpoint *ep; + grpc_endpoint* ep; struct read_socket_state state; size_t written_bytes; grpc_millis deadline = @@ -171,10 +171,10 @@ static void read_test(size_t num_bytes, size_t slice_size) { create_sockets(sv); - grpc_arg a[] = {{.key = GRPC_ARG_TCP_READ_CHUNK_SIZE, - .type = GRPC_ARG_INTEGER, - .value.integer = (int)slice_size}}; - grpc_channel_args args = {.num_args = GPR_ARRAY_SIZE(a), .args = a}; + grpc_arg a[1]; + a[0].key = const_cast<char*>(GRPC_ARG_TCP_READ_CHUNK_SIZE); + a[0].type = GRPC_ARG_INTEGER, a[0].value.integer = (int)slice_size; + grpc_channel_args args = {GPR_ARRAY_SIZE(a), a}; ep = grpc_tcp_create(&exec_ctx, grpc_fd_create(sv[1], "read_test"), &args, "test"); grpc_endpoint_add_to_pollset(&exec_ctx, ep, g_pollset); @@ -192,7 +192,7 @@ static void read_test(size_t num_bytes, size_t slice_size) { gpr_mu_lock(g_mu); while (state.read_bytes < state.target_read_bytes) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline))); @@ -212,7 +212,7 @@ static void read_test(size_t num_bytes, size_t slice_size) { API. */ static void large_read_test(size_t slice_size) { int sv[2]; - grpc_endpoint *ep; + grpc_endpoint* ep; struct read_socket_state state; ssize_t written_bytes; grpc_millis deadline = @@ -223,10 +223,11 @@ static void large_read_test(size_t slice_size) { create_sockets(sv); - grpc_arg a[] = {{.key = GRPC_ARG_TCP_READ_CHUNK_SIZE, - .type = GRPC_ARG_INTEGER, - .value.integer = (int)slice_size}}; - grpc_channel_args args = {.num_args = GPR_ARRAY_SIZE(a), .args = a}; + grpc_arg a[1]; + a[0].key = const_cast<char*>(GRPC_ARG_TCP_READ_CHUNK_SIZE); + a[0].type = GRPC_ARG_INTEGER; + a[0].value.integer = (int)slice_size; + grpc_channel_args args = {GPR_ARRAY_SIZE(a), a}; ep = grpc_tcp_create(&exec_ctx, grpc_fd_create(sv[1], "large_read_test"), &args, "test"); grpc_endpoint_add_to_pollset(&exec_ctx, ep, g_pollset); @@ -244,7 +245,7 @@ static void large_read_test(size_t slice_size) { gpr_mu_lock(g_mu); while (state.read_bytes < state.target_read_bytes) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline))); @@ -261,17 +262,17 @@ static void large_read_test(size_t slice_size) { } struct write_socket_state { - grpc_endpoint *ep; + grpc_endpoint* ep; int write_done; }; -static grpc_slice *allocate_blocks(size_t num_bytes, size_t slice_size, - size_t *num_blocks, uint8_t *current_data) { +static grpc_slice* allocate_blocks(size_t num_bytes, size_t slice_size, + size_t* num_blocks, uint8_t* current_data) { size_t nslices = num_bytes / slice_size + (num_bytes % slice_size ? 1u : 0u); - grpc_slice *slices = (grpc_slice *)gpr_malloc(sizeof(grpc_slice) * nslices); + grpc_slice* slices = (grpc_slice*)gpr_malloc(sizeof(grpc_slice) * nslices); size_t num_bytes_left = num_bytes; unsigned i, j; - unsigned char *buf; + unsigned char* buf; *num_blocks = nslices; for (i = 0; i < nslices; ++i) { @@ -288,10 +289,10 @@ static grpc_slice *allocate_blocks(size_t num_bytes, size_t slice_size, return slices; } -static void write_done(grpc_exec_ctx *exec_ctx, - void *user_data /* write_socket_state */, - grpc_error *error) { - struct write_socket_state *state = (struct write_socket_state *)user_data; +static void write_done(grpc_exec_ctx* exec_ctx, + void* user_data /* write_socket_state */, + grpc_error* error) { + struct write_socket_state* state = (struct write_socket_state*)user_data; gpr_log(GPR_INFO, "Write done callback called"); gpr_mu_lock(g_mu); gpr_log(GPR_INFO, "Signalling write done"); @@ -302,7 +303,7 @@ static void write_done(grpc_exec_ctx *exec_ctx, } void drain_socket_blocking(int fd, size_t num_bytes, size_t read_size) { - unsigned char *buf = (unsigned char *)gpr_malloc(read_size); + unsigned char* buf = (unsigned char*)gpr_malloc(read_size); ssize_t bytes_read; size_t bytes_left = num_bytes; int flags; @@ -314,7 +315,7 @@ void drain_socket_blocking(int fd, size_t num_bytes, size_t read_size) { GPR_ASSERT(fcntl(fd, F_SETFL, flags & ~O_NONBLOCK) == 0); for (;;) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; gpr_mu_lock(g_mu); GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", @@ -346,10 +347,10 @@ void drain_socket_blocking(int fd, size_t num_bytes, size_t read_size) { socket in parallel with the read. */ static void write_test(size_t num_bytes, size_t slice_size) { int sv[2]; - grpc_endpoint *ep; + grpc_endpoint* ep; struct write_socket_state state; size_t num_blocks; - grpc_slice *slices; + grpc_slice* slices; uint8_t current_data = 0; grpc_slice_buffer outgoing; grpc_closure write_done_closure; @@ -363,10 +364,10 @@ static void write_test(size_t num_bytes, size_t slice_size) { create_sockets(sv); - grpc_arg a[] = {{.key = GRPC_ARG_TCP_READ_CHUNK_SIZE, - .type = GRPC_ARG_INTEGER, - .value.integer = (int)slice_size}}; - grpc_channel_args args = {.num_args = GPR_ARRAY_SIZE(a), .args = a}; + grpc_arg a[1]; + a[0].key = const_cast<char*>(GRPC_ARG_TCP_READ_CHUNK_SIZE); + a[0].type = GRPC_ARG_INTEGER, a[0].value.integer = (int)slice_size; + grpc_channel_args args = {GPR_ARRAY_SIZE(a), a}; ep = grpc_tcp_create(&exec_ctx, grpc_fd_create(sv[1], "write_test"), &args, "test"); grpc_endpoint_add_to_pollset(&exec_ctx, ep, g_pollset); @@ -385,7 +386,7 @@ static void write_test(size_t num_bytes, size_t slice_size) { drain_socket_blocking(sv[0], num_bytes, num_bytes); gpr_mu_lock(g_mu); for (;;) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; if (state.write_done) { break; } @@ -404,8 +405,8 @@ static void write_test(size_t num_bytes, size_t slice_size) { grpc_exec_ctx_finish(&exec_ctx); } -void on_fd_released(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *errors) { - int *done = (int *)arg; +void on_fd_released(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* errors) { + int* done = (int*)arg; *done = 1; GPR_ASSERT(GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(exec_ctx, g_pollset, NULL))); @@ -415,7 +416,7 @@ void on_fd_released(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *errors) { grpc_tcp_fd() is available before the fd is released. */ static void release_fd_test(size_t num_bytes, size_t slice_size) { int sv[2]; - grpc_endpoint *ep; + grpc_endpoint* ep; struct read_socket_state state; size_t written_bytes; int fd; @@ -433,10 +434,11 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) { create_sockets(sv); - grpc_arg a[] = {{.key = GRPC_ARG_TCP_READ_CHUNK_SIZE, - .type = GRPC_ARG_INTEGER, - .value.integer = (int)slice_size}}; - grpc_channel_args args = {.num_args = GPR_ARRAY_SIZE(a), .args = a}; + grpc_arg a[1]; + a[0].key = const_cast<char*>(GRPC_ARG_TCP_READ_CHUNK_SIZE); + a[0].type = GRPC_ARG_INTEGER; + a[0].value.integer = (int)slice_size; + grpc_channel_args args = {GPR_ARRAY_SIZE(a), a}; ep = grpc_tcp_create(&exec_ctx, grpc_fd_create(sv[1], "read_test"), &args, "test"); GPR_ASSERT(grpc_tcp_fd(ep) == sv[1] && sv[1] >= 0); @@ -455,7 +457,7 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) { gpr_mu_lock(g_mu); while (state.read_bytes < state.target_read_bytes) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline))); @@ -473,7 +475,7 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) { grpc_exec_ctx_flush(&exec_ctx); gpr_mu_lock(g_mu); while (!fd_released_done) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline))); @@ -523,12 +525,13 @@ static grpc_endpoint_test_fixture create_fixture_tcp_socketpair( grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; create_sockets(sv); - grpc_resource_quota *resource_quota = + grpc_resource_quota* resource_quota = grpc_resource_quota_create("tcp_posix_test_socketpair"); - grpc_arg a[] = {{.key = GRPC_ARG_TCP_READ_CHUNK_SIZE, - .type = GRPC_ARG_INTEGER, - .value.integer = (int)slice_size}}; - grpc_channel_args args = {.num_args = GPR_ARRAY_SIZE(a), .args = a}; + grpc_arg a[1]; + a[0].key = const_cast<char*>(GRPC_ARG_TCP_READ_CHUNK_SIZE); + a[0].type = GRPC_ARG_INTEGER; + a[0].value.integer = (int)slice_size; + grpc_channel_args args = {GPR_ARRAY_SIZE(a), a}; f.client_ep = grpc_tcp_create( &exec_ctx, grpc_fd_create(sv[0], "fixture:client"), &args, "test"); f.server_ep = grpc_tcp_create( @@ -546,17 +549,17 @@ static grpc_endpoint_test_config configs[] = { {"tcp/tcp_socketpair", create_fixture_tcp_socketpair, clean_up}, }; -static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, - grpc_error *error) { - grpc_pollset_destroy(exec_ctx, (grpc_pollset *)p); +static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p, + grpc_error* error) { + grpc_pollset_destroy(exec_ctx, (grpc_pollset*)p); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_closure destroyed; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_test_init(argc, argv); grpc_init(); - g_pollset = (grpc_pollset *)gpr_zalloc(grpc_pollset_size()); + g_pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size()); grpc_pollset_init(g_pollset, &g_mu); grpc_endpoint_tests(configs[0], g_pollset, g_mu); run_tests(); @@ -572,6 +575,6 @@ int main(int argc, char **argv) { #else /* GRPC_POSIX_SOCKET */ -int main(int argc, char **argv) { return 1; } +int main(int argc, char** argv) { return 1; } #endif /* GRPC_POSIX_SOCKET */ diff --git a/test/core/iomgr/tcp_server_posix_test.c b/test/core/iomgr/tcp_server_posix_test.cc index 782dfb413a..6efa74c706 100644 --- a/test/core/iomgr/tcp_server_posix_test.c +++ b/test/core/iomgr/tcp_server_posix_test.cc @@ -47,20 +47,20 @@ #define LOG_TEST(x) gpr_log(GPR_INFO, "%s", #x) -static gpr_mu *g_mu; -static grpc_pollset *g_pollset; +static gpr_mu* g_mu; +static grpc_pollset* g_pollset; static int g_nconnects = 0; typedef struct { /* Owns a ref to server. */ - grpc_tcp_server *server; + grpc_tcp_server* server; unsigned port_index; unsigned fd_index; int server_fd; } on_connect_result; typedef struct { - grpc_tcp_server *server; + grpc_tcp_server* server; /* arg is this server_weak_ref. */ grpc_closure server_shutdown; @@ -81,7 +81,7 @@ typedef struct { static on_connect_result g_result = {NULL, 0, 0, -1}; static char family_name_buf[1024]; -static const char *sock_family_name(int family) { +static const char* sock_family_name(int family) { if (family == AF_INET) { return "AF_INET"; } else if (family == AF_INET6) { @@ -94,15 +94,15 @@ static const char *sock_family_name(int family) { } } -static void on_connect_result_init(on_connect_result *result) { +static void on_connect_result_init(on_connect_result* result) { result->server = NULL; result->port_index = 0; result->fd_index = 0; result->server_fd = -1; } -static void on_connect_result_set(on_connect_result *result, - const grpc_tcp_server_acceptor *acceptor) { +static void on_connect_result_set(on_connect_result* result, + const grpc_tcp_server_acceptor* acceptor) { result->server = grpc_tcp_server_ref(acceptor->from_server); result->port_index = acceptor->port_index; result->fd_index = acceptor->fd_index; @@ -110,13 +110,13 @@ static void on_connect_result_set(on_connect_result *result, result->server, acceptor->port_index, acceptor->fd_index); } -static void server_weak_ref_shutdown(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { - server_weak_ref *weak_ref = arg; +static void server_weak_ref_shutdown(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { + server_weak_ref* weak_ref = static_cast<server_weak_ref*>(arg); weak_ref->server = NULL; } -static void server_weak_ref_init(server_weak_ref *weak_ref) { +static void server_weak_ref_init(server_weak_ref* weak_ref) { weak_ref->server = NULL; GRPC_CLOSURE_INIT(&weak_ref->server_shutdown, server_weak_ref_shutdown, weak_ref, grpc_schedule_on_exec_ctx); @@ -127,14 +127,14 @@ static void server_weak_ref_init(server_weak_ref *weak_ref) { weak_ref->server_shutdown has returned. A strong ref on grpc_tcp_server should be held until server_weak_ref_set() returns to avoid a race where the server is deleted before the shutdown_starting cb is added. */ -static void server_weak_ref_set(server_weak_ref *weak_ref, - grpc_tcp_server *server) { +static void server_weak_ref_set(server_weak_ref* weak_ref, + grpc_tcp_server* server) { grpc_tcp_server_shutdown_starting_add(server, &weak_ref->server_shutdown); weak_ref->server = server; } -static void test_addr_init_str(test_addr *addr) { - char *str = NULL; +static void test_addr_init_str(test_addr* addr) { + char* str = NULL; if (grpc_sockaddr_to_string(&str, &addr->addr, 0) != -1) { size_t str_len; memcpy(addr->str, str, (str_len = strnlen(str, sizeof(addr->str) - 1))); @@ -145,9 +145,9 @@ static void test_addr_init_str(test_addr *addr) { } } -static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp, - grpc_pollset *pollset, - grpc_tcp_server_acceptor *acceptor) { +static void on_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* tcp, + grpc_pollset* pollset, + grpc_tcp_server_acceptor* acceptor) { grpc_endpoint_shutdown(exec_ctx, tcp, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Connected")); grpc_endpoint_destroy(exec_ctx, tcp); @@ -166,7 +166,7 @@ static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp, static void test_no_op(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_tcp_server *s; + grpc_tcp_server* s; GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s)); grpc_tcp_server_unref(&exec_ctx, s); @@ -175,7 +175,7 @@ static void test_no_op(void) { static void test_no_op_with_start(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_tcp_server *s; + grpc_tcp_server* s; GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s)); LOG_TEST("test_no_op_with_start"); @@ -187,8 +187,8 @@ static void test_no_op_with_start(void) { static void test_no_op_with_port(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_resolved_address resolved_addr; - struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr; - grpc_tcp_server *s; + struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr; + grpc_tcp_server* s; GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s)); LOG_TEST("test_no_op_with_port"); @@ -208,8 +208,8 @@ static void test_no_op_with_port(void) { static void test_no_op_with_port_and_start(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_resolved_address resolved_addr; - struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr; - grpc_tcp_server *s; + struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr; + grpc_tcp_server* s; GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s)); LOG_TEST("test_no_op_with_port_and_start"); @@ -228,14 +228,14 @@ static void test_no_op_with_port_and_start(void) { grpc_exec_ctx_finish(&exec_ctx); } -static grpc_error *tcp_connect(grpc_exec_ctx *exec_ctx, const test_addr *remote, - on_connect_result *result) { +static grpc_error* tcp_connect(grpc_exec_ctx* exec_ctx, const test_addr* remote, + on_connect_result* result) { grpc_millis deadline = grpc_timespec_to_millis_round_up(grpc_timeout_seconds_to_deadline(10)); int clifd; int nconnects_before; - const struct sockaddr *remote_addr = - (const struct sockaddr *)remote->addr.addr; + const struct sockaddr* remote_addr = + (const struct sockaddr*)remote->addr.addr; gpr_log(GPR_INFO, "Connecting to %s", remote->str); gpr_mu_lock(g_mu); @@ -255,8 +255,8 @@ static grpc_error *tcp_connect(grpc_exec_ctx *exec_ctx, const test_addr *remote, gpr_log(GPR_DEBUG, "wait"); while (g_nconnects == nconnects_before && deadline > grpc_exec_ctx_now(exec_ctx)) { - grpc_pollset_worker *worker = NULL; - grpc_error *err; + grpc_pollset_worker* worker = NULL; + grpc_error* err; if ((err = grpc_pollset_work(exec_ctx, g_pollset, &worker, deadline)) != GRPC_ERROR_NONE) { gpr_mu_unlock(g_mu); @@ -290,21 +290,21 @@ static grpc_error *tcp_connect(grpc_exec_ctx *exec_ctx, const test_addr *remote, each destination address, set grpc_resolved_address::len=0 for failures, but don't fail the overall unitest. */ static void test_connect(size_t num_connects, - const grpc_channel_args *channel_args, - test_addrs *dst_addrs, bool test_dst_addrs) { + const grpc_channel_args* channel_args, + test_addrs* dst_addrs, bool test_dst_addrs) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_resolved_address resolved_addr; grpc_resolved_address resolved_addr1; - struct sockaddr_storage *const addr = - (struct sockaddr_storage *)resolved_addr.addr; - struct sockaddr_storage *const addr1 = - (struct sockaddr_storage *)resolved_addr1.addr; + struct sockaddr_storage* const addr = + (struct sockaddr_storage*)resolved_addr.addr; + struct sockaddr_storage* const addr1 = + (struct sockaddr_storage*)resolved_addr1.addr; unsigned svr_fd_count; int port; int svr_port; unsigned svr1_fd_count; int svr1_port; - grpc_tcp_server *s; + grpc_tcp_server* s; const unsigned num_ports = 2; GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(&exec_ctx, NULL, channel_args, &s)); @@ -362,7 +362,7 @@ static void test_connect(size_t num_connects, for (dst_idx = 0; dst_idx < dst_addrs->naddrs; ++dst_idx) { test_addr dst = dst_addrs->addrs[dst_idx]; on_connect_result result; - grpc_error *err; + grpc_error* err; if (dst.addr.len == 0) { gpr_log(GPR_DEBUG, "Skipping test of non-functional local IP %s", dst.str); @@ -394,8 +394,8 @@ static void test_connect(size_t num_connects, test_addr dst; GPR_ASSERT(fd >= 0); dst.addr.len = sizeof(dst.addr.addr); - GPR_ASSERT(getsockname(fd, (struct sockaddr *)dst.addr.addr, - (socklen_t *)&dst.addr.len) == 0); + GPR_ASSERT(getsockname(fd, (struct sockaddr*)dst.addr.addr, + (socklen_t*)&dst.addr.len) == 0); GPR_ASSERT(dst.addr.len <= sizeof(dst.addr.addr)); test_addr_init_str(&dst); gpr_log(GPR_INFO, "(%d, %d) fd %d family %s listening on %s", port_num, @@ -427,24 +427,27 @@ static void test_connect(size_t num_connects, GPR_ASSERT(weak_ref.server == NULL); } -static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, - grpc_error *error) { - grpc_pollset_destroy(exec_ctx, p); +static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p, + grpc_error* error) { + grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p)); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_closure destroyed; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_arg chan_args[] = { - {GRPC_ARG_INTEGER, GRPC_ARG_EXPAND_WILDCARD_ADDRS, {.integer = 1}}}; + grpc_arg chan_args[1]; + chan_args[0].type = GRPC_ARG_INTEGER; + chan_args[0].key = const_cast<char*>(GRPC_ARG_EXPAND_WILDCARD_ADDRS); + chan_args[0].value.integer = 1; const grpc_channel_args channel_args = {1, chan_args}; - struct ifaddrs *ifa = NULL; - struct ifaddrs *ifa_it; + struct ifaddrs* ifa = NULL; + struct ifaddrs* ifa_it; // Zalloc dst_addrs to avoid oversized frames. - test_addrs *dst_addrs = gpr_zalloc(sizeof(*dst_addrs)); + test_addrs* dst_addrs = + static_cast<test_addrs*>(gpr_zalloc(sizeof(*dst_addrs))); grpc_test_init(argc, argv); grpc_init(); - g_pollset = gpr_zalloc(grpc_pollset_size()); + g_pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size())); grpc_pollset_init(g_pollset, &g_mu); test_no_op(); @@ -504,6 +507,6 @@ int main(int argc, char **argv) { #else /* GRPC_POSIX_SOCKET */ -int main(int argc, char **argv) { return 1; } +int main(int argc, char** argv) { return 1; } #endif /* GRPC_POSIX_SOCKET */ diff --git a/test/core/iomgr/tcp_server_uv_test.c b/test/core/iomgr/tcp_server_uv_test.cc index 9fafd3177a..dd047a0498 100644 --- a/test/core/iomgr/tcp_server_uv_test.c +++ b/test/core/iomgr/tcp_server_uv_test.cc @@ -41,19 +41,19 @@ #define LOG_TEST(x) gpr_log(GPR_INFO, "%s", #x) -static gpr_mu *g_mu; -static grpc_pollset *g_pollset; +static gpr_mu* g_mu; +static grpc_pollset* g_pollset; static int g_nconnects = 0; typedef struct on_connect_result { /* Owns a ref to server. */ - grpc_tcp_server *server; + grpc_tcp_server* server; unsigned port_index; unsigned fd_index; } on_connect_result; typedef struct server_weak_ref { - grpc_tcp_server *server; + grpc_tcp_server* server; /* arg is this server_weak_ref. */ grpc_closure server_shutdown; @@ -61,26 +61,26 @@ typedef struct server_weak_ref { static on_connect_result g_result = {NULL, 0, 0}; -static void on_connect_result_init(on_connect_result *result) { +static void on_connect_result_init(on_connect_result* result) { result->server = NULL; result->port_index = 0; result->fd_index = 0; } -static void on_connect_result_set(on_connect_result *result, - const grpc_tcp_server_acceptor *acceptor) { +static void on_connect_result_set(on_connect_result* result, + const grpc_tcp_server_acceptor* acceptor) { result->server = grpc_tcp_server_ref(acceptor->from_server); result->port_index = acceptor->port_index; result->fd_index = acceptor->fd_index; } -static void server_weak_ref_shutdown(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { - server_weak_ref *weak_ref = arg; +static void server_weak_ref_shutdown(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { + server_weak_ref* weak_ref = static_cast<server_weak_ref*>(arg); weak_ref->server = NULL; } -static void server_weak_ref_init(server_weak_ref *weak_ref) { +static void server_weak_ref_init(server_weak_ref* weak_ref) { weak_ref->server = NULL; GRPC_CLOSURE_INIT(&weak_ref->server_shutdown, server_weak_ref_shutdown, weak_ref, grpc_schedule_on_exec_ctx); @@ -91,15 +91,15 @@ static void server_weak_ref_init(server_weak_ref *weak_ref) { weak_ref->server_shutdown has returned. A strong ref on grpc_tcp_server should be held until server_weak_ref_set() returns to avoid a race where the server is deleted before the shutdown_starting cb is added. */ -static void server_weak_ref_set(server_weak_ref *weak_ref, - grpc_tcp_server *server) { +static void server_weak_ref_set(server_weak_ref* weak_ref, + grpc_tcp_server* server) { grpc_tcp_server_shutdown_starting_add(server, &weak_ref->server_shutdown); weak_ref->server = server; } -static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp, - grpc_pollset *pollset, - grpc_tcp_server_acceptor *acceptor) { +static void on_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* tcp, + grpc_pollset* pollset, + grpc_tcp_server_acceptor* acceptor) { grpc_endpoint_shutdown(exec_ctx, tcp, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Connected")); grpc_endpoint_destroy(exec_ctx, tcp); @@ -118,7 +118,7 @@ static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp, static void test_no_op(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_tcp_server *s; + grpc_tcp_server* s; GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s)); grpc_tcp_server_unref(&exec_ctx, s); @@ -127,7 +127,7 @@ static void test_no_op(void) { static void test_no_op_with_start(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_tcp_server *s; + grpc_tcp_server* s; GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s)); LOG_TEST("test_no_op_with_start"); @@ -139,8 +139,8 @@ static void test_no_op_with_start(void) { static void test_no_op_with_port(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_resolved_address resolved_addr; - struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr; - grpc_tcp_server *s; + struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr; + grpc_tcp_server* s; GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s)); LOG_TEST("test_no_op_with_port"); @@ -160,8 +160,8 @@ static void test_no_op_with_port(void) { static void test_no_op_with_port_and_start(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_resolved_address resolved_addr; - struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr; - grpc_tcp_server *s; + struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr; + grpc_tcp_server* s; GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s)); LOG_TEST("test_no_op_with_port_and_start"); @@ -180,18 +180,20 @@ static void test_no_op_with_port_and_start(void) { grpc_exec_ctx_finish(&exec_ctx); } -static void connect_cb(uv_connect_t *req, int status) { +static void connect_cb(uv_connect_t* req, int status) { GPR_ASSERT(status == 0); gpr_free(req); } -static void close_cb(uv_handle_t *handle) { gpr_free(handle); } +static void close_cb(uv_handle_t* handle) { gpr_free(handle); } -static void tcp_connect(grpc_exec_ctx *exec_ctx, const struct sockaddr *remote, - socklen_t remote_len, on_connect_result *result) { +static void tcp_connect(grpc_exec_ctx* exec_ctx, const struct sockaddr* remote, + socklen_t remote_len, on_connect_result* result) { gpr_timespec deadline = grpc_timeout_seconds_to_deadline(10); - uv_tcp_t *client_handle = gpr_malloc(sizeof(uv_tcp_t)); - uv_connect_t *req = gpr_malloc(sizeof(uv_connect_t)); + uv_tcp_t* client_handle = + static_cast<uv_tcp_t*>(gpr_malloc(sizeof(uv_tcp_t))); + uv_connect_t* req = + static_cast<uv_connect_t*>(gpr_malloc(sizeof(uv_connect_t))); int nconnects_before; gpr_mu_lock(g_mu); @@ -203,7 +205,7 @@ static void tcp_connect(grpc_exec_ctx *exec_ctx, const struct sockaddr *remote, gpr_log(GPR_DEBUG, "wait"); while (g_nconnects == nconnects_before && gpr_time_cmp(deadline, gpr_now(deadline.clock_type)) > 0) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(exec_ctx, g_pollset, &worker, @@ -214,7 +216,7 @@ static void tcp_connect(grpc_exec_ctx *exec_ctx, const struct sockaddr *remote, } gpr_log(GPR_DEBUG, "wait done"); GPR_ASSERT(g_nconnects == nconnects_before + 1); - uv_close((uv_handle_t *)client_handle, close_cb); + uv_close((uv_handle_t*)client_handle, close_cb); *result = g_result; gpr_mu_unlock(g_mu); @@ -225,12 +227,12 @@ static void test_connect(unsigned n) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_resolved_address resolved_addr; grpc_resolved_address resolved_addr1; - struct sockaddr_storage *addr = (struct sockaddr_storage *)resolved_addr.addr; - struct sockaddr_storage *addr1 = - (struct sockaddr_storage *)resolved_addr1.addr; + struct sockaddr_storage* addr = (struct sockaddr_storage*)resolved_addr.addr; + struct sockaddr_storage* addr1 = + (struct sockaddr_storage*)resolved_addr1.addr; int svr_port; int svr1_port; - grpc_tcp_server *s; + grpc_tcp_server* s; GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(&exec_ctx, NULL, NULL, &s)); unsigned i; @@ -246,7 +248,7 @@ static void test_connect(unsigned n) { GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_add_port(s, &resolved_addr, &svr_port)); GPR_ASSERT(svr_port > 0); - GPR_ASSERT((uv_ip6_addr("::", svr_port, (struct sockaddr_in6 *)addr)) == 0); + GPR_ASSERT((uv_ip6_addr("::", svr_port, (struct sockaddr_in6*)addr)) == 0); /* Cannot use wildcard (port==0), because add_port() will try to reuse the same port as a previous add_port(). */ svr1_port = grpc_pick_unused_port_or_die(); @@ -257,13 +259,13 @@ static void test_connect(unsigned n) { grpc_tcp_server_start(&exec_ctx, s, &g_pollset, 1, on_connect, NULL); - GPR_ASSERT(uv_ip6_addr("::", svr_port, (struct sockaddr_in6 *)addr1) == 0); + GPR_ASSERT(uv_ip6_addr("::", svr_port, (struct sockaddr_in6*)addr1) == 0); for (i = 0; i < n; i++) { on_connect_result result; on_connect_result_init(&result); - tcp_connect(&exec_ctx, (struct sockaddr *)addr, - (socklen_t)resolved_addr.len, &result); + tcp_connect(&exec_ctx, (struct sockaddr*)addr, (socklen_t)resolved_addr.len, + &result); GPR_ASSERT(result.port_index == 0); GPR_ASSERT(result.server == s); if (weak_ref.server == NULL) { @@ -272,7 +274,7 @@ static void test_connect(unsigned n) { grpc_tcp_server_unref(&exec_ctx, result.server); on_connect_result_init(&result); - tcp_connect(&exec_ctx, (struct sockaddr *)addr1, + tcp_connect(&exec_ctx, (struct sockaddr*)addr1, (socklen_t)resolved_addr1.len, &result); GPR_ASSERT(result.port_index == 1); GPR_ASSERT(result.server == s); @@ -289,17 +291,17 @@ static void test_connect(unsigned n) { GPR_ASSERT(weak_ref.server == NULL); } -static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, - grpc_error *error) { - grpc_pollset_destroy(exec_ctx, p); +static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p, + grpc_error* error) { + grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p)); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_closure destroyed; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_test_init(argc, argv); grpc_init(); - g_pollset = gpr_malloc(grpc_pollset_size()); + g_pollset = static_cast<grpc_pollset*>(gpr_malloc(grpc_pollset_size())); grpc_pollset_init(g_pollset, &g_mu); test_no_op(); @@ -320,6 +322,6 @@ int main(int argc, char **argv) { #else /* GRPC_UV */ -int main(int argc, char **argv) { return 1; } +int main(int argc, char** argv) { return 1; } #endif /* GRPC_UV */ diff --git a/test/core/iomgr/time_averaged_stats_test.c b/test/core/iomgr/time_averaged_stats_test.cc index 508e3c5bf8..b932e62d1f 100644 --- a/test/core/iomgr/time_averaged_stats_test.c +++ b/test/core/iomgr/time_averaged_stats_test.cc @@ -179,7 +179,7 @@ static void some_regress_some_persist_test(void) { EXPECT_DOUBLE_EQ(2.8304, tas.aggregate_total_weight); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); no_regress_no_persist_test_1(); no_regress_no_persist_test_2(); diff --git a/test/core/iomgr/timer_heap_test.c b/test/core/iomgr/timer_heap_test.cc index ee5a474fd1..20a383371d 100644 --- a/test/core/iomgr/timer_heap_test.c +++ b/test/core/iomgr/timer_heap_test.cc @@ -34,8 +34,9 @@ static gpr_atm random_deadline(void) { return rand(); } -static grpc_timer *create_test_elements(size_t num_elements) { - grpc_timer *elems = gpr_malloc(num_elements * sizeof(grpc_timer)); +static grpc_timer* create_test_elements(size_t num_elements) { + grpc_timer* elems = + static_cast<grpc_timer*>(gpr_malloc(num_elements * sizeof(grpc_timer))); size_t i; for (i = 0; i < num_elements; i++) { elems[i].deadline = random_deadline(); @@ -43,7 +44,7 @@ static grpc_timer *create_test_elements(size_t num_elements) { return elems; } -static int contains(grpc_timer_heap *pq, grpc_timer *el) { +static int contains(grpc_timer_heap* pq, grpc_timer* el) { size_t i; for (i = 0; i < pq->timer_count; i++) { if (pq->timers[i] == el) return 1; @@ -51,7 +52,7 @@ static int contains(grpc_timer_heap *pq, grpc_timer *el) { return 0; } -static void check_valid(grpc_timer_heap *pq) { +static void check_valid(grpc_timer_heap* pq) { size_t i; for (i = 0; i < pq->timer_count; ++i) { size_t left_child = 1u + 2u * i; @@ -74,8 +75,8 @@ static void test1(void) { const size_t num_test_elements = 200; const size_t num_test_operations = 10000; size_t i; - grpc_timer *test_elements = create_test_elements(num_test_elements); - uint8_t *inpq = gpr_malloc(num_test_elements); + grpc_timer* test_elements = create_test_elements(num_test_elements); + uint8_t* inpq = static_cast<uint8_t*>(gpr_malloc(num_test_elements)); gpr_log(GPR_INFO, "test1"); @@ -102,7 +103,7 @@ static void test1(void) { for (i = 0; i < num_test_operations; ++i) { size_t elem_num = (size_t)rand() % num_test_elements; - grpc_timer *el = &test_elements[elem_num]; + grpc_timer* el = &test_elements[elem_num]; if (!inpq[elem_num]) { /* not in pq */ GPR_ASSERT(!contains(&pq, el)); el->deadline = random_deadline(); @@ -133,9 +134,10 @@ typedef struct { bool inserted; } elem_struct; -static elem_struct *search_elems(elem_struct *elems, size_t count, +static elem_struct* search_elems(elem_struct* elems, size_t count, bool inserted) { - size_t *search_order = gpr_malloc(count * sizeof(*search_order)); + size_t* search_order = + static_cast<size_t*>(gpr_malloc(count * sizeof(*search_order))); for (size_t i = 0; i < count; i++) { search_order[i] = i; } @@ -144,7 +146,7 @@ static elem_struct *search_elems(elem_struct *elems, size_t count, size_t b = (size_t)rand() % count; GPR_SWAP(size_t, search_order[a], search_order[b]); } - elem_struct *out = NULL; + elem_struct* out = NULL; for (size_t i = 0; out == NULL && i < count; i++) { if (elems[search_order[i]].inserted == inserted) { out = &elems[search_order[i]]; @@ -160,7 +162,8 @@ static void test2(void) { grpc_timer_heap pq; static const size_t elems_size = 1000; - elem_struct *elems = gpr_malloc(elems_size * sizeof(elem_struct)); + elem_struct* elems = + static_cast<elem_struct*>(gpr_malloc(elems_size * sizeof(elem_struct))); size_t num_inserted = 0; grpc_timer_heap_init(&pq); @@ -170,7 +173,7 @@ static void test2(void) { int r = rand() % 1000; if (r <= 550) { /* 55% of the time we try to add something */ - elem_struct *el = search_elems(elems, GPR_ARRAY_SIZE(elems), false); + elem_struct* el = search_elems(elems, GPR_ARRAY_SIZE(elems), false); if (el != NULL) { el->elem.deadline = random_deadline(); grpc_timer_heap_add(&pq, &el->elem); @@ -180,7 +183,7 @@ static void test2(void) { } } else if (r <= 650) { /* 10% of the time we try to remove something */ - elem_struct *el = search_elems(elems, GPR_ARRAY_SIZE(elems), true); + elem_struct* el = search_elems(elems, GPR_ARRAY_SIZE(elems), true); if (el != NULL) { grpc_timer_heap_remove(&pq, &el->elem); el->inserted = false; @@ -190,7 +193,7 @@ static void test2(void) { } else { /* the remaining times we pop */ if (num_inserted > 0) { - grpc_timer *top = grpc_timer_heap_top(&pq); + grpc_timer* top = grpc_timer_heap_top(&pq); grpc_timer_heap_pop(&pq); for (size_t i = 0; i < elems_size; i++) { if (top == &elems[i].elem) { @@ -204,7 +207,7 @@ static void test2(void) { } if (num_inserted) { - gpr_atm *min_deadline = NULL; + gpr_atm* min_deadline = NULL; for (size_t i = 0; i < elems_size; i++) { if (elems[i].inserted) { if (min_deadline == NULL) { @@ -246,7 +249,7 @@ static void shrink_test(void) { /* Remove elements until the Size is 1/4 the original size. */ while (pq.timer_count > num_elements / 4) { - grpc_timer *const te = pq.timers[pq.timer_count - 1]; + grpc_timer* const te = pq.timers[pq.timer_count - 1]; grpc_timer_heap_remove(&pq, te); gpr_free(te); } @@ -263,7 +266,7 @@ static void shrink_test(void) { expected_size = pq.timer_count; while (pq.timer_count > 0) { const size_t which = (size_t)rand() % pq.timer_count; - grpc_timer *te = pq.timers[which]; + grpc_timer* te = pq.timers[which]; grpc_timer_heap_remove(&pq, te); gpr_free(te); expected_size--; @@ -283,7 +286,7 @@ static void shrink_test(void) { grpc_timer_heap_destroy(&pq); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { int i; grpc_test_init(argc, argv); @@ -299,6 +302,6 @@ int main(int argc, char **argv) { #else /* GRPC_TIMER_USE_GENERIC */ -int main(int argc, char **argv) { return 1; } +int main(int argc, char** argv) { return 1; } #endif /* GRPC_TIMER_USE_GENERIC */ diff --git a/test/core/iomgr/timer_list_test.c b/test/core/iomgr/timer_list_test.cc index c3d9f9d88d..8783c5c6d7 100644 --- a/test/core/iomgr/timer_list_test.c +++ b/test/core/iomgr/timer_list_test.cc @@ -31,12 +31,12 @@ #define MAX_CB 30 -extern grpc_tracer_flag grpc_timer_trace; -extern grpc_tracer_flag grpc_timer_check_trace; +extern "C" grpc_tracer_flag grpc_timer_trace; +extern "C" grpc_tracer_flag grpc_timer_check_trace; static int cb_called[MAX_CB][2]; -static void cb(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { +static void cb(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { cb_called[(intptr_t)arg][error == GRPC_ERROR_NONE]++; } @@ -56,16 +56,16 @@ static void add_test(void) { /* 10 ms timers. will expire in the current epoch */ for (i = 0; i < 10; i++) { - grpc_timer_init(&exec_ctx, &timers[i], start + 10, - GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)i, - grpc_schedule_on_exec_ctx)); + grpc_timer_init( + &exec_ctx, &timers[i], start + 10, + GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)i, grpc_schedule_on_exec_ctx)); } /* 1010 ms timers. will expire in the next epoch */ for (i = 10; i < 20; i++) { - grpc_timer_init(&exec_ctx, &timers[i], start + 1010, - GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)i, - grpc_schedule_on_exec_ctx)); + grpc_timer_init( + &exec_ctx, &timers[i], start + 1010, + GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)i, grpc_schedule_on_exec_ctx)); } /* collect timers. Only the first batch should be ready. */ @@ -123,19 +123,19 @@ void destruction_test(void) { grpc_timer_init( &exec_ctx, &timers[0], 100, - GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)0, grpc_schedule_on_exec_ctx)); + GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)0, grpc_schedule_on_exec_ctx)); grpc_timer_init( &exec_ctx, &timers[1], 3, - GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)1, grpc_schedule_on_exec_ctx)); + GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)1, grpc_schedule_on_exec_ctx)); grpc_timer_init( &exec_ctx, &timers[2], 100, - GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)2, grpc_schedule_on_exec_ctx)); + GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)2, grpc_schedule_on_exec_ctx)); grpc_timer_init( &exec_ctx, &timers[3], 3, - GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)3, grpc_schedule_on_exec_ctx)); + GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)3, grpc_schedule_on_exec_ctx)); grpc_timer_init( &exec_ctx, &timers[4], 1, - GRPC_CLOSURE_CREATE(cb, (void *)(intptr_t)4, grpc_schedule_on_exec_ctx)); + GRPC_CLOSURE_CREATE(cb, (void*)(intptr_t)4, grpc_schedule_on_exec_ctx)); exec_ctx.now = 2; GPR_ASSERT(grpc_timer_check(&exec_ctx, NULL) == GRPC_TIMERS_FIRED); grpc_exec_ctx_finish(&exec_ctx); @@ -152,7 +152,7 @@ void destruction_test(void) { GPR_ASSERT(1 == cb_called[2][0]); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); gpr_set_log_verbosity(GPR_LOG_SEVERITY_DEBUG); add_test(); @@ -162,6 +162,6 @@ int main(int argc, char **argv) { #else /* GRPC_TIMER_USE_GENERIC */ -int main(int argc, char **argv) { return 1; } +int main(int argc, char** argv) { return 1; } #endif /* GRPC_TIMER_USE_GENERIC */ diff --git a/test/core/iomgr/udp_server_test.c b/test/core/iomgr/udp_server_test.cc index 2e44d0abc8..4e8f234a8b 100644 --- a/test/core/iomgr/udp_server_test.c +++ b/test/core/iomgr/udp_server_test.cc @@ -43,14 +43,14 @@ #define LOG_TEST(x) gpr_log(GPR_INFO, "%s", #x) -static grpc_pollset *g_pollset; -static gpr_mu *g_mu; +static grpc_pollset* g_pollset; +static gpr_mu* g_mu; static int g_number_of_reads = 0; static int g_number_of_writes = 0; static int g_number_of_bytes_read = 0; static int g_number_of_orphan_calls = 0; -static void on_read(grpc_exec_ctx *exec_ctx, grpc_fd *emfd, void *user_data) { +static void on_read(grpc_exec_ctx* exec_ctx, grpc_fd* emfd, void* user_data) { char read_buffer[512]; ssize_t byte_count; @@ -66,7 +66,7 @@ static void on_read(grpc_exec_ctx *exec_ctx, grpc_fd *emfd, void *user_data) { gpr_mu_unlock(g_mu); } -static void on_write(grpc_exec_ctx *exec_ctx, grpc_fd *emfd, void *user_data) { +static void on_write(grpc_exec_ctx* exec_ctx, grpc_fd* emfd, void* user_data) { gpr_mu_lock(g_mu); g_number_of_writes++; @@ -75,8 +75,8 @@ static void on_write(grpc_exec_ctx *exec_ctx, grpc_fd *emfd, void *user_data) { gpr_mu_unlock(g_mu); } -static void on_fd_orphaned(grpc_exec_ctx *exec_ctx, grpc_fd *emfd, - grpc_closure *closure, void *user_data) { +static void on_fd_orphaned(grpc_exec_ctx* exec_ctx, grpc_fd* emfd, + grpc_closure* closure, void* user_data) { gpr_log(GPR_INFO, "gRPC FD about to be orphaned: %d", grpc_fd_wrapped_fd(emfd)); g_number_of_orphan_calls++; @@ -89,27 +89,27 @@ struct test_socket_factory { }; typedef struct test_socket_factory test_socket_factory; -static int test_socket_factory_socket(grpc_socket_factory *factory, int domain, +static int test_socket_factory_socket(grpc_socket_factory* factory, int domain, int type, int protocol) { - test_socket_factory *f = (test_socket_factory *)factory; + test_socket_factory* f = (test_socket_factory*)factory; f->number_of_socket_calls++; return socket(domain, type, protocol); } -static int test_socket_factory_bind(grpc_socket_factory *factory, int sockfd, - const grpc_resolved_address *addr) { - test_socket_factory *f = (test_socket_factory *)factory; +static int test_socket_factory_bind(grpc_socket_factory* factory, int sockfd, + const grpc_resolved_address* addr) { + test_socket_factory* f = (test_socket_factory*)factory; f->number_of_bind_calls++; - return bind(sockfd, (struct sockaddr *)addr->addr, (socklen_t)addr->len); + return bind(sockfd, (struct sockaddr*)addr->addr, (socklen_t)addr->len); } -static int test_socket_factory_compare(grpc_socket_factory *a, - grpc_socket_factory *b) { +static int test_socket_factory_compare(grpc_socket_factory* a, + grpc_socket_factory* b) { return GPR_ICMP(a, b); } -static void test_socket_factory_destroy(grpc_socket_factory *factory) { - test_socket_factory *f = (test_socket_factory *)factory; +static void test_socket_factory_destroy(grpc_socket_factory* factory) { + test_socket_factory* f = (test_socket_factory*)factory; gpr_free(f); } @@ -117,8 +117,9 @@ static const grpc_socket_factory_vtable test_socket_factory_vtable = { test_socket_factory_socket, test_socket_factory_bind, test_socket_factory_compare, test_socket_factory_destroy}; -static test_socket_factory *test_socket_factory_create(void) { - test_socket_factory *factory = gpr_malloc(sizeof(test_socket_factory)); +static test_socket_factory* test_socket_factory_create(void) { + test_socket_factory* factory = static_cast<test_socket_factory*>( + gpr_malloc(sizeof(test_socket_factory))); grpc_socket_factory_init(&factory->base, &test_socket_factory_vtable); factory->number_of_socket_calls = 0; factory->number_of_bind_calls = 0; @@ -127,14 +128,14 @@ static test_socket_factory *test_socket_factory_create(void) { static void test_no_op(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_udp_server *s = grpc_udp_server_create(NULL); + grpc_udp_server* s = grpc_udp_server_create(NULL); grpc_udp_server_destroy(&exec_ctx, s, NULL); grpc_exec_ctx_finish(&exec_ctx); } static void test_no_op_with_start(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_udp_server *s = grpc_udp_server_create(NULL); + grpc_udp_server* s = grpc_udp_server_create(NULL); LOG_TEST("test_no_op_with_start"); grpc_udp_server_start(&exec_ctx, s, NULL, 0, NULL); grpc_udp_server_destroy(&exec_ctx, s, NULL); @@ -145,8 +146,8 @@ static void test_no_op_with_port(void) { g_number_of_orphan_calls = 0; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_resolved_address resolved_addr; - struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr; - grpc_udp_server *s = grpc_udp_server_create(NULL); + struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr; + grpc_udp_server* s = grpc_udp_server_create(NULL); LOG_TEST("test_no_op_with_port"); memset(&resolved_addr, 0, sizeof(resolved_addr)); @@ -166,14 +167,14 @@ static void test_no_op_with_port_and_socket_factory(void) { g_number_of_orphan_calls = 0; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_resolved_address resolved_addr; - struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr; + struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr; - test_socket_factory *socket_factory = test_socket_factory_create(); + test_socket_factory* socket_factory = test_socket_factory_create(); grpc_arg socket_factory_arg = grpc_socket_factory_to_arg(&socket_factory->base); - grpc_channel_args *channel_args = + grpc_channel_args* channel_args = grpc_channel_args_copy_and_add(NULL, &socket_factory_arg, 1); - grpc_udp_server *s = grpc_udp_server_create(channel_args); + grpc_udp_server* s = grpc_udp_server_create(channel_args); grpc_channel_args_destroy(&exec_ctx, channel_args); LOG_TEST("test_no_op_with_port_and_socket_factory"); @@ -198,8 +199,8 @@ static void test_no_op_with_port_and_start(void) { g_number_of_orphan_calls = 0; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_resolved_address resolved_addr; - struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr; - grpc_udp_server *s = grpc_udp_server_create(NULL); + struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr; + grpc_udp_server* s = grpc_udp_server_create(NULL); LOG_TEST("test_no_op_with_port_and_start"); memset(&resolved_addr, 0, sizeof(resolved_addr)); @@ -221,13 +222,13 @@ static void test_no_op_with_port_and_start(void) { static void test_receive(int number_of_clients) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_resolved_address resolved_addr; - struct sockaddr_storage *addr = (struct sockaddr_storage *)resolved_addr.addr; + struct sockaddr_storage* addr = (struct sockaddr_storage*)resolved_addr.addr; int clifd, svrfd; - grpc_udp_server *s = grpc_udp_server_create(NULL); + grpc_udp_server* s = grpc_udp_server_create(NULL); int i; int number_of_reads_before; grpc_millis deadline; - grpc_pollset *pollsets[1]; + grpc_pollset* pollsets[1]; LOG_TEST("test_receive"); gpr_log(GPR_INFO, "clients=%d", number_of_clients); @@ -242,8 +243,8 @@ static void test_receive(int number_of_clients) { svrfd = grpc_udp_server_get_fd(s, 0); GPR_ASSERT(svrfd >= 0); - GPR_ASSERT(getsockname(svrfd, (struct sockaddr *)addr, - (socklen_t *)&resolved_addr.len) == 0); + GPR_ASSERT(getsockname(svrfd, (struct sockaddr*)addr, + (socklen_t*)&resolved_addr.len) == 0); GPR_ASSERT(resolved_addr.len <= sizeof(struct sockaddr_storage)); pollsets[0] = g_pollset; @@ -259,12 +260,12 @@ static void test_receive(int number_of_clients) { /* Create a socket, send a packet to the UDP server. */ clifd = socket(addr->ss_family, SOCK_DGRAM, 0); GPR_ASSERT(clifd >= 0); - GPR_ASSERT(connect(clifd, (struct sockaddr *)addr, + GPR_ASSERT(connect(clifd, (struct sockaddr*)addr, (socklen_t)resolved_addr.len) == 0); GPR_ASSERT(5 == write(clifd, "hello", 5)); while (g_number_of_reads == number_of_reads_before && deadline > grpc_exec_ctx_now(&exec_ctx)) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, g_pollset, &worker, deadline))); @@ -290,17 +291,17 @@ static void test_receive(int number_of_clients) { GPR_ASSERT(g_number_of_writes > 0); } -static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, - grpc_error *error) { - grpc_pollset_destroy(exec_ctx, p); +static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p, + grpc_error* error) { + grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p)); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_closure destroyed; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_test_init(argc, argv); grpc_init(); - g_pollset = gpr_zalloc(grpc_pollset_size()); + g_pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size())); grpc_pollset_init(g_pollset, &g_mu); test_no_op(); @@ -322,6 +323,6 @@ int main(int argc, char **argv) { #else /* GRPC_POSIX_SOCKET */ -int main(int argc, char **argv) { return 1; } +int main(int argc, char** argv) { return 1; } #endif /* GRPC_POSIX_SOCKET */ diff --git a/test/core/iomgr/wakeup_fd_cv_test.c b/test/core/iomgr/wakeup_fd_cv_test.cc index 0b211274f2..dc1d77a0ab 100644 --- a/test/core/iomgr/wakeup_fd_cv_test.c +++ b/test/core/iomgr/wakeup_fd_cv_test.cc @@ -32,7 +32,7 @@ #include "src/core/lib/support/env.h" typedef struct poll_args { - struct pollfd *fds; + struct pollfd* fds; nfds_t nfds; int timeout; int result; @@ -57,7 +57,7 @@ void reset_socket_event() { } // Mocks posix poll() function -int mock_poll(struct pollfd *fds, nfds_t nfds, int timeout) { +int mock_poll(struct pollfd* fds, nfds_t nfds, int timeout) { int res = 0; gpr_timespec poll_time; gpr_mu_lock(&poll_mu); @@ -84,8 +84,8 @@ int mock_poll(struct pollfd *fds, nfds_t nfds, int timeout) { return res; } -void background_poll(void *args) { - poll_args *pargs = (poll_args *)args; +void background_poll(void* args) { + poll_args* pargs = (poll_args*)args; pargs->result = grpc_poll_function(pargs->fds, pargs->nfds, pargs->timeout); } @@ -211,7 +211,7 @@ void test_poll_cv_trigger(void) { GPR_ASSERT(pfds[5].revents == 0); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { gpr_setenv("GRPC_POLL_STRATEGY", "poll-cv"); grpc_poll_function = &mock_poll; gpr_mu_init(&poll_mu); @@ -229,6 +229,6 @@ int main(int argc, char **argv) { #else /* GRPC_POSIX_SOCKET */ -int main(int argc, char **argv) { return 1; } +int main(int argc, char** argv) { return 1; } #endif /* GRPC_POSIX_SOCKET */ |