aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar Noah Eisen <ncteisen@gmail.com>2018-02-10 08:58:46 -0800
committerGravatar GitHub <noreply@github.com>2018-02-10 08:58:46 -0800
commit10a9e4e4fb5fb6aaacf2d02f10dc7690b98197e7 (patch)
treead77e09e79127aaf26911001f884b7ca8c92edc7 /test
parent2650c9730f6b6288a57c5126f629f1e42c2a282c (diff)
parente1bec40dfb8ff7562fc6a6dafb6d0369294e852f (diff)
Merge pull request #14150 from ncteisen/more-clang-tidy
Remove and Prohibit C Style Casts
Diffstat (limited to 'test')
-rw-r--r--test/core/avl/avl_test.cc14
-rw-r--r--test/core/backoff/backoff_test.cc22
-rw-r--r--test/core/bad_client/bad_client.cc8
-rw-r--r--test/core/bad_client/tests/duplicate_header.cc6
-rw-r--r--test/core/bad_client/tests/head_of_line_blocking.cc6
-rw-r--r--test/core/bad_client/tests/window_overflow.cc7
-rw-r--r--test/core/bad_ssl/bad_ssl_test.cc4
-rw-r--r--test/core/bad_ssl/servers/cert.cc6
-rw-r--r--test/core/channel/channel_args_test.cc13
-rw-r--r--test/core/channel/channel_stack_builder_test.cc2
-rw-r--r--test/core/channel/channel_stack_test.cc16
-rw-r--r--test/core/client_channel/parse_address_test.cc9
-rw-r--r--test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc2
-rw-r--r--test/core/compression/stream_compression_test.cc10
-rw-r--r--test/core/end2end/bad_server_response_test.cc10
-rw-r--r--test/core/end2end/cq_verifier.cc4
-rw-r--r--test/core/end2end/dualstack_socket_test.cc11
-rw-r--r--test/core/end2end/fixtures/h2_oauth2.cc6
-rw-r--r--test/core/end2end/fixtures/http_proxy_fixture.cc30
-rw-r--r--test/core/end2end/fixtures/proxy.cc37
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer.cc14
-rw-r--r--test/core/end2end/fuzzers/client_fuzzer.cc2
-rw-r--r--test/core/end2end/fuzzers/server_fuzzer.cc4
-rw-r--r--test/core/end2end/goaway_server_test.cc7
-rw-r--r--test/core/end2end/h2_ssl_cert_test.cc3
-rw-r--r--test/core/end2end/invalid_call_argument_test.cc4
-rw-r--r--test/core/end2end/tests/authority_not_supported.cc3
-rw-r--r--test/core/end2end/tests/bad_hostname.cc3
-rw-r--r--test/core/end2end/tests/bad_ping.cc6
-rw-r--r--test/core/end2end/tests/binary_metadata.cc9
-rw-r--r--test/core/end2end/tests/call_creds.cc12
-rw-r--r--test/core/end2end/tests/cancel_after_accept.cc6
-rw-r--r--test/core/end2end/tests/cancel_after_client_done.cc6
-rw-r--r--test/core/end2end/tests/cancel_after_round_trip.cc12
-rw-r--r--test/core/end2end/tests/compressed_payload.cc39
-rw-r--r--test/core/end2end/tests/connectivity.cc2
-rw-r--r--test/core/end2end/tests/default_host.cc6
-rw-r--r--test/core/end2end/tests/disappearing_server.cc6
-rw-r--r--test/core/end2end/tests/filter_call_init_fails.cc12
-rw-r--r--test/core/end2end/tests/filter_causes_close.cc9
-rw-r--r--test/core/end2end/tests/filter_latency.cc8
-rw-r--r--test/core/end2end/tests/filter_status_code.cc14
-rw-r--r--test/core/end2end/tests/graceful_server_shutdown.cc6
-rw-r--r--test/core/end2end/tests/high_initial_seqno.cc6
-rw-r--r--test/core/end2end/tests/hpack_size.cc6
-rw-r--r--test/core/end2end/tests/idempotent_request.cc6
-rw-r--r--test/core/end2end/tests/invoke_large_request.cc9
-rw-r--r--test/core/end2end/tests/keepalive_timeout.cc9
-rw-r--r--test/core/end2end/tests/large_metadata.cc11
-rw-r--r--test/core/end2end/tests/load_reporting_hook.cc9
-rw-r--r--test/core/end2end/tests/max_concurrent_streams.cc56
-rw-r--r--test/core/end2end/tests/max_connection_age.cc15
-rw-r--r--test/core/end2end/tests/max_connection_idle.cc6
-rw-r--r--test/core/end2end/tests/max_message_length.cc12
-rw-r--r--test/core/end2end/tests/network_status_change.cc9
-rw-r--r--test/core/end2end/tests/no_logging.cc6
-rw-r--r--test/core/end2end/tests/payload.cc13
-rw-r--r--test/core/end2end/tests/ping_pong_streaming.cc23
-rw-r--r--test/core/end2end/tests/proxy_auth.cc6
-rw-r--r--test/core/end2end/tests/registered_call.cc6
-rw-r--r--test/core/end2end/tests/request_with_flags.cc3
-rw-r--r--test/core/end2end/tests/request_with_payload.cc9
-rw-r--r--test/core/end2end/tests/resource_quota_server.cc55
-rw-r--r--test/core/end2end/tests/server_finishes_request.cc6
-rw-r--r--test/core/end2end/tests/shutdown_finishes_calls.cc6
-rw-r--r--test/core/end2end/tests/shutdown_finishes_tags.cc2
-rw-r--r--test/core/end2end/tests/simple_cacheable_request.cc9
-rw-r--r--test/core/end2end/tests/simple_delayed_request.cc6
-rw-r--r--test/core/end2end/tests/simple_metadata.cc9
-rw-r--r--test/core/end2end/tests/simple_request.cc6
-rw-r--r--test/core/end2end/tests/stream_compression_compressed_payload.cc39
-rw-r--r--test/core/end2end/tests/stream_compression_payload.cc13
-rw-r--r--test/core/end2end/tests/stream_compression_ping_pong_streaming.cc23
-rw-r--r--test/core/end2end/tests/streaming_error_response.cc18
-rw-r--r--test/core/end2end/tests/trailing_metadata.cc9
-rw-r--r--test/core/end2end/tests/workaround_cronet_compression.cc23
-rw-r--r--test/core/end2end/tests/write_buffering.cc27
-rw-r--r--test/core/end2end/tests/write_buffering_at_end.cc27
-rw-r--r--test/core/fling/client.cc5
-rw-r--r--test/core/fling/fling_stream_test.cc2
-rw-r--r--test/core/fling/fling_test.cc2
-rw-r--r--test/core/fling/server.cc5
-rw-r--r--test/core/gpr/alloc_test.cc4
-rw-r--r--test/core/gpr/arena_test.cc2
-rw-r--r--test/core/gpr/cpu_test.cc4
-rw-r--r--test/core/gpr/mpscq_test.cc6
-rw-r--r--test/core/gpr/murmur_hash_test.cc4
-rw-r--r--test/core/gpr/spinlock_test.cc15
-rw-r--r--test/core/gpr/sync_test.cc13
-rw-r--r--test/core/gpr/time_test.cc2
-rw-r--r--test/core/handshake/client_ssl.cc27
-rw-r--r--test/core/handshake/readahead_handshaker_server_ssl.cc3
-rw-r--r--test/core/handshake/server_ssl_common.cc23
-rw-r--r--test/core/http/httpcli_test.cc6
-rw-r--r--test/core/http/httpscli_test.cc6
-rw-r--r--test/core/iomgr/endpoint_pair_test.cc2
-rw-r--r--test/core/iomgr/endpoint_tests.cc9
-rw-r--r--test/core/iomgr/ev_epollsig_linux_test.cc2
-rw-r--r--test/core/iomgr/fd_posix_test.cc8
-rw-r--r--test/core/iomgr/pollset_set_test.cc2
-rw-r--r--test/core/iomgr/resource_quota_test.cc4
-rw-r--r--test/core/iomgr/sockaddr_utils_test.cc19
-rw-r--r--test/core/iomgr/socket_utils_test.cc15
-rw-r--r--test/core/iomgr/tcp_client_posix_test.cc9
-rw-r--r--test/core/iomgr/tcp_posix_test.cc41
-rw-r--r--test/core/iomgr/tcp_server_posix_test.cc20
-rw-r--r--test/core/iomgr/timer_heap_test.cc10
-rw-r--r--test/core/iomgr/udp_server_test.cc24
-rw-r--r--test/core/iomgr/wakeup_fd_cv_test.cc2
-rw-r--r--test/core/json/json_rewrite.cc4
-rw-r--r--test/core/json/json_rewrite_test.cc4
-rw-r--r--test/core/memory_usage/client.cc61
-rw-r--r--test/core/memory_usage/memory_usage_test.cc2
-rw-r--r--test/core/memory_usage/server.cc16
-rw-r--r--test/core/network_benchmarks/low_level_ping_pong.cc18
-rw-r--r--test/core/security/create_jwt.cc2
-rw-r--r--test/core/security/credentials_test.cc30
-rw-r--r--test/core/security/fetch_oauth2.cc3
-rw-r--r--test/core/security/json_token_test.cc12
-rw-r--r--test/core/security/jwt_verifier_test.cc10
-rw-r--r--test/core/security/oauth2_utils.cc7
-rw-r--r--test/core/security/print_google_default_creds_token.cc8
-rw-r--r--test/core/security/secure_endpoint_test.cc15
-rw-r--r--test/core/security/verify_jwt.cc4
-rw-r--r--test/core/slice/b64_test.cc6
-rw-r--r--test/core/slice/percent_encode_fuzzer.cc3
-rw-r--r--test/core/slice/slice_test.cc10
-rw-r--r--test/core/surface/completion_queue_threading_test.cc18
-rw-r--r--test/core/surface/concurrent_connectivity_test.cc24
-rw-r--r--test/core/surface/lame_client_test.cc6
-rw-r--r--test/core/transport/chttp2/hpack_encoder_test.cc4
-rw-r--r--test/core/transport/chttp2/settings_timeout_test.cc6
-rw-r--r--test/core/transport/chttp2/stream_map_test.cc8
-rw-r--r--test/core/transport/metadata_test.cc8
-rw-r--r--test/core/transport/timeout_encoding_test.cc14
-rw-r--r--test/core/tsi/fake_transport_security_test.cc5
-rw-r--r--test/core/tsi/ssl_transport_security_test.cc46
-rw-r--r--test/core/tsi/transport_security_test_lib.cc11
-rw-r--r--test/core/util/cmdline.cc21
-rw-r--r--test/core/util/debugger_macros.cc3
-rw-r--r--test/core/util/histogram.cc16
-rw-r--r--test/core/util/memory_counters.cc8
-rw-r--r--test/core/util/mock_endpoint.cc15
-rw-r--r--test/core/util/parse_hexstring.cc5
-rw-r--r--test/core/util/passthru_endpoint.cc24
-rw-r--r--test/core/util/port.cc4
-rw-r--r--test/core/util/port_server_client.cc16
-rw-r--r--test/core/util/reconnect_server.cc6
-rw-r--r--test/core/util/slice_splitter.cc11
-rw-r--r--test/core/util/subprocess_posix.cc7
-rw-r--r--test/core/util/test_config.cc14
-rw-r--r--test/core/util/test_tcp_server.cc5
-rw-r--r--test/core/util/trickle_endpoint.cc33
-rw-r--r--test/cpp/codegen/proto_utils_test.cc4
-rw-r--r--test/cpp/common/alarm_test.cc40
-rw-r--r--test/cpp/end2end/async_end2end_test.cc2
-rw-r--r--test/cpp/end2end/end2end_test.cc3
-rw-r--r--test/cpp/end2end/filter_end2end_test.cc2
-rw-r--r--test/cpp/end2end/generic_end2end_test.cc2
-rw-r--r--test/cpp/end2end/hybrid_end2end_test.cc2
-rw-r--r--test/cpp/end2end/thread_stress_test.cc2
-rw-r--r--test/cpp/grpclb/grpclb_test.cc38
-rw-r--r--test/cpp/interop/interop_client.cc5
-rw-r--r--test/cpp/microbenchmarks/bm_chttp2_hpack.cc7
-rw-r--r--test/cpp/microbenchmarks/bm_cq_multiple_threads.cc7
-rw-r--r--test/cpp/microbenchmarks/fullstack_context_mutators.h4
-rw-r--r--test/cpp/microbenchmarks/fullstack_fixtures.h6
-rw-r--r--test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h24
-rw-r--r--test/cpp/microbenchmarks/fullstack_streaming_pump.h10
-rw-r--r--test/cpp/microbenchmarks/fullstack_unary_ping_pong.h2
-rw-r--r--test/cpp/microbenchmarks/helpers.cc15
-rw-r--r--test/cpp/performance/writes_per_rpc_test.cc5
-rw-r--r--test/cpp/qps/report.cc9
-rw-r--r--test/cpp/qps/server.h2
-rw-r--r--test/cpp/util/cli_call.cc2
-rw-r--r--test/cpp/util/proto_reflection_descriptor_database.cc3
176 files changed, 1147 insertions, 812 deletions
diff --git a/test/core/avl/avl_test.cc b/test/core/avl/avl_test.cc
index ac1ab5c8e9..ecebe833b3 100644
--- a/test/core/avl/avl_test.cc
+++ b/test/core/avl/avl_test.cc
@@ -34,9 +34,11 @@ static int* box(int x) {
}
static long int_compare(void* int1, void* int2, void* unused) {
- return (*(int*)int1) - (*(int*)int2);
+ return (*static_cast<int*>(int1)) - (*static_cast<int*>(int2));
+}
+static void* int_copy(void* p, void* unused) {
+ return box(*static_cast<int*>(p));
}
-static void* int_copy(void* p, void* unused) { return box(*(int*)p); }
static void destroy(void* p, void* unused) { gpr_free(p); }
@@ -3604,17 +3606,17 @@ static void test_stress(int amount_of_stress) {
int deletions = 0;
grpc_avl avl;
- unsigned seed = (unsigned)time(nullptr);
+ unsigned seed = static_cast<unsigned>(time(nullptr));
gpr_log(GPR_DEBUG, "test_stress amount=%d seed=%u", amount_of_stress, seed);
- srand((unsigned)time(nullptr));
+ srand(static_cast<unsigned>(time(nullptr)));
avl = grpc_avl_create(&int_int_vtable);
memset(added, 0, sizeof(added));
for (i = 1; deletions < amount_of_stress; i++) {
- int idx = rand() % (int)GPR_ARRAY_SIZE(added);
+ int idx = rand() % static_cast<int> GPR_ARRAY_SIZE(added);
GPR_ASSERT(i);
if (rand() < RAND_MAX / 2) {
added[idx] = i;
@@ -3627,7 +3629,7 @@ static void test_stress(int amount_of_stress) {
printf("avl = remove_int(avl, %d); /* d=%d */\n", idx, deletions);
avl = remove_int(avl, idx);
}
- for (j = 0; j < (int)GPR_ARRAY_SIZE(added); j++) {
+ for (j = 0; j < static_cast<int> GPR_ARRAY_SIZE(added); j++) {
if (added[j] != 0) {
check_get(avl, j, added[j]);
} else {
diff --git a/test/core/backoff/backoff_test.cc b/test/core/backoff/backoff_test.cc
index 53e910eddd..1998a83977 100644
--- a/test/core/backoff/backoff_test.cc
+++ b/test/core/backoff/backoff_test.cc
@@ -143,10 +143,10 @@ TEST(BackOffTest, JitterBackOff) {
grpc_millis next = backoff.NextAttemptTime();
EXPECT_EQ(next - grpc_core::ExecCtx::Get()->Now(), initial_backoff);
- grpc_millis expected_next_lower_bound =
- (grpc_millis)((double)current_backoff * (1 - jitter));
- grpc_millis expected_next_upper_bound =
- (grpc_millis)((double)current_backoff * (1 + jitter));
+ grpc_millis expected_next_lower_bound = static_cast<grpc_millis>(
+ static_cast<double>(current_backoff) * (1 - jitter));
+ grpc_millis expected_next_upper_bound = static_cast<grpc_millis>(
+ static_cast<double>(current_backoff) * (1 + jitter));
for (int i = 0; i < 10000; i++) {
next = backoff.NextAttemptTime();
@@ -155,12 +155,14 @@ TEST(BackOffTest, JitterBackOff) {
const grpc_millis timeout_millis = next - grpc_core::ExecCtx::Get()->Now();
EXPECT_GE(timeout_millis, expected_next_lower_bound);
EXPECT_LE(timeout_millis, expected_next_upper_bound);
- current_backoff = std::min(
- (grpc_millis)((double)current_backoff * multiplier), max_backoff);
- expected_next_lower_bound =
- (grpc_millis)((double)current_backoff * (1 - jitter));
- expected_next_upper_bound =
- (grpc_millis)((double)current_backoff * (1 + jitter));
+ current_backoff =
+ std::min(static_cast<grpc_millis>(static_cast<double>(current_backoff) *
+ multiplier),
+ max_backoff);
+ expected_next_lower_bound = static_cast<grpc_millis>(
+ static_cast<double>(current_backoff) * (1 - jitter));
+ expected_next_upper_bound = static_cast<grpc_millis>(
+ static_cast<double>(current_backoff) * (1 + jitter));
}
}
diff --git a/test/core/bad_client/bad_client.cc b/test/core/bad_client/bad_client.cc
index df803d16a2..ee55a95e4e 100644
--- a/test/core/bad_client/bad_client.cc
+++ b/test/core/bad_client/bad_client.cc
@@ -49,7 +49,7 @@ typedef struct {
/* Run the server side validator and set done_thd once done */
static void thd_func(void* arg) {
- thd_args* a = (thd_args*)arg;
+ thd_args* a = static_cast<thd_args*>(arg);
if (a->validator != nullptr) {
a->validator(a->server, a->cq, a->registered_method);
}
@@ -58,12 +58,12 @@ static void thd_func(void* arg) {
/* Sets the done_write event */
static void set_done_write(void* arg, grpc_error* error) {
- gpr_event* done_write = (gpr_event*)arg;
+ gpr_event* done_write = static_cast<gpr_event*>(arg);
gpr_event_set(done_write, (void*)1);
}
static void server_setup_transport(void* ts, grpc_transport* transport) {
- thd_args* a = (thd_args*)ts;
+ thd_args* a = static_cast<thd_args*>(ts);
grpc_core::ExecCtx exec_ctx;
grpc_server_setup_transport(a->server, transport, nullptr,
grpc_server_get_channel_args(a->server));
@@ -71,7 +71,7 @@ static void server_setup_transport(void* ts, grpc_transport* transport) {
/* Sets the read_done event */
static void set_read_done(void* arg, grpc_error* error) {
- gpr_event* read_done = (gpr_event*)arg;
+ gpr_event* read_done = static_cast<gpr_event*>(arg);
gpr_event_set(read_done, (void*)1);
}
diff --git a/test/core/bad_client/tests/duplicate_header.cc b/test/core/bad_client/tests/duplicate_header.cc
index 0d689bbb7e..e3cae8b595 100644
--- a/test/core/bad_client/tests/duplicate_header.cc
+++ b/test/core/bad_client/tests/duplicate_header.cc
@@ -87,7 +87,8 @@ static void verifier(grpc_server* server, grpc_completion_queue* cq,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -108,7 +109,8 @@ static void verifier(grpc_server* server, grpc_completion_queue* cq,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(103),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
diff --git a/test/core/bad_client/tests/head_of_line_blocking.cc b/test/core/bad_client/tests/head_of_line_blocking.cc
index 8668e091b6..427db46446 100644
--- a/test/core/bad_client/tests/head_of_line_blocking.cc
+++ b/test/core/bad_client/tests/head_of_line_blocking.cc
@@ -117,9 +117,9 @@ int main(int argc, char** argv) {
addbuf(prefix, sizeof(prefix) - 1);
for (i = 0; i < NUM_FRAMES; i++) {
- uint8_t hdr[9] = {(uint8_t)(FRAME_SIZE >> 16),
- (uint8_t)(FRAME_SIZE >> 8),
- (uint8_t)FRAME_SIZE,
+ uint8_t hdr[9] = {static_cast<uint8_t>(FRAME_SIZE >> 16),
+ static_cast<uint8_t>(FRAME_SIZE >> 8),
+ static_cast<uint8_t>(FRAME_SIZE),
0,
0,
0,
diff --git a/test/core/bad_client/tests/window_overflow.cc b/test/core/bad_client/tests/window_overflow.cc
index fe6b05d03a..b552704e9c 100644
--- a/test/core/bad_client/tests/window_overflow.cc
+++ b/test/core/bad_client/tests/window_overflow.cc
@@ -76,9 +76,10 @@ int main(int argc, char** argv) {
addbuf(PFX_STR, sizeof(PFX_STR) - 1);
for (i = 0; i < NUM_FRAMES; i++) {
- uint8_t hdr[9] = {(uint8_t)(FRAME_SIZE >> 16),
- (uint8_t)(FRAME_SIZE >> 8),
- (uint8_t)FRAME_SIZE,
+ uint8_t hdr[9] = {static_cast<uint8_t>(FRAME_SIZE >> 16),
+ static_cast<uint8_t>(FRAME_SIZE >> 8),
+ static_cast<uint8_t>
+ FRAME_SIZE,
0,
0,
0,
diff --git a/test/core/bad_ssl/bad_ssl_test.cc b/test/core/bad_ssl/bad_ssl_test.cc
index e2ab22e014..e2ea7540ef 100644
--- a/test/core/bad_ssl/bad_ssl_test.cc
+++ b/test/core/bad_ssl/bad_ssl_test.cc
@@ -127,7 +127,7 @@ int main(int argc, char** argv) {
gpr_subprocess* svr;
/* figure out where we are */
if (lslash) {
- memcpy(root, me, (size_t)(lslash - me));
+ memcpy(root, me, static_cast<size_t>(lslash - me));
root[lslash - me] = 0;
} else {
strcpy(root, ".");
@@ -139,7 +139,7 @@ int main(int argc, char** argv) {
tmp = lunder - 1;
while (*tmp != '_') tmp--;
tmp++;
- memcpy(test, tmp, (size_t)(lunder - tmp));
+ memcpy(test, tmp, static_cast<size_t>(lunder - tmp));
/* start the server */
gpr_asprintf(&args[0], "%s/bad_ssl_%s_server%s", root, test,
gpr_subprocess_binary_extension());
diff --git a/test/core/bad_ssl/servers/cert.cc b/test/core/bad_ssl/servers/cert.cc
index 3ed7d029ee..0722d6b57c 100644
--- a/test/core/bad_ssl/servers/cert.cc
+++ b/test/core/bad_ssl/servers/cert.cc
@@ -45,8 +45,10 @@ int main(int argc, char** argv) {
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"load_file",
grpc_load_file("src/core/tsi/test_creds/badserver.key", 1, &key_slice)));
- pem_key_cert_pair.private_key = (const char*)GRPC_SLICE_START_PTR(key_slice);
- pem_key_cert_pair.cert_chain = (const char*)GRPC_SLICE_START_PTR(cert_slice);
+ pem_key_cert_pair.private_key =
+ reinterpret_cast<const char*> GRPC_SLICE_START_PTR(key_slice);
+ pem_key_cert_pair.cert_chain =
+ reinterpret_cast<const char*> GRPC_SLICE_START_PTR(cert_slice);
ssl_creds = grpc_ssl_server_credentials_create(nullptr, &pem_key_cert_pair, 1,
0, nullptr);
diff --git a/test/core/channel/channel_args_test.cc b/test/core/channel/channel_args_test.cc
index d232bc02ac..57ff7370ad 100644
--- a/test/core/channel/channel_args_test.cc
+++ b/test/core/channel/channel_args_test.cc
@@ -81,8 +81,8 @@ static void test_compression_algorithm_states(void) {
ch_args = grpc_channel_args_copy_and_add(nullptr, nullptr, 0);
/* by default, all enabled */
- states_bitset =
- (unsigned)grpc_channel_args_compression_algorithm_get_states(ch_args);
+ states_bitset = static_cast<unsigned>(
+ grpc_channel_args_compression_algorithm_get_states(ch_args));
for (i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) {
GPR_ASSERT(GPR_BITGET(states_bitset, i));
@@ -100,8 +100,9 @@ static void test_compression_algorithm_states(void) {
&ch_args_wo_gzip_deflate, GRPC_COMPRESS_STREAM_GZIP, 0);
GPR_ASSERT(ch_args_wo_gzip_deflate == ch_args_wo_gzip_deflate_gzip);
- states_bitset = (unsigned)grpc_channel_args_compression_algorithm_get_states(
- ch_args_wo_gzip_deflate);
+ states_bitset =
+ static_cast<unsigned>(grpc_channel_args_compression_algorithm_get_states(
+ ch_args_wo_gzip_deflate));
for (i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) {
if (i == GRPC_COMPRESS_GZIP || i == GRPC_COMPRESS_DEFLATE ||
i == GRPC_COMPRESS_STREAM_GZIP) {
@@ -118,8 +119,8 @@ static void test_compression_algorithm_states(void) {
&ch_args_wo_gzip, GRPC_COMPRESS_STREAM_GZIP, 1);
GPR_ASSERT(ch_args_wo_gzip == ch_args_wo_gzip_deflate_gzip);
- states_bitset = (unsigned)grpc_channel_args_compression_algorithm_get_states(
- ch_args_wo_gzip);
+ states_bitset = static_cast<unsigned>(
+ grpc_channel_args_compression_algorithm_get_states(ch_args_wo_gzip));
for (i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) {
if (i == GRPC_COMPRESS_DEFLATE) {
GPR_ASSERT(GPR_BITGET(states_bitset, i) == 0);
diff --git a/test/core/channel/channel_stack_builder_test.cc b/test/core/channel/channel_stack_builder_test.cc
index ef6db81b0b..aad6d6eee9 100644
--- a/test/core/channel/channel_stack_builder_test.cc
+++ b/test/core/channel/channel_stack_builder_test.cc
@@ -116,7 +116,7 @@ static bool add_replacement_filter(grpc_channel_stack_builder* builder,
static bool add_original_filter(grpc_channel_stack_builder* builder,
void* arg) {
return grpc_channel_stack_builder_prepend_filter(
- builder, (const grpc_channel_filter*)arg, set_arg_once_fn,
+ builder, static_cast<const grpc_channel_filter*>(arg), set_arg_once_fn,
&g_original_fn_called);
}
diff --git a/test/core/channel/channel_stack_test.cc b/test/core/channel/channel_stack_test.cc
index ef43facd6e..2f5329a96d 100644
--- a/test/core/channel/channel_stack_test.cc
+++ b/test/core/channel/channel_stack_test.cc
@@ -35,14 +35,14 @@ static grpc_error* channel_init_func(grpc_channel_element* elem,
GPR_ASSERT(args->channel_args->args[0].value.integer == 42);
GPR_ASSERT(args->is_first);
GPR_ASSERT(args->is_last);
- *(int*)(elem->channel_data) = 0;
+ *static_cast<int*>(elem->channel_data) = 0;
return GRPC_ERROR_NONE;
}
static grpc_error* call_init_func(grpc_call_element* elem,
const grpc_call_element_args* args) {
- ++*(int*)(elem->channel_data);
- *(int*)(elem->call_data) = 0;
+ ++*static_cast<int*>(elem->channel_data);
+ *static_cast<int*>(elem->call_data) = 0;
return GRPC_ERROR_NONE;
}
@@ -51,16 +51,16 @@ static void channel_destroy_func(grpc_channel_element* elem) {}
static void call_destroy_func(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {
- ++*(int*)(elem->channel_data);
+ ++*static_cast<int*>(elem->channel_data);
}
static void call_func(grpc_call_element* elem,
grpc_transport_stream_op_batch* op) {
- ++*(int*)(elem->call_data);
+ ++*static_cast<int*>(elem->call_data);
}
static void channel_func(grpc_channel_element* elem, grpc_transport_op* op) {
- ++*(int*)(elem->channel_data);
+ ++*static_cast<int*>(elem->channel_data);
}
static void free_channel(void* arg, grpc_error* error) {
@@ -111,7 +111,7 @@ static void test_create_channel_stack(void) {
&chan_args, nullptr, "test", channel_stack);
GPR_ASSERT(channel_stack->count == 1);
channel_elem = grpc_channel_stack_element(channel_stack, 0);
- channel_data = (int*)channel_elem->channel_data;
+ channel_data = static_cast<int*>(channel_elem->channel_data);
GPR_ASSERT(*channel_data == 0);
call_stack =
@@ -133,7 +133,7 @@ static void test_create_channel_stack(void) {
call_elem = grpc_call_stack_element(call_stack, 0);
GPR_ASSERT(call_elem->filter == channel_elem->filter);
GPR_ASSERT(call_elem->channel_data == channel_elem->channel_data);
- call_data = (int*)call_elem->call_data;
+ call_data = static_cast<int*>(call_elem->call_data);
GPR_ASSERT(*call_data == 0);
GPR_ASSERT(*channel_data == 1);
diff --git a/test/core/client_channel/parse_address_test.cc b/test/core/client_channel/parse_address_test.cc
index 6d56961d84..373ed76cbe 100644
--- a/test/core/client_channel/parse_address_test.cc
+++ b/test/core/client_channel/parse_address_test.cc
@@ -39,7 +39,8 @@ static void test_grpc_parse_unix(const char* uri_text, const char* pathname) {
grpc_resolved_address addr;
GPR_ASSERT(1 == grpc_parse_unix(uri, &addr));
- struct sockaddr_un* addr_un = (struct sockaddr_un*)addr.addr;
+ struct sockaddr_un* addr_un =
+ reinterpret_cast<struct sockaddr_un*>(addr.addr);
GPR_ASSERT(AF_UNIX == addr_un->sun_family);
GPR_ASSERT(0 == strcmp(addr_un->sun_path, pathname));
@@ -60,7 +61,8 @@ static void test_grpc_parse_ipv4(const char* uri_text, const char* host,
char ntop_buf[INET_ADDRSTRLEN];
GPR_ASSERT(1 == grpc_parse_ipv4(uri, &addr));
- struct sockaddr_in* addr_in = (struct sockaddr_in*)addr.addr;
+ struct sockaddr_in* addr_in =
+ reinterpret_cast<struct sockaddr_in*>(addr.addr);
GPR_ASSERT(AF_INET == addr_in->sin_family);
GPR_ASSERT(nullptr != grpc_inet_ntop(AF_INET, &addr_in->sin_addr, ntop_buf,
sizeof(ntop_buf)));
@@ -78,7 +80,8 @@ static void test_grpc_parse_ipv6(const char* uri_text, const char* host,
char ntop_buf[INET6_ADDRSTRLEN];
GPR_ASSERT(1 == grpc_parse_ipv6(uri, &addr));
- struct sockaddr_in6* addr_in6 = (struct sockaddr_in6*)addr.addr;
+ struct sockaddr_in6* addr_in6 =
+ reinterpret_cast<struct sockaddr_in6*>(addr.addr);
GPR_ASSERT(AF_INET6 == addr_in6->sin6_family);
GPR_ASSERT(nullptr != grpc_inet_ntop(AF_INET6, &addr_in6->sin6_addr, ntop_buf,
sizeof(ntop_buf)));
diff --git a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc
index 8cafadf05a..966fb1d14b 100644
--- a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc
+++ b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc
@@ -95,7 +95,7 @@ static grpc_core::OrphanablePtr<grpc_core::Resolver> create_resolver(
}
static void on_done(void* ev, grpc_error* error) {
- gpr_event_set((gpr_event*)ev, (void*)1);
+ gpr_event_set(static_cast<gpr_event*>(ev), (void*)1);
}
// interleave waiting for an event with a timer check
diff --git a/test/core/compression/stream_compression_test.cc b/test/core/compression/stream_compression_test.cc
index 2f30b7fc19..0b84366198 100644
--- a/test/core/compression/stream_compression_test.cc
+++ b/test/core/compression/stream_compression_test.cc
@@ -29,7 +29,7 @@ static void generate_random_payload(char* payload, size_t size) {
size_t i;
static const char chars[] = "abcdefghijklmnopqrstuvwxyz1234567890";
for (i = 0; i < size - 1; ++i) {
- payload[i] = chars[rand() % (int)(sizeof(chars) - 1)];
+ payload[i] = chars[rand() % static_cast<int>(sizeof(chars) - 1)];
}
payload[size - 1] = '\0';
}
@@ -43,8 +43,10 @@ static bool slice_buffer_equals_string(grpc_slice_buffer* buf,
size_t pointer = 0;
for (i = 0; i < buf->count; i++) {
size_t slice_len = GRPC_SLICE_LENGTH(buf->slices[i]);
- if (0 != strncmp(str + pointer, (char*)GRPC_SLICE_START_PTR(buf->slices[i]),
- slice_len)) {
+ if (0 !=
+ strncmp(str + pointer,
+ reinterpret_cast<char*> GRPC_SLICE_START_PTR(buf->slices[i]),
+ slice_len)) {
return false;
}
pointer += slice_len;
@@ -112,7 +114,7 @@ test_stream_compression_simple_compress_decompress_with_output_size_constraint()
GPR_ASSERT(output_size == max_output_size);
GPR_ASSERT(end_of_context == false);
grpc_slice slice_recv = grpc_slice_buffer_take_first(&sink);
- char* str_recv = (char*)GRPC_SLICE_START_PTR(slice_recv);
+ char* str_recv = reinterpret_cast<char*> GRPC_SLICE_START_PTR(slice_recv);
GPR_ASSERT(GRPC_SLICE_LENGTH(slice_recv) == max_output_size);
GPR_ASSERT(0 == strncmp(test_str, str_recv, max_output_size));
grpc_slice_unref(slice_recv);
diff --git a/test/core/end2end/bad_server_response_test.cc b/test/core/end2end/bad_server_response_test.cc
index 2b98620164..79331bca6f 100644
--- a/test/core/end2end/bad_server_response_test.cc
+++ b/test/core/end2end/bad_server_response_test.cc
@@ -133,7 +133,7 @@ static void on_connect(void* arg, grpc_endpoint* tcp,
grpc_pollset* accepting_pollset,
grpc_tcp_server_acceptor* acceptor) {
gpr_free(acceptor);
- test_tcp_server* server = (test_tcp_server*)arg;
+ test_tcp_server* server = static_cast<test_tcp_server*>(arg);
GRPC_CLOSURE_INIT(&on_read, handle_read, nullptr, grpc_schedule_on_exec_ctx);
GRPC_CLOSURE_INIT(&on_write, done_write, nullptr, grpc_schedule_on_exec_ctx);
grpc_slice_buffer_init(&state.temp_incoming_buffer);
@@ -196,8 +196,8 @@ static void start_rpc(int target_port, grpc_status_code expected_status,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(state.call, ops, (size_t)(op - ops), tag(1),
- nullptr);
+ error = grpc_call_start_batch(state.call, ops, static_cast<size_t>(op - ops),
+ tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
@@ -236,7 +236,7 @@ typedef struct {
} poll_args;
static void actually_poll_server(void* arg) {
- poll_args* pa = (poll_args*)arg;
+ poll_args* pa = static_cast<poll_args*>(arg);
gpr_timespec deadline = n_sec_deadline(10);
while (true) {
bool done = gpr_atm_acq_load(&state.done_atm) != 0;
@@ -258,7 +258,7 @@ static void poll_server_until_read_done(test_tcp_server* server,
gpr_atm_rel_store(&state.done_atm, 0);
state.write_done = 0;
gpr_thd_id id;
- poll_args* pa = (poll_args*)gpr_malloc(sizeof(*pa));
+ poll_args* pa = static_cast<poll_args*>(gpr_malloc(sizeof(*pa)));
pa->server = server;
pa->signal_when_done = signal_when_done;
gpr_thd_new(&id, "grpc_poll_server", actually_poll_server, pa, nullptr);
diff --git a/test/core/end2end/cq_verifier.cc b/test/core/end2end/cq_verifier.cc
index a7b37f3c12..c3a3f43fe1 100644
--- a/test/core/end2end/cq_verifier.cc
+++ b/test/core/end2end/cq_verifier.cc
@@ -61,7 +61,7 @@ struct cq_verifier {
};
cq_verifier* cq_verifier_create(grpc_completion_queue* cq) {
- cq_verifier* v = (cq_verifier*)gpr_malloc(sizeof(cq_verifier));
+ cq_verifier* v = static_cast<cq_verifier*>(gpr_malloc(sizeof(cq_verifier)));
v->cq = cq;
v->first_expectation = nullptr;
return v;
@@ -305,7 +305,7 @@ void cq_verify_empty(cq_verifier* v) { cq_verify_empty_timeout(v, 1); }
static void add(cq_verifier* v, const char* file, int line,
grpc_completion_type type, void* tag, bool success) {
- expectation* e = (expectation*)gpr_malloc(sizeof(expectation));
+ expectation* e = static_cast<expectation*>(gpr_malloc(sizeof(expectation)));
e->type = type;
e->file = file;
e->line = line;
diff --git a/test/core/end2end/dualstack_socket_test.cc b/test/core/end2end/dualstack_socket_test.cc
index 2dc72b885f..411d0f2308 100644
--- a/test/core/end2end/dualstack_socket_test.cc
+++ b/test/core/end2end/dualstack_socket_test.cc
@@ -128,8 +128,8 @@ void test_connect(const char* server_host, const char* client_host, int port,
grpc_slice_buffer uri_parts;
char** hosts_with_port;
- uri_slice =
- grpc_slice_new((char*)client_host, strlen(client_host), do_nothing);
+ uri_slice = grpc_slice_new(const_cast<char*>(client_host),
+ strlen(client_host), do_nothing);
grpc_slice_buffer_init(&uri_parts);
grpc_slice_split(uri_slice, ",", &uri_parts);
hosts_with_port =
@@ -199,7 +199,8 @@ void test_connect(const char* server_host, const char* client_host, int port,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
if (expect_ok) {
@@ -227,8 +228,8 @@ void test_connect(const char* server_host, const char* client_host, int port,
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
op++;
- error =
- grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops),
+ tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
diff --git a/test/core/end2end/fixtures/h2_oauth2.cc b/test/core/end2end/fixtures/h2_oauth2.cc
index 795e94a9e8..9453f2f7cb 100644
--- a/test/core/end2end/fixtures/h2_oauth2.cc
+++ b/test/core/end2end/fixtures/h2_oauth2.cc
@@ -66,7 +66,7 @@ static void process_oauth2_success(void* state, grpc_auth_context* ctx,
test_processor_state* s;
GPR_ASSERT(state != nullptr);
- s = (test_processor_state*)state;
+ s = static_cast<test_processor_state*>(state);
GPR_ASSERT(s->pseudo_refcount == 1);
GPR_ASSERT(oauth2 != nullptr);
grpc_auth_context_add_cstring_property(ctx, client_identity_property_name,
@@ -84,7 +84,7 @@ static void process_oauth2_failure(void* state, grpc_auth_context* ctx,
find_metadata(md, md_count, "authorization", oauth2_md);
test_processor_state* s;
GPR_ASSERT(state != nullptr);
- s = (test_processor_state*)state;
+ s = static_cast<test_processor_state*>(state);
GPR_ASSERT(s->pseudo_refcount == 1);
GPR_ASSERT(oauth2 != nullptr);
cb(user_data, oauth2, 1, nullptr, 0, GRPC_STATUS_UNAUTHENTICATED, nullptr);
@@ -177,7 +177,7 @@ static int fail_server_auth_check(grpc_channel_args* server_args) {
}
static void processor_destroy(void* state) {
- test_processor_state* s = (test_processor_state*)state;
+ test_processor_state* s = static_cast<test_processor_state*>(state);
GPR_ASSERT((s->pseudo_refcount--) == 1);
gpr_free(s);
}
diff --git a/test/core/end2end/fixtures/http_proxy_fixture.cc b/test/core/end2end/fixtures/http_proxy_fixture.cc
index 2d5e841aea..63a15753a4 100644
--- a/test/core/end2end/fixtures/http_proxy_fixture.cc
+++ b/test/core/end2end/fixtures/http_proxy_fixture.cc
@@ -185,7 +185,7 @@ static void proxy_connection_failed(proxy_connection* conn,
// Callback for writing proxy data to the client.
static void on_client_write_done(void* arg, grpc_error* error) {
- proxy_connection* conn = (proxy_connection*)arg;
+ proxy_connection* conn = static_cast<proxy_connection*>(arg);
conn->client_is_writing = false;
if (error != GRPC_ERROR_NONE) {
proxy_connection_failed(conn, CLIENT_WRITE_FAILED,
@@ -210,7 +210,7 @@ static void on_client_write_done(void* arg, grpc_error* error) {
// Callback for writing proxy data to the backend server.
static void on_server_write_done(void* arg, grpc_error* error) {
- proxy_connection* conn = (proxy_connection*)arg;
+ proxy_connection* conn = static_cast<proxy_connection*>(arg);
conn->server_is_writing = false;
if (error != GRPC_ERROR_NONE) {
proxy_connection_failed(conn, SERVER_WRITE_FAILED,
@@ -236,7 +236,7 @@ static void on_server_write_done(void* arg, grpc_error* error) {
// Callback for reading data from the client, which will be proxied to
// the backend server.
static void on_client_read_done(void* arg, grpc_error* error) {
- proxy_connection* conn = (proxy_connection*)arg;
+ proxy_connection* conn = static_cast<proxy_connection*>(arg);
if (error != GRPC_ERROR_NONE) {
proxy_connection_failed(conn, CLIENT_READ_FAILED, "HTTP proxy client read",
GRPC_ERROR_REF(error));
@@ -267,7 +267,7 @@ static void on_client_read_done(void* arg, grpc_error* error) {
// Callback for reading data from the backend server, which will be
// proxied to the client.
static void on_server_read_done(void* arg, grpc_error* error) {
- proxy_connection* conn = (proxy_connection*)arg;
+ proxy_connection* conn = static_cast<proxy_connection*>(arg);
if (error != GRPC_ERROR_NONE) {
proxy_connection_failed(conn, SERVER_READ_FAILED, "HTTP proxy server read",
GRPC_ERROR_REF(error));
@@ -297,7 +297,7 @@ static void on_server_read_done(void* arg, grpc_error* error) {
// Callback to write the HTTP response for the CONNECT request.
static void on_write_response_done(void* arg, grpc_error* error) {
- proxy_connection* conn = (proxy_connection*)arg;
+ proxy_connection* conn = static_cast<proxy_connection*>(arg);
conn->client_is_writing = false;
if (error != GRPC_ERROR_NONE) {
proxy_connection_failed(conn, SETUP_FAILED, "HTTP proxy write response",
@@ -321,7 +321,7 @@ static void on_write_response_done(void* arg, grpc_error* error) {
// Callback to connect to the backend server specified by the HTTP
// CONNECT request.
static void on_server_connect_done(void* arg, grpc_error* error) {
- proxy_connection* conn = (proxy_connection*)arg;
+ proxy_connection* conn = static_cast<proxy_connection*>(arg);
if (error != GRPC_ERROR_NONE) {
// TODO(roth): Technically, in this case, we should handle the error
// by returning an HTTP response to the client indicating that the
@@ -370,7 +370,7 @@ static bool proxy_auth_header_matches(char* proxy_auth_header_val,
// of this test code, it's fine to pretend this is a client-side error,
// which will cause the client connection to be dropped.
static void on_read_request_done(void* arg, grpc_error* error) {
- proxy_connection* conn = (proxy_connection*)arg;
+ proxy_connection* conn = static_cast<proxy_connection*>(arg);
gpr_log(GPR_DEBUG, "on_read_request_done: %p %s", conn,
grpc_error_string(error));
if (error != GRPC_ERROR_NONE) {
@@ -456,9 +456,10 @@ static void on_accept(void* arg, grpc_endpoint* endpoint,
grpc_pollset* accepting_pollset,
grpc_tcp_server_acceptor* acceptor) {
gpr_free(acceptor);
- grpc_end2end_http_proxy* proxy = (grpc_end2end_http_proxy*)arg;
+ grpc_end2end_http_proxy* proxy = static_cast<grpc_end2end_http_proxy*>(arg);
// Instantiate proxy_connection.
- proxy_connection* conn = (proxy_connection*)gpr_zalloc(sizeof(*conn));
+ proxy_connection* conn =
+ static_cast<proxy_connection*>(gpr_zalloc(sizeof(*conn)));
gpr_ref(&proxy->users);
conn->client_endpoint = endpoint;
conn->proxy = proxy;
@@ -499,7 +500,7 @@ static void on_accept(void* arg, grpc_endpoint* endpoint,
//
static void thread_main(void* arg) {
- grpc_end2end_http_proxy* proxy = (grpc_end2end_http_proxy*)arg;
+ grpc_end2end_http_proxy* proxy = static_cast<grpc_end2end_http_proxy*>(arg);
grpc_core::ExecCtx exec_ctx;
do {
gpr_ref(&proxy->users);
@@ -518,7 +519,7 @@ grpc_end2end_http_proxy* grpc_end2end_http_proxy_create(
grpc_channel_args* args) {
grpc_core::ExecCtx exec_ctx;
grpc_end2end_http_proxy* proxy =
- (grpc_end2end_http_proxy*)gpr_malloc(sizeof(*proxy));
+ static_cast<grpc_end2end_http_proxy*>(gpr_malloc(sizeof(*proxy)));
memset(proxy, 0, sizeof(*proxy));
proxy->combiner = grpc_combiner_create();
gpr_ref_init(&proxy->users, 1);
@@ -533,7 +534,8 @@ grpc_end2end_http_proxy* grpc_end2end_http_proxy_create(
GPR_ASSERT(error == GRPC_ERROR_NONE);
// Bind to port.
grpc_resolved_address resolved_addr;
- struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
+ struct sockaddr_in* addr =
+ reinterpret_cast<struct sockaddr_in*>(resolved_addr.addr);
memset(&resolved_addr, 0, sizeof(resolved_addr));
addr->sin_family = AF_INET;
grpc_sockaddr_set_port(&resolved_addr, proxy_port);
@@ -542,7 +544,7 @@ grpc_end2end_http_proxy* grpc_end2end_http_proxy_create(
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(port == proxy_port);
// Start server.
- proxy->pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size());
+ proxy->pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
grpc_pollset_init(proxy->pollset, &proxy->mu);
grpc_tcp_server_start(proxy->server, &proxy->pollset, 1, on_accept, proxy);
@@ -555,7 +557,7 @@ grpc_end2end_http_proxy* grpc_end2end_http_proxy_create(
}
static void destroy_pollset(void* arg, grpc_error* error) {
- grpc_pollset* pollset = (grpc_pollset*)arg;
+ grpc_pollset* pollset = static_cast<grpc_pollset*>(arg);
grpc_pollset_destroy(pollset);
gpr_free(pollset);
}
diff --git a/test/core/end2end/fixtures/proxy.cc b/test/core/end2end/fixtures/proxy.cc
index 7a35796e9c..918988d9dc 100644
--- a/test/core/end2end/fixtures/proxy.cc
+++ b/test/core/end2end/fixtures/proxy.cc
@@ -80,7 +80,8 @@ grpc_end2end_proxy* grpc_end2end_proxy_create(const grpc_end2end_proxy_def* def,
int proxy_port = grpc_pick_unused_port_or_die();
int server_port = grpc_pick_unused_port_or_die();
- grpc_end2end_proxy* proxy = (grpc_end2end_proxy*)gpr_malloc(sizeof(*proxy));
+ grpc_end2end_proxy* proxy =
+ static_cast<grpc_end2end_proxy*>(gpr_malloc(sizeof(*proxy)));
memset(proxy, 0, sizeof(*proxy));
gpr_join_host_port(&proxy->proxy_port, "localhost", proxy_port);
@@ -107,14 +108,14 @@ grpc_end2end_proxy* grpc_end2end_proxy_create(const grpc_end2end_proxy_def* def,
}
static closure* new_closure(void (*func)(void* arg, int success), void* arg) {
- closure* cl = (closure*)gpr_malloc(sizeof(*cl));
+ closure* cl = static_cast<closure*>(gpr_malloc(sizeof(*cl)));
cl->func = func;
cl->arg = arg;
return cl;
}
static void shutdown_complete(void* arg, int success) {
- grpc_end2end_proxy* proxy = (grpc_end2end_proxy*)arg;
+ grpc_end2end_proxy* proxy = static_cast<grpc_end2end_proxy*>(arg);
proxy->shutdown = 1;
grpc_completion_queue_shutdown(proxy->cq);
}
@@ -147,12 +148,12 @@ static void unrefpc(proxy_call* pc, const char* reason) {
static void refpc(proxy_call* pc, const char* reason) { gpr_ref(&pc->refs); }
static void on_c2p_sent_initial_metadata(void* arg, int success) {
- proxy_call* pc = (proxy_call*)arg;
+ proxy_call* pc = static_cast<proxy_call*>(arg);
unrefpc(pc, "on_c2p_sent_initial_metadata");
}
static void on_p2s_recv_initial_metadata(void* arg, int success) {
- proxy_call* pc = (proxy_call*)arg;
+ proxy_call* pc = static_cast<proxy_call*>(arg);
grpc_op op;
grpc_call_error err;
@@ -174,14 +175,14 @@ static void on_p2s_recv_initial_metadata(void* arg, int success) {
}
static void on_p2s_sent_initial_metadata(void* arg, int success) {
- proxy_call* pc = (proxy_call*)arg;
+ proxy_call* pc = static_cast<proxy_call*>(arg);
unrefpc(pc, "on_p2s_sent_initial_metadata");
}
static void on_c2p_recv_msg(void* arg, int success);
static void on_p2s_sent_message(void* arg, int success) {
- proxy_call* pc = (proxy_call*)arg;
+ proxy_call* pc = static_cast<proxy_call*>(arg);
grpc_op op;
grpc_call_error err;
@@ -201,12 +202,12 @@ static void on_p2s_sent_message(void* arg, int success) {
}
static void on_p2s_sent_close(void* arg, int success) {
- proxy_call* pc = (proxy_call*)arg;
+ proxy_call* pc = static_cast<proxy_call*>(arg);
unrefpc(pc, "on_p2s_sent_close");
}
static void on_c2p_recv_msg(void* arg, int success) {
- proxy_call* pc = (proxy_call*)arg;
+ proxy_call* pc = static_cast<proxy_call*>(arg);
grpc_op op;
grpc_call_error err;
@@ -241,7 +242,7 @@ static void on_c2p_recv_msg(void* arg, int success) {
static void on_p2s_recv_msg(void* arg, int success);
static void on_c2p_sent_message(void* arg, int success) {
- proxy_call* pc = (proxy_call*)arg;
+ proxy_call* pc = static_cast<proxy_call*>(arg);
grpc_op op;
grpc_call_error err;
@@ -261,7 +262,7 @@ static void on_c2p_sent_message(void* arg, int success) {
}
static void on_p2s_recv_msg(void* arg, int success) {
- proxy_call* pc = (proxy_call*)arg;
+ proxy_call* pc = static_cast<proxy_call*>(arg);
grpc_op op;
grpc_call_error err;
@@ -281,12 +282,12 @@ static void on_p2s_recv_msg(void* arg, int success) {
}
static void on_c2p_sent_status(void* arg, int success) {
- proxy_call* pc = (proxy_call*)arg;
+ proxy_call* pc = static_cast<proxy_call*>(arg);
unrefpc(pc, "on_c2p_sent_status");
}
static void on_p2s_status(void* arg, int success) {
- proxy_call* pc = (proxy_call*)arg;
+ proxy_call* pc = static_cast<proxy_call*>(arg);
grpc_op op;
grpc_call_error err;
@@ -311,18 +312,18 @@ static void on_p2s_status(void* arg, int success) {
}
static void on_c2p_closed(void* arg, int success) {
- proxy_call* pc = (proxy_call*)arg;
+ proxy_call* pc = static_cast<proxy_call*>(arg);
unrefpc(pc, "on_c2p_closed");
}
static void on_new_call(void* arg, int success) {
- grpc_end2end_proxy* proxy = (grpc_end2end_proxy*)arg;
+ grpc_end2end_proxy* proxy = static_cast<grpc_end2end_proxy*>(arg);
grpc_call_error err;
if (success) {
grpc_op op;
memset(&op, 0, sizeof(op));
- proxy_call* pc = (proxy_call*)gpr_malloc(sizeof(*pc));
+ proxy_call* pc = static_cast<proxy_call*>(gpr_malloc(sizeof(*pc)));
memset(pc, 0, sizeof(*pc));
pc->proxy = proxy;
GPR_SWAP(grpc_metadata_array, pc->c2p_initial_metadata,
@@ -412,7 +413,7 @@ static void request_call(grpc_end2end_proxy* proxy) {
}
static void thread_main(void* arg) {
- grpc_end2end_proxy* proxy = (grpc_end2end_proxy*)arg;
+ grpc_end2end_proxy* proxy = static_cast<grpc_end2end_proxy*>(arg);
closure* cl;
for (;;) {
grpc_event ev = grpc_completion_queue_next(
@@ -424,7 +425,7 @@ static void thread_main(void* arg) {
case GRPC_QUEUE_SHUTDOWN:
return;
case GRPC_OP_COMPLETE:
- cl = (closure*)ev.tag;
+ cl = static_cast<closure*>(ev.tag);
cl->func(cl->arg, ev.success);
gpr_free(cl);
break;
diff --git a/test/core/end2end/fuzzers/api_fuzzer.cc b/test/core/end2end/fuzzers/api_fuzzer.cc
index 14c155502a..dc1183b9a0 100644
--- a/test/core/end2end/fuzzers/api_fuzzer.cc
+++ b/test/core/end2end/fuzzers/api_fuzzer.cc
@@ -93,7 +93,7 @@ static char* read_string(input_stream* inp, bool* special) {
cap = GPR_MAX(3 * cap / 2, cap + 8);
str = static_cast<char*>(gpr_realloc(str, cap));
}
- c = (char)next_byte(inp);
+ c = static_cast<char>(next_byte(inp));
str[sz++] = c;
} while (c != 0 && c != 1);
if (special != nullptr) {
@@ -116,7 +116,7 @@ static void read_buffer(input_stream* inp, char** buffer, size_t* length,
}
*buffer = static_cast<char*>(gpr_malloc(*length));
for (size_t i = 0; i < *length; i++) {
- (*buffer)[i] = (char)next_byte(inp);
+ (*buffer)[i] = static_cast<char>(next_byte(inp));
}
}
@@ -192,7 +192,9 @@ static grpc_byte_buffer* read_message(input_stream* inp) {
return out;
}
-static int read_int(input_stream* inp) { return (int)read_uint32(inp); }
+static int read_int(input_stream* inp) {
+ return static_cast<int>(read_uint32(inp));
+}
static grpc_channel_args* read_args(input_stream* inp) {
size_t n = next_byte(inp);
@@ -529,10 +531,12 @@ static validator* create_validator(void (*validate)(void* arg, bool success),
static void assert_success_and_decrement(void* counter, bool success) {
GPR_ASSERT(success);
- --*(int*)counter;
+ --*static_cast<int*>(counter);
}
-static void decrement(void* counter, bool success) { --*(int*)counter; }
+static void decrement(void* counter, bool success) {
+ --*static_cast<int*>(counter);
+}
typedef struct connectivity_watch {
int* counter;
diff --git a/test/core/end2end/fuzzers/client_fuzzer.cc b/test/core/end2end/fuzzers/client_fuzzer.cc
index c17d581d8b..16acf8ef28 100644
--- a/test/core/end2end/fuzzers/client_fuzzer.cc
+++ b/test/core/end2end/fuzzers/client_fuzzer.cc
@@ -33,7 +33,7 @@ bool leak_check = true;
static void discard_write(grpc_slice slice) {}
-static void* tag(int n) { return (void*)(uintptr_t)n; }
+static void* tag(int n) { return (void*)static_cast<uintptr_t>(n); }
static void dont_log(gpr_log_func_args* args) {}
diff --git a/test/core/end2end/fuzzers/server_fuzzer.cc b/test/core/end2end/fuzzers/server_fuzzer.cc
index 61c55e0afd..5eb83ede7a 100644
--- a/test/core/end2end/fuzzers/server_fuzzer.cc
+++ b/test/core/end2end/fuzzers/server_fuzzer.cc
@@ -30,8 +30,8 @@ bool leak_check = true;
static void discard_write(grpc_slice slice) {}
-static void* tag(int n) { return (void*)(uintptr_t)n; }
-static int detag(void* p) { return (int)(uintptr_t)p; }
+static void* tag(int n) { return (void*)static_cast<uintptr_t>(n); }
+static int detag(void* p) { return static_cast<int>((uintptr_t)p); }
static void dont_log(gpr_log_func_args* args) {}
diff --git a/test/core/end2end/goaway_server_test.cc b/test/core/end2end/goaway_server_test.cc
index f23d87ea68..09f0301c44 100644
--- a/test/core/end2end/goaway_server_test.cc
+++ b/test/core/end2end/goaway_server_test.cc
@@ -77,10 +77,11 @@ static void my_resolve_address(const char* addr, const char* default_port,
(*addrs)->addrs = static_cast<grpc_resolved_address*>(
gpr_malloc(sizeof(*(*addrs)->addrs)));
memset((*addrs)->addrs, 0, sizeof(*(*addrs)->addrs));
- struct sockaddr_in* sa = (struct sockaddr_in*)(*addrs)->addrs[0].addr;
+ struct sockaddr_in* sa =
+ reinterpret_cast<struct sockaddr_in*>((*addrs)->addrs[0].addr);
sa->sin_family = AF_INET;
sa->sin_addr.s_addr = htonl(0x7f000001);
- sa->sin_port = htons((uint16_t)g_resolve_port);
+ sa->sin_port = htons(static_cast<uint16_t>(g_resolve_port));
(*addrs)->addrs[0].len = sizeof(*sa);
gpr_mu_unlock(&g_mu);
}
@@ -109,7 +110,7 @@ static grpc_ares_request* my_dns_lookup_ares(
gpr_zalloc(sizeof(struct sockaddr_in)));
sa->sin_family = AF_INET;
sa->sin_addr.s_addr = htonl(0x7f000001);
- sa->sin_port = htons((uint16_t)g_resolve_port);
+ sa->sin_port = htons(static_cast<uint16_t>(g_resolve_port));
grpc_lb_addresses_set_address(*lb_addrs, 0, sa, sizeof(*sa), false, nullptr,
nullptr);
gpr_free(sa);
diff --git a/test/core/end2end/h2_ssl_cert_test.cc b/test/core/end2end/h2_ssl_cert_test.cc
index cd62c3f4e2..9e2082ce9d 100644
--- a/test/core/end2end/h2_ssl_cert_test.cc
+++ b/test/core/end2end/h2_ssl_cert_test.cc
@@ -333,7 +333,8 @@ static void simple_request_body(grpc_end2end_test_fixture f,
op->flags = GRPC_INITIAL_METADATA_WAIT_FOR_READY;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(1), expected_result == SUCCESS);
diff --git a/test/core/end2end/invalid_call_argument_test.cc b/test/core/end2end/invalid_call_argument_test.cc
index d2b26e7131..6cb2e3ee80 100644
--- a/test/core/end2end/invalid_call_argument_test.cc
+++ b/test/core/end2end/invalid_call_argument_test.cc
@@ -209,7 +209,7 @@ static void test_too_many_metadata() {
op = g_state.ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
- op->data.send_initial_metadata.count = (size_t)INT_MAX + 1;
+ op->data.send_initial_metadata.count = static_cast<size_t>(INT_MAX) + 1;
op->flags = 0;
op->reserved = nullptr;
op++;
@@ -499,7 +499,7 @@ static void test_too_many_trailing_metadata() {
op = g_state.ops;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count =
- (size_t)INT_MAX + 1;
+ static_cast<size_t>(INT_MAX) + 1;
op->data.send_status_from_server.status = GRPC_STATUS_UNIMPLEMENTED;
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
diff --git a/test/core/end2end/tests/authority_not_supported.cc b/test/core/end2end/tests/authority_not_supported.cc
index f2852f772e..01a95e4e10 100644
--- a/test/core/end2end/tests/authority_not_supported.cc
+++ b/test/core/end2end/tests/authority_not_supported.cc
@@ -154,7 +154,8 @@ static void test_with_authority_header(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
diff --git a/test/core/end2end/tests/bad_hostname.cc b/test/core/end2end/tests/bad_hostname.cc
index 63bfd76120..b6f06a20d6 100644
--- a/test/core/end2end/tests/bad_hostname.cc
+++ b/test/core/end2end/tests/bad_hostname.cc
@@ -133,7 +133,8 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
diff --git a/test/core/end2end/tests/bad_ping.cc b/test/core/end2end/tests/bad_ping.cc
index 672c2f4c6e..ddab3faa27 100644
--- a/test/core/end2end/tests/bad_ping.cc
+++ b/test/core/end2end/tests/bad_ping.cc
@@ -144,7 +144,8 @@ static void test_bad_ping(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -188,7 +189,8 @@ static void test_bad_ping(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
diff --git a/test/core/end2end/tests/binary_metadata.cc b/test/core/end2end/tests/binary_metadata.cc
index 8a0d667428..e66b4da6cc 100644
--- a/test/core/end2end/tests/binary_metadata.cc
+++ b/test/core/end2end/tests/binary_metadata.cc
@@ -182,7 +182,8 @@ static void test_request_response_with_metadata_and_payload(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -205,7 +206,8 @@ static void test_request_response_with_metadata_and_payload(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -246,7 +248,8 @@ static void test_request_response_with_metadata_and_payload(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(103),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
diff --git a/test/core/end2end/tests/call_creds.cc b/test/core/end2end/tests/call_creds.cc
index 968dab1995..e9cbaa3088 100644
--- a/test/core/end2end/tests/call_creds.cc
+++ b/test/core/end2end/tests/call_creds.cc
@@ -219,7 +219,8 @@ static void request_response_with_payload_and_call_creds(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -253,7 +254,8 @@ static void request_response_with_payload_and_call_creds(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -279,7 +281,8 @@ static void request_response_with_payload_and_call_creds(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(103),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
@@ -443,7 +446,8 @@ static void test_request_with_server_rejecting_client_creds(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(error == GRPC_CALL_OK);
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
diff --git a/test/core/end2end/tests/cancel_after_accept.cc b/test/core/end2end/tests/cancel_after_accept.cc
index 11bf4e79b7..ee1a0bbccc 100644
--- a/test/core/end2end/tests/cancel_after_accept.cc
+++ b/test/core/end2end/tests/cancel_after_accept.cc
@@ -186,7 +186,8 @@ static void test_cancel_after_accept(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error = grpc_server_request_call(f.server, &s, &call_details,
@@ -217,7 +218,8 @@ static void test_cancel_after_accept(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(3), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(3),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
GPR_ASSERT(GRPC_CALL_OK == mode.initiate_cancel(c, nullptr));
diff --git a/test/core/end2end/tests/cancel_after_client_done.cc b/test/core/end2end/tests/cancel_after_client_done.cc
index b0702b7f44..31c3ea6f74 100644
--- a/test/core/end2end/tests/cancel_after_client_done.cc
+++ b/test/core/end2end/tests/cancel_after_client_done.cc
@@ -164,7 +164,8 @@ static void test_cancel_after_accept_and_writes_closed(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error = grpc_server_request_call(f.server, &s, &call_details,
@@ -195,7 +196,8 @@ static void test_cancel_after_accept_and_writes_closed(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(3), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(3),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
GPR_ASSERT(GRPC_CALL_OK == mode.initiate_cancel(c, nullptr));
diff --git a/test/core/end2end/tests/cancel_after_round_trip.cc b/test/core/end2end/tests/cancel_after_round_trip.cc
index 63e6505f0e..bf3be1c8b7 100644
--- a/test/core/end2end/tests/cancel_after_round_trip.cc
+++ b/test/core/end2end/tests/cancel_after_round_trip.cc
@@ -181,7 +181,8 @@ static void test_cancel_after_round_trip(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -208,7 +209,8 @@ static void test_cancel_after_round_trip(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -234,7 +236,8 @@ static void test_cancel_after_round_trip(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(2),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
GPR_ASSERT(GRPC_CALL_OK == mode.initiate_cancel(c, nullptr));
@@ -251,7 +254,8 @@ static void test_cancel_after_round_trip(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(103),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(2), 1);
diff --git a/test/core/end2end/tests/compressed_payload.cc b/test/core/end2end/tests/compressed_payload.cc
index 63bf472906..85cfe16508 100644
--- a/test/core/end2end/tests/compressed_payload.cc
+++ b/test/core/end2end/tests/compressed_payload.cc
@@ -187,7 +187,8 @@ static void request_for_disabled_algorithm(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(101), true);
@@ -205,7 +206,8 @@ static void request_for_disabled_algorithm(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), false);
@@ -216,7 +218,8 @@ static void request_for_disabled_algorithm(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(103),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), true);
@@ -338,7 +341,8 @@ static void request_with_payload_template(
op->flags = client_send_flags_bitmask;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(2),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(2), true);
}
@@ -367,7 +371,8 @@ static void request_with_payload_template(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -403,7 +408,8 @@ static void request_with_payload_template(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(101), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(101),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
for (int i = 0; i < 2; i++) {
@@ -418,8 +424,8 @@ static void request_with_payload_template(
op->flags = client_send_flags_bitmask;
op->reserved = nullptr;
op++;
- error =
- grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops),
+ tag(2), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(2), 1);
}
@@ -431,8 +437,8 @@ static void request_with_payload_template(
op->flags = 0;
op->reserved = nullptr;
op++;
- error =
- grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops),
+ tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -450,8 +456,8 @@ static void request_with_payload_template(
op->flags = 0;
op->reserved = nullptr;
op++;
- error =
- grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops),
+ tag(103), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -461,7 +467,8 @@ static void request_with_payload_template(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(3),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
@@ -495,7 +502,8 @@ static void request_with_payload_template(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(4), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(4),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -508,7 +516,8 @@ static void request_with_payload_template(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(104),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
diff --git a/test/core/end2end/tests/connectivity.cc b/test/core/end2end/tests/connectivity.cc
index da65080bc0..56e5189a22 100644
--- a/test/core/end2end/tests/connectivity.cc
+++ b/test/core/end2end/tests/connectivity.cc
@@ -34,7 +34,7 @@ typedef struct {
} child_events;
static void child_thread(void* arg) {
- child_events* ce = (child_events*)arg;
+ child_events* ce = static_cast<child_events*>(arg);
grpc_event ev;
gpr_event_set(&ce->started, (void*)1);
gpr_log(GPR_DEBUG, "verifying");
diff --git a/test/core/end2end/tests/default_host.cc b/test/core/end2end/tests/default_host.cc
index 33be5f1273..3191f76688 100644
--- a/test/core/end2end/tests/default_host.cc
+++ b/test/core/end2end/tests/default_host.cc
@@ -140,7 +140,8 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(error == GRPC_CALL_OK);
error =
@@ -179,7 +180,8 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(error == GRPC_CALL_OK);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
diff --git a/test/core/end2end/tests/disappearing_server.cc b/test/core/end2end/tests/disappearing_server.cc
index 1b2f729ba8..d5b6f8fbf0 100644
--- a/test/core/end2end/tests/disappearing_server.cc
+++ b/test/core/end2end/tests/disappearing_server.cc
@@ -120,7 +120,8 @@ static void do_request_and_shutdown_server(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -154,7 +155,8 @@ static void do_request_and_shutdown_server(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
diff --git a/test/core/end2end/tests/filter_call_init_fails.cc b/test/core/end2end/tests/filter_call_init_fails.cc
index f60a47f8ff..6f72a1843a 100644
--- a/test/core/end2end/tests/filter_call_init_fails.cc
+++ b/test/core/end2end/tests/filter_call_init_fails.cc
@@ -158,7 +158,8 @@ static void test_server_channel_filter(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -253,7 +254,8 @@ static void test_client_channel_filter(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
@@ -344,7 +346,8 @@ static void test_client_subchannel_filter(grpc_end2end_test_config config) {
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
@@ -368,7 +371,8 @@ static void test_client_subchannel_filter(grpc_end2end_test_config config) {
nullptr);
GPR_ASSERT(c);
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(2),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(2), 1);
diff --git a/test/core/end2end/tests/filter_causes_close.cc b/test/core/end2end/tests/filter_causes_close.cc
index 43f20d7cc0..bc4cb8633d 100644
--- a/test/core/end2end/tests/filter_causes_close.cc
+++ b/test/core/end2end/tests/filter_causes_close.cc
@@ -152,7 +152,8 @@ static void test_request(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -197,8 +198,8 @@ typedef struct {
} channel_data;
static void recv_im_ready(void* arg, grpc_error* error) {
- grpc_call_element* elem = (grpc_call_element*)arg;
- call_data* calld = (call_data*)elem->call_data;
+ grpc_call_element* elem = static_cast<grpc_call_element*>(arg);
+ call_data* calld = static_cast<call_data*>(elem->call_data);
GRPC_CLOSURE_RUN(
calld->recv_im_ready,
grpc_error_set_int(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
@@ -209,7 +210,7 @@ static void recv_im_ready(void* arg, grpc_error* error) {
static void start_transport_stream_op_batch(
grpc_call_element* elem, grpc_transport_stream_op_batch* op) {
- call_data* calld = (call_data*)elem->call_data;
+ call_data* calld = static_cast<call_data*>(elem->call_data);
if (op->recv_initial_metadata) {
calld->recv_im_ready =
op->payload->recv_initial_metadata.recv_initial_metadata_ready;
diff --git a/test/core/end2end/tests/filter_latency.cc b/test/core/end2end/tests/filter_latency.cc
index d6cf3b034e..51f54c9742 100644
--- a/test/core/end2end/tests/filter_latency.cc
+++ b/test/core/end2end/tests/filter_latency.cc
@@ -165,7 +165,8 @@ static void test_request(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -196,7 +197,8 @@ static void test_request(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -305,7 +307,7 @@ static const grpc_channel_filter test_server_filter = {
*/
static bool maybe_add_filter(grpc_channel_stack_builder* builder, void* arg) {
- grpc_channel_filter* filter = (grpc_channel_filter*)arg;
+ grpc_channel_filter* filter = static_cast<grpc_channel_filter*>(arg);
if (g_enable_filter) {
// Want to add the filter as close to the end as possible, to make
// sure that all of the filters work well together. However, we
diff --git a/test/core/end2end/tests/filter_status_code.cc b/test/core/end2end/tests/filter_status_code.cc
index ad80f23d6f..32cd95410e 100644
--- a/test/core/end2end/tests/filter_status_code.cc
+++ b/test/core/end2end/tests/filter_status_code.cc
@@ -164,7 +164,8 @@ static void test_request(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -199,7 +200,8 @@ static void test_request(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -250,7 +252,7 @@ typedef struct final_status_data {
static grpc_error* init_call_elem(grpc_call_element* elem,
const grpc_call_element_args* args) {
- final_status_data* data = (final_status_data*)elem->call_data;
+ final_status_data* data = static_cast<final_status_data*>(elem->call_data);
data->call = args->call_stack;
return GRPC_ERROR_NONE;
}
@@ -258,7 +260,7 @@ static grpc_error* init_call_elem(grpc_call_element* elem,
static void client_destroy_call_elem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {
- final_status_data* data = (final_status_data*)elem->call_data;
+ final_status_data* data = static_cast<final_status_data*>(elem->call_data);
gpr_mu_lock(&g_mu);
// Some fixtures, like proxies, will spawn intermidiate calls
// We only want the results from our explicit calls
@@ -273,7 +275,7 @@ static void client_destroy_call_elem(grpc_call_element* elem,
static void server_destroy_call_elem(grpc_call_element* elem,
const grpc_call_final_info* final_info,
grpc_closure* ignored) {
- final_status_data* data = (final_status_data*)elem->call_data;
+ final_status_data* data = static_cast<final_status_data*>(elem->call_data);
gpr_mu_lock(&g_mu);
// Some fixtures, like proxies, will spawn intermidiate calls
// We only want the results from our explicit calls
@@ -323,7 +325,7 @@ static const grpc_channel_filter test_server_filter = {
*/
static bool maybe_add_filter(grpc_channel_stack_builder* builder, void* arg) {
- grpc_channel_filter* filter = (grpc_channel_filter*)arg;
+ grpc_channel_filter* filter = static_cast<grpc_channel_filter*>(arg);
if (g_enable_filter) {
// Want to add the filter as close to the end as possible, to make
// sure that all of the filters work well together. However, we
diff --git a/test/core/end2end/tests/graceful_server_shutdown.cc b/test/core/end2end/tests/graceful_server_shutdown.cc
index 3b6872bfd7..3ef414f83c 100644
--- a/test/core/end2end/tests/graceful_server_shutdown.cc
+++ b/test/core/end2end/tests/graceful_server_shutdown.cc
@@ -135,7 +135,8 @@ static void test_early_server_shutdown_finishes_inflight_calls(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -169,7 +170,8 @@ static void test_early_server_shutdown_finishes_inflight_calls(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
diff --git a/test/core/end2end/tests/high_initial_seqno.cc b/test/core/end2end/tests/high_initial_seqno.cc
index 989cd5610f..8767437802 100644
--- a/test/core/end2end/tests/high_initial_seqno.cc
+++ b/test/core/end2end/tests/high_initial_seqno.cc
@@ -139,7 +139,8 @@ static void simple_request_body(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -169,7 +170,8 @@ static void simple_request_body(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
diff --git a/test/core/end2end/tests/hpack_size.cc b/test/core/end2end/tests/hpack_size.cc
index 66b3a4019f..b49736841e 100644
--- a/test/core/end2end/tests/hpack_size.cc
+++ b/test/core/end2end/tests/hpack_size.cc
@@ -293,7 +293,8 @@ static void simple_request_body(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -323,7 +324,8 @@ static void simple_request_body(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
diff --git a/test/core/end2end/tests/idempotent_request.cc b/test/core/end2end/tests/idempotent_request.cc
index 578510d407..56be2d6afe 100644
--- a/test/core/end2end/tests/idempotent_request.cc
+++ b/test/core/end2end/tests/idempotent_request.cc
@@ -144,7 +144,8 @@ static void simple_request_body(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -183,7 +184,8 @@ static void simple_request_body(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
diff --git a/test/core/end2end/tests/invoke_large_request.cc b/test/core/end2end/tests/invoke_large_request.cc
index b7afa97401..1aab34c2ce 100644
--- a/test/core/end2end/tests/invoke_large_request.cc
+++ b/test/core/end2end/tests/invoke_large_request.cc
@@ -176,7 +176,8 @@ static void test_invoke_large_request(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -198,7 +199,8 @@ static void test_invoke_large_request(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -224,7 +226,8 @@ static void test_invoke_large_request(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(103),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
diff --git a/test/core/end2end/tests/keepalive_timeout.cc b/test/core/end2end/tests/keepalive_timeout.cc
index 0cdd12e9ca..f0dd061e33 100644
--- a/test/core/end2end/tests/keepalive_timeout.cc
+++ b/test/core/end2end/tests/keepalive_timeout.cc
@@ -155,7 +155,8 @@ static void test_keepalive_timeout(grpc_end2end_test_config config) {
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &response_payload_recv;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
@@ -172,7 +173,8 @@ static void test_keepalive_timeout(grpc_end2end_test_config config) {
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = response_payload;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -186,7 +188,8 @@ static void test_keepalive_timeout(grpc_end2end_test_config config) {
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(3),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(3), 1);
diff --git a/test/core/end2end/tests/large_metadata.cc b/test/core/end2end/tests/large_metadata.cc
index c1343f902d..da0615bf6e 100644
--- a/test/core/end2end/tests/large_metadata.cc
+++ b/test/core/end2end/tests/large_metadata.cc
@@ -96,7 +96,7 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) {
grpc_arg arg;
arg.type = GRPC_ARG_INTEGER;
arg.key = const_cast<char*>(GRPC_ARG_MAX_METADATA_SIZE);
- arg.value.integer = (int)large_size + 1024;
+ arg.value.integer = static_cast<int>(large_size) + 1024;
grpc_channel_args args = {1, &arg};
grpc_end2end_test_fixture f =
begin_test(config, "test_request_with_large_metadata", &args, &args);
@@ -160,7 +160,8 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -184,7 +185,8 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -207,7 +209,8 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(103),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
diff --git a/test/core/end2end/tests/load_reporting_hook.cc b/test/core/end2end/tests/load_reporting_hook.cc
index cfe5814755..9e79d02be4 100644
--- a/test/core/end2end/tests/load_reporting_hook.cc
+++ b/test/core/end2end/tests/load_reporting_hook.cc
@@ -185,7 +185,8 @@ static void request_response_with_payload(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -207,7 +208,8 @@ static void request_response_with_payload(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -235,7 +237,8 @@ static void request_response_with_payload(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(103),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
diff --git a/test/core/end2end/tests/max_concurrent_streams.cc b/test/core/end2end/tests/max_concurrent_streams.cc
index 642c0f7ce6..789b3d4b77 100644
--- a/test/core/end2end/tests/max_concurrent_streams.cc
+++ b/test/core/end2end/tests/max_concurrent_streams.cc
@@ -135,7 +135,8 @@ static void simple_request_body(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -165,7 +166,8 @@ static void simple_request_body(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -274,7 +276,8 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c1, ops, (size_t)(op - ops), tag(301), nullptr);
+ error = grpc_call_start_batch(c1, ops, static_cast<size_t>(op - ops),
+ tag(301), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -292,7 +295,8 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c1, ops, (size_t)(op - ops), tag(302), nullptr);
+ error = grpc_call_start_batch(c1, ops, static_cast<size_t>(op - ops),
+ tag(302), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -306,7 +310,8 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c2, ops, (size_t)(op - ops), tag(401), nullptr);
+ error = grpc_call_start_batch(c2, ops, static_cast<size_t>(op - ops),
+ tag(401), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -324,7 +329,8 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c2, ops, (size_t)(op - ops), tag(402), nullptr);
+ error = grpc_call_start_batch(c2, ops, static_cast<size_t>(op - ops),
+ tag(402), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
got_client_start = 0;
@@ -345,7 +351,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
* both);
* check this here */
/* We'll get tag 303 or 403, we want 300, 400 */
- live_call = ((int)(intptr_t)ev.tag) - 1;
+ live_call = (static_cast<int>((intptr_t)ev.tag)) - 1;
got_client_start = 1;
}
}
@@ -371,7 +377,8 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s1, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s1, ops, static_cast<size_t>(op - ops),
+ tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -408,7 +415,8 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s2, ops, (size_t)(op - ops), tag(202), nullptr);
+ error = grpc_call_start_batch(s2, ops, static_cast<size_t>(op - ops),
+ tag(202), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(live_call + 2), 1);
@@ -514,7 +522,8 @@ static void test_max_concurrent_streams_with_timeout_on_first(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c1, ops, (size_t)(op - ops), tag(301), nullptr);
+ error = grpc_call_start_batch(c1, ops, static_cast<size_t>(op - ops),
+ tag(301), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -532,7 +541,8 @@ static void test_max_concurrent_streams_with_timeout_on_first(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c1, ops, (size_t)(op - ops), tag(302), nullptr);
+ error = grpc_call_start_batch(c1, ops, static_cast<size_t>(op - ops),
+ tag(302), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(101), 1);
@@ -550,7 +560,8 @@ static void test_max_concurrent_streams_with_timeout_on_first(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c2, ops, (size_t)(op - ops), tag(401), nullptr);
+ error = grpc_call_start_batch(c2, ops, static_cast<size_t>(op - ops),
+ tag(401), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -568,7 +579,8 @@ static void test_max_concurrent_streams_with_timeout_on_first(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c2, ops, (size_t)(op - ops), tag(402), nullptr);
+ error = grpc_call_start_batch(c2, ops, static_cast<size_t>(op - ops),
+ tag(402), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
grpc_call_details_destroy(&call_details);
@@ -603,7 +615,8 @@ static void test_max_concurrent_streams_with_timeout_on_first(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s2, ops, (size_t)(op - ops), tag(202), nullptr);
+ error = grpc_call_start_batch(s2, ops, static_cast<size_t>(op - ops),
+ tag(202), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(402), 1);
@@ -709,7 +722,8 @@ static void test_max_concurrent_streams_with_timeout_on_second(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c1, ops, (size_t)(op - ops), tag(301), nullptr);
+ error = grpc_call_start_batch(c1, ops, static_cast<size_t>(op - ops),
+ tag(301), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -727,7 +741,8 @@ static void test_max_concurrent_streams_with_timeout_on_second(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c1, ops, (size_t)(op - ops), tag(302), nullptr);
+ error = grpc_call_start_batch(c1, ops, static_cast<size_t>(op - ops),
+ tag(302), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(101), 1);
@@ -745,7 +760,8 @@ static void test_max_concurrent_streams_with_timeout_on_second(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c2, ops, (size_t)(op - ops), tag(401), nullptr);
+ error = grpc_call_start_batch(c2, ops, static_cast<size_t>(op - ops),
+ tag(401), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -763,7 +779,8 @@ static void test_max_concurrent_streams_with_timeout_on_second(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c2, ops, (size_t)(op - ops), tag(402), nullptr);
+ error = grpc_call_start_batch(c2, ops, static_cast<size_t>(op - ops),
+ tag(402), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
/* the second request is time out*/
@@ -796,7 +813,8 @@ static void test_max_concurrent_streams_with_timeout_on_second(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s1, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s1, ops, static_cast<size_t>(op - ops),
+ tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(302), 1);
diff --git a/test/core/end2end/tests/max_connection_age.cc b/test/core/end2end/tests/max_connection_age.cc
index df5fd5cc1e..e494dad19c 100644
--- a/test/core/end2end/tests/max_connection_age.cc
+++ b/test/core/end2end/tests/max_connection_age.cc
@@ -145,7 +145,8 @@ static void test_max_age_forcibly_close(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -156,7 +157,8 @@ static void test_max_age_forcibly_close(grpc_end2end_test_config config) {
cq_verify(cqv);
gpr_timespec expect_shutdown_time = grpc_timeout_milliseconds_to_deadline(
- (int)(MAX_CONNECTION_AGE_MS * MAX_CONNECTION_AGE_JITTER_MULTIPLIER) +
+ static_cast<int>(MAX_CONNECTION_AGE_MS *
+ MAX_CONNECTION_AGE_JITTER_MULTIPLIER) +
MAX_CONNECTION_AGE_GRACE_MS + IMMEDIATE_SHUTDOWN_GRACE_TIME_MS);
/* Wait for the channel to reach its max age */
@@ -190,7 +192,8 @@ static void test_max_age_forcibly_close(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), true);
cq_verify(cqv);
@@ -288,7 +291,8 @@ static void test_max_age_gracefully_close(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -325,7 +329,8 @@ static void test_max_age_gracefully_close(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), true);
diff --git a/test/core/end2end/tests/max_connection_idle.cc b/test/core/end2end/tests/max_connection_idle.cc
index 09b4a54df3..2f212b965f 100644
--- a/test/core/end2end/tests/max_connection_idle.cc
+++ b/test/core/end2end/tests/max_connection_idle.cc
@@ -100,7 +100,8 @@ static void simple_request_body(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -139,7 +140,8 @@ static void simple_request_body(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
diff --git a/test/core/end2end/tests/max_message_length.cc b/test/core/end2end/tests/max_message_length.cc
index b1757a9b0d..3dd1737793 100644
--- a/test/core/end2end/tests/max_message_length.cc
+++ b/test/core/end2end/tests/max_message_length.cc
@@ -219,7 +219,8 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
if (send_limit) {
@@ -247,7 +248,8 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -408,7 +410,8 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -443,7 +446,8 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
diff --git a/test/core/end2end/tests/network_status_change.cc b/test/core/end2end/tests/network_status_change.cc
index 809f8ffb5c..83cb172f26 100644
--- a/test/core/end2end/tests/network_status_change.cc
+++ b/test/core/end2end/tests/network_status_change.cc
@@ -150,7 +150,8 @@ static void test_invoke_network_status_change(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
@@ -170,7 +171,8 @@ static void test_invoke_network_status_change(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -193,7 +195,8 @@ static void test_invoke_network_status_change(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(103),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
diff --git a/test/core/end2end/tests/no_logging.cc b/test/core/end2end/tests/no_logging.cc
index b4908d4926..b357e3b0ad 100644
--- a/test/core/end2end/tests/no_logging.cc
+++ b/test/core/end2end/tests/no_logging.cc
@@ -170,7 +170,8 @@ static void simple_request_body(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -207,7 +208,8 @@ static void simple_request_body(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
diff --git a/test/core/end2end/tests/payload.cc b/test/core/end2end/tests/payload.cc
index 3535d802e9..340c76e173 100644
--- a/test/core/end2end/tests/payload.cc
+++ b/test/core/end2end/tests/payload.cc
@@ -90,9 +90,9 @@ static grpc_slice generate_random_slice() {
static const char chars[] = "abcdefghijklmnopqrstuvwxyz1234567890";
char* output;
const size_t output_size = 1024 * 1024;
- output = (char*)gpr_malloc(output_size);
+ output = static_cast<char*>(gpr_malloc(output_size));
for (i = 0; i < output_size - 1; ++i) {
- output[i] = chars[rand() % (int)(sizeof(chars) - 1)];
+ output[i] = chars[rand() % static_cast<int>(sizeof(chars) - 1)];
}
output[output_size - 1] = '\0';
grpc_slice out = grpc_slice_from_copied_string(output);
@@ -174,7 +174,8 @@ static void request_response_with_payload(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -196,7 +197,8 @@ static void request_response_with_payload(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -222,7 +224,8 @@ static void request_response_with_payload(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(103),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
diff --git a/test/core/end2end/tests/ping_pong_streaming.cc b/test/core/end2end/tests/ping_pong_streaming.cc
index 714a7681b2..9ca880481f 100644
--- a/test/core/end2end/tests/ping_pong_streaming.cc
+++ b/test/core/end2end/tests/ping_pong_streaming.cc
@@ -143,7 +143,8 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -165,7 +166,8 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(101), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(101),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
for (i = 0; i < messages; i++) {
@@ -184,7 +186,8 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(2),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -194,8 +197,8 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error =
- grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops),
+ tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
cq_verify(cqv);
@@ -207,8 +210,8 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error =
- grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops),
+ tag(103), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
CQ_EXPECT_COMPLETION(cqv, tag(2), 1);
@@ -229,7 +232,8 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(3),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -242,7 +246,8 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(104),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
diff --git a/test/core/end2end/tests/proxy_auth.cc b/test/core/end2end/tests/proxy_auth.cc
index c34505c878..5a2e0ef414 100644
--- a/test/core/end2end/tests/proxy_auth.cc
+++ b/test/core/end2end/tests/proxy_auth.cc
@@ -148,7 +148,8 @@ static void simple_request_body(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -187,7 +188,8 @@ static void simple_request_body(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
diff --git a/test/core/end2end/tests/registered_call.cc b/test/core/end2end/tests/registered_call.cc
index d1c37dca20..d4ca146707 100644
--- a/test/core/end2end/tests/registered_call.cc
+++ b/test/core/end2end/tests/registered_call.cc
@@ -135,7 +135,8 @@ static void simple_request_body(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -165,7 +166,8 @@ static void simple_request_body(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
diff --git a/test/core/end2end/tests/request_with_flags.cc b/test/core/end2end/tests/request_with_flags.cc
index 46023133ba..4a54318d0f 100644
--- a/test/core/end2end/tests/request_with_flags.cc
+++ b/test/core/end2end/tests/request_with_flags.cc
@@ -151,7 +151,8 @@ static void test_invoke_request_with_flags(
op->reserved = nullptr;
op++;
expectation = call_start_batch_expected_result;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(expectation == error);
if (expectation == GRPC_CALL_OK) {
diff --git a/test/core/end2end/tests/request_with_payload.cc b/test/core/end2end/tests/request_with_payload.cc
index 28818c80e7..44398df52d 100644
--- a/test/core/end2end/tests/request_with_payload.cc
+++ b/test/core/end2end/tests/request_with_payload.cc
@@ -147,7 +147,8 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
@@ -168,7 +169,8 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -189,7 +191,8 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(103),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
diff --git a/test/core/end2end/tests/resource_quota_server.cc b/test/core/end2end/tests/resource_quota_server.cc
index 6d35d086aa..33d6b4ef31 100644
--- a/test/core/end2end/tests/resource_quota_server.cc
+++ b/test/core/end2end/tests/resource_quota_server.cc
@@ -91,9 +91,9 @@ static grpc_slice generate_random_slice() {
static const char chars[] = "abcdefghijklmnopqrstuvwxyz1234567890";
char* output;
const size_t output_size = 1024 * 1024;
- output = (char*)gpr_malloc(output_size);
+ output = static_cast<char*>(gpr_malloc(output_size));
for (i = 0; i < output_size - 1; ++i) {
- output[i] = chars[rand() % (int)(sizeof(chars) - 1)];
+ output[i] = chars[rand() % static_cast<int>(sizeof(chars) - 1)];
}
output[output_size - 1] = '\0';
grpc_slice out = grpc_slice_from_copied_string(output);
@@ -132,25 +132,29 @@ void resource_quota_server(grpc_end2end_test_config config) {
grpc_slice request_payload_slice = generate_random_slice();
grpc_call** client_calls =
- (grpc_call**)malloc(sizeof(grpc_call*) * NUM_CALLS);
+ static_cast<grpc_call**>(malloc(sizeof(grpc_call*) * NUM_CALLS));
grpc_call** server_calls =
- (grpc_call**)malloc(sizeof(grpc_call*) * NUM_CALLS);
+ static_cast<grpc_call**>(malloc(sizeof(grpc_call*) * NUM_CALLS));
grpc_metadata_array* initial_metadata_recv =
- (grpc_metadata_array*)malloc(sizeof(grpc_metadata_array) * NUM_CALLS);
+ static_cast<grpc_metadata_array*>(
+ malloc(sizeof(grpc_metadata_array) * NUM_CALLS));
grpc_metadata_array* trailing_metadata_recv =
- (grpc_metadata_array*)malloc(sizeof(grpc_metadata_array) * NUM_CALLS);
+ static_cast<grpc_metadata_array*>(
+ malloc(sizeof(grpc_metadata_array) * NUM_CALLS));
grpc_metadata_array* request_metadata_recv =
- (grpc_metadata_array*)malloc(sizeof(grpc_metadata_array) * NUM_CALLS);
- grpc_call_details* call_details =
- (grpc_call_details*)malloc(sizeof(grpc_call_details) * NUM_CALLS);
- grpc_status_code* status =
- (grpc_status_code*)malloc(sizeof(grpc_status_code) * NUM_CALLS);
- grpc_slice* details = (grpc_slice*)malloc(sizeof(grpc_slice) * NUM_CALLS);
- grpc_byte_buffer** request_payload =
- (grpc_byte_buffer**)malloc(sizeof(grpc_byte_buffer*) * NUM_CALLS);
- grpc_byte_buffer** request_payload_recv =
- (grpc_byte_buffer**)malloc(sizeof(grpc_byte_buffer*) * NUM_CALLS);
- int* was_cancelled = (int*)malloc(sizeof(int) * NUM_CALLS);
+ static_cast<grpc_metadata_array*>(
+ malloc(sizeof(grpc_metadata_array) * NUM_CALLS));
+ grpc_call_details* call_details = static_cast<grpc_call_details*>(
+ malloc(sizeof(grpc_call_details) * NUM_CALLS));
+ grpc_status_code* status = static_cast<grpc_status_code*>(
+ malloc(sizeof(grpc_status_code) * NUM_CALLS));
+ grpc_slice* details =
+ static_cast<grpc_slice*>(malloc(sizeof(grpc_slice) * NUM_CALLS));
+ grpc_byte_buffer** request_payload = static_cast<grpc_byte_buffer**>(
+ malloc(sizeof(grpc_byte_buffer*) * NUM_CALLS));
+ grpc_byte_buffer** request_payload_recv = static_cast<grpc_byte_buffer**>(
+ malloc(sizeof(grpc_byte_buffer*) * NUM_CALLS));
+ int* was_cancelled = static_cast<int*>(malloc(sizeof(int) * NUM_CALLS));
grpc_call_error error;
int pending_client_calls = 0;
int pending_server_start_calls = 0;
@@ -220,7 +224,8 @@ void resource_quota_server(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(client_calls[i], ops, (size_t)(op - ops),
+ error = grpc_call_start_batch(client_calls[i], ops,
+ static_cast<size_t>(op - ops),
tag(CLIENT_BASE_TAG + i), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
@@ -234,7 +239,7 @@ void resource_quota_server(grpc_end2end_test_config config) {
grpc_completion_queue_next(f.cq, n_seconds_from_now(60), nullptr);
GPR_ASSERT(ev.type == GRPC_OP_COMPLETE);
- int ev_tag = (int)(intptr_t)ev.tag;
+ int ev_tag = static_cast<int>((intptr_t)ev.tag);
if (ev_tag < CLIENT_BASE_TAG) {
abort(); /* illegal tag */
} else if (ev_tag < SERVER_START_BASE_TAG) {
@@ -285,9 +290,9 @@ void resource_quota_server(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error =
- grpc_call_start_batch(server_calls[call_id], ops, (size_t)(op - ops),
- tag(SERVER_RECV_BASE_TAG + call_id), nullptr);
+ error = grpc_call_start_batch(
+ server_calls[call_id], ops, static_cast<size_t>(op - ops),
+ tag(SERVER_RECV_BASE_TAG + call_id), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
GPR_ASSERT(pending_server_start_calls > 0);
@@ -326,9 +331,9 @@ void resource_quota_server(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error =
- grpc_call_start_batch(server_calls[call_id], ops, (size_t)(op - ops),
- tag(SERVER_END_BASE_TAG + call_id), nullptr);
+ error = grpc_call_start_batch(
+ server_calls[call_id], ops, static_cast<size_t>(op - ops),
+ tag(SERVER_END_BASE_TAG + call_id), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
GPR_ASSERT(pending_server_recv_calls > 0);
diff --git a/test/core/end2end/tests/server_finishes_request.cc b/test/core/end2end/tests/server_finishes_request.cc
index f135851f86..6fc06cfaa1 100644
--- a/test/core/end2end/tests/server_finishes_request.cc
+++ b/test/core/end2end/tests/server_finishes_request.cc
@@ -133,7 +133,8 @@ static void simple_request_body(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -163,7 +164,8 @@ static void simple_request_body(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
diff --git a/test/core/end2end/tests/shutdown_finishes_calls.cc b/test/core/end2end/tests/shutdown_finishes_calls.cc
index 2e19e059ae..34c4ebbf0a 100644
--- a/test/core/end2end/tests/shutdown_finishes_calls.cc
+++ b/test/core/end2end/tests/shutdown_finishes_calls.cc
@@ -128,7 +128,8 @@ static void test_early_server_shutdown_finishes_inflight_calls(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -145,7 +146,8 @@ static void test_early_server_shutdown_finishes_inflight_calls(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
/* shutdown and destroy the server */
diff --git a/test/core/end2end/tests/shutdown_finishes_tags.cc b/test/core/end2end/tests/shutdown_finishes_tags.cc
index d160647295..55caacb7ff 100644
--- a/test/core/end2end/tests/shutdown_finishes_tags.cc
+++ b/test/core/end2end/tests/shutdown_finishes_tags.cc
@@ -77,7 +77,7 @@ static void test_early_server_shutdown_finishes_tags(
grpc_end2end_test_fixture f = begin_test(
config, "test_early_server_shutdown_finishes_tags", nullptr, nullptr);
cq_verifier* cqv = cq_verifier_create(f.cq);
- grpc_call* s = (grpc_call*)(uintptr_t)1;
+ grpc_call* s = (grpc_call*)static_cast<uintptr_t>(1);
grpc_call_details call_details;
grpc_metadata_array request_metadata_recv;
diff --git a/test/core/end2end/tests/simple_cacheable_request.cc b/test/core/end2end/tests/simple_cacheable_request.cc
index b4732aed3f..4ae8398a6e 100644
--- a/test/core/end2end/tests/simple_cacheable_request.cc
+++ b/test/core/end2end/tests/simple_cacheable_request.cc
@@ -178,7 +178,8 @@ static void test_cacheable_request_response_with_metadata_and_payload(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -201,7 +202,8 @@ static void test_cacheable_request_response_with_metadata_and_payload(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -227,7 +229,8 @@ static void test_cacheable_request_response_with_metadata_and_payload(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(103),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
diff --git a/test/core/end2end/tests/simple_delayed_request.cc b/test/core/end2end/tests/simple_delayed_request.cc
index 54517fb242..f8a1ddfdc3 100644
--- a/test/core/end2end/tests/simple_delayed_request.cc
+++ b/test/core/end2end/tests/simple_delayed_request.cc
@@ -129,7 +129,8 @@ static void simple_delayed_request_body(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -159,7 +160,8 @@ static void simple_delayed_request_body(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
diff --git a/test/core/end2end/tests/simple_metadata.cc b/test/core/end2end/tests/simple_metadata.cc
index 5911834c91..1f39f8983b 100644
--- a/test/core/end2end/tests/simple_metadata.cc
+++ b/test/core/end2end/tests/simple_metadata.cc
@@ -176,7 +176,8 @@ static void test_request_response_with_metadata_and_payload(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -199,7 +200,8 @@ static void test_request_response_with_metadata_and_payload(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -225,7 +227,8 @@ static void test_request_response_with_metadata_and_payload(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(103),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
diff --git a/test/core/end2end/tests/simple_request.cc b/test/core/end2end/tests/simple_request.cc
index 6ec4a14959..926e2c7452 100644
--- a/test/core/end2end/tests/simple_request.cc
+++ b/test/core/end2end/tests/simple_request.cc
@@ -152,7 +152,8 @@ static void simple_request_body(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -191,7 +192,8 @@ static void simple_request_body(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
diff --git a/test/core/end2end/tests/stream_compression_compressed_payload.cc b/test/core/end2end/tests/stream_compression_compressed_payload.cc
index 637b7b2422..e90d54f054 100644
--- a/test/core/end2end/tests/stream_compression_compressed_payload.cc
+++ b/test/core/end2end/tests/stream_compression_compressed_payload.cc
@@ -187,7 +187,8 @@ static void request_for_disabled_algorithm(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(101), true);
@@ -205,7 +206,8 @@ static void request_for_disabled_algorithm(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), false);
@@ -216,7 +218,8 @@ static void request_for_disabled_algorithm(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(103),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), true);
@@ -345,7 +348,8 @@ static void request_with_payload_template(
op->flags = client_send_flags_bitmask;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(2),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(2), true);
}
@@ -374,7 +378,8 @@ static void request_with_payload_template(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -414,7 +419,8 @@ static void request_with_payload_template(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(101), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(101),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
for (int i = 0; i < 2; i++) {
@@ -429,8 +435,8 @@ static void request_with_payload_template(
op->flags = client_send_flags_bitmask;
op->reserved = nullptr;
op++;
- error =
- grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops),
+ tag(2), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(2), 1);
}
@@ -442,8 +448,8 @@ static void request_with_payload_template(
op->flags = 0;
op->reserved = nullptr;
op++;
- error =
- grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops),
+ tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -459,8 +465,8 @@ static void request_with_payload_template(
op->flags = 0;
op->reserved = nullptr;
op++;
- error =
- grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops),
+ tag(103), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -470,7 +476,8 @@ static void request_with_payload_template(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(3),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
@@ -495,7 +502,8 @@ static void request_with_payload_template(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(4), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(4),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -508,7 +516,8 @@ static void request_with_payload_template(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(104),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
diff --git a/test/core/end2end/tests/stream_compression_payload.cc b/test/core/end2end/tests/stream_compression_payload.cc
index 6abb3bbf5d..9eace97afd 100644
--- a/test/core/end2end/tests/stream_compression_payload.cc
+++ b/test/core/end2end/tests/stream_compression_payload.cc
@@ -93,9 +93,9 @@ static grpc_slice generate_random_slice() {
static const char chars[] = "abcdefghijklmnopqrstuvwxyz1234567890";
char* output;
const size_t output_size = 1024 * 1024;
- output = (char*)gpr_malloc(output_size);
+ output = static_cast<char*>(gpr_malloc(output_size));
for (i = 0; i < output_size - 1; ++i) {
- output[i] = chars[rand() % (int)(sizeof(chars) - 1)];
+ output[i] = chars[rand() % static_cast<int>(sizeof(chars) - 1)];
}
output[output_size - 1] = '\0';
grpc_slice out = grpc_slice_from_copied_string(output);
@@ -177,7 +177,8 @@ static void request_response_with_payload(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -199,7 +200,8 @@ static void request_response_with_payload(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -225,7 +227,8 @@ static void request_response_with_payload(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(103),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
diff --git a/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc b/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc
index 8242c2cdd1..5b033292b0 100644
--- a/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc
+++ b/test/core/end2end/tests/stream_compression_ping_pong_streaming.cc
@@ -151,7 +151,8 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -173,7 +174,8 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(101), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(101),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
for (i = 0; i < messages; i++) {
@@ -192,7 +194,8 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(2),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -202,8 +205,8 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error =
- grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops),
+ tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
cq_verify(cqv);
@@ -215,8 +218,8 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error =
- grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops),
+ tag(103), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
CQ_EXPECT_COMPLETION(cqv, tag(2), 1);
@@ -237,7 +240,8 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(3),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -250,7 +254,8 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(104),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
diff --git a/test/core/end2end/tests/streaming_error_response.cc b/test/core/end2end/tests/streaming_error_response.cc
index 167530a6ae..7c7d778d1e 100644
--- a/test/core/end2end/tests/streaming_error_response.cc
+++ b/test/core/end2end/tests/streaming_error_response.cc
@@ -148,7 +148,8 @@ static void test(grpc_end2end_test_config config, bool request_status_early) {
op->data.recv_status_on_client.status_details = &details;
op++;
}
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
@@ -165,7 +166,8 @@ static void test(grpc_end2end_test_config config, bool request_status_early) {
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = response_payload1;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -179,7 +181,8 @@ static void test(grpc_end2end_test_config config, bool request_status_early) {
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = response_payload2;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(103),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
@@ -190,7 +193,8 @@ static void test(grpc_end2end_test_config config, bool request_status_early) {
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &response_payload2_recv;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(2),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(2), 1);
@@ -208,7 +212,8 @@ static void test(grpc_end2end_test_config config, bool request_status_early) {
grpc_slice status_details = grpc_slice_from_static_string("xyz");
op->data.send_status_from_server.status_details = &status_details;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(104),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(104), 1);
@@ -225,7 +230,8 @@ static void test(grpc_end2end_test_config config, bool request_status_early) {
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(3),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(3), 1);
diff --git a/test/core/end2end/tests/trailing_metadata.cc b/test/core/end2end/tests/trailing_metadata.cc
index 150c1cbd51..24069854ac 100644
--- a/test/core/end2end/tests/trailing_metadata.cc
+++ b/test/core/end2end/tests/trailing_metadata.cc
@@ -184,7 +184,8 @@ static void test_request_response_with_metadata_and_payload(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -207,7 +208,8 @@ static void test_request_response_with_metadata_and_payload(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
@@ -234,7 +236,8 @@ static void test_request_response_with_metadata_and_payload(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(103),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
diff --git a/test/core/end2end/tests/workaround_cronet_compression.cc b/test/core/end2end/tests/workaround_cronet_compression.cc
index edf03d8ffc..4d4c369a42 100644
--- a/test/core/end2end/tests/workaround_cronet_compression.cc
+++ b/test/core/end2end/tests/workaround_cronet_compression.cc
@@ -191,7 +191,8 @@ static void request_with_payload_template(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
error =
@@ -227,7 +228,8 @@ static void request_with_payload_template(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(101), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(101),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
for (int i = 0; i < 2; i++) {
@@ -246,7 +248,8 @@ static void request_with_payload_template(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(2),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -256,8 +259,8 @@ static void request_with_payload_template(
op->flags = 0;
op->reserved = nullptr;
op++;
- error =
- grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops),
+ tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(102), 1);
cq_verify(cqv);
@@ -274,8 +277,8 @@ static void request_with_payload_template(
op->flags = 0;
op->reserved = nullptr;
op++;
- error =
- grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops),
+ tag(103), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(103), 1);
CQ_EXPECT_COMPLETION(cqv, tag(2), 1);
@@ -308,7 +311,8 @@ static void request_with_payload_template(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(3),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -321,7 +325,8 @@ static void request_with_payload_template(
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(104),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
diff --git a/test/core/end2end/tests/write_buffering.cc b/test/core/end2end/tests/write_buffering.cc
index 7f3d1abc39..5d76d238b9 100644
--- a/test/core/end2end/tests/write_buffering.cc
+++ b/test/core/end2end/tests/write_buffering.cc
@@ -128,7 +128,8 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -138,7 +139,8 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(2),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
@@ -154,7 +156,8 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->data.send_message.send_message = request_payload1;
op->flags = GRPC_WRITE_BUFFER_HINT;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(3),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -162,7 +165,8 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
/* recv message should not succeed yet - it's buffered at the client still */
@@ -171,7 +175,8 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &request_payload_recv1;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(103),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(2), true);
@@ -186,7 +191,8 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->data.send_message.send_message = request_payload2;
op->flags = 0;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(4), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(4),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
/* now the first send should match up with the first recv */
@@ -200,7 +206,8 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &request_payload_recv2;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(104),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(104), true);
@@ -219,7 +226,8 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(4), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(4),
+ nullptr);
memset(ops, 0, sizeof(ops));
op = ops;
@@ -236,7 +244,8 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(105), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(105),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(105), 1);
diff --git a/test/core/end2end/tests/write_buffering_at_end.cc b/test/core/end2end/tests/write_buffering_at_end.cc
index a1fbfef3fc..bd046ef9cc 100644
--- a/test/core/end2end/tests/write_buffering_at_end.cc
+++ b/test/core/end2end/tests/write_buffering_at_end.cc
@@ -125,7 +125,8 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -135,7 +136,8 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(2),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call(
@@ -151,7 +153,8 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->data.send_message.send_message = request_payload;
op->flags = GRPC_WRITE_BUFFER_HINT;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(3),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
@@ -159,7 +162,8 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(102),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
/* recv message should not succeed yet - it's buffered at the client still */
@@ -168,7 +172,8 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &request_payload_recv1;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(103),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(2), true);
@@ -181,7 +186,8 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op = ops;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(4), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(4),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
/* now the first send should match up with the first recv */
@@ -195,7 +201,8 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message.recv_message = &request_payload_recv2;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(104),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(104), true);
@@ -210,7 +217,8 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(4), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(4),
+ nullptr);
memset(ops, 0, sizeof(ops));
op = ops;
@@ -227,7 +235,8 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(105), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(105),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(105), 1);
diff --git a/test/core/fling/client.cc b/test/core/fling/client.cc
index 92f59b7fdb..05dc3052d1 100644
--- a/test/core/fling/client.cc
+++ b/test/core/fling/client.cc
@@ -127,7 +127,7 @@ static void step_ping_pong_stream(void) {
static double now(void) {
gpr_timespec tv = gpr_now(GPR_CLOCK_REALTIME);
- return 1e9 * (double)tv.tv_sec + tv.tv_nsec;
+ return 1e9 * static_cast<double>(tv.tv_sec) + tv.tv_nsec;
}
typedef struct {
@@ -195,7 +195,8 @@ int main(int argc, char** argv) {
channel = grpc_insecure_channel_create(target, nullptr, nullptr);
cq = grpc_completion_queue_create_for_next(nullptr);
- the_buffer = grpc_raw_byte_buffer_create(&slice, (size_t)payload_size);
+ the_buffer =
+ grpc_raw_byte_buffer_create(&slice, static_cast<size_t>(payload_size));
histogram = grpc_histogram_create(0.01, 60e9);
sc.init();
diff --git a/test/core/fling/fling_stream_test.cc b/test/core/fling/fling_stream_test.cc
index d5fd7a8d46..32bc989641 100644
--- a/test/core/fling/fling_stream_test.cc
+++ b/test/core/fling/fling_stream_test.cc
@@ -37,7 +37,7 @@ int main(int argc, char** argv) {
gpr_subprocess *svr, *cli;
/* figure out where we are */
if (lslash) {
- memcpy(root, me, (size_t)(lslash - me));
+ memcpy(root, me, static_cast<size_t>(lslash - me));
root[lslash - me] = 0;
} else {
strcpy(root, ".");
diff --git a/test/core/fling/fling_test.cc b/test/core/fling/fling_test.cc
index d95317b7e6..3587a4acaa 100644
--- a/test/core/fling/fling_test.cc
+++ b/test/core/fling/fling_test.cc
@@ -37,7 +37,7 @@ int main(int argc, const char** argv) {
gpr_subprocess *svr, *cli;
/* figure out where we are */
if (lslash) {
- memcpy(root, me, (size_t)(lslash - me));
+ memcpy(root, me, static_cast<size_t>(lslash - me));
root[lslash - me] = 0;
} else {
strcpy(root, ".");
diff --git a/test/core/fling/server.cc b/test/core/fling/server.cc
index b19a25a185..cf7e2465d9 100644
--- a/test/core/fling/server.cc
+++ b/test/core/fling/server.cc
@@ -112,7 +112,8 @@ static void handle_unary_method(void) {
op->data.recv_close_on_server.cancelled = &was_cancelled;
op++;
- error = grpc_call_start_batch(call, unary_ops, (size_t)(op - unary_ops),
+ error = grpc_call_start_batch(call, unary_ops,
+ static_cast<size_t>(op - unary_ops),
tag(FLING_SERVER_BATCH_OPS_FOR_UNARY), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
}
@@ -189,7 +190,7 @@ int main(int argc, char** argv) {
grpc_test_init(1, fake_argv);
grpc_init();
- srand((unsigned)clock());
+ srand(static_cast<unsigned>(clock()));
cl = gpr_cmdline_create("fling server");
gpr_cmdline_add_string(cl, "bind", "Bind host:port", &addr);
diff --git a/test/core/gpr/alloc_test.cc b/test/core/gpr/alloc_test.cc
index bf4471c36f..36cdc02ff2 100644
--- a/test/core/gpr/alloc_test.cc
+++ b/test/core/gpr/alloc_test.cc
@@ -27,7 +27,9 @@ static void* fake_malloc(size_t size) { return (void*)size; }
static void* fake_realloc(void* addr, size_t size) { return (void*)size; }
-static void fake_free(void* addr) { *((intptr_t*)addr) = (intptr_t)0xdeadd00d; }
+static void fake_free(void* addr) {
+ *(static_cast<intptr_t*>(addr)) = static_cast<intptr_t>(0xdeadd00d);
+}
static void test_custom_allocs() {
const gpr_allocation_functions default_fns = gpr_get_allocation_functions();
diff --git a/test/core/gpr/arena_test.cc b/test/core/gpr/arena_test.cc
index 087a800462..c10d7eaff7 100644
--- a/test/core/gpr/arena_test.cc
+++ b/test/core/gpr/arena_test.cc
@@ -86,7 +86,7 @@ static void concurrent_test_body(void* arg) {
concurrent_test_args* a = static_cast<concurrent_test_args*>(arg);
gpr_event_wait(&a->ev_start, gpr_inf_future(GPR_CLOCK_REALTIME));
for (size_t i = 0; i < concurrent_test_iterations(); i++) {
- *(char*)gpr_arena_alloc(a->arena, 1) = (char)i;
+ *static_cast<char*>(gpr_arena_alloc(a->arena, 1)) = static_cast<char>(i);
}
}
diff --git a/test/core/gpr/cpu_test.cc b/test/core/gpr/cpu_test.cc
index 87cdc0fb50..46a168665c 100644
--- a/test/core/gpr/cpu_test.cc
+++ b/test/core/gpr/cpu_test.cc
@@ -62,7 +62,7 @@ struct cpu_test {
};
static void worker_thread(void* arg) {
- struct cpu_test* ct = (struct cpu_test*)arg;
+ struct cpu_test* ct = static_cast<struct cpu_test*>(arg);
uint32_t cpu;
unsigned r = 12345678;
unsigned i, j;
@@ -103,7 +103,7 @@ static void cpu_test(void) {
gpr_thd_id thd;
ct.ncores = gpr_cpu_num_cores();
GPR_ASSERT(ct.ncores > 0);
- ct.nthreads = (int)ct.ncores * 3;
+ ct.nthreads = static_cast<int>(ct.ncores) * 3;
ct.used = static_cast<int*>(gpr_malloc(ct.ncores * sizeof(int)));
memset(ct.used, 0, ct.ncores * sizeof(int));
gpr_mu_init(&ct.mu);
diff --git a/test/core/gpr/mpscq_test.cc b/test/core/gpr/mpscq_test.cc
index 58df2f14fc..333390e928 100644
--- a/test/core/gpr/mpscq_test.cc
+++ b/test/core/gpr/mpscq_test.cc
@@ -49,7 +49,7 @@ static void test_serial(void) {
gpr_mpscq_push(&q, &new_node(i, nullptr)->node);
}
for (size_t i = 0; i < 10000000; i++) {
- test_node* n = (test_node*)gpr_mpscq_pop(&q);
+ test_node* n = reinterpret_cast<test_node*>(gpr_mpscq_pop(&q));
GPR_ASSERT(n);
GPR_ASSERT(n->i == i);
gpr_free(n);
@@ -97,7 +97,7 @@ static void test_mt(void) {
while ((n = gpr_mpscq_pop(&q)) == nullptr) {
spins++;
}
- test_node* tn = (test_node*)n;
+ test_node* tn = reinterpret_cast<test_node*>(n);
GPR_ASSERT(*tn->ctr == tn->i - 1);
*tn->ctr = tn->i;
if (tn->i == THREAD_ITERATIONS) num_done++;
@@ -134,7 +134,7 @@ static void pull_thread(void* arg) {
while ((n = gpr_mpscq_pop(pa->q)) == nullptr) {
pa->spins++;
}
- test_node* tn = (test_node*)n;
+ test_node* tn = reinterpret_cast<test_node*>(n);
GPR_ASSERT(*tn->ctr == tn->i - 1);
*tn->ctr = tn->i;
if (tn->i == THREAD_ITERATIONS) pa->num_done++;
diff --git a/test/core/gpr/murmur_hash_test.cc b/test/core/gpr/murmur_hash_test.cc
index d920dd3f95..2d2fa72cfb 100644
--- a/test/core/gpr/murmur_hash_test.cc
+++ b/test/core/gpr/murmur_hash_test.cc
@@ -42,8 +42,8 @@ static void verification_test(hash_func hash, uint32_t expected) {
the seed */
for (i = 0; i < 256; i++) {
- key[i] = (uint8_t)i;
- hashes[i] = hash(key, i, (uint32_t)(256u - i));
+ key[i] = static_cast<uint8_t>(i);
+ hashes[i] = hash(key, i, static_cast<uint32_t>(256u - i));
}
/* Then hash the result array */
diff --git a/test/core/gpr/spinlock_test.cc b/test/core/gpr/spinlock_test.cc
index 77e3dfbede..cd6de69126 100644
--- a/test/core/gpr/spinlock_test.cc
+++ b/test/core/gpr/spinlock_test.cc
@@ -46,7 +46,7 @@ static struct test* test_new(int threads, int64_t iterations, int incr_step) {
struct test* m = static_cast<struct test*>(gpr_malloc(sizeof(*m)));
m->thread_count = threads;
m->threads = static_cast<gpr_thd_id*>(
- gpr_malloc(sizeof(*m->threads) * (size_t)threads));
+ gpr_malloc(sizeof(*m->threads) * static_cast<size_t>(threads)));
m->iterations = iterations;
m->counter = 0;
m->thread_count = 0;
@@ -93,27 +93,30 @@ static void test(const char* name, void (*body)(void* m), int timeout_s,
gpr_timespec start = gpr_now(GPR_CLOCK_REALTIME);
gpr_timespec time_taken;
gpr_timespec deadline = gpr_time_add(
- start, gpr_time_from_micros((int64_t)timeout_s * 1000000, GPR_TIMESPAN));
+ start, gpr_time_from_micros(static_cast<int64_t>(timeout_s) * 1000000,
+ GPR_TIMESPAN));
fprintf(stderr, "%s:", name);
fflush(stderr);
while (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0) {
if (iterations < INT64_MAX / 2) iterations <<= 1;
- fprintf(stderr, " %ld", (long)iterations);
+ fprintf(stderr, " %ld", static_cast<long>(iterations));
fflush(stderr);
m = test_new(10, iterations, incr_step);
test_create_threads(m, body);
test_wait(m);
if (m->counter != m->thread_count * m->iterations * m->incr_step) {
fprintf(stderr, "counter %ld threads %d iterations %ld\n",
- (long)m->counter, m->thread_count, (long)m->iterations);
+ static_cast<long>(m->counter), m->thread_count,
+ static_cast<long>(m->iterations));
fflush(stderr);
GPR_ASSERT(0);
}
test_destroy(m);
}
time_taken = gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), start);
- fprintf(stderr, " done %lld.%09d s\n", (long long)time_taken.tv_sec,
- (int)time_taken.tv_nsec);
+ fprintf(stderr, " done %lld.%09d s\n",
+ static_cast<long long>(time_taken.tv_sec),
+ static_cast<int>(time_taken.tv_nsec));
fflush(stderr);
}
diff --git a/test/core/gpr/sync_test.cc b/test/core/gpr/sync_test.cc
index 768f96d093..39ff8852b6 100644
--- a/test/core/gpr/sync_test.cc
+++ b/test/core/gpr/sync_test.cc
@@ -236,11 +236,12 @@ static void test(const char* name, void (*body)(void* m),
gpr_timespec start = gpr_now(GPR_CLOCK_REALTIME);
gpr_timespec time_taken;
gpr_timespec deadline = gpr_time_add(
- start, gpr_time_from_micros((int64_t)timeout_s * 1000000, GPR_TIMESPAN));
+ start, gpr_time_from_micros(static_cast<int64_t>(timeout_s) * 1000000,
+ GPR_TIMESPAN));
fprintf(stderr, "%s:", name);
fflush(stderr);
while (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0) {
- fprintf(stderr, " %ld", (long)iterations);
+ fprintf(stderr, " %ld", static_cast<long>(iterations));
fflush(stderr);
m = test_new(10, iterations, incr_step);
if (extra != nullptr) {
@@ -252,7 +253,8 @@ static void test(const char* name, void (*body)(void* m),
test_wait(m);
if (m->counter != m->threads * m->iterations * m->incr_step) {
fprintf(stderr, "counter %ld threads %d iterations %ld\n",
- (long)m->counter, m->threads, (long)m->iterations);
+ static_cast<long>(m->counter), m->threads,
+ static_cast<long>(m->iterations));
fflush(stderr);
GPR_ASSERT(0);
}
@@ -260,8 +262,9 @@ static void test(const char* name, void (*body)(void* m),
iterations <<= 1;
}
time_taken = gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), start);
- fprintf(stderr, " done %lld.%09d s\n", (long long)time_taken.tv_sec,
- (int)time_taken.tv_nsec);
+ fprintf(stderr, " done %lld.%09d s\n",
+ static_cast<long long>(time_taken.tv_sec),
+ static_cast<int>(time_taken.tv_nsec));
fflush(stderr);
}
diff --git a/test/core/gpr/time_test.cc b/test/core/gpr/time_test.cc
index b2b4dce58e..ef7a961d0a 100644
--- a/test/core/gpr/time_test.cc
+++ b/test/core/gpr/time_test.cc
@@ -29,7 +29,7 @@
#include "test/core/util/test_config.h"
static void to_fp(void* arg, const char* buf, size_t len) {
- fwrite(buf, 1, len, (FILE*)arg);
+ fwrite(buf, 1, len, static_cast<FILE*>(arg));
}
/* Convert gpr_intmax x to ascii base b (2..16), and write with
diff --git a/test/core/handshake/client_ssl.cc b/test/core/handshake/client_ssl.cc
index 2302e3da2f..088df3845e 100644
--- a/test/core/handshake/client_ssl.cc
+++ b/test/core/handshake/client_ssl.cc
@@ -68,7 +68,7 @@ static int create_socket(int* out_port) {
return -1;
}
- if (bind(s, (struct sockaddr*)&addr, sizeof(addr)) < 0) {
+ if (bind(s, reinterpret_cast<struct sockaddr*>(&addr), sizeof(addr)) < 0) {
perror("Unable to bind");
gpr_log(GPR_ERROR, "%s", "Unable to bind to any port");
close(s);
@@ -82,7 +82,8 @@ static int create_socket(int* out_port) {
}
addr_len = sizeof(addr);
- if (getsockname(s, (struct sockaddr*)&addr, &addr_len) != 0 ||
+ if (getsockname(s, reinterpret_cast<struct sockaddr*>(&addr), &addr_len) !=
+ 0 ||
addr_len > sizeof(addr)) {
perror("getsockname");
gpr_log(GPR_ERROR, "%s", "Unable to get socket local address");
@@ -98,19 +99,19 @@ static int create_socket(int* out_port) {
// SSL_CTX_set_alpn_select_cb.
static int alpn_select_cb(SSL* ssl, const uint8_t** out, uint8_t* out_len,
const uint8_t* in, unsigned in_len, void* arg) {
- const uint8_t* alpn_preferred = (const uint8_t*)arg;
+ const uint8_t* alpn_preferred = static_cast<const uint8_t*>(arg);
*out = alpn_preferred;
- *out_len = (uint8_t)strlen((char*)alpn_preferred);
+ *out_len = static_cast<uint8_t>(strlen((char*)alpn_preferred));
// Validate that the ALPN list includes "h2" and "grpc-exp", that "grpc-exp"
// precedes "h2".
bool grpc_exp_seen = false;
bool h2_seen = false;
- const char* inp = (const char*)in;
+ const char* inp = reinterpret_cast<const char*>(in);
const char* in_end = inp + in_len;
while (inp < in_end) {
- const size_t length = (size_t)*inp++;
+ const size_t length = static_cast<size_t>(*inp++);
if (length == strlen("grpc-exp") && strncmp(inp, "grpc-exp", length) == 0) {
grpc_exp_seen = true;
GPR_ASSERT(!h2_seen);
@@ -133,7 +134,7 @@ static int alpn_select_cb(SSL* ssl, const uint8_t** out, uint8_t* out_len,
// https://wiki.openssl.org/index.php/Simple_TLS_Server and the gRPC core
// internals in src/core/tsi/ssl_transport_security.c.
static void server_thread(void* arg) {
- const server_args* args = (server_args*)arg;
+ const server_args* args = static_cast<server_args*>(arg);
SSL_load_error_strings();
OpenSSL_add_ssl_algorithms();
@@ -175,7 +176,8 @@ static void server_thread(void* arg) {
gpr_log(GPR_INFO, "Server listening");
struct sockaddr_in addr;
socklen_t len = sizeof(addr);
- const int client = accept(sock, (struct sockaddr*)&addr, &len);
+ const int client =
+ accept(sock, reinterpret_cast<struct sockaddr*>(&addr), &len);
if (client < 0) {
perror("Unable to accept");
abort();
@@ -243,9 +245,12 @@ static bool client_ssl_test(char* server_alpn_preferred) {
grpc_load_file(SSL_CERT_PATH, 1, &cert_slice)));
GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file",
grpc_load_file(SSL_KEY_PATH, 1, &key_slice)));
- const char* ca_cert = (const char*)GRPC_SLICE_START_PTR(ca_slice);
- pem_key_cert_pair.private_key = (const char*)GRPC_SLICE_START_PTR(key_slice);
- pem_key_cert_pair.cert_chain = (const char*)GRPC_SLICE_START_PTR(cert_slice);
+ const char* ca_cert =
+ reinterpret_cast<const char*> GRPC_SLICE_START_PTR(ca_slice);
+ pem_key_cert_pair.private_key =
+ reinterpret_cast<const char*> GRPC_SLICE_START_PTR(key_slice);
+ pem_key_cert_pair.cert_chain =
+ reinterpret_cast<const char*> GRPC_SLICE_START_PTR(cert_slice);
grpc_channel_credentials* ssl_creds =
grpc_ssl_credentials_create(ca_cert, &pem_key_cert_pair, nullptr);
diff --git a/test/core/handshake/readahead_handshaker_server_ssl.cc b/test/core/handshake/readahead_handshaker_server_ssl.cc
index 599e0e16e2..fa3ee0bc1e 100644
--- a/test/core/handshake/readahead_handshaker_server_ssl.cc
+++ b/test/core/handshake/readahead_handshaker_server_ssl.cc
@@ -67,7 +67,8 @@ const grpc_handshaker_vtable readahead_handshaker_vtable = {
readahead_handshaker_do_handshake};
static grpc_handshaker* readahead_handshaker_create() {
- grpc_handshaker* h = (grpc_handshaker*)gpr_zalloc(sizeof(grpc_handshaker));
+ grpc_handshaker* h =
+ static_cast<grpc_handshaker*>(gpr_zalloc(sizeof(grpc_handshaker)));
grpc_handshaker_init(&readahead_handshaker_vtable, h);
return h;
}
diff --git a/test/core/handshake/server_ssl_common.cc b/test/core/handshake/server_ssl_common.cc
index 0bf453a204..6f1a097dbd 100644
--- a/test/core/handshake/server_ssl_common.cc
+++ b/test/core/handshake/server_ssl_common.cc
@@ -48,7 +48,7 @@ static int create_socket(int port) {
struct sockaddr_in addr;
addr.sin_family = AF_INET;
- addr.sin_port = htons((uint16_t)port);
+ addr.sin_port = htons(static_cast<uint16_t>(port));
addr.sin_addr.s_addr = htonl(INADDR_ANY);
s = socket(AF_INET, SOCK_STREAM, 0);
@@ -57,7 +57,7 @@ static int create_socket(int port) {
return -1;
}
- if (connect(s, (struct sockaddr*)&addr, sizeof(addr)) < 0) {
+ if (connect(s, reinterpret_cast<struct sockaddr*>(&addr), sizeof(addr)) < 0) {
perror("Unable to connect");
return -1;
}
@@ -67,7 +67,7 @@ static int create_socket(int port) {
// Simple gRPC server. This listens until client_handshake_complete occurs.
static void server_thread(void* arg) {
- const int port = *(int*)arg;
+ const int port = *static_cast<int*>(arg);
// Load key pair and establish server SSL credentials.
grpc_ssl_pem_key_cert_pair pem_key_cert_pair;
@@ -78,9 +78,12 @@ static void server_thread(void* arg) {
grpc_load_file(SSL_CERT_PATH, 1, &cert_slice)));
GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file",
grpc_load_file(SSL_KEY_PATH, 1, &key_slice)));
- const char* ca_cert = (const char*)GRPC_SLICE_START_PTR(ca_slice);
- pem_key_cert_pair.private_key = (const char*)GRPC_SLICE_START_PTR(key_slice);
- pem_key_cert_pair.cert_chain = (const char*)GRPC_SLICE_START_PTR(cert_slice);
+ const char* ca_cert =
+ reinterpret_cast<const char*> GRPC_SLICE_START_PTR(ca_slice);
+ pem_key_cert_pair.private_key =
+ reinterpret_cast<const char*> GRPC_SLICE_START_PTR(key_slice);
+ pem_key_cert_pair.cert_chain =
+ reinterpret_cast<const char*> GRPC_SLICE_START_PTR(cert_slice);
grpc_server_credentials* ssl_creds = grpc_ssl_server_credentials_create(
ca_cert, &pem_key_cert_pair, 1, 0, nullptr);
@@ -176,13 +179,13 @@ bool server_ssl_test(const char* alpn_list[], unsigned int alpn_list_len,
// wire format, see documentation for SSL_CTX_set_alpn_protos.
unsigned int alpn_protos_len = alpn_list_len;
for (unsigned int i = 0; i < alpn_list_len; ++i) {
- alpn_protos_len += (unsigned int)strlen(alpn_list[i]);
+ alpn_protos_len += static_cast<unsigned int>(strlen(alpn_list[i]));
}
unsigned char* alpn_protos =
static_cast<unsigned char*>(gpr_malloc(alpn_protos_len));
unsigned char* p = alpn_protos;
for (unsigned int i = 0; i < alpn_list_len; ++i) {
- const uint8_t len = (uint8_t)strlen(alpn_list[i]);
+ const uint8_t len = static_cast<uint8_t>(strlen(alpn_list[i]));
*p++ = len;
memcpy(p, alpn_list[i], len);
p += len;
@@ -217,8 +220,8 @@ bool server_ssl_test(const char* alpn_list[], unsigned int alpn_list_len,
unsigned int alpn_selected_len;
SSL_get0_alpn_selected(ssl, &alpn_selected, &alpn_selected_len);
if (strlen(alpn_expected) != alpn_selected_len ||
- strncmp((const char*)alpn_selected, alpn_expected, alpn_selected_len) !=
- 0) {
+ strncmp(reinterpret_cast<const char*>(alpn_selected), alpn_expected,
+ alpn_selected_len) != 0) {
gpr_log(GPR_ERROR, "Unexpected ALPN protocol preference");
success = false;
}
diff --git a/test/core/http/httpcli_test.cc b/test/core/http/httpcli_test.cc
index 3d892b939c..346568fcf2 100644
--- a/test/core/http/httpcli_test.cc
+++ b/test/core/http/httpcli_test.cc
@@ -157,14 +157,14 @@ int main(int argc, char** argv) {
char* root;
if (lslash != nullptr) {
/* Hack for bazel target */
- if ((unsigned)(lslash - me) >= (sizeof("http") - 1) &&
+ if (static_cast<unsigned>(lslash - me) >= (sizeof("http") - 1) &&
strncmp(me + (lslash - me) - sizeof("http") + 1, "http",
sizeof("http") - 1) == 0) {
lslash = me + (lslash - me) - sizeof("http");
}
root = static_cast<char*>(
- gpr_malloc((size_t)(lslash - me + sizeof("/../.."))));
- memcpy(root, me, (size_t)(lslash - me));
+ gpr_malloc(static_cast<size_t>(lslash - me + sizeof("/../.."))));
+ memcpy(root, me, static_cast<size_t>(lslash - me));
memcpy(root + (lslash - me), "/../..", sizeof("/../.."));
} else {
root = gpr_strdup(".");
diff --git a/test/core/http/httpscli_test.cc b/test/core/http/httpscli_test.cc
index 7e99ad4249..a38f306ef3 100644
--- a/test/core/http/httpscli_test.cc
+++ b/test/core/http/httpscli_test.cc
@@ -157,14 +157,14 @@ int main(int argc, char** argv) {
char* root;
if (lslash != nullptr) {
/* Hack for bazel target */
- if ((unsigned)(lslash - me) >= (sizeof("http") - 1) &&
+ if (static_cast<unsigned>(lslash - me) >= (sizeof("http") - 1) &&
strncmp(me + (lslash - me) - sizeof("http") + 1, "http",
sizeof("http") - 1) == 0) {
lslash = me + (lslash - me) - sizeof("http");
}
root = static_cast<char*>(
- gpr_malloc((size_t)(lslash - me + sizeof("/../.."))));
- memcpy(root, me, (size_t)(lslash - me));
+ gpr_malloc(static_cast<size_t>(lslash - me + sizeof("/../.."))));
+ memcpy(root, me, static_cast<size_t>(lslash - me));
memcpy(root + (lslash - me), "/../..", sizeof("/../.."));
} else {
root = gpr_strdup(".");
diff --git a/test/core/iomgr/endpoint_pair_test.cc b/test/core/iomgr/endpoint_pair_test.cc
index 4251f27c81..ad38076b51 100644
--- a/test/core/iomgr/endpoint_pair_test.cc
+++ b/test/core/iomgr/endpoint_pair_test.cc
@@ -38,7 +38,7 @@ static grpc_endpoint_test_fixture create_fixture_endpoint_pair(
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;
+ a[0].value.integer = static_cast<int>(slice_size);
grpc_channel_args args = {GPR_ARRAY_SIZE(a), a};
grpc_endpoint_pair p = grpc_iomgr_create_endpoint_pair("test", &args);
diff --git a/test/core/iomgr/endpoint_tests.cc b/test/core/iomgr/endpoint_tests.cc
index 842be8fc92..8db8ac5ed6 100644
--- a/test/core/iomgr/endpoint_tests.cc
+++ b/test/core/iomgr/endpoint_tests.cc
@@ -77,7 +77,8 @@ 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) {
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 =
+ static_cast<grpc_slice*>(gpr_malloc(sizeof(grpc_slice) * nslices));
size_t num_bytes_left = num_bytes;
size_t i;
size_t j;
@@ -117,7 +118,7 @@ struct read_and_write_test_state {
static void read_and_write_test_read_handler(void* data, grpc_error* error) {
struct read_and_write_test_state* state =
- (struct read_and_write_test_state*)data;
+ static_cast<struct read_and_write_test_state*>(data);
state->bytes_read += count_slices(
state->incoming.slices, state->incoming.count, &state->current_read_data);
@@ -134,7 +135,7 @@ static void read_and_write_test_read_handler(void* data, grpc_error* error) {
static void read_and_write_test_write_handler(void* data, grpc_error* error) {
struct read_and_write_test_state* state =
- (struct read_and_write_test_state*)data;
+ static_cast<struct read_and_write_test_state*>(data);
grpc_slice* slices = nullptr;
size_t nslices;
@@ -246,7 +247,7 @@ static void read_and_write_test(grpc_endpoint_test_config config,
static void inc_on_failure(void* arg, grpc_error* error) {
gpr_mu_lock(g_mu);
- *(int*)arg += (error != GRPC_ERROR_NONE);
+ *static_cast<int*>(arg) += (error != GRPC_ERROR_NONE);
GPR_ASSERT(GRPC_LOG_IF_ERROR("kick", grpc_pollset_kick(g_pollset, nullptr)));
gpr_mu_unlock(g_mu);
}
diff --git a/test/core/iomgr/ev_epollsig_linux_test.cc b/test/core/iomgr/ev_epollsig_linux_test.cc
index 07a69a27c7..5ae68d2e47 100644
--- a/test/core/iomgr/ev_epollsig_linux_test.cc
+++ b/test/core/iomgr/ev_epollsig_linux_test.cc
@@ -98,7 +98,7 @@ static void test_pollset_init(test_pollset* pollsets, int num_pollsets) {
}
static void destroy_pollset(void* p, grpc_error* error) {
- grpc_pollset_destroy((grpc_pollset*)p);
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(p));
}
static void test_pollset_cleanup(test_pollset* pollsets, int num_pollsets) {
diff --git a/test/core/iomgr/fd_posix_test.cc b/test/core/iomgr/fd_posix_test.cc
index cf75517538..b81c73b2c0 100644
--- a/test/core/iomgr/fd_posix_test.cc
+++ b/test/core/iomgr/fd_posix_test.cc
@@ -78,7 +78,7 @@ static void create_test_socket(int port, int* socket_fd,
sin->sin_family = AF_INET;
sin->sin_addr.s_addr = htonl(0x7f000001);
GPR_ASSERT(port >= 0 && port < 65536);
- sin->sin_port = htons((uint16_t)port);
+ sin->sin_port = htons(static_cast<uint16_t>(port));
}
/* Dummy gRPC callback */
@@ -196,7 +196,8 @@ static void listen_cb(void* arg, /*=sv_arg*/
return;
}
- fd = accept(grpc_fd_wrapped_fd(listen_em_fd), (struct sockaddr*)&ss, &slen);
+ fd = accept(grpc_fd_wrapped_fd(listen_em_fd),
+ reinterpret_cast<struct sockaddr*>(&ss), &slen);
GPR_ASSERT(fd >= 0);
GPR_ASSERT(fd < FD_SETSIZE);
flags = fcntl(fd, F_GETFL, 0);
@@ -335,7 +336,8 @@ static void client_start(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, reinterpret_cast<struct sockaddr*>(&sin), sizeof(sin)) ==
+ -1) {
if (errno == EINPROGRESS) {
struct pollfd pfd;
pfd.fd = fd;
diff --git a/test/core/iomgr/pollset_set_test.cc b/test/core/iomgr/pollset_set_test.cc
index 114f39726d..0dc75a5f3f 100644
--- a/test/core/iomgr/pollset_set_test.cc
+++ b/test/core/iomgr/pollset_set_test.cc
@@ -103,7 +103,7 @@ typedef struct test_fd {
} test_fd;
void on_readable(void* tfd, grpc_error* error) {
- ((test_fd*)tfd)->is_on_readable_called = true;
+ (static_cast<test_fd*>(tfd))->is_on_readable_called = true;
}
static void reset_test_fd(test_fd* tfd) {
diff --git a/test/core/iomgr/resource_quota_test.cc b/test/core/iomgr/resource_quota_test.cc
index 07682d2630..921a24ebf2 100644
--- a/test/core/iomgr/resource_quota_test.cc
+++ b/test/core/iomgr/resource_quota_test.cc
@@ -29,7 +29,7 @@ gpr_cv g_cv;
static void inc_int_cb(void* a, grpc_error* error) {
gpr_mu_lock(&g_mu);
- ++*(int*)a;
+ ++*static_cast<int*>(a);
gpr_cv_signal(&g_cv);
gpr_mu_unlock(&g_mu);
}
@@ -44,7 +44,7 @@ static void assert_counter_becomes(int* ctr, int value) {
}
static void set_event_cb(void* a, grpc_error* error) {
- gpr_event_set((gpr_event*)a, (void*)1);
+ gpr_event_set(static_cast<gpr_event*>(a), (void*)1);
}
grpc_closure* set_event(gpr_event* ev) {
return GRPC_CLOSURE_CREATE(set_event_cb, ev, grpc_schedule_on_exec_ctx);
diff --git a/test/core/iomgr/sockaddr_utils_test.cc b/test/core/iomgr/sockaddr_utils_test.cc
index a445714851..32d2a384bd 100644
--- a/test/core/iomgr/sockaddr_utils_test.cc
+++ b/test/core/iomgr/sockaddr_utils_test.cc
@@ -33,7 +33,8 @@
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 =
+ reinterpret_cast<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));
@@ -45,7 +46,8 @@ static grpc_resolved_address make_addr4(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 =
+ reinterpret_cast<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));
@@ -56,7 +58,8 @@ static grpc_resolved_address make_addr6(const uint8_t* data, size_t data_len) {
}
static void set_addr6_scope_id(grpc_resolved_address* addr, uint32_t scope_id) {
- struct sockaddr_in6* addr6 = (struct sockaddr_in6*)addr->addr;
+ struct sockaddr_in6* addr6 =
+ reinterpret_cast<struct sockaddr_in6*>(addr->addr);
GPR_ASSERT(addr6->sin6_family == AF_INET6);
addr6->sin6_scope_id = scope_id;
}
@@ -143,7 +146,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 = reinterpret_cast<struct sockaddr_in*>(&wild4.addr);
memset(&wild4_addr->sin_addr.s_addr, 0xbd, 1);
GPR_ASSERT(!grpc_sockaddr_is_wildcard(&wild4, &port));
@@ -151,7 +154,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 = reinterpret_cast<struct sockaddr_in6*>(&wild6.addr);
memset(&wild6_addr->sin6_addr.s6_addr, 0xbd, 1);
GPR_ASSERT(!grpc_sockaddr_is_wildcard(&wild6, &port));
@@ -159,7 +162,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 = reinterpret_cast<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));
@@ -234,7 +237,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 = reinterpret_cast<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);
@@ -260,7 +263,7 @@ 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 = reinterpret_cast<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);
diff --git a/test/core/iomgr/socket_utils_test.cc b/test/core/iomgr/socket_utils_test.cc
index 67391a547d..a21f3fac62 100644
--- a/test/core/iomgr/socket_utils_test.cc
+++ b/test/core/iomgr/socket_utils_test.cc
@@ -43,7 +43,8 @@ struct test_socket_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 =
+ reinterpret_cast<struct test_socket_mutator*>(mutator);
if (0 != setsockopt(fd, IPPROTO_IP, IP_TOS, &m->option_value,
sizeof(m->option_value))) {
@@ -59,14 +60,17 @@ static bool mutate_fd(int fd, grpc_socket_mutator* mutator) {
}
static void destroy_test_mutator(grpc_socket_mutator* mutator) {
- struct test_socket_mutator* m = (struct test_socket_mutator*)mutator;
+ struct test_socket_mutator* m =
+ reinterpret_cast<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;
+ struct test_socket_mutator* ma =
+ reinterpret_cast<struct test_socket_mutator*>(a);
+ struct test_socket_mutator* mb =
+ reinterpret_cast<struct test_socket_mutator*>(b);
return GPR_ICMP(ma->option_value, mb->option_value);
}
@@ -117,7 +121,8 @@ int main(int argc, char** argv) {
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, reinterpret_cast<grpc_socket_mutator*>(&mutator));
GPR_ASSERT(err != GRPC_ERROR_NONE);
GRPC_ERROR_UNREF(err);
diff --git a/test/core/iomgr/tcp_client_posix_test.cc b/test/core/iomgr/tcp_client_posix_test.cc
index 40a050ed9f..8a43170043 100644
--- a/test/core/iomgr/tcp_client_posix_test.cc
+++ b/test/core/iomgr/tcp_client_posix_test.cc
@@ -78,7 +78,8 @@ static void must_fail(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 =
+ reinterpret_cast<struct sockaddr_in*>(resolved_addr.addr);
int svr_fd;
int r;
int connections_complete_before;
@@ -112,7 +113,8 @@ 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, reinterpret_cast<struct sockaddr*>(addr),
+ reinterpret_cast<socklen_t*>(&resolved_addr.len));
} while (r == -1 && errno == EINTR);
GPR_ASSERT(r >= 0);
close(r);
@@ -136,7 +138,8 @@ 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 =
+ reinterpret_cast<struct sockaddr_in*>(resolved_addr.addr);
int connections_complete_before;
grpc_closure done;
grpc_core::ExecCtx exec_ctx;
diff --git a/test/core/iomgr/tcp_posix_test.cc b/test/core/iomgr/tcp_posix_test.cc
index 3a79b9b430..f4df6fca23 100644
--- a/test/core/iomgr/tcp_posix_test.cc
+++ b/test/core/iomgr/tcp_posix_test.cc
@@ -74,7 +74,7 @@ static ssize_t fill_socket(int fd) {
int i;
unsigned char buf[256];
for (i = 0; i < 256; ++i) {
- buf[i] = (uint8_t)i;
+ buf[i] = static_cast<uint8_t>(i);
}
do {
write_bytes = write(fd, buf, 256);
@@ -89,16 +89,16 @@ 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 = static_cast<unsigned char*>(gpr_malloc(bytes));
unsigned i;
for (i = 0; i < bytes; ++i) {
- buf[i] = (uint8_t)(i % 256);
+ buf[i] = static_cast<uint8_t>(i % 256);
}
do {
write_bytes = write(fd, buf, bytes - total_bytes);
if (write_bytes > 0) {
- total_bytes += (size_t)write_bytes;
+ total_bytes += static_cast<size_t>(write_bytes);
}
} while ((write_bytes >= 0 || errno == EINTR) && bytes > total_bytes);
@@ -132,7 +132,8 @@ static size_t count_slices(grpc_slice* slices, size_t nslices,
}
static void read_cb(void* user_data, grpc_error* error) {
- struct read_socket_state* state = (struct read_socket_state*)user_data;
+ struct read_socket_state* state =
+ static_cast<struct read_socket_state*>(user_data);
size_t read_bytes;
int current_data;
@@ -172,7 +173,8 @@ static void read_test(size_t num_bytes, size_t slice_size) {
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;
+ a[0].type = GRPC_ARG_INTEGER,
+ a[0].value.integer = static_cast<int>(slice_size);
grpc_channel_args args = {GPR_ARRAY_SIZE(a), a};
ep = grpc_tcp_create(grpc_fd_create(sv[1], "read_test"), &args, "test");
grpc_endpoint_add_to_pollset(ep, g_pollset);
@@ -222,7 +224,7 @@ static void large_read_test(size_t slice_size) {
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;
+ a[0].value.integer = static_cast<int>(slice_size);
grpc_channel_args args = {GPR_ARRAY_SIZE(a), a};
ep = grpc_tcp_create(grpc_fd_create(sv[1], "large_read_test"), &args, "test");
grpc_endpoint_add_to_pollset(ep, g_pollset);
@@ -232,7 +234,7 @@ static void large_read_test(size_t slice_size) {
state.ep = ep;
state.read_bytes = 0;
- state.target_read_bytes = (size_t)written_bytes;
+ state.target_read_bytes = static_cast<size_t>(written_bytes);
grpc_slice_buffer_init(&state.incoming);
GRPC_CLOSURE_INIT(&state.read_cb, read_cb, &state, grpc_schedule_on_exec_ctx);
@@ -262,7 +264,8 @@ struct write_socket_state {
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 =
+ static_cast<grpc_slice*>(gpr_malloc(sizeof(grpc_slice) * nslices));
size_t num_bytes_left = num_bytes;
unsigned i, j;
unsigned char* buf;
@@ -284,7 +287,8 @@ static grpc_slice* allocate_blocks(size_t num_bytes, size_t slice_size,
static void write_done(void* user_data /* write_socket_state */,
grpc_error* error) {
- struct write_socket_state* state = (struct write_socket_state*)user_data;
+ struct write_socket_state* state =
+ static_cast<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");
@@ -295,7 +299,7 @@ static void write_done(void* user_data /* write_socket_state */,
}
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 = static_cast<unsigned char*>(gpr_malloc(read_size));
ssize_t bytes_read;
size_t bytes_left = num_bytes;
int flags;
@@ -325,7 +329,7 @@ void drain_socket_blocking(int fd, size_t num_bytes, size_t read_size) {
GPR_ASSERT(buf[i] == current);
current = (current + 1) % 256;
}
- bytes_left -= (size_t)bytes_read;
+ bytes_left -= static_cast<size_t>(bytes_read);
if (bytes_left == 0) break;
}
flags = fcntl(fd, F_GETFL, 0);
@@ -358,7 +362,8 @@ static void write_test(size_t num_bytes, size_t slice_size) {
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;
+ a[0].type = GRPC_ARG_INTEGER,
+ a[0].value.integer = static_cast<int>(slice_size);
grpc_channel_args args = {GPR_ARRAY_SIZE(a), a};
ep = grpc_tcp_create(grpc_fd_create(sv[1], "write_test"), &args, "test");
grpc_endpoint_add_to_pollset(ep, g_pollset);
@@ -395,7 +400,7 @@ static void write_test(size_t num_bytes, size_t slice_size) {
}
void on_fd_released(void* arg, grpc_error* errors) {
- int* done = (int*)arg;
+ int* done = static_cast<int*>(arg);
*done = 1;
GPR_ASSERT(
GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr)));
@@ -426,7 +431,7 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) {
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;
+ a[0].value.integer = static_cast<int>(slice_size);
grpc_channel_args args = {GPR_ARRAY_SIZE(a), a};
ep = grpc_tcp_create(grpc_fd_create(sv[1], "read_test"), &args, "test");
GPR_ASSERT(grpc_tcp_fd(ep) == sv[1] && sv[1] >= 0);
@@ -515,7 +520,7 @@ static grpc_endpoint_test_fixture create_fixture_tcp_socketpair(
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;
+ a[0].value.integer = static_cast<int>(slice_size);
grpc_channel_args args = {GPR_ARRAY_SIZE(a), a};
f.client_ep =
grpc_tcp_create(grpc_fd_create(sv[0], "fixture:client"), &args, "test");
@@ -533,7 +538,7 @@ static grpc_endpoint_test_config configs[] = {
};
static void destroy_pollset(void* p, grpc_error* error) {
- grpc_pollset_destroy((grpc_pollset*)p);
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(p));
}
int main(int argc, char** argv) {
@@ -542,7 +547,7 @@ int main(int argc, char** argv) {
grpc_init();
{
grpc_core::ExecCtx exec_ctx;
- g_pollset = (grpc_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);
run_tests();
diff --git a/test/core/iomgr/tcp_server_posix_test.cc b/test/core/iomgr/tcp_server_posix_test.cc
index 3c9ca2109e..dde77da547 100644
--- a/test/core/iomgr/tcp_server_posix_test.cc
+++ b/test/core/iomgr/tcp_server_posix_test.cc
@@ -181,7 +181,8 @@ static void test_no_op_with_start(void) {
static void test_no_op_with_port(void) {
grpc_core::ExecCtx exec_ctx;
grpc_resolved_address resolved_addr;
- struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
+ struct sockaddr_in* addr =
+ reinterpret_cast<struct sockaddr_in*>(resolved_addr.addr);
grpc_tcp_server* s;
GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(nullptr, nullptr, &s));
LOG_TEST("test_no_op_with_port");
@@ -200,7 +201,8 @@ static void test_no_op_with_port(void) {
static void test_no_op_with_port_and_start(void) {
grpc_core::ExecCtx exec_ctx;
grpc_resolved_address resolved_addr;
- struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
+ struct sockaddr_in* addr =
+ reinterpret_cast<struct sockaddr_in*>(resolved_addr.addr);
grpc_tcp_server* s;
GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(nullptr, nullptr, &s));
LOG_TEST("test_no_op_with_port_and_start");
@@ -225,7 +227,7 @@ static grpc_error* tcp_connect(const test_addr* remote,
int clifd;
int nconnects_before;
const struct sockaddr* remote_addr =
- (const struct sockaddr*)remote->addr.addr;
+ reinterpret_cast<const struct sockaddr*>(remote->addr.addr);
gpr_log(GPR_INFO, "Connecting to %s", remote->str);
gpr_mu_lock(g_mu);
@@ -237,7 +239,8 @@ static grpc_error* tcp_connect(const test_addr* remote,
return GRPC_OS_ERROR(errno, "Failed to create socket");
}
gpr_log(GPR_DEBUG, "start connect to %s", remote->str);
- if (connect(clifd, remote_addr, (socklen_t)remote->addr.len) != 0) {
+ if (connect(clifd, remote_addr, static_cast<socklen_t>(remote->addr.len)) !=
+ 0) {
gpr_mu_unlock(g_mu);
close(clifd);
return GRPC_OS_ERROR(errno, "connect");
@@ -286,9 +289,9 @@ static void test_connect(size_t num_connects,
grpc_resolved_address resolved_addr;
grpc_resolved_address resolved_addr1;
struct sockaddr_storage* const addr =
- (struct sockaddr_storage*)resolved_addr.addr;
+ reinterpret_cast<struct sockaddr_storage*>(resolved_addr.addr);
struct sockaddr_storage* const addr1 =
- (struct sockaddr_storage*)resolved_addr1.addr;
+ reinterpret_cast<struct sockaddr_storage*>(resolved_addr1.addr);
unsigned svr_fd_count;
int port;
int svr_port;
@@ -305,8 +308,9 @@ static void test_connect(size_t num_connects,
LOG_TEST("test_connect");
gpr_log(GPR_INFO,
"clients=%lu, num chan args=%lu, remote IP=%s, test_dst_addrs=%d",
- (unsigned long)num_connects,
- (unsigned long)(channel_args != nullptr ? channel_args->num_args : 0),
+ static_cast<unsigned long>(num_connects),
+ static_cast<unsigned long>(
+ channel_args != nullptr ? channel_args->num_args : 0),
dst_addrs != nullptr ? "<specific>" : "::", test_dst_addrs);
memset(&resolved_addr, 0, sizeof(resolved_addr));
memset(&resolved_addr1, 0, sizeof(resolved_addr1));
diff --git a/test/core/iomgr/timer_heap_test.cc b/test/core/iomgr/timer_heap_test.cc
index ed66b7df8d..08f5d632e3 100644
--- a/test/core/iomgr/timer_heap_test.cc
+++ b/test/core/iomgr/timer_heap_test.cc
@@ -102,7 +102,7 @@ static void test1(void) {
check_valid(&pq);
for (i = 0; i < num_test_operations; ++i) {
- size_t elem_num = (size_t)rand() % num_test_elements;
+ size_t elem_num = static_cast<size_t>(rand()) % num_test_elements;
grpc_timer* el = &test_elements[elem_num];
if (!inpq[elem_num]) { /* not in pq */
GPR_ASSERT(!contains(&pq, el));
@@ -142,8 +142,8 @@ static elem_struct* search_elems(elem_struct* elems, size_t count,
search_order[i] = i;
}
for (size_t i = 0; i < count * 2; i++) {
- size_t a = (size_t)rand() % count;
- size_t b = (size_t)rand() % count;
+ size_t a = static_cast<size_t>(rand()) % count;
+ size_t b = static_cast<size_t>(rand()) % count;
GPR_SWAP(size_t, search_order[a], search_order[b]);
}
elem_struct* out = nullptr;
@@ -235,7 +235,7 @@ static void shrink_test(void) {
size_t expected_size;
/* A large random number to allow for multiple shrinkages, at least 512. */
- const size_t num_elements = (size_t)rand() % 2000 + 512;
+ const size_t num_elements = static_cast<size_t>(rand()) % 2000 + 512;
grpc_timer_heap_init(&pq);
@@ -265,7 +265,7 @@ static void shrink_test(void) {
4 times the Size and not less than 2 times, but never goes below 16. */
expected_size = pq.timer_count;
while (pq.timer_count > 0) {
- const size_t which = (size_t)rand() % pq.timer_count;
+ const size_t which = static_cast<size_t>(rand()) % pq.timer_count;
grpc_timer* te = pq.timers[which];
grpc_timer_heap_remove(&pq, te);
gpr_free(te);
diff --git a/test/core/iomgr/udp_server_test.cc b/test/core/iomgr/udp_server_test.cc
index 4c92a6b69e..13cbf2f6df 100644
--- a/test/core/iomgr/udp_server_test.cc
+++ b/test/core/iomgr/udp_server_test.cc
@@ -65,7 +65,7 @@ static bool on_read(grpc_fd* emfd) {
recv(grpc_fd_wrapped_fd(emfd), read_buffer, sizeof(read_buffer), 0);
g_number_of_reads++;
- g_number_of_bytes_read += (int)byte_count;
+ g_number_of_bytes_read += static_cast<int>(byte_count);
GPR_ASSERT(
GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, nullptr)));
@@ -100,16 +100,18 @@ typedef struct test_socket_factory test_socket_factory;
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 = reinterpret_cast<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;
+ test_socket_factory* f = reinterpret_cast<test_socket_factory*>(factory);
f->number_of_bind_calls++;
- return bind(sockfd, (struct sockaddr*)addr->addr, (socklen_t)addr->len);
+ return bind(sockfd,
+ reinterpret_cast<struct sockaddr*>(const_cast<char*>(addr->addr)),
+ static_cast<socklen_t>(addr->len));
}
static int test_socket_factory_compare(grpc_socket_factory* a,
@@ -118,7 +120,7 @@ static int test_socket_factory_compare(grpc_socket_factory* a,
}
static void test_socket_factory_destroy(grpc_socket_factory* factory) {
- test_socket_factory* f = (test_socket_factory*)factory;
+ test_socket_factory* f = reinterpret_cast<test_socket_factory*>(factory);
gpr_free(f);
}
@@ -173,7 +175,8 @@ static void test_no_op_with_port(void) {
g_number_of_orphan_calls = 0;
grpc_core::ExecCtx exec_ctx;
grpc_resolved_address resolved_addr;
- struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
+ struct sockaddr_in* addr =
+ reinterpret_cast<struct sockaddr_in*>(resolved_addr.addr);
grpc_udp_server* s = grpc_udp_server_create(nullptr);
LOG_TEST("test_no_op_with_port");
@@ -196,7 +199,8 @@ static void test_no_op_with_port_and_socket_factory(void) {
g_number_of_orphan_calls = 0;
grpc_core::ExecCtx exec_ctx;
grpc_resolved_address resolved_addr;
- struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
+ struct sockaddr_in* addr =
+ reinterpret_cast<struct sockaddr_in*>(resolved_addr.addr);
test_socket_factory* socket_factory = test_socket_factory_create();
grpc_arg socket_factory_arg =
@@ -231,7 +235,8 @@ static void test_no_op_with_port_and_start(void) {
g_number_of_orphan_calls = 0;
grpc_core::ExecCtx exec_ctx;
grpc_resolved_address resolved_addr;
- struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
+ struct sockaddr_in* addr =
+ reinterpret_cast<struct sockaddr_in*>(resolved_addr.addr);
grpc_udp_server* s = grpc_udp_server_create(nullptr);
LOG_TEST("test_no_op_with_port_and_start");
@@ -256,7 +261,8 @@ static void test_receive(int number_of_clients) {
grpc_pollset_init(g_pollset, &g_mu);
grpc_core::ExecCtx exec_ctx;
grpc_resolved_address resolved_addr;
- struct sockaddr_storage* addr = (struct sockaddr_storage*)resolved_addr.addr;
+ struct sockaddr_storage* addr =
+ reinterpret_cast<struct sockaddr_storage*>(resolved_addr.addr);
int clifd, svrfd;
grpc_udp_server* s = grpc_udp_server_create(nullptr);
int i;
diff --git a/test/core/iomgr/wakeup_fd_cv_test.cc b/test/core/iomgr/wakeup_fd_cv_test.cc
index 2d64520b92..a3f3f2008b 100644
--- a/test/core/iomgr/wakeup_fd_cv_test.cc
+++ b/test/core/iomgr/wakeup_fd_cv_test.cc
@@ -84,7 +84,7 @@ int mock_poll(struct pollfd* fds, nfds_t nfds, int timeout) {
}
void background_poll(void* args) {
- poll_args* pargs = (poll_args*)args;
+ poll_args* pargs = static_cast<poll_args*>(args);
pargs->result = grpc_poll_function(pargs->fds, pargs->nfds, pargs->timeout);
}
diff --git a/test/core/json/json_rewrite.cc b/test/core/json/json_rewrite.cc
index 0319d15024..da2f50ec59 100644
--- a/test/core/json/json_rewrite.cc
+++ b/test/core/json/json_rewrite.cc
@@ -86,7 +86,7 @@ static void json_reader_string_add_char(void* userdata, uint32_t c) {
json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata);
check_string(state, 1);
GPR_ASSERT(c < 256);
- state->scratchpad[state->string_len++] = (char)c;
+ state->scratchpad[state->string_len++] = static_cast<char>(c);
}
static void json_reader_string_add_utf32(void* userdata, uint32_t c) {
@@ -122,7 +122,7 @@ static uint32_t json_reader_read_char(void* userdata) {
r = fgetc(state->in);
if (r == EOF) r = GRPC_JSON_READ_CHAR_EOF;
- return (uint32_t)r;
+ return static_cast<uint32_t>(r);
}
static void json_reader_container_begins(void* userdata, grpc_json_type type) {
diff --git a/test/core/json/json_rewrite_test.cc b/test/core/json/json_rewrite_test.cc
index 8846d4612b..2fade12e13 100644
--- a/test/core/json/json_rewrite_test.cc
+++ b/test/core/json/json_rewrite_test.cc
@@ -97,7 +97,7 @@ static void json_reader_string_add_char(void* userdata, uint32_t c) {
json_reader_userdata* state = static_cast<json_reader_userdata*>(userdata);
check_string(state, 1);
GPR_ASSERT(c <= 256);
- state->scratchpad[state->string_len++] = (char)c;
+ state->scratchpad[state->string_len++] = static_cast<char>(c);
}
static void json_reader_string_add_utf32(void* userdata, uint32_t c) {
@@ -140,7 +140,7 @@ static uint32_t json_reader_read_char(void* userdata) {
r = fgetc(state->in);
if (r == EOF) r = GRPC_JSON_READ_CHAR_EOF;
- return (uint32_t)r;
+ return static_cast<uint32_t>(r);
}
static void json_reader_container_begins(void* userdata, grpc_json_type type) {
diff --git a/test/core/memory_usage/client.cc b/test/core/memory_usage/client.cc
index 4f2ca9e937..3c3fa53b51 100644
--- a/test/core/memory_usage/client.cc
+++ b/test/core/memory_usage/client.cc
@@ -155,16 +155,20 @@ static struct grpc_memory_counters send_snapshot_request(int call_idx,
struct grpc_memory_counters snapshot;
snapshot.total_size_absolute =
- ((struct grpc_memory_counters*)GRPC_SLICE_START_PTR(response))
+ (reinterpret_cast<struct grpc_memory_counters*> GRPC_SLICE_START_PTR(
+ response))
->total_size_absolute;
snapshot.total_allocs_absolute =
- ((struct grpc_memory_counters*)GRPC_SLICE_START_PTR(response))
+ (reinterpret_cast<struct grpc_memory_counters*> GRPC_SLICE_START_PTR(
+ response))
->total_allocs_absolute;
snapshot.total_size_relative =
- ((struct grpc_memory_counters*)GRPC_SLICE_START_PTR(response))
+ (reinterpret_cast<struct grpc_memory_counters*> GRPC_SLICE_START_PTR(
+ response))
->total_size_relative;
snapshot.total_allocs_relative =
- ((struct grpc_memory_counters*)GRPC_SLICE_START_PTR(response))
+ (reinterpret_cast<struct grpc_memory_counters*> GRPC_SLICE_START_PTR(
+ response))
->total_allocs_relative;
grpc_metadata_array_destroy(&calls[call_idx].initial_metadata_recv);
@@ -284,10 +288,11 @@ int main(int argc, char** argv) {
grpc_shutdown();
gpr_log(GPR_INFO, "---------client stats--------");
- gpr_log(GPR_INFO, "client call memory usage: %f bytes per call",
- (double)(client_calls_inflight.total_size_relative -
- client_benchmark_calls_start.total_size_relative) /
- benchmark_iterations);
+ gpr_log(
+ GPR_INFO, "client call memory usage: %f bytes per call",
+ static_cast<double>(client_calls_inflight.total_size_relative -
+ client_benchmark_calls_start.total_size_relative) /
+ benchmark_iterations);
gpr_log(GPR_INFO, "client channel memory usage %zi bytes",
client_channel_end.total_size_relative -
client_channel_start.total_size_relative);
@@ -296,10 +301,11 @@ int main(int argc, char** argv) {
gpr_log(GPR_INFO, "server create: %zi bytes",
after_server_create.total_size_relative -
before_server_create.total_size_relative);
- gpr_log(GPR_INFO, "server call memory usage: %f bytes per call",
- (double)(server_calls_inflight.total_size_relative -
- server_benchmark_calls_start.total_size_relative) /
- benchmark_iterations);
+ gpr_log(
+ GPR_INFO, "server call memory usage: %f bytes per call",
+ static_cast<double>(server_calls_inflight.total_size_relative -
+ server_benchmark_calls_start.total_size_relative) /
+ benchmark_iterations);
gpr_log(GPR_INFO, "server channel memory usage %zi bytes",
server_calls_end.total_size_relative -
after_server_create.total_size_relative);
@@ -309,21 +315,22 @@ int main(int argc, char** argv) {
if (csv) {
char* env_build = gpr_getenv("BUILD_NUMBER");
char* env_job = gpr_getenv("JOB_NAME");
- fprintf(csv, "%f,%zi,%zi,%f,%zi,%s,%s\n",
- (double)(client_calls_inflight.total_size_relative -
- client_benchmark_calls_start.total_size_relative) /
- benchmark_iterations,
- client_channel_end.total_size_relative -
- client_channel_start.total_size_relative,
- after_server_create.total_size_relative -
- before_server_create.total_size_relative,
- (double)(server_calls_inflight.total_size_relative -
- server_benchmark_calls_start.total_size_relative) /
- benchmark_iterations,
- server_calls_end.total_size_relative -
- after_server_create.total_size_relative,
- env_build == nullptr ? "" : env_build,
- env_job == nullptr ? "" : env_job);
+ fprintf(
+ csv, "%f,%zi,%zi,%f,%zi,%s,%s\n",
+ static_cast<double>(client_calls_inflight.total_size_relative -
+ client_benchmark_calls_start.total_size_relative) /
+ benchmark_iterations,
+ client_channel_end.total_size_relative -
+ client_channel_start.total_size_relative,
+ after_server_create.total_size_relative -
+ before_server_create.total_size_relative,
+ static_cast<double>(server_calls_inflight.total_size_relative -
+ server_benchmark_calls_start.total_size_relative) /
+ benchmark_iterations,
+ server_calls_end.total_size_relative -
+ after_server_create.total_size_relative,
+ env_build == nullptr ? "" : env_build,
+ env_job == nullptr ? "" : env_job);
fclose(csv);
gpr_log(GPR_INFO, "Summary written to %s", csv_file);
}
diff --git a/test/core/memory_usage/memory_usage_test.cc b/test/core/memory_usage/memory_usage_test.cc
index cc3528b060..c170f5ad26 100644
--- a/test/core/memory_usage/memory_usage_test.cc
+++ b/test/core/memory_usage/memory_usage_test.cc
@@ -37,7 +37,7 @@ int main(int argc, char** argv) {
gpr_subprocess *svr, *cli;
/* figure out where we are */
if (lslash) {
- memcpy(root, me, (size_t)(lslash - me));
+ memcpy(root, me, static_cast<size_t>(lslash - me));
root[lslash - me] = 0;
} else {
strcpy(root, ".");
diff --git a/test/core/memory_usage/server.cc b/test/core/memory_usage/server.cc
index a276102e83..3e7bb7e11f 100644
--- a/test/core/memory_usage/server.cc
+++ b/test/core/memory_usage/server.cc
@@ -73,7 +73,7 @@ typedef struct {
static fling_call calls[100006];
static void request_call_unary(int call_idx) {
- if (call_idx == (int)(sizeof(calls) / sizeof(fling_call))) {
+ if (call_idx == static_cast<int>(sizeof(calls) / sizeof(fling_call))) {
gpr_log(GPR_INFO, "Used all call slots (10000) on server. Server exit.");
_exit(0);
}
@@ -84,7 +84,8 @@ static void request_call_unary(int call_idx) {
}
static void send_initial_metadata_unary(void* tag) {
- grpc_metadata_array_init(&(*(fling_call*)tag).initial_metadata_send);
+ grpc_metadata_array_init(
+ &(*static_cast<fling_call*>(tag)).initial_metadata_send);
metadata_ops[0].op = GRPC_OP_SEND_INITIAL_METADATA;
metadata_ops[0].data.send_initial_metadata.count = 0;
@@ -111,7 +112,8 @@ static void send_snapshot(void* tag, struct grpc_memory_counters* snapshot) {
grpc_slice snapshot_slice =
grpc_slice_new(snapshot, sizeof(*snapshot), gpr_free);
payload_buffer = grpc_raw_byte_buffer_create(&snapshot_slice, 1);
- grpc_metadata_array_init(&(*(fling_call*)tag).initial_metadata_send);
+ grpc_metadata_array_init(
+ &(*static_cast<fling_call*>(tag)).initial_metadata_send);
op = snapshot_ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@@ -163,7 +165,7 @@ int main(int argc, char** argv) {
grpc_test_init(1, fake_argv);
grpc_init();
- srand((unsigned)clock());
+ srand(static_cast<unsigned>(clock()));
cl = gpr_cmdline_create("fling server");
gpr_cmdline_add_string(cl, "bind", "Bind host:port", &addr);
@@ -204,7 +206,8 @@ int main(int argc, char** argv) {
addr = addr_buf = nullptr;
// initialize call instances
- for (int i = 0; i < (int)(sizeof(calls) / sizeof(fling_call)); i++) {
+ for (int i = 0; i < static_cast<int>(sizeof(calls) / sizeof(fling_call));
+ i++) {
grpc_call_details_init(&calls[i].call_details);
calls[i].state = FLING_SERVER_NEW_REQUEST;
}
@@ -281,7 +284,8 @@ int main(int argc, char** argv) {
grpc_metadata_array_destroy(&s->request_metadata_recv);
break;
case FLING_SERVER_BATCH_SEND_STATUS_FLING_CALL:
- for (int k = 0; k < (int)(sizeof(calls) / sizeof(fling_call));
+ for (int k = 0;
+ k < static_cast<int>(sizeof(calls) / sizeof(fling_call));
++k) {
if (calls[k].state == FLING_SERVER_WAIT_FOR_DESTROY) {
calls[k].state = FLING_SERVER_SEND_STATUS_FLING_CALL;
diff --git a/test/core/network_benchmarks/low_level_ping_pong.cc b/test/core/network_benchmarks/low_level_ping_pong.cc
index 8fd2c75438..52c423b14a 100644
--- a/test/core/network_benchmarks/low_level_ping_pong.cc
+++ b/test/core/network_benchmarks/low_level_ping_pong.cc
@@ -84,7 +84,7 @@ static int read_bytes(int fd, char* buf, size_t read_size, int spin) {
return -1;
}
} else {
- bytes_read += (size_t)err;
+ bytes_read += static_cast<size_t>(err);
}
} while (bytes_read < read_size);
return 0;
@@ -127,7 +127,7 @@ static int poll_read_bytes(int fd, char* buf, size_t read_size, int spin) {
gpr_log(GPR_ERROR, "Read failed: %s", strerror(errno));
return -1;
}
- bytes_read += (size_t)err2;
+ bytes_read += static_cast<size_t>(err2);
} while (bytes_read < read_size);
return 0;
}
@@ -166,7 +166,7 @@ static int epoll_read_bytes(struct thread_args* args, char* buf, int spin) {
read(args->fds.read_fd, buf + bytes_read, read_size - bytes_read);
} while (err2 < 0 && errno == EINTR);
if (errno == EAGAIN) break;
- bytes_read += (size_t)err2;
+ bytes_read += static_cast<size_t>(err2);
/* TODO(klempner): This should really be doing an extra call after we are
done to ensure we see an EAGAIN */
} while (bytes_read < read_size);
@@ -203,7 +203,7 @@ static int blocking_write_bytes(struct thread_args* args, char* buf) {
return -1;
}
} else {
- bytes_written += (size_t)err;
+ bytes_written += static_cast<size_t>(err);
}
} while (bytes_written < write_size);
return 0;
@@ -288,7 +288,7 @@ static void print_histogram(grpc_histogram* histogram) {
static double now(void) {
gpr_timespec tv = gpr_now(GPR_CLOCK_REALTIME);
- return 1e9 * (double)tv.tv_sec + (double)tv.tv_nsec;
+ return 1e9 * static_cast<double>(tv.tv_sec) + static_cast<double>(tv.tv_nsec);
}
static void client_thread(thread_args* args) {
@@ -420,7 +420,7 @@ static int create_sockets_tcp(fd_pair* client_fds, fd_pair* server_fds) {
int server_fd = -1;
struct sockaddr_in port;
- struct sockaddr* sa_port = (struct sockaddr*)&port;
+ struct sockaddr* sa_port = reinterpret_cast<struct sockaddr*>(&port);
port.sin_family = AF_INET;
port.sin_port = 0;
@@ -652,7 +652,7 @@ int main(int argc, char** argv) {
if (read_strategy == nullptr) {
gpr_log(GPR_INFO, "No strategy specified, running all benchmarks");
- return run_all_benchmarks((size_t)msg_size);
+ return run_all_benchmarks(static_cast<size_t>(msg_size));
}
if (socket_type == nullptr) {
@@ -679,12 +679,12 @@ int main(int argc, char** argv) {
client_args->read_bytes = strategy->read_strategy;
client_args->write_bytes = blocking_write_bytes;
client_args->setup = strategy->setup;
- client_args->msg_size = (size_t)msg_size;
+ client_args->msg_size = static_cast<size_t>(msg_size);
client_args->strategy_name = read_strategy;
server_args->read_bytes = strategy->read_strategy;
server_args->write_bytes = blocking_write_bytes;
server_args->setup = strategy->setup;
- server_args->msg_size = (size_t)msg_size;
+ server_args->msg_size = static_cast<size_t>(msg_size);
server_args->strategy_name = read_strategy;
error = run_benchmark(socket_type, client_args, server_args);
diff --git a/test/core/security/create_jwt.cc b/test/core/security/create_jwt.cc
index bb8227f08f..2ea640b605 100644
--- a/test/core/security/create_jwt.cc
+++ b/test/core/security/create_jwt.cc
@@ -36,7 +36,7 @@ void create_jwt(const char* json_key_file_path, const char* service_url,
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"load_file", grpc_load_file(json_key_file_path, 1, &json_key_data)));
key = grpc_auth_json_key_create_from_string(
- (const char*)GRPC_SLICE_START_PTR(json_key_data));
+ reinterpret_cast<const char*> GRPC_SLICE_START_PTR(json_key_data));
grpc_slice_unref(json_key_data);
if (!grpc_auth_json_key_is_valid(&key)) {
fprintf(stderr, "Could not parse json key.\n");
diff --git a/test/core/security/credentials_test.cc b/test/core/security/credentials_test.cc
index 90310469aa..ce92e21d73 100644
--- a/test/core/security/credentials_test.cc
+++ b/test/core/security/credentials_test.cc
@@ -140,7 +140,7 @@ static grpc_httpcli_response http_response(int status, const char* body) {
grpc_httpcli_response response;
memset(&response, 0, sizeof(grpc_httpcli_response));
response.status = status;
- response.body = gpr_strdup((char*)body);
+ response.body = gpr_strdup(const_cast<char*>(body));
response.body_length = strlen(body);
return response;
}
@@ -324,7 +324,7 @@ static void check_metadata(const expected_md* expected,
}
static void check_request_metadata(void* arg, grpc_error* error) {
- request_metadata_state* state = (request_metadata_state*)arg;
+ request_metadata_state* state = static_cast<request_metadata_state*>(arg);
gpr_log(GPR_INFO, "expected_error: %s",
grpc_error_string(state->expected_error));
gpr_log(GPR_INFO, "actual_error: %s", grpc_error_string(error));
@@ -754,7 +754,7 @@ static grpc_service_account_jwt_access_credentials* creds_as_jwt(
grpc_call_credentials* creds) {
GPR_ASSERT(creds != nullptr);
GPR_ASSERT(strcmp(creds->type, GRPC_CALL_CREDENTIALS_TYPE_JWT) == 0);
- return (grpc_service_account_jwt_access_credentials*)creds;
+ return reinterpret_cast<grpc_service_account_jwt_access_credentials*>(creds);
}
static void test_jwt_creds_lifetime(void) {
@@ -873,10 +873,11 @@ static void test_google_default_creds_auth_key(void) {
set_google_default_creds_env_var_with_file_contents(
"json_key_google_default_creds", json_key);
gpr_free(json_key);
- creds = (grpc_composite_channel_credentials*)
- grpc_google_default_credentials_create();
+ creds = reinterpret_cast<grpc_composite_channel_credentials*>(
+ grpc_google_default_credentials_create());
GPR_ASSERT(creds != nullptr);
- jwt = (grpc_service_account_jwt_access_credentials*)creds->call_creds;
+ jwt = reinterpret_cast<grpc_service_account_jwt_access_credentials*>(
+ creds->call_creds);
GPR_ASSERT(
strcmp(jwt->key.client_id,
"777-abaslkan11hlb6nmim3bpspl31ud.apps.googleusercontent.com") ==
@@ -892,10 +893,11 @@ static void test_google_default_creds_refresh_token(void) {
grpc_flush_cached_google_default_credentials();
set_google_default_creds_env_var_with_file_contents(
"refresh_token_google_default_creds", test_refresh_token_str);
- creds = (grpc_composite_channel_credentials*)
- grpc_google_default_credentials_create();
+ creds = reinterpret_cast<grpc_composite_channel_credentials*>(
+ grpc_google_default_credentials_create());
GPR_ASSERT(creds != nullptr);
- refresh = (grpc_google_refresh_token_credentials*)creds->call_creds;
+ refresh = reinterpret_cast<grpc_google_refresh_token_credentials*>(
+ creds->call_creds);
GPR_ASSERT(strcmp(refresh->refresh_token.client_id,
"32555999999.apps.googleusercontent.com") == 0);
grpc_channel_credentials_unref(&creds->base);
@@ -938,8 +940,8 @@ static void test_google_default_creds_gce(void) {
default_creds_gce_detection_httpcli_get_success_override,
httpcli_post_should_not_be_called);
grpc_composite_channel_credentials* creds =
- (grpc_composite_channel_credentials*)
- grpc_google_default_credentials_create();
+ reinterpret_cast<grpc_composite_channel_credentials*>(
+ grpc_google_default_credentials_create());
/* Verify that the default creds actually embeds a GCE creds. */
GPR_ASSERT(creds != nullptr);
@@ -1018,7 +1020,7 @@ static int plugin_get_metadata_success(
GPR_ASSERT(context.reserved == nullptr);
GPR_ASSERT(GPR_ARRAY_SIZE(plugin_md) <
GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX);
- plugin_state* s = (plugin_state*)state;
+ plugin_state* s = static_cast<plugin_state*>(state);
*s = PLUGIN_GET_METADATA_CALLED_STATE;
for (size_t i = 0; i < GPR_ARRAY_SIZE(plugin_md); ++i) {
memset(&creds_md[i], 0, sizeof(grpc_metadata));
@@ -1041,7 +1043,7 @@ static int plugin_get_metadata_failure(
GPR_ASSERT(strcmp(context.method_name, test_method) == 0);
GPR_ASSERT(context.channel_auth_context == nullptr);
GPR_ASSERT(context.reserved == nullptr);
- plugin_state* s = (plugin_state*)state;
+ plugin_state* s = static_cast<plugin_state*>(state);
*s = PLUGIN_GET_METADATA_CALLED_STATE;
*status = GRPC_STATUS_UNAUTHENTICATED;
*error_details = gpr_strdup(plugin_error_details);
@@ -1049,7 +1051,7 @@ static int plugin_get_metadata_failure(
}
static void plugin_destroy(void* state) {
- plugin_state* s = (plugin_state*)state;
+ plugin_state* s = static_cast<plugin_state*>(state);
*s = PLUGIN_DESTROY_CALLED_STATE;
}
diff --git a/test/core/security/fetch_oauth2.cc b/test/core/security/fetch_oauth2.cc
index b0fa514400..82efe682be 100644
--- a/test/core/security/fetch_oauth2.cc
+++ b/test/core/security/fetch_oauth2.cc
@@ -38,7 +38,8 @@ static grpc_call_credentials* create_refresh_token_creds(
"load_file",
grpc_load_file(json_refresh_token_file_path, 1, &refresh_token)));
return grpc_google_refresh_token_credentials_create(
- (const char*)GRPC_SLICE_START_PTR(refresh_token), nullptr);
+ reinterpret_cast<const char*> GRPC_SLICE_START_PTR(refresh_token),
+ nullptr);
}
int main(int argc, char** argv) {
diff --git a/test/core/security/json_token_test.cc b/test/core/security/json_token_test.cc
index aac9cc0029..7a5b3355fe 100644
--- a/test/core/security/json_token_test.cc
+++ b/test/core/security/json_token_test.cc
@@ -218,7 +218,7 @@ static grpc_json* parse_json_part_from_jwt(const char* str, size_t len,
slice = grpc_base64_decode(b64, 1);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(slice));
decoded = static_cast<char*>(gpr_malloc(GRPC_SLICE_LENGTH(slice) + 1));
- strncpy(decoded, (const char*)GRPC_SLICE_START_PTR(slice),
+ strncpy(decoded, reinterpret_cast<const char*> GRPC_SLICE_START_PTR(slice),
GRPC_SLICE_LENGTH(slice));
decoded[GRPC_SLICE_LENGTH(slice)] = '\0';
json = grpc_json_parse_string(decoded);
@@ -385,21 +385,21 @@ static void test_jwt_encode_and_sign(
char* jwt = jwt_encode_and_sign_func(&json_key);
const char* dot = strchr(jwt, '.');
GPR_ASSERT(dot != nullptr);
- parsed_header =
- parse_json_part_from_jwt(jwt, (size_t)(dot - jwt), &scratchpad);
+ parsed_header = parse_json_part_from_jwt(jwt, static_cast<size_t>(dot - jwt),
+ &scratchpad);
GPR_ASSERT(parsed_header != nullptr);
check_jwt_header(parsed_header);
- offset = (size_t)(dot - jwt) + 1;
+ offset = static_cast<size_t>(dot - jwt) + 1;
grpc_json_destroy(parsed_header);
gpr_free(scratchpad);
dot = strchr(jwt + offset, '.');
GPR_ASSERT(dot != nullptr);
parsed_claim = parse_json_part_from_jwt(
- jwt + offset, (size_t)(dot - (jwt + offset)), &scratchpad);
+ jwt + offset, static_cast<size_t>(dot - (jwt + offset)), &scratchpad);
GPR_ASSERT(parsed_claim != nullptr);
check_jwt_claim_func(parsed_claim);
- offset = (size_t)(dot - jwt) + 1;
+ offset = static_cast<size_t>(dot - jwt) + 1;
grpc_json_destroy(parsed_claim);
gpr_free(scratchpad);
diff --git a/test/core/security/jwt_verifier_test.cc b/test/core/security/jwt_verifier_test.cc
index e219260b1d..9718580a08 100644
--- a/test/core/security/jwt_verifier_test.cc
+++ b/test/core/security/jwt_verifier_test.cc
@@ -207,7 +207,7 @@ static void test_claims_success(void) {
grpc_jwt_claims* claims;
grpc_slice s = grpc_slice_from_copied_string(claims_without_time_constraint);
grpc_json* json = grpc_json_parse_string_with_len(
- (char*)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
+ reinterpret_cast<char*> GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
GPR_ASSERT(json != nullptr);
grpc_core::ExecCtx exec_ctx;
claims = grpc_jwt_claims_from_json(json, s);
@@ -226,7 +226,7 @@ static void test_expired_claims_failure(void) {
grpc_jwt_claims* claims;
grpc_slice s = grpc_slice_from_copied_string(expired_claims);
grpc_json* json = grpc_json_parse_string_with_len(
- (char*)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
+ reinterpret_cast<char*> GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
gpr_timespec exp_iat = {100, 0, GPR_CLOCK_REALTIME};
gpr_timespec exp_exp = {120, 0, GPR_CLOCK_REALTIME};
gpr_timespec exp_nbf = {60, 0, GPR_CLOCK_REALTIME};
@@ -251,7 +251,7 @@ static void test_expired_claims_failure(void) {
static void test_invalid_claims_failure(void) {
grpc_slice s = grpc_slice_from_copied_string(invalid_claims);
grpc_json* json = grpc_json_parse_string_with_len(
- (char*)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
+ reinterpret_cast<char*> GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
grpc_core::ExecCtx exec_ctx;
GPR_ASSERT(grpc_jwt_claims_from_json(json, s) == nullptr);
}
@@ -260,7 +260,7 @@ static void test_bad_audience_claims_failure(void) {
grpc_jwt_claims* claims;
grpc_slice s = grpc_slice_from_copied_string(claims_without_time_constraint);
grpc_json* json = grpc_json_parse_string_with_len(
- (char*)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
+ reinterpret_cast<char*> GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
GPR_ASSERT(json != nullptr);
grpc_core::ExecCtx exec_ctx;
claims = grpc_jwt_claims_from_json(json, s);
@@ -274,7 +274,7 @@ static void test_bad_subject_claims_failure(void) {
grpc_jwt_claims* claims;
grpc_slice s = grpc_slice_from_copied_string(claims_with_bad_subject);
grpc_json* json = grpc_json_parse_string_with_len(
- (char*)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
+ reinterpret_cast<char*> GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
GPR_ASSERT(json != nullptr);
grpc_core::ExecCtx exec_ctx;
claims = grpc_jwt_claims_from_json(json, s);
diff --git a/test/core/security/oauth2_utils.cc b/test/core/security/oauth2_utils.cc
index 0d3a1279af..469129a6d0 100644
--- a/test/core/security/oauth2_utils.cc
+++ b/test/core/security/oauth2_utils.cc
@@ -40,7 +40,7 @@ typedef struct {
} oauth2_request;
static void on_oauth2_response(void* arg, grpc_error* error) {
- oauth2_request* request = (oauth2_request*)arg;
+ oauth2_request* request = static_cast<oauth2_request*>(arg);
char* token = nullptr;
grpc_slice token_slice;
if (error != GRPC_ERROR_NONE) {
@@ -48,7 +48,7 @@ static void on_oauth2_response(void* arg, grpc_error* error) {
} else {
GPR_ASSERT(request->md_array.size == 1);
token_slice = GRPC_MDVALUE(request->md_array.md[0]);
- token = (char*)gpr_malloc(GRPC_SLICE_LENGTH(token_slice) + 1);
+ token = static_cast<char*>(gpr_malloc(GRPC_SLICE_LENGTH(token_slice) + 1));
memcpy(token, GRPC_SLICE_START_PTR(token_slice),
GRPC_SLICE_LENGTH(token_slice));
token[GRPC_SLICE_LENGTH(token_slice)] = '\0';
@@ -73,7 +73,8 @@ char* grpc_test_fetch_oauth2_token_with_credentials(
grpc_closure do_nothing_closure;
grpc_auth_metadata_context null_ctx = {"", "", nullptr, nullptr};
- grpc_pollset* pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size());
+ grpc_pollset* pollset =
+ static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
grpc_pollset_init(pollset, &request.mu);
request.pops = grpc_polling_entity_create_from_pollset(pollset);
request.is_done = false;
diff --git a/test/core/security/print_google_default_creds_token.cc b/test/core/security/print_google_default_creds_token.cc
index 828694afd1..4d251391ff 100644
--- a/test/core/security/print_google_default_creds_token.cc
+++ b/test/core/security/print_google_default_creds_token.cc
@@ -88,7 +88,7 @@ int main(int argc, char** argv) {
}
memset(&sync, 0, sizeof(sync));
- pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size());
+ pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
grpc_pollset_init(pollset, &sync.mu);
sync.pops = grpc_polling_entity_create_from_pollset(pollset);
sync.is_done = false;
@@ -97,8 +97,10 @@ int main(int argc, char** argv) {
error = GRPC_ERROR_NONE;
if (grpc_call_credentials_get_request_metadata(
- ((grpc_composite_channel_credentials*)creds)->call_creds, &sync.pops,
- context, &sync.md_array, &sync.on_request_metadata, &error)) {
+ (reinterpret_cast<grpc_composite_channel_credentials*>(creds))
+ ->call_creds,
+ &sync.pops, context, &sync.md_array, &sync.on_request_metadata,
+ &error)) {
// Synchronous response. Invoke callback directly.
on_metadata_response(&sync, error);
GRPC_ERROR_UNREF(error);
diff --git a/test/core/security/secure_endpoint_test.cc b/test/core/security/secure_endpoint_test.cc
index 8e92a21e5d..23cef99dfa 100644
--- a/test/core/security/secure_endpoint_test.cc
+++ b/test/core/security/secure_endpoint_test.cc
@@ -57,7 +57,7 @@ static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair(
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;
+ a[0].value.integer = static_cast<int>(slice_size);
grpc_channel_args args = {GPR_ARRAY_SIZE(a), a};
tcp = grpc_iomgr_create_endpoint_pair("fixture", &args);
grpc_endpoint_add_to_pollset(tcp.client, g_pollset);
@@ -73,7 +73,7 @@ static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair(
size_t still_pending_size;
size_t total_buffer_size = 8192;
size_t buffer_size = total_buffer_size;
- uint8_t* encrypted_buffer = (uint8_t*)gpr_malloc(buffer_size);
+ uint8_t* encrypted_buffer = static_cast<uint8_t*>(gpr_malloc(buffer_size));
uint8_t* cur = encrypted_buffer;
grpc_slice encrypted_leftover;
for (i = 0; i < leftover_nslices; i++) {
@@ -106,7 +106,8 @@ static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair(
buffer_size -= protected_buffer_size_to_send;
} while (still_pending_size > 0);
encrypted_leftover = grpc_slice_from_copied_buffer(
- (const char*)encrypted_buffer, total_buffer_size - buffer_size);
+ reinterpret_cast<const char*>(encrypted_buffer),
+ total_buffer_size - buffer_size);
f.client_ep = grpc_secure_endpoint_create(
fake_read_protector, fake_read_zero_copy_protector, tcp.client,
&encrypted_leftover, 1);
@@ -165,7 +166,9 @@ static grpc_endpoint_test_config configs[] = {
clean_up},
};
-static void inc_call_ctr(void* arg, grpc_error* error) { ++*(int*)arg; }
+static void inc_call_ctr(void* arg, grpc_error* error) {
+ ++*static_cast<int*>(arg);
+}
static void test_leftover(grpc_endpoint_test_config config, size_t slice_size) {
grpc_endpoint_test_fixture f = config.create_fixture(slice_size);
@@ -200,7 +203,7 @@ static void test_leftover(grpc_endpoint_test_config config, size_t slice_size) {
}
static void destroy_pollset(void* p, grpc_error* error) {
- grpc_pollset_destroy((grpc_pollset*)p);
+ grpc_pollset_destroy(static_cast<grpc_pollset*>(p));
}
int main(int argc, char** argv) {
@@ -210,7 +213,7 @@ int main(int argc, char** argv) {
{
grpc_core::ExecCtx exec_ctx;
- g_pollset = (grpc_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_endpoint_tests(configs[1], g_pollset, g_mu);
diff --git a/test/core/security/verify_jwt.cc b/test/core/security/verify_jwt.cc
index 747508f6f6..61dde0e7d9 100644
--- a/test/core/security/verify_jwt.cc
+++ b/test/core/security/verify_jwt.cc
@@ -54,8 +54,8 @@ static void on_jwt_verification_done(void* user_data,
if (sync->success) {
char* claims_str;
GPR_ASSERT(claims != nullptr);
- claims_str =
- grpc_json_dump_to_string((grpc_json*)grpc_jwt_claims_json(claims), 2);
+ claims_str = grpc_json_dump_to_string(
+ const_cast<grpc_json*>(grpc_jwt_claims_json(claims)), 2);
printf("Claims: \n\n%s\n", claims_str);
gpr_free(claims_str);
grpc_jwt_claims_destroy(claims);
diff --git a/test/core/slice/b64_test.cc b/test/core/slice/b64_test.cc
index 94785fd1e2..6b29443ba1 100644
--- a/test/core/slice/b64_test.cc
+++ b/test/core/slice/b64_test.cc
@@ -34,7 +34,7 @@ static int buffers_are_equal(const unsigned char* buf1,
for (i = 0; i < size; i++) {
if (buf1[i] != buf2[i]) {
gpr_log(GPR_ERROR, "buf1 and buf2 differ: buf1[%d] = %x vs buf2[%d] = %x",
- (int)i, buf1[i], (int)i, buf2[i]);
+ static_cast<int>(i), buf1[i], static_cast<int>(i), buf2[i]);
return 0;
}
}
@@ -61,7 +61,7 @@ static void test_full_range_encode_decode_b64(int url_safe, int multiline) {
size_t i;
char* b64;
grpc_slice orig_decoded;
- for (i = 0; i < sizeof(orig); i++) orig[i] = (uint8_t)i;
+ for (i = 0; i < sizeof(orig); i++) orig[i] = static_cast<uint8_t>(i);
/* Try all the different paddings. */
for (i = 0; i < 3; i++) {
@@ -114,7 +114,7 @@ static void test_url_safe_unsafe_mismatch_failure(void) {
char* b64;
grpc_slice orig_decoded;
int url_safe = 1;
- for (i = 0; i < sizeof(orig); i++) orig[i] = (uint8_t)i;
+ for (i = 0; i < sizeof(orig); i++) orig[i] = static_cast<uint8_t>(i);
grpc_core::ExecCtx exec_ctx;
b64 = grpc_base64_encode(orig, sizeof(orig), url_safe, 0);
diff --git a/test/core/slice/percent_encode_fuzzer.cc b/test/core/slice/percent_encode_fuzzer.cc
index 201ae2790e..1fd197e180 100644
--- a/test/core/slice/percent_encode_fuzzer.cc
+++ b/test/core/slice/percent_encode_fuzzer.cc
@@ -34,7 +34,8 @@ static void test(const uint8_t* data, size_t size, const uint8_t* dict) {
struct grpc_memory_counters counters;
grpc_init();
grpc_memory_counters_init();
- grpc_slice input = grpc_slice_from_copied_buffer((const char*)data, size);
+ grpc_slice input =
+ grpc_slice_from_copied_buffer(reinterpret_cast<const char*>(data), size);
grpc_slice output = grpc_percent_encode_slice(input, dict);
grpc_slice decoded_output;
// encoder must always produce decodable output
diff --git a/test/core/slice/slice_test.cc b/test/core/slice/slice_test.cc
index e40154dd0e..5a49793a9e 100644
--- a/test/core/slice/slice_test.cc
+++ b/test/core/slice/slice_test.cc
@@ -57,7 +57,7 @@ static void test_slice_malloc_returns_something_sensible(void) {
}
/* We must be able to write to every byte of the data */
for (i = 0; i < length; i++) {
- GRPC_SLICE_START_PTR(slice)[i] = (uint8_t)i;
+ GRPC_SLICE_START_PTR(slice)[i] = static_cast<uint8_t>(i);
}
/* And finally we must succeed in destroying the slice */
grpc_slice_unref(slice);
@@ -77,7 +77,7 @@ static void test_slice_new_returns_something_sensible(void) {
}
/* destroy function that sets a mark to indicate it was called. */
-static void set_mark(void* p) { *((int*)p) = 1; }
+static void set_mark(void* p) { *(static_cast<int*>(p)) = 1; }
static void test_slice_new_with_user_data(void) {
int marker = 0;
@@ -143,7 +143,7 @@ static void test_slice_sub_works(unsigned length) {
beginning of the slice. */
slice = grpc_slice_malloc(length);
for (i = 0; i < length; i++) {
- GRPC_SLICE_START_PTR(slice)[i] = (uint8_t)i;
+ GRPC_SLICE_START_PTR(slice)[i] = static_cast<uint8_t>(i);
}
/* Ensure that for all subsets length is correct and that we start on the
@@ -183,7 +183,7 @@ static void test_slice_split_head_works(size_t length) {
beginning of the slice. */
slice = grpc_slice_malloc(length);
for (i = 0; i < length; i++) {
- GRPC_SLICE_START_PTR(slice)[i] = (uint8_t)i;
+ GRPC_SLICE_START_PTR(slice)[i] = static_cast<uint8_t>(i);
}
/* Ensure that for all subsets length is correct and that we start on the
@@ -211,7 +211,7 @@ static void test_slice_split_tail_works(size_t length) {
beginning of the slice. */
slice = grpc_slice_malloc(length);
for (i = 0; i < length; i++) {
- GRPC_SLICE_START_PTR(slice)[i] = (uint8_t)i;
+ GRPC_SLICE_START_PTR(slice)[i] = static_cast<uint8_t>(i);
}
/* Ensure that for all subsets length is correct and that we start on the
diff --git a/test/core/surface/completion_queue_threading_test.cc b/test/core/surface/completion_queue_threading_test.cc
index d97e98b7a4..e5015723f7 100644
--- a/test/core/surface/completion_queue_threading_test.cc
+++ b/test/core/surface/completion_queue_threading_test.cc
@@ -146,7 +146,7 @@ static void producer_thread(void* arg) {
int i;
gpr_log(GPR_INFO, "producer %d started", opt->id);
- gpr_event_set(&opt->on_started, (void*)(intptr_t)1);
+ gpr_event_set(&opt->on_started, (void*)static_cast<intptr_t>(1));
GPR_ASSERT(gpr_event_wait(opt->phase1, ten_seconds_time()));
gpr_log(GPR_INFO, "producer %d phase 1", opt->id);
@@ -155,13 +155,13 @@ static void producer_thread(void* arg) {
}
gpr_log(GPR_INFO, "producer %d phase 1 done", opt->id);
- gpr_event_set(&opt->on_phase1_done, (void*)(intptr_t)1);
+ gpr_event_set(&opt->on_phase1_done, (void*)static_cast<intptr_t>(1));
GPR_ASSERT(gpr_event_wait(opt->phase2, ten_seconds_time()));
gpr_log(GPR_INFO, "producer %d phase 2", opt->id);
for (i = 0; i < TEST_THREAD_EVENTS; i++) {
grpc_core::ExecCtx exec_ctx;
- grpc_cq_end_op(opt->cc, (void*)(intptr_t)1, GRPC_ERROR_NONE,
+ grpc_cq_end_op(opt->cc, (void*)static_cast<intptr_t>(1), GRPC_ERROR_NONE,
free_completion, nullptr,
static_cast<grpc_cq_completion*>(
gpr_malloc(sizeof(grpc_cq_completion))));
@@ -169,7 +169,7 @@ static void producer_thread(void* arg) {
}
gpr_log(GPR_INFO, "producer %d phase 2 done", opt->id);
- gpr_event_set(&opt->on_finished, (void*)(intptr_t)1);
+ gpr_event_set(&opt->on_finished, (void*)static_cast<intptr_t>(1));
}
static void consumer_thread(void* arg) {
@@ -177,13 +177,13 @@ static void consumer_thread(void* arg) {
grpc_event ev;
gpr_log(GPR_INFO, "consumer %d started", opt->id);
- gpr_event_set(&opt->on_started, (void*)(intptr_t)1);
+ gpr_event_set(&opt->on_started, (void*)static_cast<intptr_t>(1));
GPR_ASSERT(gpr_event_wait(opt->phase1, ten_seconds_time()));
gpr_log(GPR_INFO, "consumer %d phase 1", opt->id);
gpr_log(GPR_INFO, "consumer %d phase 1 done", opt->id);
- gpr_event_set(&opt->on_phase1_done, (void*)(intptr_t)1);
+ gpr_event_set(&opt->on_phase1_done, (void*)static_cast<intptr_t>(1));
GPR_ASSERT(gpr_event_wait(opt->phase2, ten_seconds_time()));
gpr_log(GPR_INFO, "consumer %d phase 2", opt->id);
@@ -197,7 +197,7 @@ static void consumer_thread(void* arg) {
break;
case GRPC_QUEUE_SHUTDOWN:
gpr_log(GPR_INFO, "consumer %d phase 2 done", opt->id);
- gpr_event_set(&opt->on_finished, (void*)(intptr_t)1);
+ gpr_event_set(&opt->on_finished, (void*)static_cast<intptr_t>(1));
return;
case GRPC_QUEUE_TIMEOUT:
gpr_log(GPR_ERROR, "Invalid timeout received");
@@ -240,7 +240,7 @@ static void test_threading(size_t producers, size_t consumers) {
/* start phase1: producers will pre-declare all operations they will
complete */
gpr_log(GPR_INFO, "start phase 1");
- gpr_event_set(&phase1, (void*)(intptr_t)1);
+ gpr_event_set(&phase1, (void*)static_cast<intptr_t>(1));
gpr_log(GPR_INFO, "wait phase 1");
for (i = 0; i < producers + consumers; i++) {
@@ -250,7 +250,7 @@ static void test_threading(size_t producers, size_t consumers) {
/* start phase2: operations will complete, and consumers will consume them */
gpr_log(GPR_INFO, "start phase 2");
- gpr_event_set(&phase2, (void*)(intptr_t)1);
+ gpr_event_set(&phase2, (void*)static_cast<intptr_t>(1));
/* in parallel, we shutdown the completion channel - all events should still
be consumed */
diff --git a/test/core/surface/concurrent_connectivity_test.cc b/test/core/surface/concurrent_connectivity_test.cc
index 235d136376..bbee073c71 100644
--- a/test/core/surface/concurrent_connectivity_test.cc
+++ b/test/core/surface/concurrent_connectivity_test.cc
@@ -55,14 +55,14 @@
// it should never take longer that this to shutdown the server
#define SERVER_SHUTDOWN_TIMEOUT 30000
-static void* tag(int n) { return (void*)(uintptr_t)n; }
-static int detag(void* p) { return (int)(uintptr_t)p; }
+static void* tag(int n) { return (void*)static_cast<uintptr_t>(n); }
+static int detag(void* p) { return static_cast<int>((uintptr_t)p); }
void create_loop_destroy(void* addr) {
for (int i = 0; i < NUM_OUTER_LOOPS; ++i) {
grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
- grpc_channel* chan =
- grpc_insecure_channel_create((char*)addr, nullptr, nullptr);
+ grpc_channel* chan = grpc_insecure_channel_create(static_cast<char*>(addr),
+ nullptr, nullptr);
for (int j = 0; j < NUM_INNER_LOOPS; ++j) {
gpr_timespec later_time =
@@ -94,7 +94,8 @@ struct server_thread_args {
};
void server_thread(void* vargs) {
- struct server_thread_args* args = (struct server_thread_args*)vargs;
+ struct server_thread_args* args =
+ static_cast<struct server_thread_args*>(vargs);
grpc_event ev;
gpr_timespec deadline =
grpc_timeout_milliseconds_to_deadline(SERVER_SHUTDOWN_TIMEOUT);
@@ -107,7 +108,8 @@ static void on_connect(void* vargs, grpc_endpoint* tcp,
grpc_pollset* accepting_pollset,
grpc_tcp_server_acceptor* acceptor) {
gpr_free(acceptor);
- struct server_thread_args* args = (struct server_thread_args*)vargs;
+ struct server_thread_args* args =
+ static_cast<struct server_thread_args*>(vargs);
grpc_endpoint_shutdown(tcp,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Connected"));
grpc_endpoint_destroy(tcp);
@@ -117,11 +119,13 @@ static void on_connect(void* vargs, grpc_endpoint* tcp,
}
void bad_server_thread(void* vargs) {
- struct server_thread_args* args = (struct server_thread_args*)vargs;
+ struct server_thread_args* args =
+ static_cast<struct server_thread_args*>(vargs);
grpc_core::ExecCtx exec_ctx;
grpc_resolved_address resolved_addr;
- struct sockaddr_storage* addr = (struct sockaddr_storage*)resolved_addr.addr;
+ struct sockaddr_storage* addr =
+ reinterpret_cast<struct sockaddr_storage*>(resolved_addr.addr);
int port;
grpc_tcp_server* s;
grpc_error* error = grpc_tcp_server_create(nullptr, nullptr, &s);
@@ -244,8 +248,8 @@ int run_concurrent_connectivity_test() {
void watches_with_short_timeouts(void* addr) {
for (int i = 0; i < NUM_OUTER_LOOPS_SHORT_TIMEOUTS; ++i) {
grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
- grpc_channel* chan =
- grpc_insecure_channel_create((char*)addr, nullptr, nullptr);
+ grpc_channel* chan = grpc_insecure_channel_create(static_cast<char*>(addr),
+ nullptr, nullptr);
for (int j = 0; j < NUM_INNER_LOOPS_SHORT_TIMEOUTS; ++j) {
gpr_timespec later_time =
diff --git a/test/core/surface/lame_client_test.cc b/test/core/surface/lame_client_test.cc
index 4bf40569e6..fac5ca8f7f 100644
--- a/test/core/surface/lame_client_test.cc
+++ b/test/core/surface/lame_client_test.cc
@@ -112,7 +112,8 @@ int main(int argc, char** argv) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(call, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(call, ops, static_cast<size_t>(op - ops),
+ tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
/* the call should immediately fail */
@@ -128,7 +129,8 @@ int main(int argc, char** argv) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(call, ops, (size_t)(op - ops), tag(2), nullptr);
+ error = grpc_call_start_batch(call, ops, static_cast<size_t>(op - ops),
+ tag(2), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
/* the call should immediately fail */
diff --git a/test/core/transport/chttp2/hpack_encoder_test.cc b/test/core/transport/chttp2/hpack_encoder_test.cc
index a40bd643ec..d3ba50a91c 100644
--- a/test/core/transport/chttp2/hpack_encoder_test.cc
+++ b/test/core/transport/chttp2/hpack_encoder_test.cc
@@ -152,10 +152,10 @@ static void test_basic_headers() {
}
static void encode_int_to_str(int i, char* p) {
- p[0] = (char)('a' + i % 26);
+ p[0] = static_cast<char>('a' + i % 26);
i /= 26;
GPR_ASSERT(i < 26);
- p[1] = (char)('a' + i);
+ p[1] = static_cast<char>('a' + i);
p[2] = 0;
}
diff --git a/test/core/transport/chttp2/settings_timeout_test.cc b/test/core/transport/chttp2/settings_timeout_test.cc
index 7fb395d4b6..39ae587bae 100644
--- a/test/core/transport/chttp2/settings_timeout_test.cc
+++ b/test/core/transport/chttp2/settings_timeout_test.cc
@@ -104,7 +104,7 @@ class Client {
grpc_blocking_resolve_address(server_address_, "80", &server_addresses);
ASSERT_EQ(GRPC_ERROR_NONE, error) << grpc_error_string(error);
ASSERT_GE(server_addresses->naddrs, 1UL);
- pollset_ = (grpc_pollset*)gpr_zalloc(grpc_pollset_size());
+ pollset_ = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
grpc_pollset_init(pollset_, &mu_);
grpc_pollset_set* pollset_set = grpc_pollset_set_create();
grpc_pollset_set_add_pollset(pollset_set, pollset_);
@@ -177,7 +177,7 @@ class Client {
private:
static void OnEventDone(void* arg, grpc_error* error) {
gpr_log(GPR_INFO, "OnEventDone(): %s", grpc_error_string(error));
- EventState* state = (EventState*)arg;
+ EventState* state = static_cast<EventState*>(arg);
state->error_ = GRPC_ERROR_REF(error);
gpr_atm_rel_store(&state->done_atm_, 1);
}
@@ -203,7 +203,7 @@ class Client {
}
static void PollsetDestroy(void* arg, grpc_error* error) {
- grpc_pollset* pollset = (grpc_pollset*)arg;
+ grpc_pollset* pollset = static_cast<grpc_pollset*>(arg);
grpc_pollset_destroy(pollset);
gpr_free(pollset);
}
diff --git a/test/core/transport/chttp2/stream_map_test.cc b/test/core/transport/chttp2/stream_map_test.cc
index 9b21cb2364..773eb3a35f 100644
--- a/test/core/transport/chttp2/stream_map_test.cc
+++ b/test/core/transport/chttp2/stream_map_test.cc
@@ -78,7 +78,7 @@ static void test_basic_add_find(uint32_t n) {
grpc_chttp2_stream_map_init(&map, 8);
GPR_ASSERT(0 == grpc_chttp2_stream_map_size(&map));
for (i = 1; i <= n; i++) {
- grpc_chttp2_stream_map_add(&map, i, (void*)(uintptr_t)i);
+ grpc_chttp2_stream_map_add(&map, i, (void*)static_cast<uintptr_t>(i));
}
GPR_ASSERT(n == grpc_chttp2_stream_map_size(&map));
GPR_ASSERT(nullptr == grpc_chttp2_stream_map_find(&map, 0));
@@ -133,7 +133,7 @@ static void test_delete_evens_sweep(uint32_t n) {
grpc_chttp2_stream_map_init(&map, 8);
for (i = 1; i <= n; i++) {
- grpc_chttp2_stream_map_add(&map, i, (void*)(uintptr_t)i);
+ grpc_chttp2_stream_map_add(&map, i, (void*)static_cast<uintptr_t>(i));
}
for (i = 1; i <= n; i++) {
if ((i & 1) == 0) {
@@ -155,7 +155,7 @@ static void test_delete_evens_incremental(uint32_t n) {
grpc_chttp2_stream_map_init(&map, 8);
for (i = 1; i <= n; i++) {
- grpc_chttp2_stream_map_add(&map, i, (void*)(uintptr_t)i);
+ grpc_chttp2_stream_map_add(&map, i, (void*)static_cast<uintptr_t>(i));
if ((i & 1) == 0) {
grpc_chttp2_stream_map_delete(&map, i);
}
@@ -177,7 +177,7 @@ static void test_periodic_compaction(uint32_t n) {
grpc_chttp2_stream_map_init(&map, 16);
GPR_ASSERT(map.capacity == 16);
for (i = 1; i <= n; i++) {
- grpc_chttp2_stream_map_add(&map, i, (void*)(uintptr_t)i);
+ grpc_chttp2_stream_map_add(&map, i, (void*)static_cast<uintptr_t>(i));
if (i > 8) {
del = i - 8;
GPR_ASSERT((void*)(uintptr_t)del ==
diff --git a/test/core/transport/metadata_test.cc b/test/core/transport/metadata_test.cc
index 7d943fd5c7..786df97285 100644
--- a/test/core/transport/metadata_test.cc
+++ b/test/core/transport/metadata_test.cc
@@ -240,8 +240,8 @@ static void test_things_stick_around(void) {
}
for (i = 0; i < nstrs; i++) {
- size_t p = (size_t)rand() % nstrs;
- size_t q = (size_t)rand() % nstrs;
+ size_t p = static_cast<size_t>(rand()) % nstrs;
+ size_t q = static_cast<size_t>(rand()) % nstrs;
size_t temp = shuf[p];
shuf[p] = shuf[q];
shuf[q] = temp;
@@ -307,8 +307,8 @@ static void verify_binary_header_size(const char* key, const uint8_t* value,
intern_value));
GPR_ASSERT(grpc_is_binary_header(GRPC_MDKEY(elem)));
size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem, false);
- grpc_slice value_slice =
- grpc_slice_from_copied_buffer((const char*)value, value_len);
+ grpc_slice value_slice = grpc_slice_from_copied_buffer(
+ reinterpret_cast<const char*>(value), value_len);
grpc_slice base64_encoded = grpc_chttp2_base64_encode(value_slice);
size_t expected_size = 32 + strlen(key) + GRPC_SLICE_LENGTH(base64_encoded);
GPR_ASSERT(expected_size == elem_size);
diff --git a/test/core/transport/timeout_encoding_test.cc b/test/core/transport/timeout_encoding_test.cc
index 26e0785488..2367accc2e 100644
--- a/test/core/transport/timeout_encoding_test.cc
+++ b/test/core/transport/timeout_encoding_test.cc
@@ -103,20 +103,22 @@ void decode_suite(char ext, grpc_millis (*answer)(int64_t x)) {
}
static grpc_millis millis_from_nanos(int64_t x) {
- return (grpc_millis)(x / GPR_NS_PER_MS + (x % GPR_NS_PER_MS != 0));
+ return static_cast<grpc_millis>(x / GPR_NS_PER_MS + (x % GPR_NS_PER_MS != 0));
}
static grpc_millis millis_from_micros(int64_t x) {
- return (grpc_millis)(x / GPR_US_PER_MS + (x % GPR_US_PER_MS != 0));
+ return static_cast<grpc_millis>(x / GPR_US_PER_MS + (x % GPR_US_PER_MS != 0));
+}
+static grpc_millis millis_from_millis(int64_t x) {
+ return static_cast<grpc_millis>(x);
}
-static grpc_millis millis_from_millis(int64_t x) { return (grpc_millis)x; }
static grpc_millis millis_from_seconds(int64_t x) {
- return (grpc_millis)(x * GPR_MS_PER_SEC);
+ return static_cast<grpc_millis>(x * GPR_MS_PER_SEC);
}
static grpc_millis millis_from_minutes(int64_t x) {
- return (grpc_millis)(x * 60 * GPR_MS_PER_SEC);
+ return static_cast<grpc_millis>(x * 60 * GPR_MS_PER_SEC);
}
static grpc_millis millis_from_hours(int64_t x) {
- return (grpc_millis)(x * 3600 * GPR_MS_PER_SEC);
+ return static_cast<grpc_millis>(x * 3600 * GPR_MS_PER_SEC);
}
void test_decoding(void) {
diff --git a/test/core/tsi/fake_transport_security_test.cc b/test/core/tsi/fake_transport_security_test.cc
index 73643fc9fd..ea392d347d 100644
--- a/test/core/tsi/fake_transport_security_test.cc
+++ b/test/core/tsi/fake_transport_security_test.cc
@@ -102,7 +102,8 @@ void fake_tsi_test_do_round_trip_for_all_configs() {
v <<= 1;
}
tsi_test_fixture* fixture = fake_tsi_test_fixture_create();
- fake_tsi_test_fixture* fake_fixture = (fake_tsi_test_fixture*)fixture;
+ fake_tsi_test_fixture* fake_fixture =
+ reinterpret_cast<fake_tsi_test_fixture*>(fixture);
tsi_test_frame_protector_config_destroy(fake_fixture->base.config);
fake_fixture->base.config = tsi_test_frame_protector_config_create(
bit_array[0], bit_array[1], bit_array[2], bit_array[3], bit_array[4],
@@ -123,7 +124,7 @@ void fake_tsi_test_do_round_trip_odd_buffer_size() {
for (size_t ind5 = 0; ind5 < size; ind5++) {
tsi_test_fixture* fixture = fake_tsi_test_fixture_create();
fake_tsi_test_fixture* fake_fixture =
- (fake_tsi_test_fixture*)fixture;
+ reinterpret_cast<fake_tsi_test_fixture*>(fixture);
tsi_test_frame_protector_config_set_buffer_size(
fake_fixture->base.config, odd_sizes[ind1], odd_sizes[ind2],
odd_sizes[ind3], odd_sizes[ind4], odd_sizes[ind5]);
diff --git a/test/core/tsi/ssl_transport_security_test.cc b/test/core/tsi/ssl_transport_security_test.cc
index bf54383c54..d7a4d747e1 100644
--- a/test/core/tsi/ssl_transport_security_test.cc
+++ b/test/core/tsi/ssl_transport_security_test.cc
@@ -81,7 +81,8 @@ typedef struct ssl_tsi_test_fixture {
} ssl_tsi_test_fixture;
static void ssl_test_setup_handshakers(tsi_test_fixture* fixture) {
- ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture;
+ ssl_tsi_test_fixture* ssl_fixture =
+ reinterpret_cast<ssl_tsi_test_fixture*>(fixture);
GPR_ASSERT(ssl_fixture != nullptr);
GPR_ASSERT(ssl_fixture->key_cert_lib != nullptr);
GPR_ASSERT(ssl_fixture->alpn_lib != nullptr);
@@ -244,7 +245,8 @@ static void check_client_peer(ssl_tsi_test_fixture* ssl_fixture,
}
static void ssl_test_check_handshaker_peers(tsi_test_fixture* fixture) {
- ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture;
+ ssl_tsi_test_fixture* ssl_fixture =
+ reinterpret_cast<ssl_tsi_test_fixture*>(fixture);
GPR_ASSERT(ssl_fixture != nullptr);
GPR_ASSERT(ssl_fixture->key_cert_lib != nullptr);
ssl_key_cert_lib* key_cert_lib = ssl_fixture->key_cert_lib;
@@ -281,7 +283,8 @@ static void ssl_test_pem_key_cert_pair_destroy(tsi_ssl_pem_key_cert_pair kp) {
}
static void ssl_test_destruct(tsi_test_fixture* fixture) {
- ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture;
+ ssl_tsi_test_fixture* ssl_fixture =
+ reinterpret_cast<ssl_tsi_test_fixture*>(fixture);
if (ssl_fixture == nullptr) {
return;
}
@@ -425,7 +428,8 @@ void ssl_tsi_test_do_handshake() {
void ssl_tsi_test_do_handshake_with_client_authentication() {
tsi_test_fixture* fixture = ssl_tsi_test_fixture_create();
- ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture;
+ ssl_tsi_test_fixture* ssl_fixture =
+ reinterpret_cast<ssl_tsi_test_fixture*>(fixture);
ssl_fixture->force_client_auth = true;
tsi_test_do_handshake(fixture);
tsi_test_fixture_destroy(fixture);
@@ -434,7 +438,8 @@ void ssl_tsi_test_do_handshake_with_client_authentication() {
void ssl_tsi_test_do_handshake_with_server_name_indication_exact_domain() {
/* server1 cert contains "waterzooi.test.google.be" in SAN. */
tsi_test_fixture* fixture = ssl_tsi_test_fixture_create();
- ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture;
+ ssl_tsi_test_fixture* ssl_fixture =
+ reinterpret_cast<ssl_tsi_test_fixture*>(fixture);
ssl_fixture->server_name_indication =
const_cast<char*>("waterzooi.test.google.be");
tsi_test_do_handshake(fixture);
@@ -444,7 +449,8 @@ void ssl_tsi_test_do_handshake_with_server_name_indication_exact_domain() {
void ssl_tsi_test_do_handshake_with_server_name_indication_wild_star_domain() {
/* server1 cert contains "*.test.google.fr" in SAN. */
tsi_test_fixture* fixture = ssl_tsi_test_fixture_create();
- ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture;
+ ssl_tsi_test_fixture* ssl_fixture =
+ reinterpret_cast<ssl_tsi_test_fixture*>(fixture);
ssl_fixture->server_name_indication =
const_cast<char*>("juju.test.google.fr");
tsi_test_do_handshake(fixture);
@@ -453,7 +459,8 @@ void ssl_tsi_test_do_handshake_with_server_name_indication_wild_star_domain() {
void ssl_tsi_test_do_handshake_with_bad_server_cert() {
tsi_test_fixture* fixture = ssl_tsi_test_fixture_create();
- ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture;
+ ssl_tsi_test_fixture* ssl_fixture =
+ reinterpret_cast<ssl_tsi_test_fixture*>(fixture);
ssl_fixture->key_cert_lib->use_bad_server_cert = true;
tsi_test_do_handshake(fixture);
tsi_test_fixture_destroy(fixture);
@@ -461,7 +468,8 @@ void ssl_tsi_test_do_handshake_with_bad_server_cert() {
void ssl_tsi_test_do_handshake_with_bad_client_cert() {
tsi_test_fixture* fixture = ssl_tsi_test_fixture_create();
- ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture;
+ ssl_tsi_test_fixture* ssl_fixture =
+ reinterpret_cast<ssl_tsi_test_fixture*>(fixture);
ssl_fixture->key_cert_lib->use_bad_client_cert = true;
ssl_fixture->force_client_auth = true;
tsi_test_do_handshake(fixture);
@@ -470,7 +478,8 @@ void ssl_tsi_test_do_handshake_with_bad_client_cert() {
void ssl_tsi_test_do_handshake_alpn_client_no_server() {
tsi_test_fixture* fixture = ssl_tsi_test_fixture_create();
- ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture;
+ ssl_tsi_test_fixture* ssl_fixture =
+ reinterpret_cast<ssl_tsi_test_fixture*>(fixture);
ssl_fixture->alpn_lib->alpn_mode = ALPN_CLIENT_NO_SERVER;
tsi_test_do_handshake(fixture);
tsi_test_fixture_destroy(fixture);
@@ -478,7 +487,8 @@ void ssl_tsi_test_do_handshake_alpn_client_no_server() {
void ssl_tsi_test_do_handshake_alpn_server_no_client() {
tsi_test_fixture* fixture = ssl_tsi_test_fixture_create();
- ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture;
+ ssl_tsi_test_fixture* ssl_fixture =
+ reinterpret_cast<ssl_tsi_test_fixture*>(fixture);
ssl_fixture->alpn_lib->alpn_mode = ALPN_SERVER_NO_CLIENT;
tsi_test_do_handshake(fixture);
tsi_test_fixture_destroy(fixture);
@@ -486,7 +496,8 @@ void ssl_tsi_test_do_handshake_alpn_server_no_client() {
void ssl_tsi_test_do_handshake_alpn_client_server_mismatch() {
tsi_test_fixture* fixture = ssl_tsi_test_fixture_create();
- ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture;
+ ssl_tsi_test_fixture* ssl_fixture =
+ reinterpret_cast<ssl_tsi_test_fixture*>(fixture);
ssl_fixture->alpn_lib->alpn_mode = ALPN_CLIENT_SERVER_MISMATCH;
tsi_test_do_handshake(fixture);
tsi_test_fixture_destroy(fixture);
@@ -494,7 +505,8 @@ void ssl_tsi_test_do_handshake_alpn_client_server_mismatch() {
void ssl_tsi_test_do_handshake_alpn_client_server_ok() {
tsi_test_fixture* fixture = ssl_tsi_test_fixture_create();
- ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture;
+ ssl_tsi_test_fixture* ssl_fixture =
+ reinterpret_cast<ssl_tsi_test_fixture*>(fixture);
ssl_fixture->alpn_lib->alpn_mode = ALPN_CLIENT_SERVER_OK;
tsi_test_do_handshake(fixture);
tsi_test_fixture_destroy(fixture);
@@ -511,7 +523,8 @@ void ssl_tsi_test_do_round_trip_for_all_configs() {
v <<= 1;
}
tsi_test_fixture* fixture = ssl_tsi_test_fixture_create();
- ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture;
+ ssl_tsi_test_fixture* ssl_fixture =
+ reinterpret_cast<ssl_tsi_test_fixture*>(fixture);
tsi_test_frame_protector_config_destroy(ssl_fixture->base.config);
ssl_fixture->base.config = tsi_test_frame_protector_config_create(
bit_array[0], bit_array[1], bit_array[2], bit_array[3], bit_array[4],
@@ -531,7 +544,8 @@ void ssl_tsi_test_do_round_trip_odd_buffer_size() {
for (size_t ind4 = 0; ind4 < size; ind4++) {
for (size_t ind5 = 0; ind5 < size; ind5++) {
tsi_test_fixture* fixture = ssl_tsi_test_fixture_create();
- ssl_tsi_test_fixture* ssl_fixture = (ssl_tsi_test_fixture*)fixture;
+ ssl_tsi_test_fixture* ssl_fixture =
+ reinterpret_cast<ssl_tsi_test_fixture*>(fixture);
tsi_test_frame_protector_config_set_buffer_size(
ssl_fixture->base.config, odd_sizes[ind1], odd_sizes[ind2],
odd_sizes[ind3], odd_sizes[ind4], odd_sizes[ind5]);
@@ -571,7 +585,7 @@ void test_tsi_ssl_client_handshaker_factory_refcounting() {
handshaker_factory_destructor_called = false;
original_vtable = tsi_ssl_handshaker_factory_swap_vtable(
- (tsi_ssl_handshaker_factory*)client_handshaker_factory,
+ reinterpret_cast<tsi_ssl_handshaker_factory*>(client_handshaker_factory),
&test_handshaker_factory_vtable);
tsi_handshaker* handshaker[3];
@@ -615,7 +629,7 @@ void test_tsi_ssl_server_handshaker_factory_refcounting() {
handshaker_factory_destructor_called = false;
original_vtable = tsi_ssl_handshaker_factory_swap_vtable(
- (tsi_ssl_handshaker_factory*)server_handshaker_factory,
+ reinterpret_cast<tsi_ssl_handshaker_factory*>(server_handshaker_factory),
&test_handshaker_factory_vtable);
for (i = 0; i < 3; ++i) {
diff --git a/test/core/tsi/transport_security_test_lib.cc b/test/core/tsi/transport_security_test_lib.cc
index 3537366de9..080585365f 100644
--- a/test/core/tsi/transport_security_test_lib.cc
+++ b/test/core/tsi/transport_security_test_lib.cc
@@ -144,8 +144,9 @@ static void maybe_append_unused_bytes(handshaker_args* args) {
tsi_test_fixture* fixture = args->fixture;
if (fixture->test_unused_bytes && !args->appended_unused_bytes) {
args->appended_unused_bytes = true;
- send_bytes_to_peer(fixture, (const unsigned char*)TSI_TEST_UNUSED_BYTES,
- strlen(TSI_TEST_UNUSED_BYTES), args->is_client);
+ send_bytes_to_peer(
+ fixture, reinterpret_cast<const unsigned char*>(TSI_TEST_UNUSED_BYTES),
+ strlen(TSI_TEST_UNUSED_BYTES), args->is_client);
if (fixture->client_result != nullptr &&
fixture->server_result == nullptr) {
fixture->has_client_finished_first = true;
@@ -288,7 +289,7 @@ grpc_error* on_handshake_next_done(tsi_result result, void* user_data,
const unsigned char* bytes_to_send,
size_t bytes_to_send_size,
tsi_handshaker_result* handshaker_result) {
- handshaker_args* args = (handshaker_args*)user_data;
+ handshaker_args* args = static_cast<handshaker_args*>(user_data);
GPR_ASSERT(args != nullptr);
GPR_ASSERT(args->fixture != nullptr);
tsi_test_fixture* fixture = args->fixture;
@@ -327,7 +328,7 @@ grpc_error* on_handshake_next_done(tsi_result result, void* user_data,
static void on_handshake_next_done_wrapper(
tsi_result result, void* user_data, const unsigned char* bytes_to_send,
size_t bytes_to_send_size, tsi_handshaker_result* handshaker_result) {
- handshaker_args* args = (handshaker_args*)user_data;
+ handshaker_args* args = static_cast<handshaker_args*>(user_data);
args->error = on_handshake_next_done(result, user_data, bytes_to_send,
bytes_to_send_size, handshaker_result);
}
@@ -471,7 +472,7 @@ static unsigned char* generate_random_message(size_t size) {
unsigned char* output =
static_cast<unsigned char*>(gpr_zalloc(sizeof(unsigned char) * size));
for (i = 0; i < size - 1; ++i) {
- output[i] = chars[rand() % (int)(sizeof(chars) - 1)];
+ output[i] = chars[rand() % static_cast<int>(sizeof(chars) - 1)];
}
return output;
}
diff --git a/test/core/util/cmdline.cc b/test/core/util/cmdline.cc
index 20bce273cd..e76acb5e2b 100644
--- a/test/core/util/cmdline.cc
+++ b/test/core/util/cmdline.cc
@@ -56,7 +56,7 @@ struct gpr_cmdline {
static int normal_state(gpr_cmdline* cl, char* arg);
gpr_cmdline* gpr_cmdline_create(const char* description) {
- gpr_cmdline* cl = (gpr_cmdline*)gpr_zalloc(sizeof(gpr_cmdline));
+ gpr_cmdline* cl = static_cast<gpr_cmdline*>(gpr_zalloc(sizeof(gpr_cmdline)));
cl->description = description;
cl->state = normal_state;
@@ -85,7 +85,7 @@ static void add_arg(gpr_cmdline* cl, const char* name, const char* help,
GPR_ASSERT(0 != strcmp(a->name, name));
}
- a = (arg*)gpr_zalloc(sizeof(arg));
+ a = static_cast<arg*>(gpr_zalloc(sizeof(arg)));
a->name = name;
a->help = help;
a->type = type;
@@ -223,13 +223,13 @@ static int value_state(gpr_cmdline* cl, char* str) {
cl->cur_arg->name);
return print_usage_and_die(cl);
}
- *(int*)cl->cur_arg->value = (int)intval;
+ *static_cast<int*>(cl->cur_arg->value) = static_cast<int>(intval);
break;
case ARGTYPE_BOOL:
if (0 == strcmp(str, "1") || 0 == strcmp(str, "true")) {
- *(int*)cl->cur_arg->value = 1;
+ *static_cast<int*>(cl->cur_arg->value) = 1;
} else if (0 == strcmp(str, "0") || 0 == strcmp(str, "false")) {
- *(int*)cl->cur_arg->value = 0;
+ *static_cast<int*>(cl->cur_arg->value) = 0;
} else {
fprintf(stderr, "expected boolean, got '%s' for %s\n", str,
cl->cur_arg->name);
@@ -237,7 +237,7 @@ static int value_state(gpr_cmdline* cl, char* str) {
}
break;
case ARGTYPE_STRING:
- *(char**)cl->cur_arg->value = str;
+ *static_cast<char**>(cl->cur_arg->value) = str;
break;
}
@@ -281,14 +281,15 @@ static int normal_state(gpr_cmdline* cl, char* str) {
fprintf(stderr, "%s is not a flag argument\n", str);
return print_usage_and_die(cl);
}
- *(int*)cl->cur_arg->value = 0;
+ *static_cast<int*>(cl->cur_arg->value) = 0;
return 1; /* early out */
}
eq = strchr(str, '=');
if (eq != nullptr) {
/* copy the string into a temp buffer and extract the name */
- tmp = arg_name = (char*)gpr_malloc((size_t)(eq - str + 1));
- memcpy(arg_name, str, (size_t)(eq - str));
+ tmp = arg_name =
+ static_cast<char*>(gpr_malloc(static_cast<size_t>(eq - str + 1)));
+ memcpy(arg_name, str, static_cast<size_t>(eq - str));
arg_name[eq - str] = 0;
} else {
arg_name = str;
@@ -305,7 +306,7 @@ static int normal_state(gpr_cmdline* cl, char* str) {
cl->state = value_state;
} else {
/* flag parameter: just set the value */
- *(int*)cl->cur_arg->value = 1;
+ *static_cast<int*>(cl->cur_arg->value) = 1;
}
} else {
r = extra_state(cl, str);
diff --git a/test/core/util/debugger_macros.cc b/test/core/util/debugger_macros.cc
index bb96fc7054..05fb146173 100644
--- a/test/core/util/debugger_macros.cc
+++ b/test/core/util/debugger_macros.cc
@@ -54,5 +54,6 @@ grpc_stream* grpc_transport_stream_from_call(grpc_call* call) {
}
grpc_chttp2_stream* grpc_chttp2_stream_from_call(grpc_call* call) {
- return (grpc_chttp2_stream*)grpc_transport_stream_from_call(call);
+ return reinterpret_cast<grpc_chttp2_stream*>(
+ grpc_transport_stream_from_call(call));
}
diff --git a/test/core/util/histogram.cc b/test/core/util/histogram.cc
index b2518279ac..f028ac404e 100644
--- a/test/core/util/histogram.cc
+++ b/test/core/util/histogram.cc
@@ -57,7 +57,7 @@ struct grpc_histogram {
/* determine a bucket index given a value - does no bounds checking */
static size_t bucket_for_unchecked(grpc_histogram* h, double x) {
- return (size_t)(log(x) * h->one_on_log_multiplier);
+ return static_cast<size_t>(log(x) * h->one_on_log_multiplier);
}
/* bounds checked version of the above */
@@ -74,7 +74,8 @@ static double bucket_start(grpc_histogram* h, double x) {
grpc_histogram* grpc_histogram_create(double resolution,
double max_bucket_start) {
- grpc_histogram* h = (grpc_histogram*)gpr_malloc(sizeof(grpc_histogram));
+ grpc_histogram* h =
+ static_cast<grpc_histogram*>(gpr_malloc(sizeof(grpc_histogram)));
GPR_ASSERT(resolution > 0.0);
GPR_ASSERT(max_bucket_start > resolution);
h->sum = 0.0;
@@ -88,7 +89,8 @@ grpc_histogram* grpc_histogram_create(double resolution,
h->num_buckets = bucket_for_unchecked(h, max_bucket_start) + 1;
GPR_ASSERT(h->num_buckets > 1);
GPR_ASSERT(h->num_buckets < 100000000);
- h->buckets = (uint32_t*)gpr_zalloc(sizeof(uint32_t) * h->num_buckets);
+ h->buckets =
+ static_cast<uint32_t*>(gpr_zalloc(sizeof(uint32_t) * h->num_buckets));
return h;
}
@@ -176,14 +178,14 @@ static double threshold_for_count_below(grpc_histogram* h, double count_below) {
break;
}
}
- return (bucket_start(h, (double)lower_idx) +
- bucket_start(h, (double)upper_idx)) /
+ return (bucket_start(h, static_cast<double>(lower_idx)) +
+ bucket_start(h, static_cast<double>(upper_idx))) /
2.0;
} else {
/* treat values as uniform throughout the bucket, and find where this value
should lie */
- lower_bound = bucket_start(h, (double)lower_idx);
- upper_bound = bucket_start(h, (double)(lower_idx + 1));
+ lower_bound = bucket_start(h, static_cast<double>(lower_idx));
+ upper_bound = bucket_start(h, static_cast<double>(lower_idx + 1));
return GPR_CLAMP(upper_bound - (upper_bound - lower_bound) *
(count_so_far - count_below) /
h->buckets[lower_idx],
diff --git a/test/core/util/memory_counters.cc b/test/core/util/memory_counters.cc
index 32d7b89c9a..4960fe0757 100644
--- a/test/core/util/memory_counters.cc
+++ b/test/core/util/memory_counters.cc
@@ -48,13 +48,13 @@ static void* guard_malloc(size_t size) {
NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_relative, (gpr_atm)size);
NO_BARRIER_FETCH_ADD(&g_memory_counters.total_allocs_absolute, (gpr_atm)1);
NO_BARRIER_FETCH_ADD(&g_memory_counters.total_allocs_relative, (gpr_atm)1);
- ptr = (size_t*)g_old_allocs.malloc_fn(size + sizeof(size));
+ ptr = static_cast<size_t*>(g_old_allocs.malloc_fn(size + sizeof(size)));
*ptr++ = size;
return ptr;
}
static void* guard_realloc(void* vptr, size_t size) {
- size_t* ptr = (size_t*)vptr;
+ size_t* ptr = static_cast<size_t*>(vptr);
if (vptr == nullptr) {
return guard_malloc(size);
}
@@ -67,13 +67,13 @@ static void* guard_realloc(void* vptr, size_t size) {
NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_relative, -(gpr_atm)*ptr);
NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_relative, (gpr_atm)size);
NO_BARRIER_FETCH_ADD(&g_memory_counters.total_allocs_absolute, (gpr_atm)1);
- ptr = (size_t*)g_old_allocs.realloc_fn(ptr, size + sizeof(size));
+ ptr = static_cast<size_t*>(g_old_allocs.realloc_fn(ptr, size + sizeof(size)));
*ptr++ = size;
return ptr;
}
static void guard_free(void* vptr) {
- size_t* ptr = (size_t*)vptr;
+ size_t* ptr = static_cast<size_t*>(vptr);
if (!vptr) return;
--ptr;
NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_relative, -(gpr_atm)*ptr);
diff --git a/test/core/util/mock_endpoint.cc b/test/core/util/mock_endpoint.cc
index 4b35a581b1..adeff18ef0 100644
--- a/test/core/util/mock_endpoint.cc
+++ b/test/core/util/mock_endpoint.cc
@@ -42,7 +42,7 @@ typedef struct grpc_mock_endpoint {
static void me_read(grpc_endpoint* ep, grpc_slice_buffer* slices,
grpc_closure* cb) {
- grpc_mock_endpoint* m = (grpc_mock_endpoint*)ep;
+ grpc_mock_endpoint* m = reinterpret_cast<grpc_mock_endpoint*>(ep);
gpr_mu_lock(&m->mu);
if (m->read_buffer.count > 0) {
grpc_slice_buffer_swap(&m->read_buffer, slices);
@@ -56,7 +56,7 @@ static void me_read(grpc_endpoint* ep, grpc_slice_buffer* slices,
static void me_write(grpc_endpoint* ep, grpc_slice_buffer* slices,
grpc_closure* cb) {
- grpc_mock_endpoint* m = (grpc_mock_endpoint*)ep;
+ grpc_mock_endpoint* m = reinterpret_cast<grpc_mock_endpoint*>(ep);
for (size_t i = 0; i < slices->count; i++) {
m->on_write(slices->slices[i]);
}
@@ -72,7 +72,7 @@ static void me_delete_from_pollset_set(grpc_endpoint* ep,
grpc_pollset_set* pollset) {}
static void me_shutdown(grpc_endpoint* ep, grpc_error* why) {
- grpc_mock_endpoint* m = (grpc_mock_endpoint*)ep;
+ grpc_mock_endpoint* m = reinterpret_cast<grpc_mock_endpoint*>(ep);
gpr_mu_lock(&m->mu);
if (m->on_read) {
GRPC_CLOSURE_SCHED(m->on_read,
@@ -86,7 +86,7 @@ static void me_shutdown(grpc_endpoint* ep, grpc_error* why) {
}
static void me_destroy(grpc_endpoint* ep) {
- grpc_mock_endpoint* m = (grpc_mock_endpoint*)ep;
+ grpc_mock_endpoint* m = reinterpret_cast<grpc_mock_endpoint*>(ep);
grpc_slice_buffer_destroy(&m->read_buffer);
grpc_resource_user_unref(m->resource_user);
gpr_free(m);
@@ -97,7 +97,7 @@ static char* me_get_peer(grpc_endpoint* ep) {
}
static grpc_resource_user* me_get_resource_user(grpc_endpoint* ep) {
- grpc_mock_endpoint* m = (grpc_mock_endpoint*)ep;
+ grpc_mock_endpoint* m = reinterpret_cast<grpc_mock_endpoint*>(ep);
return m->resource_user;
}
@@ -118,7 +118,8 @@ static const grpc_endpoint_vtable vtable = {
grpc_endpoint* grpc_mock_endpoint_create(void (*on_write)(grpc_slice slice),
grpc_resource_quota* resource_quota) {
- grpc_mock_endpoint* m = (grpc_mock_endpoint*)gpr_malloc(sizeof(*m));
+ grpc_mock_endpoint* m =
+ static_cast<grpc_mock_endpoint*>(gpr_malloc(sizeof(*m)));
m->base.vtable = &vtable;
char* name;
gpr_asprintf(&name, "mock_endpoint_%" PRIxPTR, (intptr_t)m);
@@ -132,7 +133,7 @@ grpc_endpoint* grpc_mock_endpoint_create(void (*on_write)(grpc_slice slice),
}
void grpc_mock_endpoint_put_read(grpc_endpoint* ep, grpc_slice slice) {
- grpc_mock_endpoint* m = (grpc_mock_endpoint*)ep;
+ grpc_mock_endpoint* m = reinterpret_cast<grpc_mock_endpoint*>(ep);
gpr_mu_lock(&m->mu);
if (m->on_read != nullptr) {
grpc_slice_buffer_add(m->on_read_out, slice);
diff --git a/test/core/util/parse_hexstring.cc b/test/core/util/parse_hexstring.cc
index 622642a298..cd64843bd3 100644
--- a/test/core/util/parse_hexstring.cc
+++ b/test/core/util/parse_hexstring.cc
@@ -39,10 +39,11 @@ grpc_slice parse_hexstring(const char* hexstring) {
temp = 0;
for (p = hexstring; *p; p++) {
if (*p >= '0' && *p <= '9') {
- temp = (uint8_t)(temp << 4) | (uint8_t)(*p - '0');
+ temp = static_cast<uint8_t>(temp << 4) | static_cast<uint8_t>(*p - '0');
nibbles++;
} else if (*p >= 'a' && *p <= 'f') {
- temp = (uint8_t)(temp << 4) | (uint8_t)(*p - 'a' + 10);
+ temp =
+ static_cast<uint8_t>(temp << 4) | static_cast<uint8_t>(*p - 'a' + 10);
nibbles++;
}
if (nibbles == 2) {
diff --git a/test/core/util/passthru_endpoint.cc b/test/core/util/passthru_endpoint.cc
index 0da0765979..5958216747 100644
--- a/test/core/util/passthru_endpoint.cc
+++ b/test/core/util/passthru_endpoint.cc
@@ -55,7 +55,7 @@ struct passthru_endpoint {
static void me_read(grpc_endpoint* ep, grpc_slice_buffer* slices,
grpc_closure* cb) {
- half* m = (half*)ep;
+ half* m = reinterpret_cast<half*>(ep);
gpr_mu_lock(&m->parent->mu);
if (m->parent->shutdown) {
GRPC_CLOSURE_SCHED(
@@ -77,7 +77,7 @@ static half* other_half(half* h) {
static void me_write(grpc_endpoint* ep, grpc_slice_buffer* slices,
grpc_closure* cb) {
- half* m = other_half((half*)ep);
+ half* m = other_half(reinterpret_cast<half*>(ep));
gpr_mu_lock(&m->parent->mu);
grpc_error* error = GRPC_ERROR_NONE;
gpr_atm_no_barrier_fetch_add(&m->parent->stats->num_writes, (gpr_atm)1);
@@ -108,7 +108,7 @@ static void me_delete_from_pollset_set(grpc_endpoint* ep,
grpc_pollset_set* pollset) {}
static void me_shutdown(grpc_endpoint* ep, grpc_error* why) {
- half* m = (half*)ep;
+ half* m = reinterpret_cast<half*>(ep);
gpr_mu_lock(&m->parent->mu);
m->parent->shutdown = true;
if (m->on_read) {
@@ -130,7 +130,7 @@ static void me_shutdown(grpc_endpoint* ep, grpc_error* why) {
}
static void me_destroy(grpc_endpoint* ep) {
- passthru_endpoint* p = ((half*)ep)->parent;
+ passthru_endpoint* p = (reinterpret_cast<half*>(ep))->parent;
gpr_mu_lock(&p->mu);
if (0 == --p->halves) {
gpr_mu_unlock(&p->mu);
@@ -147,15 +147,16 @@ static void me_destroy(grpc_endpoint* ep) {
}
static char* me_get_peer(grpc_endpoint* ep) {
- passthru_endpoint* p = ((half*)ep)->parent;
- return ((half*)ep) == &p->client ? gpr_strdup("fake:mock_client_endpoint")
- : gpr_strdup("fake:mock_server_endpoint");
+ passthru_endpoint* p = (reinterpret_cast<half*>(ep))->parent;
+ return (reinterpret_cast<half*>(ep)) == &p->client
+ ? gpr_strdup("fake:mock_client_endpoint")
+ : gpr_strdup("fake:mock_server_endpoint");
}
static int me_get_fd(grpc_endpoint* ep) { return -1; }
static grpc_resource_user* me_get_resource_user(grpc_endpoint* ep) {
- half* m = (half*)ep;
+ half* m = reinterpret_cast<half*>(ep);
return m->resource_user;
}
@@ -190,7 +191,8 @@ void grpc_passthru_endpoint_create(grpc_endpoint** client,
grpc_endpoint** server,
grpc_resource_quota* resource_quota,
grpc_passthru_endpoint_stats* stats) {
- passthru_endpoint* m = (passthru_endpoint*)gpr_malloc(sizeof(*m));
+ passthru_endpoint* m =
+ static_cast<passthru_endpoint*>(gpr_malloc(sizeof(*m)));
m->halves = 2;
m->shutdown = 0;
if (stats == nullptr) {
@@ -208,8 +210,8 @@ void grpc_passthru_endpoint_create(grpc_endpoint** client,
grpc_passthru_endpoint_stats* grpc_passthru_endpoint_stats_create() {
grpc_passthru_endpoint_stats* stats =
- (grpc_passthru_endpoint_stats*)gpr_malloc(
- sizeof(grpc_passthru_endpoint_stats));
+ static_cast<grpc_passthru_endpoint_stats*>(
+ gpr_malloc(sizeof(grpc_passthru_endpoint_stats)));
memset(stats, 0, sizeof(*stats));
gpr_ref_init(&stats->refs, 1);
return stats;
diff --git a/test/core/util/port.cc b/test/core/util/port.cc
index 9d02b673ed..303306de45 100644
--- a/test/core/util/port.cc
+++ b/test/core/util/port.cc
@@ -75,8 +75,8 @@ static void chose_port(int port) {
atexit(free_chosen_ports);
}
num_chosen_ports++;
- chosen_ports =
- (int*)gpr_realloc(chosen_ports, sizeof(int) * num_chosen_ports);
+ chosen_ports = static_cast<int*>(
+ gpr_realloc(chosen_ports, sizeof(int) * num_chosen_ports));
chosen_ports[num_chosen_ports - 1] = port;
}
diff --git a/test/core/util/port_server_client.cc b/test/core/util/port_server_client.cc
index 7e76c8063f..9a4159944b 100644
--- a/test/core/util/port_server_client.cc
+++ b/test/core/util/port_server_client.cc
@@ -41,13 +41,14 @@ typedef struct freereq {
} freereq;
static void destroy_pops_and_shutdown(void* p, grpc_error* error) {
- grpc_pollset* pollset = grpc_polling_entity_pollset((grpc_polling_entity*)p);
+ grpc_pollset* pollset =
+ grpc_polling_entity_pollset(static_cast<grpc_polling_entity*>(p));
grpc_pollset_destroy(pollset);
gpr_free(pollset);
}
static void freed_port_from_server(void* arg, grpc_error* error) {
- freereq* pr = (freereq*)arg;
+ freereq* pr = static_cast<freereq*>(arg);
gpr_mu_lock(pr->mu);
pr->done = 1;
GRPC_LOG_IF_ERROR(
@@ -71,7 +72,8 @@ void grpc_free_port_using_server(int port) {
memset(&req, 0, sizeof(req));
memset(&rsp, 0, sizeof(rsp));
- grpc_pollset* pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size());
+ grpc_pollset* pollset =
+ static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
grpc_pollset_init(pollset, &pr.mu);
pr.pops = grpc_polling_entity_create_from_pollset(pollset);
shutdown_closure = GRPC_CLOSURE_CREATE(destroy_pops_and_shutdown, &pr.pops,
@@ -127,7 +129,7 @@ typedef struct portreq {
static void got_port_from_server(void* arg, grpc_error* error) {
size_t i;
int port = 0;
- portreq* pr = (portreq*)arg;
+ portreq* pr = static_cast<portreq*>(arg);
int failed = 0;
grpc_httpcli_response* response = &pr->response;
@@ -158,7 +160,8 @@ static void got_port_from_server(void* arg, grpc_error* error) {
gpr_sleep_until(gpr_time_add(
gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_millis(
- (int64_t)(1000.0 * (1 + pow(1.3, pr->retries) * rand() / RAND_MAX)),
+ static_cast<int64_t>(
+ 1000.0 * (1 + pow(1.3, pr->retries) * rand() / RAND_MAX)),
GPR_TIMESPAN)));
pr->retries++;
req.host = pr->server;
@@ -201,7 +204,8 @@ int grpc_pick_port_using_server(void) {
grpc_core::ExecCtx exec_ctx;
memset(&pr, 0, sizeof(pr));
memset(&req, 0, sizeof(req));
- grpc_pollset* pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size());
+ grpc_pollset* pollset =
+ static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
grpc_pollset_init(pollset, &pr.mu);
pr.pops = grpc_polling_entity_create_from_pollset(pollset);
shutdown_closure = GRPC_CLOSURE_CREATE(destroy_pops_and_shutdown, &pr.pops,
diff --git a/test/core/util/reconnect_server.cc b/test/core/util/reconnect_server.cc
index b5a7749385..ad7cf42f71 100644
--- a/test/core/util/reconnect_server.cc
+++ b/test/core/util/reconnect_server.cc
@@ -62,7 +62,7 @@ static void on_connect(void* arg, grpc_endpoint* tcp,
gpr_free(acceptor);
char* peer;
char* last_colon;
- reconnect_server* server = (reconnect_server*)arg;
+ reconnect_server* server = static_cast<reconnect_server*>(arg);
gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME);
timestamp_list* new_tail;
peer = grpc_endpoint_get_peer(tcp);
@@ -76,8 +76,8 @@ static void on_connect(void* arg, grpc_endpoint* tcp,
} else {
if (last_colon == nullptr) {
gpr_log(GPR_ERROR, "peer does not contain a ':'");
- } else if (strncmp(server->peer, peer, (size_t)(last_colon - peer)) !=
- 0) {
+ } else if (strncmp(server->peer, peer,
+ static_cast<size_t>(last_colon - peer)) != 0) {
gpr_log(GPR_ERROR, "mismatched peer! %s vs %s", server->peer, peer);
}
gpr_free(peer);
diff --git a/test/core/util/slice_splitter.cc b/test/core/util/slice_splitter.cc
index c92fc0affe..1f81d03d96 100644
--- a/test/core/util/slice_splitter.cc
+++ b/test/core/util/slice_splitter.cc
@@ -45,8 +45,8 @@ void grpc_split_slices(grpc_slice_split_mode mode, grpc_slice* src_slices,
switch (mode) {
case GRPC_SLICE_SPLIT_IDENTITY:
*dst_slice_count = src_slice_count;
- *dst_slices =
- (grpc_slice*)gpr_malloc(sizeof(grpc_slice) * src_slice_count);
+ *dst_slices = static_cast<grpc_slice*>(
+ gpr_malloc(sizeof(grpc_slice) * src_slice_count));
for (i = 0; i < src_slice_count; i++) {
(*dst_slices)[i] = src_slices[i];
grpc_slice_ref((*dst_slices)[i]);
@@ -58,7 +58,7 @@ void grpc_split_slices(grpc_slice_split_mode mode, grpc_slice* src_slices,
for (i = 0; i < src_slice_count; i++) {
length += GRPC_SLICE_LENGTH(src_slices[i]);
}
- *dst_slices = (grpc_slice*)gpr_malloc(sizeof(grpc_slice));
+ *dst_slices = static_cast<grpc_slice*>(gpr_malloc(sizeof(grpc_slice)));
**dst_slices = grpc_slice_malloc(length);
length = 0;
for (i = 0; i < src_slice_count; i++) {
@@ -74,7 +74,8 @@ void grpc_split_slices(grpc_slice_split_mode mode, grpc_slice* src_slices,
length += GRPC_SLICE_LENGTH(src_slices[i]);
}
*dst_slice_count = length;
- *dst_slices = (grpc_slice*)gpr_malloc(sizeof(grpc_slice) * length);
+ *dst_slices =
+ static_cast<grpc_slice*>(gpr_malloc(sizeof(grpc_slice) * length));
length = 0;
for (i = 0; i < src_slice_count; i++) {
for (j = 0; j < GRPC_SLICE_LENGTH(src_slices[i]); j++) {
@@ -114,7 +115,7 @@ grpc_slice grpc_slice_merge(grpc_slice* slices, size_t nslices) {
for (i = 0; i < nslices; i++) {
if (GRPC_SLICE_LENGTH(slices[i]) + length > capacity) {
capacity = GPR_MAX(capacity * 2, GRPC_SLICE_LENGTH(slices[i]) + length);
- out = (uint8_t*)gpr_realloc(out, capacity);
+ out = static_cast<uint8_t*>(gpr_realloc(out, capacity));
}
memcpy(out + length, GRPC_SLICE_START_PTR(slices[i]),
GRPC_SLICE_LENGTH(slices[i]));
diff --git a/test/core/util/subprocess_posix.cc b/test/core/util/subprocess_posix.cc
index 0f6c99731f..ab288d777f 100644
--- a/test/core/util/subprocess_posix.cc
+++ b/test/core/util/subprocess_posix.cc
@@ -52,8 +52,9 @@ gpr_subprocess* gpr_subprocess_create(int argc, const char** argv) {
if (pid == -1) {
return nullptr;
} else if (pid == 0) {
- exec_args = (char**)gpr_malloc(((size_t)argc + 1) * sizeof(char*));
- memcpy(exec_args, argv, (size_t)argc * sizeof(char*));
+ exec_args = static_cast<char**>(
+ gpr_malloc((static_cast<size_t>(argc) + 1) * sizeof(char*)));
+ memcpy(exec_args, argv, static_cast<size_t>(argc) * sizeof(char*));
exec_args[argc] = nullptr;
execv(exec_args[0], exec_args);
/* if we reach here, an error has occurred */
@@ -61,7 +62,7 @@ gpr_subprocess* gpr_subprocess_create(int argc, const char** argv) {
_exit(1);
return nullptr;
} else {
- r = (gpr_subprocess*)gpr_zalloc(sizeof(gpr_subprocess));
+ r = static_cast<gpr_subprocess*>(gpr_zalloc(sizeof(gpr_subprocess)));
r->pid = pid;
return r;
}
diff --git a/test/core/util/test_config.cc b/test/core/util/test_config.cc
index e381be6842..53a6297d6e 100644
--- a/test/core/util/test_config.cc
+++ b/test/core/util/test_config.cc
@@ -36,7 +36,7 @@ int64_t g_poller_slowdown_factor = 1;
#if GPR_GETPID_IN_UNISTD_H
#include <unistd.h>
-static unsigned seed(void) { return (unsigned)getpid(); }
+static unsigned seed(void) { return static_cast<unsigned>(getpid()); }
#endif
#if GPR_GETPID_IN_PROCESS_H
@@ -264,7 +264,7 @@ static void install_crash_handler() {
ss.ss_size = sizeof(g_alt_stack);
ss.ss_sp = g_alt_stack;
GPR_ASSERT(sigaltstack(&ss, nullptr) == 0);
- sa.sa_flags = (int)(SA_SIGINFO | SA_ONSTACK | SA_RESETHAND);
+ sa.sa_flags = static_cast<int>(SA_SIGINFO | SA_ONSTACK | SA_RESETHAND);
sa.sa_sigaction = crash_handler;
GPR_ASSERT(sigaction(SIGILL, &sa, nullptr) == 0);
GPR_ASSERT(sigaction(SIGABRT, &sa, nullptr) == 0);
@@ -365,15 +365,17 @@ int64_t grpc_test_slowdown_factor() {
gpr_timespec grpc_timeout_seconds_to_deadline(int64_t time_s) {
return gpr_time_add(
gpr_now(GPR_CLOCK_MONOTONIC),
- gpr_time_from_millis(grpc_test_slowdown_factor() * (int64_t)1e3 * time_s,
- GPR_TIMESPAN));
+ gpr_time_from_millis(
+ grpc_test_slowdown_factor() * static_cast<int64_t>(1e3) * time_s,
+ GPR_TIMESPAN));
}
gpr_timespec grpc_timeout_milliseconds_to_deadline(int64_t time_ms) {
return gpr_time_add(
gpr_now(GPR_CLOCK_MONOTONIC),
- gpr_time_from_micros(grpc_test_slowdown_factor() * (int64_t)1e3 * time_ms,
- GPR_TIMESPAN));
+ gpr_time_from_micros(
+ grpc_test_slowdown_factor() * static_cast<int64_t>(1e3) * time_ms,
+ GPR_TIMESPAN));
}
void grpc_test_init(int argc, char** argv) {
diff --git a/test/core/util/test_tcp_server.cc b/test/core/util/test_tcp_server.cc
index b1b5297f29..cb2bc701fa 100644
--- a/test/core/util/test_tcp_server.cc
+++ b/test/core/util/test_tcp_server.cc
@@ -54,12 +54,13 @@ void test_tcp_server_init(test_tcp_server* server,
void test_tcp_server_start(test_tcp_server* server, int port) {
grpc_resolved_address resolved_addr;
- struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr;
+ struct sockaddr_in* addr =
+ reinterpret_cast<struct sockaddr_in*>(resolved_addr.addr);
int port_added;
grpc_core::ExecCtx exec_ctx;
addr->sin_family = AF_INET;
- addr->sin_port = htons((uint16_t)port);
+ addr->sin_port = htons(static_cast<uint16_t>(port));
memset(&addr->sin_addr, 0, sizeof(addr->sin_addr));
grpc_error* error = grpc_tcp_server_create(&server->shutdown_complete,
diff --git a/test/core/util/trickle_endpoint.cc b/test/core/util/trickle_endpoint.cc
index 54e1cf19c9..f2efb049b4 100644
--- a/test/core/util/trickle_endpoint.cc
+++ b/test/core/util/trickle_endpoint.cc
@@ -48,7 +48,7 @@ typedef struct {
static void te_read(grpc_endpoint* ep, grpc_slice_buffer* slices,
grpc_closure* cb) {
- trickle_endpoint* te = (trickle_endpoint*)ep;
+ trickle_endpoint* te = reinterpret_cast<trickle_endpoint*>(ep);
grpc_endpoint_read(te->wrapped, slices, cb);
}
@@ -63,7 +63,7 @@ static void maybe_call_write_cb_locked(trickle_endpoint* te) {
static void te_write(grpc_endpoint* ep, grpc_slice_buffer* slices,
grpc_closure* cb) {
- trickle_endpoint* te = (trickle_endpoint*)ep;
+ trickle_endpoint* te = reinterpret_cast<trickle_endpoint*>(ep);
gpr_mu_lock(&te->mu);
GPR_ASSERT(te->write_cb == nullptr);
if (te->write_buffer.length == 0) {
@@ -79,24 +79,24 @@ static void te_write(grpc_endpoint* ep, grpc_slice_buffer* slices,
}
static void te_add_to_pollset(grpc_endpoint* ep, grpc_pollset* pollset) {
- trickle_endpoint* te = (trickle_endpoint*)ep;
+ trickle_endpoint* te = reinterpret_cast<trickle_endpoint*>(ep);
grpc_endpoint_add_to_pollset(te->wrapped, pollset);
}
static void te_add_to_pollset_set(grpc_endpoint* ep,
grpc_pollset_set* pollset_set) {
- trickle_endpoint* te = (trickle_endpoint*)ep;
+ trickle_endpoint* te = reinterpret_cast<trickle_endpoint*>(ep);
grpc_endpoint_add_to_pollset_set(te->wrapped, pollset_set);
}
static void te_delete_from_pollset_set(grpc_endpoint* ep,
grpc_pollset_set* pollset_set) {
- trickle_endpoint* te = (trickle_endpoint*)ep;
+ trickle_endpoint* te = reinterpret_cast<trickle_endpoint*>(ep);
grpc_endpoint_delete_from_pollset_set(te->wrapped, pollset_set);
}
static void te_shutdown(grpc_endpoint* ep, grpc_error* why) {
- trickle_endpoint* te = (trickle_endpoint*)ep;
+ trickle_endpoint* te = reinterpret_cast<trickle_endpoint*>(ep);
gpr_mu_lock(&te->mu);
if (te->error == GRPC_ERROR_NONE) {
te->error = GRPC_ERROR_REF(why);
@@ -107,7 +107,7 @@ static void te_shutdown(grpc_endpoint* ep, grpc_error* why) {
}
static void te_destroy(grpc_endpoint* ep) {
- trickle_endpoint* te = (trickle_endpoint*)ep;
+ trickle_endpoint* te = reinterpret_cast<trickle_endpoint*>(ep);
grpc_endpoint_destroy(te->wrapped);
gpr_mu_destroy(&te->mu);
grpc_slice_buffer_destroy_internal(&te->write_buffer);
@@ -117,22 +117,22 @@ static void te_destroy(grpc_endpoint* ep) {
}
static grpc_resource_user* te_get_resource_user(grpc_endpoint* ep) {
- trickle_endpoint* te = (trickle_endpoint*)ep;
+ trickle_endpoint* te = reinterpret_cast<trickle_endpoint*>(ep);
return grpc_endpoint_get_resource_user(te->wrapped);
}
static char* te_get_peer(grpc_endpoint* ep) {
- trickle_endpoint* te = (trickle_endpoint*)ep;
+ trickle_endpoint* te = reinterpret_cast<trickle_endpoint*>(ep);
return grpc_endpoint_get_peer(te->wrapped);
}
static int te_get_fd(grpc_endpoint* ep) {
- trickle_endpoint* te = (trickle_endpoint*)ep;
+ trickle_endpoint* te = reinterpret_cast<trickle_endpoint*>(ep);
return grpc_endpoint_get_fd(te->wrapped);
}
static void te_finish_write(void* arg, grpc_error* error) {
- trickle_endpoint* te = (trickle_endpoint*)arg;
+ trickle_endpoint* te = static_cast<trickle_endpoint*>(arg);
gpr_mu_lock(&te->mu);
te->writing = false;
grpc_slice_buffer_reset_and_unref(&te->writing_buffer);
@@ -152,7 +152,8 @@ static const grpc_endpoint_vtable vtable = {te_read,
grpc_endpoint* grpc_trickle_endpoint_create(grpc_endpoint* wrap,
double bytes_per_second) {
- trickle_endpoint* te = (trickle_endpoint*)gpr_malloc(sizeof(*te));
+ trickle_endpoint* te =
+ static_cast<trickle_endpoint*>(gpr_malloc(sizeof(*te)));
te->base.vtable = &vtable;
te->wrapped = wrap;
te->bytes_per_second = bytes_per_second;
@@ -166,16 +167,16 @@ grpc_endpoint* grpc_trickle_endpoint_create(grpc_endpoint* wrap,
}
static double ts2dbl(gpr_timespec s) {
- return (double)s.tv_sec + 1e-9 * (double)s.tv_nsec;
+ return static_cast<double>(s.tv_sec) + 1e-9 * static_cast<double>(s.tv_nsec);
}
size_t grpc_trickle_endpoint_trickle(grpc_endpoint* ep) {
- trickle_endpoint* te = (trickle_endpoint*)ep;
+ trickle_endpoint* te = reinterpret_cast<trickle_endpoint*>(ep);
gpr_mu_lock(&te->mu);
if (!te->writing && te->write_buffer.length > 0) {
gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
double elapsed = ts2dbl(gpr_time_sub(now, te->last_write));
- size_t bytes = (size_t)(te->bytes_per_second * elapsed);
+ size_t bytes = static_cast<size_t>(te->bytes_per_second * elapsed);
// gpr_log(GPR_DEBUG, "%lf elapsed --> %" PRIdPTR " bytes", elapsed, bytes);
if (bytes > 0) {
grpc_slice_buffer_move_first(&te->write_buffer,
@@ -195,7 +196,7 @@ size_t grpc_trickle_endpoint_trickle(grpc_endpoint* ep) {
}
size_t grpc_trickle_get_backlog(grpc_endpoint* ep) {
- trickle_endpoint* te = (trickle_endpoint*)ep;
+ trickle_endpoint* te = reinterpret_cast<trickle_endpoint*>(ep);
gpr_mu_lock(&te->mu);
size_t backlog = te->write_buffer.length;
gpr_mu_unlock(&te->mu);
diff --git a/test/cpp/codegen/proto_utils_test.cc b/test/cpp/codegen/proto_utils_test.cc
index cc355bb24a..b64f9a0d17 100644
--- a/test/cpp/codegen/proto_utils_test.cc
+++ b/test/cpp/codegen/proto_utils_test.cc
@@ -103,7 +103,7 @@ void BufferWriterTest(int block_size, int total_size, int backup_size) {
ASSERT_GT(backup_size, 0);
}
for (int i = 0; i < write_size; i++) {
- ((uint8_t*)data)[i] = written_size % 128;
+ (static_cast<uint8_t*>(data))[i] = written_size % 128;
written_size++;
}
if (should_backup) {
@@ -130,7 +130,7 @@ void BufferWriterTest(int block_size, int total_size, int backup_size) {
}
TEST(WriterTest, TinyBlockTinyBackup) {
- for (int i = 2; i < (int)GRPC_SLICE_INLINED_SIZE; i++) {
+ for (int i = 2; i < static_cast<int> GRPC_SLICE_INLINED_SIZE; i++) {
BufferWriterTest(i, 256, 1);
}
}
diff --git a/test/cpp/common/alarm_test.cc b/test/cpp/common/alarm_test.cc
index 2a933a84c4..376aa3e32e 100644
--- a/test/cpp/common/alarm_test.cc
+++ b/test/cpp/common/alarm_test.cc
@@ -35,8 +35,8 @@ TEST(AlarmTest, RegularExpiry) {
void* output_tag;
bool ok;
- const CompletionQueue::NextStatus status = cq.AsyncNext(
- (void**)&output_tag, &ok, grpc_timeout_seconds_to_deadline(2));
+ const CompletionQueue::NextStatus status =
+ cq.AsyncNext(&output_tag, &ok, grpc_timeout_seconds_to_deadline(2));
EXPECT_EQ(status, CompletionQueue::GOT_EVENT);
EXPECT_TRUE(ok);
@@ -56,8 +56,8 @@ TEST(AlarmTest, MultithreadedRegularExpiry) {
});
std::thread t2([&cq, &ok, &output_tag, &status] {
- status = cq.AsyncNext((void**)&output_tag, &ok,
- grpc_timeout_seconds_to_deadline(2));
+ status =
+ cq.AsyncNext(&output_tag, &ok, grpc_timeout_seconds_to_deadline(2));
});
t1.join();
@@ -74,8 +74,8 @@ TEST(AlarmTest, DeprecatedRegularExpiry) {
void* output_tag;
bool ok;
- const CompletionQueue::NextStatus status = cq.AsyncNext(
- (void**)&output_tag, &ok, grpc_timeout_seconds_to_deadline(2));
+ const CompletionQueue::NextStatus status =
+ cq.AsyncNext(&output_tag, &ok, grpc_timeout_seconds_to_deadline(2));
EXPECT_EQ(status, CompletionQueue::GOT_EVENT);
EXPECT_TRUE(ok);
@@ -90,8 +90,8 @@ TEST(AlarmTest, MoveConstructor) {
Alarm second(std::move(first));
void* output_tag;
bool ok;
- const CompletionQueue::NextStatus status = cq.AsyncNext(
- (void**)&output_tag, &ok, grpc_timeout_seconds_to_deadline(2));
+ const CompletionQueue::NextStatus status =
+ cq.AsyncNext(&output_tag, &ok, grpc_timeout_seconds_to_deadline(2));
EXPECT_EQ(status, CompletionQueue::GOT_EVENT);
EXPECT_TRUE(ok);
EXPECT_EQ(junk, output_tag);
@@ -107,8 +107,8 @@ TEST(AlarmTest, MoveAssignment) {
void* output_tag;
bool ok;
- const CompletionQueue::NextStatus status = cq.AsyncNext(
- (void**)&output_tag, &ok, grpc_timeout_seconds_to_deadline(2));
+ const CompletionQueue::NextStatus status =
+ cq.AsyncNext(&output_tag, &ok, grpc_timeout_seconds_to_deadline(2));
EXPECT_EQ(status, CompletionQueue::GOT_EVENT);
EXPECT_TRUE(ok);
@@ -125,8 +125,8 @@ TEST(AlarmTest, RegularExpiryChrono) {
void* output_tag;
bool ok;
- const CompletionQueue::NextStatus status = cq.AsyncNext(
- (void**)&output_tag, &ok, grpc_timeout_seconds_to_deadline(2));
+ const CompletionQueue::NextStatus status =
+ cq.AsyncNext(&output_tag, &ok, grpc_timeout_seconds_to_deadline(2));
EXPECT_EQ(status, CompletionQueue::GOT_EVENT);
EXPECT_TRUE(ok);
@@ -141,8 +141,8 @@ TEST(AlarmTest, ZeroExpiry) {
void* output_tag;
bool ok;
- const CompletionQueue::NextStatus status = cq.AsyncNext(
- (void**)&output_tag, &ok, grpc_timeout_seconds_to_deadline(1));
+ const CompletionQueue::NextStatus status =
+ cq.AsyncNext(&output_tag, &ok, grpc_timeout_seconds_to_deadline(1));
EXPECT_EQ(status, CompletionQueue::GOT_EVENT);
EXPECT_TRUE(ok);
@@ -157,8 +157,8 @@ TEST(AlarmTest, NegativeExpiry) {
void* output_tag;
bool ok;
- const CompletionQueue::NextStatus status = cq.AsyncNext(
- (void**)&output_tag, &ok, grpc_timeout_seconds_to_deadline(1));
+ const CompletionQueue::NextStatus status =
+ cq.AsyncNext(&output_tag, &ok, grpc_timeout_seconds_to_deadline(1));
EXPECT_EQ(status, CompletionQueue::GOT_EVENT);
EXPECT_TRUE(ok);
@@ -174,8 +174,8 @@ TEST(AlarmTest, Cancellation) {
void* output_tag;
bool ok;
- const CompletionQueue::NextStatus status = cq.AsyncNext(
- (void**)&output_tag, &ok, grpc_timeout_seconds_to_deadline(1));
+ const CompletionQueue::NextStatus status =
+ cq.AsyncNext(&output_tag, &ok, grpc_timeout_seconds_to_deadline(1));
EXPECT_EQ(status, CompletionQueue::GOT_EVENT);
EXPECT_FALSE(ok);
@@ -192,8 +192,8 @@ TEST(AlarmTest, SetDestruction) {
void* output_tag;
bool ok;
- const CompletionQueue::NextStatus status = cq.AsyncNext(
- (void**)&output_tag, &ok, grpc_timeout_seconds_to_deadline(1));
+ const CompletionQueue::NextStatus status =
+ cq.AsyncNext(&output_tag, &ok, grpc_timeout_seconds_to_deadline(1));
EXPECT_EQ(status, CompletionQueue::GOT_EVENT);
EXPECT_FALSE(ok);
diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc
index c00f0aeba0..219561868f 100644
--- a/test/cpp/end2end/async_end2end_test.cc
+++ b/test/cpp/end2end/async_end2end_test.cc
@@ -56,7 +56,7 @@ namespace testing {
namespace {
-void* tag(int i) { return (void*)(intptr_t)i; }
+void* tag(int i) { return (void*)static_cast<intptr_t>(i); }
int detag(void* p) { return static_cast<int>(reinterpret_cast<intptr_t>(p)); }
class Verifier {
diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc
index 967db4c57c..cd8321771a 100644
--- a/test/cpp/end2end/end2end_test.cc
+++ b/test/cpp/end2end/end2end_test.cc
@@ -347,7 +347,8 @@ static void SendRpc(grpc::testing::EchoTestService::Stub* stub, int num_rpcs,
for (int i = 0; i < num_rpcs; ++i) {
ClientContext context;
if (with_binary_metadata) {
- char bytes[8] = {'\0', '\1', '\2', '\3', '\4', '\5', '\6', (char)i};
+ char bytes[8] = {'\0', '\1', '\2', '\3',
+ '\4', '\5', '\6', static_cast<char>(i)};
context.AddMetadata("custom-bin", grpc::string(bytes, 8));
}
context.set_compression_algorithm(GRPC_COMPRESS_GZIP);
diff --git a/test/cpp/end2end/filter_end2end_test.cc b/test/cpp/end2end/filter_end2end_test.cc
index 53e86addef..d11df3a143 100644
--- a/test/cpp/end2end/filter_end2end_test.cc
+++ b/test/cpp/end2end/filter_end2end_test.cc
@@ -50,7 +50,7 @@ namespace grpc {
namespace testing {
namespace {
-void* tag(int i) { return (void*)(intptr_t)i; }
+void* tag(int i) { return (void*)static_cast<intptr_t>(i); }
void verify_ok(CompletionQueue* cq, int i, bool expect_ok) {
bool ok;
diff --git a/test/cpp/end2end/generic_end2end_test.cc b/test/cpp/end2end/generic_end2end_test.cc
index dac5faed8f..c778b205e0 100644
--- a/test/cpp/end2end/generic_end2end_test.cc
+++ b/test/cpp/end2end/generic_end2end_test.cc
@@ -47,7 +47,7 @@ namespace grpc {
namespace testing {
namespace {
-void* tag(int i) { return (void*)(intptr_t)i; }
+void* tag(int i) { return (void*)static_cast<intptr_t>(i); }
void verify_ok(CompletionQueue* cq, int i, bool expect_ok) {
bool ok;
diff --git a/test/cpp/end2end/hybrid_end2end_test.cc b/test/cpp/end2end/hybrid_end2end_test.cc
index cb515533ed..38d6bfa83b 100644
--- a/test/cpp/end2end/hybrid_end2end_test.cc
+++ b/test/cpp/end2end/hybrid_end2end_test.cc
@@ -42,7 +42,7 @@ namespace testing {
namespace {
-void* tag(int i) { return (void*)(intptr_t)i; }
+void* tag(int i) { return (void*)static_cast<intptr_t>(i); }
bool VerifyReturnSuccess(CompletionQueue* cq, int i) {
void* got_tag;
diff --git a/test/cpp/end2end/thread_stress_test.cc b/test/cpp/end2end/thread_stress_test.cc
index 90b2eddbbb..79074d8e70 100644
--- a/test/cpp/end2end/thread_stress_test.cc
+++ b/test/cpp/end2end/thread_stress_test.cc
@@ -265,7 +265,7 @@ class CommonStressTestAsyncServer : public BaseClass {
service_.RequestEcho(contexts_[i].srv_ctx.get(),
&contexts_[i].recv_request,
contexts_[i].response_writer.get(), cq_.get(),
- cq_.get(), (void*)(intptr_t)i);
+ cq_.get(), (void*)static_cast<intptr_t>(i));
}
}
struct Context {
diff --git a/test/cpp/grpclb/grpclb_test.cc b/test/cpp/grpclb/grpclb_test.cc
index 06ab8c3ff8..d17c2957a2 100644
--- a/test/cpp/grpclb/grpclb_test.cc
+++ b/test/cpp/grpclb/grpclb_test.cc
@@ -198,7 +198,8 @@ static void start_lb_server(server_fixture* sf, int* ports, size_t nports,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(202), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(202),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(202), 1);
cq_verify(cqv);
@@ -230,7 +231,8 @@ static void start_lb_server(server_fixture* sf, int* ports, size_t nports,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(201), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(201),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
gpr_log(GPR_INFO, "LB Server[%s](%s) after tag 201", sf->servers_hostport,
sf->balancer_name);
@@ -255,8 +257,8 @@ static void start_lb_server(server_fixture* sf, int* ports, size_t nports,
op->flags = 0;
op->reserved = nullptr;
op++;
- error =
- grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(203), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops),
+ tag(203), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(203), 1);
cq_verify(cqv);
@@ -278,7 +280,8 @@ static void start_lb_server(server_fixture* sf, int* ports, size_t nports,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(204), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(204),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(201), 1);
@@ -350,8 +353,8 @@ static void start_backend_server(server_fixture* sf) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error =
- grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(101), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops),
+ tag(101), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
gpr_log(GPR_INFO, "Server[%s] after tag 101", sf->servers_hostport);
@@ -364,8 +367,8 @@ static void start_backend_server(server_fixture* sf) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error =
- grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops),
+ tag(102), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
ev = grpc_completion_queue_next(
sf->cq, grpc_timeout_seconds_to_deadline(3), nullptr);
@@ -394,8 +397,8 @@ static void start_backend_server(server_fixture* sf) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103),
- nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops),
+ tag(103), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
ev = grpc_completion_queue_next(
sf->cq, grpc_timeout_seconds_to_deadline(3), nullptr);
@@ -428,8 +431,8 @@ static void start_backend_server(server_fixture* sf) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error =
- grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops),
+ tag(104), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(101), 1);
@@ -493,7 +496,8 @@ static void perform_request(client_fixture* cf) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
for (i = 0; i < 4; i++) {
@@ -510,7 +514,8 @@ static void perform_request(client_fixture* cf) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(2),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(2), 1);
@@ -529,7 +534,8 @@ static void perform_request(client_fixture* cf) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(3),
+ nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc
index 3051afa86b..865b5c407f 100644
--- a/test/cpp/interop/interop_client.cc
+++ b/test/cpp/interop/interop_client.cc
@@ -875,7 +875,8 @@ bool InteropClient::DoCacheableUnary() {
// Create request with current timestamp
gpr_timespec ts = gpr_now(GPR_CLOCK_PRECISE);
- std::string timestamp = std::to_string((long long unsigned)ts.tv_nsec);
+ std::string timestamp =
+ std::to_string(static_cast<long long unsigned>(ts.tv_nsec));
SimpleRequest request;
request.mutable_payload()->set_body(timestamp.c_str(), timestamp.size());
@@ -914,7 +915,7 @@ bool InteropClient::DoCacheableUnary() {
// Request 3
// Modify the request body so it will not get a cache hit
ts = gpr_now(GPR_CLOCK_PRECISE);
- timestamp = std::to_string((long long unsigned)ts.tv_nsec);
+ timestamp = std::to_string(static_cast<long long unsigned>(ts.tv_nsec));
SimpleRequest request1;
request1.mutable_payload()->set_body(timestamp.c_str(), timestamp.size());
ClientContext context3;
diff --git a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
index 4b7310389c..07bb3c92ae 100644
--- a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
+++ b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
@@ -82,7 +82,7 @@ static void BM_HpackEncoderEncodeDeadline(benchmark::State& state) {
static_cast<uint32_t>(state.iterations()),
true,
false,
- (size_t)1024,
+ static_cast<size_t>(1024),
&stats,
};
grpc_chttp2_encode_header(&c, nullptr, 0, &b, &hopt, &outbuf);
@@ -131,7 +131,7 @@ static void BM_HpackEncoderEncodeHeader(benchmark::State& state) {
static_cast<uint32_t>(state.iterations()),
state.range(0) != 0,
Fixture::kEnableTrueBinary,
- (size_t)state.range(1),
+ static_cast<size_t>(state.range(1)),
&stats,
};
grpc_chttp2_encode_header(&c, nullptr, 0, &b, &hopt, &outbuf);
@@ -777,7 +777,8 @@ static void OnHeaderNew(void* user_data, grpc_mdelem md) {
if (GRPC_MDELEM_IS_INTERNED(md)) {
/* not already parsed: parse it now, and store the
* result away */
- cached_timeout = (grpc_millis*)gpr_malloc(sizeof(grpc_millis));
+ cached_timeout =
+ static_cast<grpc_millis*>(gpr_malloc(sizeof(grpc_millis)));
*cached_timeout = timeout;
grpc_mdelem_set_user_data(md, free_timeout, cached_timeout);
}
diff --git a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
index 874c834931..ec79b95cd8 100644
--- a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
+++ b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
@@ -38,7 +38,7 @@ namespace testing {
auto& force_library_initialization = Library::get();
-static void* g_tag = (void*)(intptr_t)10; // Some random number
+static void* g_tag = (void*)static_cast<intptr_t>(10); // Some random number
static grpc_completion_queue* g_cq;
static grpc_event_engine_vtable g_vtable;
static const grpc_event_engine_vtable* g_old_vtable;
@@ -74,8 +74,9 @@ static grpc_error* pollset_work(grpc_pollset* ps, grpc_pollset_worker** worker,
gpr_mu_unlock(&ps->mu);
GPR_ASSERT(grpc_cq_begin_op(g_cq, g_tag));
- grpc_cq_end_op(g_cq, g_tag, GRPC_ERROR_NONE, cq_done_cb, nullptr,
- (grpc_cq_completion*)gpr_malloc(sizeof(grpc_cq_completion)));
+ grpc_cq_end_op(
+ g_cq, g_tag, GRPC_ERROR_NONE, cq_done_cb, nullptr,
+ static_cast<grpc_cq_completion*>(gpr_malloc(sizeof(grpc_cq_completion))));
grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(&ps->mu);
return GRPC_ERROR_NONE;
diff --git a/test/cpp/microbenchmarks/fullstack_context_mutators.h b/test/cpp/microbenchmarks/fullstack_context_mutators.h
index cafbeffdbe..3584280c48 100644
--- a/test/cpp/microbenchmarks/fullstack_context_mutators.h
+++ b/test/cpp/microbenchmarks/fullstack_context_mutators.h
@@ -72,7 +72,7 @@ class RandomBinaryMetadata {
grpc::string s;
s.reserve(length + 1);
for (int i = 0; i < length; i++) {
- s += (char)rand();
+ s += static_cast<char>(rand());
}
return s;
}
@@ -95,7 +95,7 @@ class RandomAsciiMetadata {
grpc::string s;
s.reserve(length + 1);
for (int i = 0; i < length; i++) {
- s += (char)(rand() % 26 + 'a');
+ s += static_cast<char>(rand() % 26 + 'a');
}
return s;
}
diff --git a/test/cpp/microbenchmarks/fullstack_fixtures.h b/test/cpp/microbenchmarks/fullstack_fixtures.h
index fdc04e51c6..ab6c194830 100644
--- a/test/cpp/microbenchmarks/fullstack_fixtures.h
+++ b/test/cpp/microbenchmarks/fullstack_fixtures.h
@@ -108,7 +108,8 @@ class FullstackFixture : public BaseFixture {
void AddToLabel(std::ostream& out, benchmark::State& state) {
BaseFixture::AddToLabel(out, state);
out << " polls/iter:"
- << (double)grpc_get_cq_poll_num(this->cq()->cq()) / state.iterations();
+ << static_cast<double>(grpc_get_cq_poll_num(this->cq()->cq())) /
+ state.iterations();
}
ServerCompletionQueue* cq() { return cq_.get(); }
@@ -236,7 +237,8 @@ class EndpointPairFixture : public BaseFixture {
void AddToLabel(std::ostream& out, benchmark::State& state) {
BaseFixture::AddToLabel(out, state);
out << " polls/iter:"
- << (double)grpc_get_cq_poll_num(this->cq()->cq()) / state.iterations();
+ << static_cast<double>(grpc_get_cq_poll_num(this->cq()->cq())) /
+ state.iterations();
}
ServerCompletionQueue* cq() { return cq_.get(); }
diff --git a/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h b/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h
index 0763d07855..f399949a32 100644
--- a/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h
+++ b/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h
@@ -83,7 +83,7 @@ static void BM_StreamingPingPong(benchmark::State& state) {
while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok);
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(need_tags & (1 << i));
need_tags &= ~(1 << i);
}
@@ -99,7 +99,7 @@ static void BM_StreamingPingPong(benchmark::State& state) {
while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok);
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
// If server recv is complete, start the server send operation
if (i == 1) {
@@ -122,7 +122,7 @@ static void BM_StreamingPingPong(benchmark::State& state) {
need_tags = (1 << 0) | (1 << 1) | (1 << 2);
while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(need_tags & (1 << i));
need_tags &= ~(1 << i);
}
@@ -175,7 +175,7 @@ static void BM_StreamingPingPongMsgs(benchmark::State& state) {
while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok);
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(need_tags & (1 << i));
need_tags &= ~(1 << i);
}
@@ -190,7 +190,7 @@ static void BM_StreamingPingPongMsgs(benchmark::State& state) {
while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok);
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
// If server recv is complete, start the server send operation
if (i == 1) {
@@ -210,7 +210,7 @@ static void BM_StreamingPingPongMsgs(benchmark::State& state) {
need_tags = (1 << 0) | (1 << 1) | (1 << 2);
while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(need_tags & (1 << i));
need_tags &= ~(1 << i);
}
@@ -297,10 +297,10 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) {
// established). It is necessary when client init metadata is
// coalesced
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
- while ((int)(intptr_t)t != 0) {
+ while (static_cast<int>((intptr_t)t) != 0) {
// In some cases tag:2 comes before tag:0 (write tag comes out
// first), this while loop is to make sure get tag:0.
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(await_tags & (1 << i));
await_tags &= ~(1 << i);
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
@@ -317,7 +317,7 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) {
while (await_tags != 0) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok);
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
// If server recv is complete, start the server send operation
if (i == 3) {
@@ -367,8 +367,8 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) {
// wait for server call data structure(call_hook, etc.) to be
// initialized, since initial metadata is corked.
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
- while ((int)(intptr_t)t != 0) {
- int i = (int)(intptr_t)t;
+ while (static_cast<int>((intptr_t)t) != 0) {
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(expect_tags & (1 << i));
expect_tags &= ~(1 << i);
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
@@ -385,7 +385,7 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) {
while (expect_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(expect_tags & (1 << i));
expect_tags &= ~(1 << i);
}
diff --git a/test/cpp/microbenchmarks/fullstack_streaming_pump.h b/test/cpp/microbenchmarks/fullstack_streaming_pump.h
index 9e826091ec..3623e373f6 100644
--- a/test/cpp/microbenchmarks/fullstack_streaming_pump.h
+++ b/test/cpp/microbenchmarks/fullstack_streaming_pump.h
@@ -62,7 +62,7 @@ static void BM_PumpStreamClientToServer(benchmark::State& state) {
while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok);
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(need_tags & (1 << i));
need_tags &= ~(1 << i);
}
@@ -85,7 +85,7 @@ static void BM_PumpStreamClientToServer(benchmark::State& state) {
need_tags = (1 << 0) | (1 << 1);
while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(need_tags & (1 << i));
need_tags &= ~(1 << i);
}
@@ -95,7 +95,7 @@ static void BM_PumpStreamClientToServer(benchmark::State& state) {
need_tags = (1 << 0) | (1 << 1);
while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(need_tags & (1 << i));
need_tags &= ~(1 << i);
}
@@ -131,7 +131,7 @@ static void BM_PumpStreamServerToClient(benchmark::State& state) {
while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok);
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(need_tags & (1 << i));
need_tags &= ~(1 << i);
}
@@ -154,7 +154,7 @@ static void BM_PumpStreamServerToClient(benchmark::State& state) {
need_tags = (1 << 0) | (1 << 1);
while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(need_tags & (1 << i));
need_tags &= ~(1 << i);
}
diff --git a/test/cpp/microbenchmarks/fullstack_unary_ping_pong.h b/test/cpp/microbenchmarks/fullstack_unary_ping_pong.h
index d448938295..a85c33c320 100644
--- a/test/cpp/microbenchmarks/fullstack_unary_ping_pong.h
+++ b/test/cpp/microbenchmarks/fullstack_unary_ping_pong.h
@@ -91,7 +91,7 @@ static void BM_UnaryPingPong(benchmark::State& state) {
for (int i = (1 << 3) | (1 << 4); i != 0;) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok);
- int tagnum = (int)reinterpret_cast<intptr_t>(t);
+ int tagnum = static_cast<int>(reinterpret_cast<intptr_t>(t));
GPR_ASSERT(i & (1 << tagnum));
i -= 1 << tagnum;
}
diff --git a/test/cpp/microbenchmarks/helpers.cc b/test/cpp/microbenchmarks/helpers.cc
index a4c0a3a0ce..e4a31f50a9 100644
--- a/test/cpp/microbenchmarks/helpers.cc
+++ b/test/cpp/microbenchmarks/helpers.cc
@@ -43,18 +43,21 @@ void TrackCounters::AddToLabel(std::ostream& out, benchmark::State& state) {
grpc_stats_data stats;
grpc_stats_diff(&stats_end, &stats_begin_, &stats);
for (int i = 0; i < GRPC_STATS_COUNTER_COUNT; i++) {
- out << " " << grpc_stats_counter_name[i]
- << "/iter:" << ((double)stats.counters[i] / (double)state.iterations());
+ out << " " << grpc_stats_counter_name[i] << "/iter:"
+ << (static_cast<double>(stats.counters[i]) /
+ static_cast<double>(state.iterations()));
}
for (int i = 0; i < GRPC_STATS_HISTOGRAM_COUNT; i++) {
std::ostringstream median_ss;
median_ss << grpc_stats_histogram_name[i] << "-median";
- state.counters[median_ss.str()] = benchmark::Counter(
- grpc_stats_histo_percentile(&stats, (grpc_stats_histograms)i, 50.0));
+ state.counters[median_ss.str()] =
+ benchmark::Counter(grpc_stats_histo_percentile(
+ &stats, static_cast<grpc_stats_histograms>(i), 50.0));
std::ostringstream tail_ss;
tail_ss << grpc_stats_histogram_name[i] << "-99p";
- state.counters[tail_ss.str()] = benchmark::Counter(
- grpc_stats_histo_percentile(&stats, (grpc_stats_histograms)i, 99.0));
+ state.counters[tail_ss.str()] =
+ benchmark::Counter(grpc_stats_histo_percentile(
+ &stats, static_cast<grpc_stats_histograms>(i), 99.0));
}
#ifdef GPR_LOW_LEVEL_COUNTERS
grpc_memory_counters counters_at_end = grpc_memory_counters_snapshot();
diff --git a/test/cpp/performance/writes_per_rpc_test.cc b/test/cpp/performance/writes_per_rpc_test.cc
index b7d951a86e..d0190de172 100644
--- a/test/cpp/performance/writes_per_rpc_test.cc
+++ b/test/cpp/performance/writes_per_rpc_test.cc
@@ -217,7 +217,7 @@ static double UnaryPingPong(int request_size, int response_size) {
for (int i = (1 << 3) | (1 << 4); i != 0;) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok);
- int tagnum = (int)reinterpret_cast<intptr_t>(t);
+ int tagnum = static_cast<int>(reinterpret_cast<intptr_t>(t));
GPR_ASSERT(i & (1 << tagnum));
i -= 1 << tagnum;
}
@@ -230,7 +230,8 @@ static double UnaryPingPong(int request_size, int response_size) {
}
double writes_per_iteration =
- (double)fixture->writes_performed() / (double)kIterations;
+ static_cast<double>(fixture->writes_performed()) /
+ static_cast<double>(kIterations);
fixture.reset();
server_env[0]->~ServerEnv();
diff --git a/test/cpp/qps/report.cc b/test/cpp/qps/report.cc
index 42ebeff41d..c5e90bd9a4 100644
--- a/test/cpp/qps/report.cc
+++ b/test/cpp/qps/report.cc
@@ -109,9 +109,12 @@ void GprLogReporter::ReportCoreStats(const char* name, int idx,
for (int i = 0; i < GRPC_STATS_HISTOGRAM_COUNT; i++) {
gpr_log(GPR_DEBUG, "%s[%d].%s = %.1lf/%.1lf/%.1lf (50/95/99%%-ile)", name,
idx, grpc_stats_histogram_name[i],
- grpc_stats_histo_percentile(&data, (grpc_stats_histograms)i, 50),
- grpc_stats_histo_percentile(&data, (grpc_stats_histograms)i, 95),
- grpc_stats_histo_percentile(&data, (grpc_stats_histograms)i, 99));
+ grpc_stats_histo_percentile(
+ &data, static_cast<grpc_stats_histograms>(i), 50),
+ grpc_stats_histo_percentile(
+ &data, static_cast<grpc_stats_histograms>(i), 95),
+ grpc_stats_histo_percentile(
+ &data, static_cast<grpc_stats_histograms>(i), 99));
}
}
diff --git a/test/cpp/qps/server.h b/test/cpp/qps/server.h
index 9da33566dd..d772e709de 100644
--- a/test/cpp/qps/server.h
+++ b/test/cpp/qps/server.h
@@ -84,7 +84,7 @@ class Server {
}
payload->set_type(type);
// Don't waste time creating a new payload of identical size.
- if (payload->body().length() != (size_t)size) {
+ if (payload->body().length() != static_cast<size_t>(size)) {
std::unique_ptr<char[]> body(new char[size]());
payload->set_body(body.get(), size);
}
diff --git a/test/cpp/util/cli_call.cc b/test/cpp/util/cli_call.cc
index 3b0bb9eeba..6fc22f35ca 100644
--- a/test/cpp/util/cli_call.cc
+++ b/test/cpp/util/cli_call.cc
@@ -30,7 +30,7 @@
namespace grpc {
namespace testing {
namespace {
-void* tag(int i) { return (void*)(intptr_t)i; }
+void* tag(int i) { return (void*)static_cast<intptr_t>(i); }
} // namespace
Status CliCall::Call(std::shared_ptr<grpc::Channel> channel,
diff --git a/test/cpp/util/proto_reflection_descriptor_database.cc b/test/cpp/util/proto_reflection_descriptor_database.cc
index 42b1f4e75c..0adbf20ce6 100644
--- a/test/cpp/util/proto_reflection_descriptor_database.cc
+++ b/test/cpp/util/proto_reflection_descriptor_database.cc
@@ -50,7 +50,8 @@ ProtoReflectionDescriptorDatabase::~ProtoReflectionDescriptorDatabase() {
}
gpr_log(GPR_INFO,
"ServerReflectionInfo rpc failed. Error code: %d, details: %s",
- (int)status.error_code(), status.error_message().c_str());
+ static_cast<int>(status.error_code()),
+ status.error_message().c_str());
}
}
}