Autofix c casts to c++ casts
diff --git a/test/core/avl/avl_test.cc b/test/core/avl/avl_test.cc
index ac1ab5c..563de81 100644
--- a/test/core/avl/avl_test.cc
+++ b/test/core/avl/avl_test.cc
@@ -34,9 +34,9 @@
}
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(*(int*)p); }
+static void* int_copy(void* p, void* unused) { return box(*static_cast<int*>(p)); }
static void destroy(void* p, void* unused) { gpr_free(p); }
@@ -3604,17 +3604,17 @@
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 +3627,7 @@
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 53e910e..35a3b14 100644
--- a/test/core/backoff/backoff_test.cc
+++ b/test/core/backoff/backoff_test.cc
@@ -144,9 +144,9 @@
EXPECT_EQ(next - grpc_core::ExecCtx::Get()->Now(), initial_backoff);
grpc_millis expected_next_lower_bound =
- (grpc_millis)((double)current_backoff * (1 - jitter));
+ static_cast<grpc_millis>(static_cast<double>(current_backoff) * (1 - jitter));
grpc_millis expected_next_upper_bound =
- (grpc_millis)((double)current_backoff * (1 + jitter));
+ static_cast<grpc_millis>(static_cast<double>(current_backoff) * (1 + jitter));
for (int i = 0; i < 10000; i++) {
next = backoff.NextAttemptTime();
@@ -156,11 +156,11 @@
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);
+ static_cast<grpc_millis>(static_cast<double>(current_backoff) * multiplier), max_backoff);
expected_next_lower_bound =
- (grpc_millis)((double)current_backoff * (1 - jitter));
+ static_cast<grpc_millis>(static_cast<double>(current_backoff) * (1 - jitter));
expected_next_upper_bound =
- (grpc_millis)((double)current_backoff * (1 + jitter));
+ 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 df803d1..ee55a95 100644
--- a/test/core/bad_client/bad_client.cc
+++ b/test/core/bad_client/bad_client.cc
@@ -49,7 +49,7 @@
/* 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 @@
/* 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 @@
/* 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 0d689bb..12b9c79 100644
--- a/test/core/bad_client/tests/duplicate_header.cc
+++ b/test/core/bad_client/tests/duplicate_header.cc
@@ -87,7 +87,7 @@
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 +108,7 @@
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 8668e09..427db46 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 @@
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 fe6b05d..7c012ac 100644
--- a/test/core/bad_client/tests/window_overflow.cc
+++ b/test/core/bad_client/tests/window_overflow.cc
@@ -76,9 +76,9 @@
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 e2ab22e..e2ea754 100644
--- a/test/core/bad_ssl/bad_ssl_test.cc
+++ b/test/core/bad_ssl/bad_ssl_test.cc
@@ -127,7 +127,7 @@
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 @@
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 3ed7d02..d9ac498 100644
--- a/test/core/bad_ssl/servers/cert.cc
+++ b/test/core/bad_ssl/servers/cert.cc
@@ -45,8 +45,8 @@
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 d232bc0..11b280e 100644
--- a/test/core/channel/channel_args_test.cc
+++ b/test/core/channel/channel_args_test.cc
@@ -82,7 +82,7 @@
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);
+ 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,8 @@
&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 +118,8 @@
&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 ef6db81..aad6d6e 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_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 ef43fac..2f5329a 100644
--- a/test/core/channel/channel_stack_test.cc
+++ b/test/core/channel/channel_stack_test.cc
@@ -35,14 +35,14 @@
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 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 @@
&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 @@
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 6d56961..670ecb4 100644
--- a/test/core/client_channel/parse_address_test.cc
+++ b/test/core/client_channel/parse_address_test.cc
@@ -39,7 +39,7 @@
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 +60,7 @@
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 +78,7 @@
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 8cafadf..966fb1d 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 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 2f30b7f..1236529 100644
--- a/test/core/compression/stream_compression_test.cc
+++ b/test/core/compression/stream_compression_test.cc
@@ -29,7 +29,7 @@
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,7 +43,7 @@
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]),
+ if (0 != strncmp(str + pointer, reinterpret_cast<char*>GRPC_SLICE_START_PTR(buf->slices[i]),
slice_len)) {
return false;
}
@@ -112,7 +112,7 @@
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 2b98620..124d05a 100644
--- a/test/core/end2end/bad_server_response_test.cc
+++ b/test/core/end2end/bad_server_response_test.cc
@@ -133,7 +133,7 @@
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,7 +196,7 @@
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(state.call, ops, (size_t)(op - ops), tag(1),
+ 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 @@
} 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 @@
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 a7b37f3..c3a3f43 100644
--- a/test/core/end2end/cq_verifier.cc
+++ b/test/core/end2end/cq_verifier.cc
@@ -61,7 +61,7 @@
};
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 @@
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 2dc72b8..a7f10e4 100644
--- a/test/core/end2end/dualstack_socket_test.cc
+++ b/test/core/end2end/dualstack_socket_test.cc
@@ -129,7 +129,7 @@
char** hosts_with_port;
uri_slice =
- grpc_slice_new((char*)client_host, strlen(client_host), do_nothing);
+ 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,7 @@
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) {
@@ -228,7 +228,7 @@
op->flags = 0;
op++;
error =
- grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ 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 795e94a..9453f2f 100644
--- a/test/core/end2end/fixtures/h2_oauth2.cc
+++ b/test/core/end2end/fixtures/h2_oauth2.cc
@@ -66,7 +66,7 @@
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 @@
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 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 2d5e841..4776cfb 100644
--- a/test/core/end2end/fixtures/http_proxy_fixture.cc
+++ b/test/core/end2end/fixtures/http_proxy_fixture.cc
@@ -185,7 +185,7 @@
// 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 @@
// 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 @@
// 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 @@
// 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 @@
// 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 @@
// 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 @@
// 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,9 @@
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 +499,7 @@
//
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 +518,7 @@
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 +533,7 @@
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 +542,7 @@
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 +555,7 @@
}
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 7a35796..d0a4bbb 100644
--- a/test/core/end2end/fixtures/proxy.cc
+++ b/test/core/end2end/fixtures/proxy.cc
@@ -80,7 +80,7 @@
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 +107,14 @@
}
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 +147,12 @@
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 +174,14 @@
}
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 +201,12 @@
}
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 +241,7 @@
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 +261,7 @@
}
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 +281,12 @@
}
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 +311,18 @@
}
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 +412,7 @@
}
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 +424,7 @@
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 14c1555..fa50c24 100644
--- a/test/core/end2end/fuzzers/api_fuzzer.cc
+++ b/test/core/end2end/fuzzers/api_fuzzer.cc
@@ -93,7 +93,7 @@
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 @@
}
*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,7 @@
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 +529,10 @@
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 c17d581..16acf8e 100644
--- a/test/core/end2end/fuzzers/client_fuzzer.cc
+++ b/test/core/end2end/fuzzers/client_fuzzer.cc
@@ -33,7 +33,7 @@
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 61c55e0..5eb83ed 100644
--- a/test/core/end2end/fuzzers/server_fuzzer.cc
+++ b/test/core/end2end/fuzzers/server_fuzzer.cc
@@ -30,8 +30,8 @@
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 f23d87e..20468ad 100644
--- a/test/core/end2end/goaway_server_test.cc
+++ b/test/core/end2end/goaway_server_test.cc
@@ -77,10 +77,10 @@
(*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 +109,7 @@
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 cd62c3f..b4b3462 100644
--- a/test/core/end2end/h2_ssl_cert_test.cc
+++ b/test/core/end2end/h2_ssl_cert_test.cc
@@ -333,7 +333,7 @@
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 d2b26e7..6cb2e3e 100644
--- a/test/core/end2end/invalid_call_argument_test.cc
+++ b/test/core/end2end/invalid_call_argument_test.cc
@@ -209,7 +209,7 @@
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 @@
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 f2852f7..498fb5c 100644
--- a/test/core/end2end/tests/authority_not_supported.cc
+++ b/test/core/end2end/tests/authority_not_supported.cc
@@ -154,7 +154,7 @@
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 63bfd76..60097df 100644
--- a/test/core/end2end/tests/bad_hostname.cc
+++ b/test/core/end2end/tests/bad_hostname.cc
@@ -133,7 +133,7 @@
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 672c2f4..0972e86 100644
--- a/test/core/end2end/tests/bad_ping.cc
+++ b/test/core/end2end/tests/bad_ping.cc
@@ -144,7 +144,7 @@
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 +188,7 @@
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 8a0d667..1313ca4 100644
--- a/test/core/end2end/tests/binary_metadata.cc
+++ b/test/core/end2end/tests/binary_metadata.cc
@@ -182,7 +182,7 @@
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 +205,7 @@
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 +246,7 @@
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 968dab1..cb65b18 100644
--- a/test/core/end2end/tests/call_creds.cc
+++ b/test/core/end2end/tests/call_creds.cc
@@ -219,7 +219,7 @@
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 +253,7 @@
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 +279,7 @@
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 +443,7 @@
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 11bf4e7..86c91c1 100644
--- a/test/core/end2end/tests/cancel_after_accept.cc
+++ b/test/core/end2end/tests/cancel_after_accept.cc
@@ -186,7 +186,7 @@
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 +217,7 @@
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 b0702b7..9e92c27 100644
--- a/test/core/end2end/tests/cancel_after_client_done.cc
+++ b/test/core/end2end/tests/cancel_after_client_done.cc
@@ -164,7 +164,7 @@
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 +195,7 @@
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 63e6505..88aa63c 100644
--- a/test/core/end2end/tests/cancel_after_round_trip.cc
+++ b/test/core/end2end/tests/cancel_after_round_trip.cc
@@ -181,7 +181,7 @@
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 +208,7 @@
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 +234,7 @@
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 +251,7 @@
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 63bf472..0879d72 100644
--- a/test/core/end2end/tests/compressed_payload.cc
+++ b/test/core/end2end/tests/compressed_payload.cc
@@ -187,7 +187,7 @@
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 +205,7 @@
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 +216,7 @@
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 +338,7 @@
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 +367,7 @@
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 +403,7 @@
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++) {
@@ -419,7 +419,7 @@
op->reserved = nullptr;
op++;
error =
- grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), nullptr);
+ 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);
}
@@ -432,7 +432,7 @@
op->reserved = nullptr;
op++;
error =
- grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ 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);
@@ -451,7 +451,7 @@
op->reserved = nullptr;
op++;
error =
- grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
+ 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 +461,7 @@
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 +495,7 @@
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 +508,7 @@
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 da65080..56e5189 100644
--- a/test/core/end2end/tests/connectivity.cc
+++ b/test/core/end2end/tests/connectivity.cc
@@ -34,7 +34,7 @@
} 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 33be5f1..fefb5a5 100644
--- a/test/core/end2end/tests/default_host.cc
+++ b/test/core/end2end/tests/default_host.cc
@@ -140,7 +140,7 @@
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 +179,7 @@
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 1b2f729..9712b9f 100644
--- a/test/core/end2end/tests/disappearing_server.cc
+++ b/test/core/end2end/tests/disappearing_server.cc
@@ -120,7 +120,7 @@
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 +154,7 @@
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 f60a47f..c63a5b9 100644
--- a/test/core/end2end/tests/filter_call_init_fails.cc
+++ b/test/core/end2end/tests/filter_call_init_fails.cc
@@ -158,7 +158,7 @@
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 +253,7 @@
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 +344,7 @@
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 +368,7 @@
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 43f20d7..07543f8 100644
--- a/test/core/end2end/tests/filter_causes_close.cc
+++ b/test/core/end2end/tests/filter_causes_close.cc
@@ -152,7 +152,7 @@
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 +197,8 @@
} 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 +209,7 @@
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 d6cf3b0..42507ad 100644
--- a/test/core/end2end/tests/filter_latency.cc
+++ b/test/core/end2end/tests/filter_latency.cc
@@ -165,7 +165,7 @@
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 +196,7 @@
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 +305,7 @@
*/
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 ad80f23..389c63b 100644
--- a/test/core/end2end/tests/filter_status_code.cc
+++ b/test/core/end2end/tests/filter_status_code.cc
@@ -164,7 +164,7 @@
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 +199,7 @@
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 +250,7 @@
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 +258,7 @@
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 +273,7 @@
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 +323,7 @@
*/
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 3b6872b..9a14476 100644
--- a/test/core/end2end/tests/graceful_server_shutdown.cc
+++ b/test/core/end2end/tests/graceful_server_shutdown.cc
@@ -135,7 +135,7 @@
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 +169,7 @@
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 989cd56..cb67787 100644
--- a/test/core/end2end/tests/high_initial_seqno.cc
+++ b/test/core/end2end/tests/high_initial_seqno.cc
@@ -139,7 +139,7 @@
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 +169,7 @@
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 66b3a40..8f7f3e6 100644
--- a/test/core/end2end/tests/hpack_size.cc
+++ b/test/core/end2end/tests/hpack_size.cc
@@ -293,7 +293,7 @@
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 +323,7 @@
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 578510d..c0eac68 100644
--- a/test/core/end2end/tests/idempotent_request.cc
+++ b/test/core/end2end/tests/idempotent_request.cc
@@ -144,7 +144,7 @@
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 +183,7 @@
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 b7afa97..5705094 100644
--- a/test/core/end2end/tests/invoke_large_request.cc
+++ b/test/core/end2end/tests/invoke_large_request.cc
@@ -176,7 +176,7 @@
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 +198,7 @@
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 +224,7 @@
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 0cdd12e..76beedb 100644
--- a/test/core/end2end/tests/keepalive_timeout.cc
+++ b/test/core/end2end/tests/keepalive_timeout.cc
@@ -155,7 +155,7 @@
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 +172,7 @@
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 +186,7 @@
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 c1343f9..5e04161 100644
--- a/test/core/end2end/tests/large_metadata.cc
+++ b/test/core/end2end/tests/large_metadata.cc
@@ -96,7 +96,7 @@
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,7 @@
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 +184,7 @@
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 +207,7 @@
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 cfe5814..de6b60c 100644
--- a/test/core/end2end/tests/load_reporting_hook.cc
+++ b/test/core/end2end/tests/load_reporting_hook.cc
@@ -185,7 +185,7 @@
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 +207,7 @@
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 +235,7 @@
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 642c0f7..ed658a3 100644
--- a/test/core/end2end/tests/max_concurrent_streams.cc
+++ b/test/core/end2end/tests/max_concurrent_streams.cc
@@ -135,7 +135,7 @@
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 +165,7 @@
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 +274,7 @@
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 +292,7 @@
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 +306,7 @@
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 +324,7 @@
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 +345,7 @@
* 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 +371,7 @@
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 +408,7 @@
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 +514,7 @@
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 +532,7 @@
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 +550,7 @@
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 +568,7 @@
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 +603,7 @@
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 +709,7 @@
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 +727,7 @@
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 +745,7 @@
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 +763,7 @@
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 +796,7 @@
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 df5fd5c..4b498e6 100644
--- a/test/core/end2end/tests/max_connection_age.cc
+++ b/test/core/end2end/tests/max_connection_age.cc
@@ -145,7 +145,7 @@
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 +156,7 @@
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 +190,7 @@
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 +288,7 @@
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 +325,7 @@
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 09b4a54..beff733 100644
--- a/test/core/end2end/tests/max_connection_idle.cc
+++ b/test/core/end2end/tests/max_connection_idle.cc
@@ -100,7 +100,7 @@
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 +139,7 @@
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 b1757a9..987c348 100644
--- a/test/core/end2end/tests/max_message_length.cc
+++ b/test/core/end2end/tests/max_message_length.cc
@@ -219,7 +219,7 @@
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 +247,7 @@
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 +408,7 @@
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 +443,7 @@
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 809f8ff..fe941e8 100644
--- a/test/core/end2end/tests/network_status_change.cc
+++ b/test/core/end2end/tests/network_status_change.cc
@@ -150,7 +150,7 @@
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 +170,7 @@
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 +193,7 @@
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 b4908d4..c4678f4 100644
--- a/test/core/end2end/tests/no_logging.cc
+++ b/test/core/end2end/tests/no_logging.cc
@@ -170,7 +170,7 @@
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 +207,7 @@
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 3535d80..0e19e29 100644
--- a/test/core/end2end/tests/payload.cc
+++ b/test/core/end2end/tests/payload.cc
@@ -90,9 +90,9 @@
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,7 @@
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 +196,7 @@
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 +222,7 @@
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 714a768..9ac4d54 100644
--- a/test/core/end2end/tests/ping_pong_streaming.cc
+++ b/test/core/end2end/tests/ping_pong_streaming.cc
@@ -143,7 +143,7 @@
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 +165,7 @@
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 +184,7 @@
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));
@@ -195,7 +195,7 @@
op->reserved = nullptr;
op++;
error =
- grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ 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);
@@ -208,7 +208,7 @@
op->reserved = nullptr;
op++;
error =
- grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
+ 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 +229,7 @@
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 +242,7 @@
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 c34505c..fd1cbad 100644
--- a/test/core/end2end/tests/proxy_auth.cc
+++ b/test/core/end2end/tests/proxy_auth.cc
@@ -148,7 +148,7 @@
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 +187,7 @@
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 d1c37dc..49a9f88 100644
--- a/test/core/end2end/tests/registered_call.cc
+++ b/test/core/end2end/tests/registered_call.cc
@@ -135,7 +135,7 @@
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 +165,7 @@
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 4602313..bfce0a0 100644
--- a/test/core/end2end/tests/request_with_flags.cc
+++ b/test/core/end2end/tests/request_with_flags.cc
@@ -151,7 +151,7 @@
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 28818c8..fc87f58 100644
--- a/test/core/end2end/tests/request_with_payload.cc
+++ b/test/core/end2end/tests/request_with_payload.cc
@@ -147,7 +147,7 @@
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 +168,7 @@
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 +189,7 @@
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 6d35d08..c9d8ab7 100644
--- a/test/core/end2end/tests/resource_quota_server.cc
+++ b/test/core/end2end/tests/resource_quota_server.cc
@@ -91,9 +91,9 @@
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,25 @@
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);
+ static_cast<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);
+ static_cast<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);
+ 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 =
- (grpc_byte_buffer**)malloc(sizeof(grpc_byte_buffer*) * NUM_CALLS);
+ static_cast<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_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 +220,7 @@
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 +234,7 @@
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) {
@@ -286,7 +286,7 @@
op->reserved = nullptr;
op++;
error =
- grpc_call_start_batch(server_calls[call_id], ops, (size_t)(op - ops),
+ 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);
@@ -327,7 +327,7 @@
op->reserved = nullptr;
op++;
error =
- grpc_call_start_batch(server_calls[call_id], ops, (size_t)(op - ops),
+ 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);
diff --git a/test/core/end2end/tests/server_finishes_request.cc b/test/core/end2end/tests/server_finishes_request.cc
index f135851..4423ed3 100644
--- a/test/core/end2end/tests/server_finishes_request.cc
+++ b/test/core/end2end/tests/server_finishes_request.cc
@@ -133,7 +133,7 @@
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 +163,7 @@
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 2e19e05..bdba7a6 100644
--- a/test/core/end2end/tests/shutdown_finishes_calls.cc
+++ b/test/core/end2end/tests/shutdown_finishes_calls.cc
@@ -128,7 +128,7 @@
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 +145,7 @@
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 d160647..55caacb 100644
--- a/test/core/end2end/tests/shutdown_finishes_tags.cc
+++ b/test/core/end2end/tests/shutdown_finishes_tags.cc
@@ -77,7 +77,7 @@
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 b4732ae..d7be887 100644
--- a/test/core/end2end/tests/simple_cacheable_request.cc
+++ b/test/core/end2end/tests/simple_cacheable_request.cc
@@ -178,7 +178,7 @@
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 +201,7 @@
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 +227,7 @@
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 54517fb..12207f0 100644
--- a/test/core/end2end/tests/simple_delayed_request.cc
+++ b/test/core/end2end/tests/simple_delayed_request.cc
@@ -129,7 +129,7 @@
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 +159,7 @@
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 5911834..246c8b0 100644
--- a/test/core/end2end/tests/simple_metadata.cc
+++ b/test/core/end2end/tests/simple_metadata.cc
@@ -176,7 +176,7 @@
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 +199,7 @@
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 +225,7 @@
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 6ec4a14..8bc7fa6 100644
--- a/test/core/end2end/tests/simple_request.cc
+++ b/test/core/end2end/tests/simple_request.cc
@@ -152,7 +152,7 @@
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 +191,7 @@
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 637b7b2..4dea64e 100644
--- a/test/core/end2end/tests/stream_compression_compressed_payload.cc
+++ b/test/core/end2end/tests/stream_compression_compressed_payload.cc
@@ -187,7 +187,7 @@
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 +205,7 @@
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 +216,7 @@
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 +345,7 @@
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 +374,7 @@
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 +414,7 @@
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++) {
@@ -430,7 +430,7 @@
op->reserved = nullptr;
op++;
error =
- grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), nullptr);
+ 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);
}
@@ -443,7 +443,7 @@
op->reserved = nullptr;
op++;
error =
- grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ 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);
@@ -460,7 +460,7 @@
op->reserved = nullptr;
op++;
error =
- grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
+ 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 +470,7 @@
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 +495,7 @@
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 +508,7 @@
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 6abb3bb..f11230f 100644
--- a/test/core/end2end/tests/stream_compression_payload.cc
+++ b/test/core/end2end/tests/stream_compression_payload.cc
@@ -93,9 +93,9 @@
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,7 @@
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 +199,7 @@
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 +225,7 @@
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 8242c2c..6f57667 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,7 @@
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 +173,7 @@
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 +192,7 @@
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));
@@ -203,7 +203,7 @@
op->reserved = nullptr;
op++;
error =
- grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ 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);
@@ -216,7 +216,7 @@
op->reserved = nullptr;
op++;
error =
- grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
+ 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 +237,7 @@
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 +250,7 @@
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 167530a..e679205 100644
--- a/test/core/end2end/tests/streaming_error_response.cc
+++ b/test/core/end2end/tests/streaming_error_response.cc
@@ -148,7 +148,7 @@
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 +165,7 @@
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 +179,7 @@
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 +190,7 @@
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 +208,7 @@
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 +225,7 @@
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 150c1cb..134baaa 100644
--- a/test/core/end2end/tests/trailing_metadata.cc
+++ b/test/core/end2end/tests/trailing_metadata.cc
@@ -184,7 +184,7 @@
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 +207,7 @@
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 +234,7 @@
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 edf03d8..3de326b 100644
--- a/test/core/end2end/tests/workaround_cronet_compression.cc
+++ b/test/core/end2end/tests/workaround_cronet_compression.cc
@@ -191,7 +191,7 @@
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 +227,7 @@
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 +246,7 @@
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));
@@ -257,7 +257,7 @@
op->reserved = nullptr;
op++;
error =
- grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), nullptr);
+ 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);
@@ -275,7 +275,7 @@
op->reserved = nullptr;
op++;
error =
- grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr);
+ 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 +308,7 @@
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 +321,7 @@
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 7f3d1ab..35ab72c 100644
--- a/test/core/end2end/tests/write_buffering.cc
+++ b/test/core/end2end/tests/write_buffering.cc
@@ -128,7 +128,7 @@
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 +138,7 @@
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 +154,7 @@
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 +162,7 @@
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 +171,7 @@
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 +186,7 @@
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 +200,7 @@
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 +219,7 @@
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 +236,7 @@
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 a1fbfef..fffb029 100644
--- a/test/core/end2end/tests/write_buffering_at_end.cc
+++ b/test/core/end2end/tests/write_buffering_at_end.cc
@@ -125,7 +125,7 @@
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 +135,7 @@
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 +151,7 @@
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 +159,7 @@
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 +168,7 @@
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 +181,7 @@
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 +195,7 @@
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 +210,7 @@
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 +227,7 @@
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 92f59b7..0141e7e 100644
--- a/test/core/fling/client.cc
+++ b/test/core/fling/client.cc
@@ -127,7 +127,7 @@
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,7 @@
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 d5fd7a8..32bc989 100644
--- a/test/core/fling/fling_stream_test.cc
+++ b/test/core/fling/fling_stream_test.cc
@@ -37,7 +37,7 @@
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 d95317b..3587a4a 100644
--- a/test/core/fling/fling_test.cc
+++ b/test/core/fling/fling_test.cc
@@ -37,7 +37,7 @@
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 b19a25a..cad4a8f 100644
--- a/test/core/fling/server.cc
+++ b/test/core/fling/server.cc
@@ -112,7 +112,7 @@
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 +189,7 @@
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 bf4471c..1f6d596 100644
--- a/test/core/gpr/alloc_test.cc
+++ b/test/core/gpr/alloc_test.cc
@@ -27,7 +27,7 @@
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 087a800..c10d7ea 100644
--- a/test/core/gpr/arena_test.cc
+++ b/test/core/gpr/arena_test.cc
@@ -86,7 +86,7 @@
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 87cdc0f..46a1686 100644
--- a/test/core/gpr/cpu_test.cc
+++ b/test/core/gpr/cpu_test.cc
@@ -62,7 +62,7 @@
};
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 @@
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 58df2f1..333390e 100644
--- a/test/core/gpr/mpscq_test.cc
+++ b/test/core/gpr/mpscq_test.cc
@@ -49,7 +49,7 @@
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 @@
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 @@
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 d920dd3..2d2fa72 100644
--- a/test/core/gpr/murmur_hash_test.cc
+++ b/test/core/gpr/murmur_hash_test.cc
@@ -42,8 +42,8 @@
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 77e3dfb..d443684 100644
--- a/test/core/gpr/spinlock_test.cc
+++ b/test/core/gpr/spinlock_test.cc
@@ -46,7 +46,7 @@
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,27 @@
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 768f96d..abad930 100644
--- a/test/core/gpr/sync_test.cc
+++ b/test/core/gpr/sync_test.cc
@@ -236,11 +236,11 @@
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 +252,7 @@
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 +260,8 @@
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 b2b4dce..ef7a961 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 2302e3d..d04295a 100644
--- a/test/core/handshake/client_ssl.cc
+++ b/test/core/handshake/client_ssl.cc
@@ -68,7 +68,7 @@
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,7 @@
}
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 +98,19 @@
// 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 +133,7 @@
// 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 +175,7 @@
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 +243,9 @@
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 599e0e1..a4f182e 100644
--- a/test/core/handshake/readahead_handshaker_server_ssl.cc
+++ b/test/core/handshake/readahead_handshaker_server_ssl.cc
@@ -67,7 +67,7 @@
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 0bf453a..6ae2471 100644
--- a/test/core/handshake/server_ssl_common.cc
+++ b/test/core/handshake/server_ssl_common.cc
@@ -48,7 +48,7 @@
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 @@
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 @@
// 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,9 @@
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 +176,13 @@
// 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,7 +217,7 @@
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) !=
+ 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 3d892b9..346568f 100644
--- a/test/core/http/httpcli_test.cc
+++ b/test/core/http/httpcli_test.cc
@@ -157,14 +157,14 @@
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 7e99ad4..a38f306 100644
--- a/test/core/http/httpscli_test.cc
+++ b/test/core/http/httpscli_test.cc
@@ -157,14 +157,14 @@
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 4251f27..ad38076 100644
--- a/test/core/iomgr/endpoint_pair_test.cc
+++ b/test/core/iomgr/endpoint_pair_test.cc
@@ -38,7 +38,7 @@
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 842be8f..9719a90 100644
--- a/test/core/iomgr/endpoint_tests.cc
+++ b/test/core/iomgr/endpoint_tests.cc
@@ -77,7 +77,7 @@
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 +117,7 @@
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 +134,7 @@
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 +246,7 @@
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 07a69a2..5ae68d2 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 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 cf75517..092c880 100644
--- a/test/core/iomgr/fd_posix_test.cc
+++ b/test/core/iomgr/fd_posix_test.cc
@@ -78,7 +78,7 @@
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,7 @@
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 +335,7 @@
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 114f397..0dc75a5 100644
--- a/test/core/iomgr/pollset_set_test.cc
+++ b/test/core/iomgr/pollset_set_test.cc
@@ -103,7 +103,7 @@
} 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 07682d2..921a24e 100644
--- a/test/core/iomgr/resource_quota_test.cc
+++ b/test/core/iomgr/resource_quota_test.cc
@@ -29,7 +29,7 @@
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 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 a445714..51ac666 100644
--- a/test/core/iomgr/sockaddr_utils_test.cc
+++ b/test/core/iomgr/sockaddr_utils_test.cc
@@ -33,7 +33,7 @@
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 +45,7 @@
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 +56,7 @@
}
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 +143,7 @@
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 +151,7 @@
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 +159,7 @@
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 +234,7 @@
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 +260,7 @@
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 67391a5..8523704 100644
--- a/test/core/iomgr/socket_utils_test.cc
+++ b/test/core/iomgr/socket_utils_test.cc
@@ -43,7 +43,7 @@
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 +59,14 @@
}
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 +117,7 @@
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 40a050e..7ce30ca 100644
--- a/test/core/iomgr/tcp_client_posix_test.cc
+++ b/test/core/iomgr/tcp_client_posix_test.cc
@@ -78,7 +78,7 @@
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 +112,7 @@
/* 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 +136,7 @@
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 3a79b9b..b059ac4 100644
--- a/test/core/iomgr/tcp_posix_test.cc
+++ b/test/core/iomgr/tcp_posix_test.cc
@@ -74,7 +74,7 @@
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 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,7 @@
}
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 +172,7 @@
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 +222,7 @@
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 +232,7 @@
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 +262,7 @@
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 +284,7 @@
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 +295,7 @@
}
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 +325,7 @@
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 +358,7 @@
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 +395,7 @@
}
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 +426,7 @@
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 +515,7 @@
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 +533,7 @@
};
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 +542,7 @@
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 3c9ca21..c1b4f36 100644
--- a/test/core/iomgr/tcp_server_posix_test.cc
+++ b/test/core/iomgr/tcp_server_posix_test.cc
@@ -181,7 +181,7 @@
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 +200,7 @@
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 +225,7 @@
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 +237,7 @@
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 +286,9 @@
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 +305,8 @@
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),
+ (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 ed66b7d..08f5d63 100644
--- a/test/core/iomgr/timer_heap_test.cc
+++ b/test/core/iomgr/timer_heap_test.cc
@@ -102,7 +102,7 @@
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 @@
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 @@
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 @@
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 4c92a6b..f21af5d 100644
--- a/test/core/iomgr/udp_server_test.cc
+++ b/test/core/iomgr/udp_server_test.cc
@@ -65,7 +65,7 @@
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,16 @@
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*>(addr->addr), static_cast<socklen_t>(addr->len));
}
static int test_socket_factory_compare(grpc_socket_factory* a,
@@ -118,7 +118,7 @@
}
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 +173,7 @@
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 +196,7 @@
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 +231,7 @@
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 +256,7 @@
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 2d64520..a3f3f20 100644
--- a/test/core/iomgr/wakeup_fd_cv_test.cc
+++ b/test/core/iomgr/wakeup_fd_cv_test.cc
@@ -84,7 +84,7 @@
}
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 0319d15..da2f50e 100644
--- a/test/core/json/json_rewrite.cc
+++ b/test/core/json/json_rewrite.cc
@@ -86,7 +86,7 @@
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 @@
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 8846d46..2fade12 100644
--- a/test/core/json/json_rewrite_test.cc
+++ b/test/core/json/json_rewrite_test.cc
@@ -97,7 +97,7 @@
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 @@
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 4f2ca9e..96ff7ca 100644
--- a/test/core/memory_usage/client.cc
+++ b/test/core/memory_usage/client.cc
@@ -155,16 +155,16 @@
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);
@@ -285,7 +285,7 @@
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 -
+ 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",
@@ -297,7 +297,7 @@
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 -
+ 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",
@@ -310,14 +310,14 @@
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 -
+ 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,
- (double)(server_calls_inflight.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 -
diff --git a/test/core/memory_usage/memory_usage_test.cc b/test/core/memory_usage/memory_usage_test.cc
index cc3528b..c170f5a 100644
--- a/test/core/memory_usage/memory_usage_test.cc
+++ b/test/core/memory_usage/memory_usage_test.cc
@@ -37,7 +37,7 @@
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 a276102..f016fb2 100644
--- a/test/core/memory_usage/server.cc
+++ b/test/core/memory_usage/server.cc
@@ -73,7 +73,7 @@
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,7 @@
}
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 +111,7 @@
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 +163,7 @@
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 +204,7 @@
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 +281,7 @@
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 8fd2c75..52c423b 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 @@
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 @@
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 @@
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 @@
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 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 @@
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 @@
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 @@
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 bb8227f..7be4ba0 100644
--- a/test/core/security/create_jwt.cc
+++ b/test/core/security/create_jwt.cc
@@ -36,7 +36,7 @@
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 9031046..77f450b 100644
--- a/test/core/security/credentials_test.cc
+++ b/test/core/security/credentials_test.cc
@@ -140,7 +140,7 @@
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_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 @@
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,9 @@
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 +891,9 @@
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 +936,7 @@
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 +1015,7 @@
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 +1038,7 @@
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 +1046,7 @@
}
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 b0fa514..70a92d7 100644
--- a/test/core/security/fetch_oauth2.cc
+++ b/test/core/security/fetch_oauth2.cc
@@ -38,7 +38,7 @@
"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 aac9cc0..80bfe45 100644
--- a/test/core/security/json_token_test.cc
+++ b/test/core/security/json_token_test.cc
@@ -218,7 +218,7 @@
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);
@@ -386,20 +386,20 @@
const char* dot = strchr(jwt, '.');
GPR_ASSERT(dot != nullptr);
parsed_header =
- parse_json_part_from_jwt(jwt, (size_t)(dot - jwt), &scratchpad);
+ 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 e219260..2c454c1 100644
--- a/test/core/security/jwt_verifier_test.cc
+++ b/test/core/security/jwt_verifier_test.cc
@@ -207,7 +207,7 @@
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 @@
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_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 @@
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 @@
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 0d3a127..b18fa45 100644
--- a/test/core/security/oauth2_utils.cc
+++ b/test/core/security/oauth2_utils.cc
@@ -40,7 +40,7 @@
} 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 @@
} 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,7 @@
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 828694a..00e0783 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 @@
}
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,7 +97,7 @@
error = GRPC_ERROR_NONE;
if (grpc_call_credentials_get_request_metadata(
- ((grpc_composite_channel_credentials*)creds)->call_creds, &sync.pops,
+ (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);
diff --git a/test/core/security/secure_endpoint_test.cc b/test/core/security/secure_endpoint_test.cc
index 8e92a21..bacadec 100644
--- a/test/core/security/secure_endpoint_test.cc
+++ b/test/core/security/secure_endpoint_test.cc
@@ -57,7 +57,7 @@
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 @@
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,7 @@
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 +165,7 @@
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 +200,7 @@
}
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 +210,7 @@
{
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 747508f..2a4e7c7 100644
--- a/test/core/security/verify_jwt.cc
+++ b/test/core/security/verify_jwt.cc
@@ -55,7 +55,7 @@
char* claims_str;
GPR_ASSERT(claims != nullptr);
claims_str =
- grpc_json_dump_to_string((grpc_json*)grpc_jwt_claims_json(claims), 2);
+ 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 94785fd..6b29443 100644
--- a/test/core/slice/b64_test.cc
+++ b/test/core/slice/b64_test.cc
@@ -34,7 +34,7 @@
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 @@
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 @@
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 201ae27..1e4e95d 100644
--- a/test/core/slice/percent_encode_fuzzer.cc
+++ b/test/core/slice/percent_encode_fuzzer.cc
@@ -34,7 +34,7 @@
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 e40154d..5a49793 100644
--- a/test/core/slice/slice_test.cc
+++ b/test/core/slice/slice_test.cc
@@ -57,7 +57,7 @@
}
/* 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 @@
}
/* 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 @@
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 @@
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 @@
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 d97e98b..e501572 100644
--- a/test/core/surface/completion_queue_threading_test.cc
+++ b/test/core/surface/completion_queue_threading_test.cc
@@ -146,7 +146,7 @@
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 @@
}
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 @@
}
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 @@
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 @@
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 @@
/* 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 @@
/* 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 235d136..ffef966 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_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,7 @@
};
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 +107,7 @@
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 +117,11 @@
}
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);
@@ -245,7 +245,7 @@
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_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 4bf4056..0ff17ba 100644
--- a/test/core/surface/lame_client_test.cc
+++ b/test/core/surface/lame_client_test.cc
@@ -112,7 +112,7 @@
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 +128,7 @@
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 a40bd64..d3ba50a 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 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 7fb395d..39ae587 100644
--- a/test/core/transport/chttp2/settings_timeout_test.cc
+++ b/test/core/transport/chttp2/settings_timeout_test.cc
@@ -104,7 +104,7 @@
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 @@
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 @@
}
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 9b21cb2..773eb3a 100644
--- a/test/core/transport/chttp2/stream_map_test.cc
+++ b/test/core/transport/chttp2/stream_map_test.cc
@@ -78,7 +78,7 @@
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 @@
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 @@
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 @@
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 7d943fd..84029dc 100644
--- a/test/core/transport/metadata_test.cc
+++ b/test/core/transport/metadata_test.cc
@@ -240,8 +240,8 @@
}
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;
@@ -308,7 +308,7 @@
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_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 26e0785..8e4e566 100644
--- a/test/core/transport/timeout_encoding_test.cc
+++ b/test/core/transport/timeout_encoding_test.cc
@@ -103,20 +103,20 @@
}
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 (grpc_millis)x; }
+static grpc_millis millis_from_millis(int64_t x) { return static_cast<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 73643fc..d709077 100644
--- a/test/core/tsi/fake_transport_security_test.cc
+++ b/test/core/tsi/fake_transport_security_test.cc
@@ -102,7 +102,7 @@
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 +123,7 @@
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 bf54383..06780f0 100644
--- a/test/core/tsi/ssl_transport_security_test.cc
+++ b/test/core/tsi/ssl_transport_security_test.cc
@@ -81,7 +81,7 @@
} 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 +244,7 @@
}
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 +281,7 @@
}
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 +425,7 @@
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 +434,7 @@
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 +444,7 @@
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 +453,7 @@
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 +461,7 @@
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 +470,7 @@
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 +478,7 @@
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 +486,7 @@
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 +494,7 @@
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 +511,7 @@
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 +531,7 @@
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 +571,7 @@
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 +615,7 @@
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 3537366..ef3b630 100644
--- a/test/core/tsi/transport_security_test_lib.cc
+++ b/test/core/tsi/transport_security_test_lib.cc
@@ -144,7 +144,7 @@
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,
+ 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) {
@@ -288,7 +288,7 @@
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 +327,7 @@
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 +471,7 @@
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 20bce27..fd3959b 100644
--- a/test/core/util/cmdline.cc
+++ b/test/core/util/cmdline.cc
@@ -56,7 +56,7 @@
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 @@
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 @@
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 @@
}
break;
case ARGTYPE_STRING:
- *(char**)cl->cur_arg->value = str;
+ *static_cast<char**>(cl->cur_arg->value) = str;
break;
}
@@ -281,14 +281,14 @@
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 +305,7 @@
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 bb96fc7..0ec5f1d 100644
--- a/test/core/util/debugger_macros.cc
+++ b/test/core/util/debugger_macros.cc
@@ -54,5 +54,5 @@
}
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 b251827..6eb0342 100644
--- a/test/core/util/histogram.cc
+++ b/test/core/util/histogram.cc
@@ -57,7 +57,7 @@
/* 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,7 @@
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 +88,7 @@
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 +176,14 @@
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 32d7b89..4960fe0 100644
--- a/test/core/util/memory_counters.cc
+++ b/test/core/util/memory_counters.cc
@@ -48,13 +48,13 @@
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 @@
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 4b35a58..37a1b62 100644
--- a/test/core/util/mock_endpoint.cc
+++ b/test/core/util/mock_endpoint.cc
@@ -42,7 +42,7 @@
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_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 @@
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_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 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,7 @@
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 +132,7 @@
}
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 622642a..7ba6776 100644
--- a/test/core/util/parse_hexstring.cc
+++ b/test/core/util/parse_hexstring.cc
@@ -39,10 +39,10 @@
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 0da0765..38c23aa 100644
--- a/test/core/util/passthru_endpoint.cc
+++ b/test/core/util/passthru_endpoint.cc
@@ -55,7 +55,7 @@
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 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 @@
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_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,15 @@
}
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")
+ 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 +190,7 @@
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 +208,8 @@
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 9d02b67..4690727 100644
--- a/test/core/util/port.cc
+++ b/test/core/util/port.cc
@@ -76,7 +76,7 @@
}
num_chosen_ports++;
chosen_ports =
- (int*)gpr_realloc(chosen_ports, sizeof(int) * num_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 7e76c80..886951c 100644
--- a/test/core/util/port_server_client.cc
+++ b/test/core/util/port_server_client.cc
@@ -41,13 +41,13 @@
} 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 +71,7 @@
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 +127,7 @@
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 +158,7 @@
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 +201,7 @@
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 b5a7749..ea8fee4 100644
--- a/test/core/util/reconnect_server.cc
+++ b/test/core/util/reconnect_server.cc
@@ -62,7 +62,7 @@
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,7 +76,7 @@
} 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)) !=
+ } 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);
}
diff --git a/test/core/util/slice_splitter.cc b/test/core/util/slice_splitter.cc
index c92fc0a..e766c19 100644
--- a/test/core/util/slice_splitter.cc
+++ b/test/core/util/slice_splitter.cc
@@ -46,7 +46,7 @@
case GRPC_SLICE_SPLIT_IDENTITY:
*dst_slice_count = src_slice_count;
*dst_slices =
- (grpc_slice*)gpr_malloc(sizeof(grpc_slice) * src_slice_count);
+ 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 @@
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,7 @@
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 +114,7 @@
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 0f6c997..bb42ccb 100644
--- a/test/core/util/subprocess_posix.cc
+++ b/test/core/util/subprocess_posix.cc
@@ -52,8 +52,8 @@
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 +61,7 @@
_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 e381be6..5c01cfd 100644
--- a/test/core/util/test_config.cc
+++ b/test/core/util/test_config.cc
@@ -36,7 +36,7 @@
#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 @@
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,14 +365,14 @@
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_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_time_from_micros(grpc_test_slowdown_factor() * static_cast<int64_t>(1e3) * time_ms,
GPR_TIMESPAN));
}
diff --git a/test/core/util/test_tcp_server.cc b/test/core/util/test_tcp_server.cc
index b1b5297..1216934 100644
--- a/test/core/util/test_tcp_server.cc
+++ b/test/core/util/test_tcp_server.cc
@@ -54,12 +54,12 @@
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 54e1cf1..87a8d9c 100644
--- a/test/core/util/trickle_endpoint.cc
+++ b/test/core/util/trickle_endpoint.cc
@@ -48,7 +48,7 @@
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 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_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_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 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,7 @@
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 +166,16 @@
}
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 +195,7 @@
}
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);