diff options
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) | 11 | ||||
-rw-r--r-- | test/core/iomgr/endpoint_pair_test.cc (renamed from test/core/iomgr/endpoint_pair_test.c) | 13 | ||||
-rw-r--r-- | test/core/iomgr/endpoint_tests.cc (renamed from test/core/iomgr/endpoint_tests.c) | 0 | ||||
-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) | 11 | ||||
-rw-r--r-- | test/core/iomgr/fd_conservation_posix_test.cc (renamed from test/core/iomgr/fd_conservation_posix_test.c) | 0 | ||||
-rw-r--r-- | test/core/iomgr/fd_posix_test.cc (renamed from test/core/iomgr/fd_posix_test.c) | 22 | ||||
-rw-r--r-- | test/core/iomgr/load_file_test.cc (renamed from test/core/iomgr/load_file_test.c) | 2 | ||||
-rw-r--r-- | test/core/iomgr/pollset_set_test.cc (renamed from test/core/iomgr/pollset_set_test.c) | 5 | ||||
-rw-r--r-- | test/core/iomgr/resolve_address_posix_test.cc (renamed from test/core/iomgr/resolve_address_posix_test.c) | 11 | ||||
-rw-r--r-- | test/core/iomgr/resolve_address_test.cc (renamed from test/core/iomgr/resolve_address_test.c) | 6 | ||||
-rw-r--r-- | test/core/iomgr/resource_quota_test.cc (renamed from test/core/iomgr/resource_quota_test.c) | 8 | ||||
-rw-r--r-- | test/core/iomgr/sockaddr_utils_test.cc (renamed from test/core/iomgr/sockaddr_utils_test.c) | 0 | ||||
-rw-r--r-- | test/core/iomgr/socket_utils_test.cc (renamed from test/core/iomgr/socket_utils_test.c) | 0 | ||||
-rw-r--r-- | test/core/iomgr/tcp_client_posix_test.cc (renamed from test/core/iomgr/tcp_client_posix_test.c) | 4 | ||||
-rw-r--r-- | test/core/iomgr/tcp_client_uv_test.cc (renamed from test/core/iomgr/tcp_client_uv_test.c) | 9 | ||||
-rw-r--r-- | test/core/iomgr/tcp_posix_test.cc (renamed from test/core/iomgr/tcp_posix_test.c) | 43 | ||||
-rw-r--r-- | test/core/iomgr/tcp_server_posix_test.cc (renamed from test/core/iomgr/tcp_server_posix_test.c) | 15 | ||||
-rw-r--r-- | test/core/iomgr/tcp_server_uv_test.cc (renamed from test/core/iomgr/tcp_server_uv_test.c) | 12 | ||||
-rw-r--r-- | test/core/iomgr/time_averaged_stats_test.cc (renamed from test/core/iomgr/time_averaged_stats_test.c) | 0 | ||||
-rw-r--r-- | test/core/iomgr/timer_heap_test.cc (renamed from test/core/iomgr/timer_heap_test.c) | 11 | ||||
-rw-r--r-- | test/core/iomgr/timer_list_test.cc (renamed from test/core/iomgr/timer_list_test.c) | 4 | ||||
-rw-r--r-- | test/core/iomgr/udp_server_test.cc (renamed from test/core/iomgr/udp_server_test.c) | 7 | ||||
-rw-r--r-- | test/core/iomgr/wakeup_fd_cv_test.cc (renamed from test/core/iomgr/wakeup_fd_cv_test.c) | 0 |
25 files changed, 149 insertions, 129 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 063bcb6433..5a825368f7 100644 --- a/test/core/iomgr/combiner_test.c +++ b/test/core/iomgr/combiner_test.cc @@ -35,7 +35,7 @@ static void test_no_op(void) { static void set_event_to_true(grpc_exec_ctx* exec_ctx, void* value, grpc_error* error) { - gpr_event_set(value, (void*)1); + gpr_event_set(static_cast<gpr_event*>(value), (void*)1); } static void test_execute_one(void) { @@ -68,19 +68,19 @@ typedef struct { } ex_args; static void check_one(grpc_exec_ctx* exec_ctx, void* a, grpc_error* error) { - ex_args* args = a; + 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; + 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, @@ -133,7 +133,8 @@ static void in_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); } diff --git a/test/core/iomgr/endpoint_pair_test.c b/test/core/iomgr/endpoint_pair_test.cc index 795061f2c3..30a0cb5924 100644 --- a/test/core/iomgr/endpoint_pair_test.c +++ b/test/core/iomgr/endpoint_pair_test.cc @@ -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; @@ -55,7 +56,7 @@ static grpc_endpoint_test_config configs[] = { static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p, grpc_error* error) { - grpc_pollset_destroy(exec_ctx, p); + grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p)); } int main(int argc, char** argv) { @@ -63,7 +64,7 @@ int main(int argc, char** argv) { 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 8e859ba909..8e859ba909 100644 --- a/test/core/iomgr/endpoint_tests.c +++ b/test/core/iomgr/endpoint_tests.cc 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 2170f5c573..3ee607d97e 100644 --- a/test/core/iomgr/ev_epollsig_linux_test.c +++ b/test/core/iomgr/ev_epollsig_linux_test.cc @@ -92,14 +92,15 @@ static void test_fd_cleanup(grpc_exec_ctx* exec_ctx, test_fd* tfds, 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); + grpc_pollset_destroy(exec_ctx, (grpc_pollset*)p); } static void test_pollset_cleanup(grpc_exec_ctx* exec_ctx, @@ -232,7 +233,7 @@ typedef struct threading_shared { static __thread int thread_wakeups = 0; static void test_threading_loop(void* arg) { - threading_shared* shared = 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; @@ -247,7 +248,7 @@ 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; + 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]; diff --git a/test/core/iomgr/fd_conservation_posix_test.c b/test/core/iomgr/fd_conservation_posix_test.cc index b76c247fb8..b76c247fb8 100644 --- a/test/core/iomgr/fd_conservation_posix_test.c +++ b/test/core/iomgr/fd_conservation_posix_test.cc diff --git a/test/core/iomgr/fd_posix_test.c b/test/core/iomgr/fd_posix_test.cc index d19ce18081..c70187ce91 100644 --- a/test/core/iomgr/fd_posix_test.c +++ b/test/core/iomgr/fd_posix_test.cc @@ -113,7 +113,7 @@ typedef struct { Close session FD and start to shutdown listen FD. */ static void session_shutdown_cb(grpc_exec_ctx* exec_ctx, void* arg, /*session */ bool success) { - session* se = arg; + session* se = static_cast<session*>(arg); server* sv = se->sv; grpc_fd_orphan(exec_ctx, se->em_fd, NULL, NULL, false /* already_closed */, "a"); @@ -126,7 +126,7 @@ 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; + session* se = static_cast<session*>(arg); int fd = grpc_fd_wrapped_fd(se->em_fd); ssize_t read_once = 0; @@ -171,7 +171,7 @@ static void session_read_cb(grpc_exec_ctx* exec_ctx, void* arg, /*session */ Close listen FD and signal that server can be shutdown. */ 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"); @@ -186,7 +186,7 @@ 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; + server* sv = static_cast<server*>(arg); int fd; int flags; session* se; @@ -204,7 +204,7 @@ static void listen_cb(grpc_exec_ctx* exec_ctx, void* arg, /*=sv_arg*/ 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); @@ -291,7 +291,7 @@ 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; + client* cl = static_cast<client*>(arg); grpc_fd_orphan(exec_ctx, cl->em_fd, NULL, NULL, false /* already_closed */, "c"); cl->done = 1; @@ -302,7 +302,7 @@ 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; + client* cl = static_cast<client*>(arg); int fd = grpc_fd_wrapped_fd(cl->em_fd); ssize_t write_once = 0; @@ -409,7 +409,7 @@ 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; + fd_change_data* fdc = static_cast<fd_change_data*>(arg); gpr_mu_lock(g_mu); fdc->cb_that_ran = first_read_callback; @@ -421,7 +421,7 @@ static void first_read_callback(grpc_exec_ctx* exec_ctx, static void second_read_callback(grpc_exec_ctx* exec_ctx, void* arg /* fd_change_data */, grpc_error* error) { - fd_change_data* fdc = arg; + fd_change_data* fdc = static_cast<fd_change_data*>(arg); gpr_mu_lock(g_mu); fdc->cb_that_ran = second_read_callback; @@ -516,7 +516,7 @@ static void test_grpc_fd_change(void) { static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p, grpc_error* error) { - grpc_pollset_destroy(exec_ctx, p); + grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p)); } int main(int argc, char** argv) { @@ -524,7 +524,7 @@ int main(int argc, char** argv) { 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(); diff --git a/test/core/iomgr/load_file_test.c b/test/core/iomgr/load_file_test.cc index f07900373e..2c9e7c33f4 100644 --- a/test/core/iomgr/load_file_test.c +++ b/test/core/iomgr/load_file_test.cc @@ -122,7 +122,7 @@ static void test_load_big_file(void) { grpc_error* error; char* tmp_name; static const size_t buffer_size = 124631; - unsigned char* buffer = gpr_malloc(buffer_size); + unsigned char* buffer = static_cast<unsigned char*>(gpr_malloc(buffer_size)); unsigned char* current; size_t i; diff --git a/test/core/iomgr/pollset_set_test.c b/test/core/iomgr/pollset_set_test.cc index d8a812341a..8d0198cace 100644 --- a/test/core/iomgr/pollset_set_test.c +++ b/test/core/iomgr/pollset_set_test.cc @@ -67,14 +67,15 @@ typedef struct test_pollset { 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); + grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p)); } static void cleanup_test_pollsets(grpc_exec_ctx* exec_ctx, diff --git a/test/core/iomgr/resolve_address_posix_test.c b/test/core/iomgr/resolve_address_posix_test.cc index c5eb2c8cb0..ba89fc8ad5 100644 --- a/test/core/iomgr/resolve_address_posix_test.c +++ b/test/core/iomgr/resolve_address_posix_test.cc @@ -50,7 +50,7 @@ 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) { 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); @@ -78,7 +78,7 @@ static grpc_millis n_sec_deadline(int seconds) { } static void actually_poll(void* argsp) { - args_struct* args = 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) { @@ -109,7 +109,7 @@ static void poll_pollset_until_request_done(args_struct* args) { static void must_succeed(grpc_exec_ctx* exec_ctx, void* argsp, grpc_error* err) { - args_struct* args = argsp; + 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); @@ -117,7 +117,7 @@ static void must_succeed(grpc_exec_ctx* exec_ctx, void* argsp, } static void must_fail(grpc_exec_ctx* exec_ctx, void* argsp, grpc_error* err) { - args_struct* args = argsp; + args_struct* args = static_cast<args_struct*>(argsp); GPR_ASSERT(err != GRPC_ERROR_NONE); gpr_atm_rel_store(&args->done_atm, 1); } @@ -142,7 +142,8 @@ static void test_unix_socket_path_name_too_long(void) { 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); + 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'; diff --git a/test/core/iomgr/resolve_address_test.c b/test/core/iomgr/resolve_address_test.cc index 64a353973d..0aa3e5f0f0 100644 --- a/test/core/iomgr/resolve_address_test.c +++ b/test/core/iomgr/resolve_address_test.cc @@ -43,7 +43,7 @@ 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) { 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); @@ -98,7 +98,7 @@ static void poll_pollset_until_request_done(args_struct* args) { static void must_succeed(grpc_exec_ctx* exec_ctx, void* argsp, grpc_error* err) { - args_struct* args = argsp; + 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); @@ -110,7 +110,7 @@ static void must_succeed(grpc_exec_ctx* exec_ctx, void* argsp, } static void must_fail(grpc_exec_ctx* exec_ctx, void* argsp, grpc_error* err) { - args_struct* args = argsp; + 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); diff --git a/test/core/iomgr/resource_quota_test.c b/test/core/iomgr/resource_quota_test.cc index 837fd01d0b..8a2faaed02 100644 --- a/test/core/iomgr/resource_quota_test.c +++ b/test/core/iomgr/resource_quota_test.cc @@ -55,18 +55,20 @@ typedef struct { grpc_resource_user* resource_user; grpc_closure* then; } reclaimer_args; + 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)); + reclaimer_args* a = static_cast<reclaimer_args*>(gpr_malloc(sizeof(*a))); a->size = size; a->resource_user = resource_user; a->then = then; @@ -76,7 +78,7 @@ grpc_closure* make_reclaimer(grpc_resource_user* resource_user, size_t size, 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) { return GRPC_CLOSURE_CREATE(unused_reclaimer_cb, then, diff --git a/test/core/iomgr/sockaddr_utils_test.c b/test/core/iomgr/sockaddr_utils_test.cc index 40f2157ba3..40f2157ba3 100644 --- a/test/core/iomgr/sockaddr_utils_test.c +++ b/test/core/iomgr/sockaddr_utils_test.cc diff --git a/test/core/iomgr/socket_utils_test.c b/test/core/iomgr/socket_utils_test.cc index 49c6f799e7..49c6f799e7 100644 --- a/test/core/iomgr/socket_utils_test.c +++ b/test/core/iomgr/socket_utils_test.cc diff --git a/test/core/iomgr/tcp_client_posix_test.c b/test/core/iomgr/tcp_client_posix_test.cc index 84b404156d..206fa5de01 100644 --- a/test/core/iomgr/tcp_client_posix_test.c +++ b/test/core/iomgr/tcp_client_posix_test.cc @@ -189,7 +189,7 @@ void test_fails(void) { static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p, grpc_error* error) { - grpc_pollset_destroy(exec_ctx, p); + grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p)); } int main(int argc, char** argv) { @@ -198,7 +198,7 @@ int main(int argc, char** argv) { 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); diff --git a/test/core/iomgr/tcp_client_uv_test.c b/test/core/iomgr/tcp_client_uv_test.cc index 978e3fa186..101d7bf6b5 100644 --- a/test/core/iomgr/tcp_client_uv_test.c +++ b/test/core/iomgr/tcp_client_uv_test.cc @@ -75,7 +75,8 @@ static void must_fail(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { 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)); + 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)); @@ -85,7 +86,7 @@ static void connection_cb(uv_stream_t* server, int status) { 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)); + 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; @@ -186,7 +187,7 @@ void test_fails(void) { static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p, grpc_error* error) { - grpc_pollset_destroy(exec_ctx, p); + grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p)); } int main(int argc, char** argv) { @@ -194,7 +195,7 @@ int main(int argc, char** argv) { 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(); diff --git a/test/core/iomgr/tcp_posix_test.c b/test/core/iomgr/tcp_posix_test.cc index 916bb9fde8..51ab0bfc6a 100644 --- a/test/core/iomgr/tcp_posix_test.c +++ b/test/core/iomgr/tcp_posix_test.cc @@ -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); @@ -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); @@ -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); @@ -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); @@ -525,10 +527,11 @@ static grpc_endpoint_test_fixture create_fixture_tcp_socketpair( create_sockets(sv); 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( diff --git a/test/core/iomgr/tcp_server_posix_test.c b/test/core/iomgr/tcp_server_posix_test.cc index 4f91669315..6efa74c706 100644 --- a/test/core/iomgr/tcp_server_posix_test.c +++ b/test/core/iomgr/tcp_server_posix_test.cc @@ -112,7 +112,7 @@ static void on_connect_result_set(on_connect_result* result, static void server_weak_ref_shutdown(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { - server_weak_ref* weak_ref = arg; + server_weak_ref* weak_ref = static_cast<server_weak_ref*>(arg); weak_ref->server = NULL; } @@ -429,22 +429,25 @@ static void test_connect(size_t num_connects, static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p, grpc_error* error) { - grpc_pollset_destroy(exec_ctx, p); + grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p)); } 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; // 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(); diff --git a/test/core/iomgr/tcp_server_uv_test.c b/test/core/iomgr/tcp_server_uv_test.cc index f2047c943f..dd047a0498 100644 --- a/test/core/iomgr/tcp_server_uv_test.c +++ b/test/core/iomgr/tcp_server_uv_test.cc @@ -76,7 +76,7 @@ static void on_connect_result_set(on_connect_result* result, static void server_weak_ref_shutdown(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { - server_weak_ref* weak_ref = arg; + server_weak_ref* weak_ref = static_cast<server_weak_ref*>(arg); weak_ref->server = NULL; } @@ -190,8 +190,10 @@ 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) { 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); @@ -291,7 +293,7 @@ static void test_connect(unsigned n) { static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p, grpc_error* error) { - grpc_pollset_destroy(exec_ctx, p); + grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p)); } int main(int argc, char** argv) { @@ -299,7 +301,7 @@ int main(int argc, char** argv) { 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(); diff --git a/test/core/iomgr/time_averaged_stats_test.c b/test/core/iomgr/time_averaged_stats_test.cc index b932e62d1f..b932e62d1f 100644 --- a/test/core/iomgr/time_averaged_stats_test.c +++ b/test/core/iomgr/time_averaged_stats_test.cc diff --git a/test/core/iomgr/timer_heap_test.c b/test/core/iomgr/timer_heap_test.cc index e0ab7b506b..20a383371d 100644 --- a/test/core/iomgr/timer_heap_test.c +++ b/test/core/iomgr/timer_heap_test.cc @@ -35,7 +35,8 @@ 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)); + 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(); @@ -75,7 +76,7 @@ static void test1(void) { 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); + uint8_t* inpq = static_cast<uint8_t*>(gpr_malloc(num_test_elements)); gpr_log(GPR_INFO, "test1"); @@ -135,7 +136,8 @@ typedef struct { 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; } @@ -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); diff --git a/test/core/iomgr/timer_list_test.c b/test/core/iomgr/timer_list_test.cc index d530dfb985..8783c5c6d7 100644 --- a/test/core/iomgr/timer_list_test.c +++ b/test/core/iomgr/timer_list_test.cc @@ -31,8 +31,8 @@ #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]; diff --git a/test/core/iomgr/udp_server_test.c b/test/core/iomgr/udp_server_test.cc index 4eb5ce1a05..4e8f234a8b 100644 --- a/test/core/iomgr/udp_server_test.c +++ b/test/core/iomgr/udp_server_test.cc @@ -118,7 +118,8 @@ static const grpc_socket_factory_vtable test_socket_factory_vtable = { 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)); + 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; @@ -292,7 +293,7 @@ static void test_receive(int number_of_clients) { static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* p, grpc_error* error) { - grpc_pollset_destroy(exec_ctx, p); + grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(p)); } int main(int argc, char** argv) { @@ -300,7 +301,7 @@ int main(int argc, char** argv) { 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(); diff --git a/test/core/iomgr/wakeup_fd_cv_test.c b/test/core/iomgr/wakeup_fd_cv_test.cc index dc1d77a0ab..dc1d77a0ab 100644 --- a/test/core/iomgr/wakeup_fd_cv_test.c +++ b/test/core/iomgr/wakeup_fd_cv_test.cc |