aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/surface
diff options
context:
space:
mode:
authorGravatar Noah Eisen <ncteisen@google.com>2018-02-09 09:16:55 -0800
committerGravatar Noah Eisen <ncteisen@google.com>2018-02-09 09:16:55 -0800
commitbe82e64b3debcdb1d9ec6a149fc85af0d46bfb7e (patch)
treecc5e1234073eb250a2c319b5a4db2919fce060ea /test/core/surface
parent194436342137924b4fb7429bede037a4b5ec7edb (diff)
Autofix c casts to c++ casts
Diffstat (limited to 'test/core/surface')
-rw-r--r--test/core/surface/completion_queue_threading_test.cc18
-rw-r--r--test/core/surface/concurrent_connectivity_test.cc16
-rw-r--r--test/core/surface/lame_client_test.cc4
3 files changed, 19 insertions, 19 deletions
diff --git a/test/core/surface/completion_queue_threading_test.cc b/test/core/surface/completion_queue_threading_test.cc
index d97e98b7a4..e5015723f7 100644
--- a/test/core/surface/completion_queue_threading_test.cc
+++ b/test/core/surface/completion_queue_threading_test.cc
@@ -146,7 +146,7 @@ static void producer_thread(void* arg) {
int i;
gpr_log(GPR_INFO, "producer %d started", opt->id);
- gpr_event_set(&opt->on_started, (void*)(intptr_t)1);
+ gpr_event_set(&opt->on_started, (void*)static_cast<intptr_t>(1));
GPR_ASSERT(gpr_event_wait(opt->phase1, ten_seconds_time()));
gpr_log(GPR_INFO, "producer %d phase 1", opt->id);
@@ -155,13 +155,13 @@ static void producer_thread(void* arg) {
}
gpr_log(GPR_INFO, "producer %d phase 1 done", opt->id);
- gpr_event_set(&opt->on_phase1_done, (void*)(intptr_t)1);
+ gpr_event_set(&opt->on_phase1_done, (void*)static_cast<intptr_t>(1));
GPR_ASSERT(gpr_event_wait(opt->phase2, ten_seconds_time()));
gpr_log(GPR_INFO, "producer %d phase 2", opt->id);
for (i = 0; i < TEST_THREAD_EVENTS; i++) {
grpc_core::ExecCtx exec_ctx;
- grpc_cq_end_op(opt->cc, (void*)(intptr_t)1, GRPC_ERROR_NONE,
+ grpc_cq_end_op(opt->cc, (void*)static_cast<intptr_t>(1), GRPC_ERROR_NONE,
free_completion, nullptr,
static_cast<grpc_cq_completion*>(
gpr_malloc(sizeof(grpc_cq_completion))));
@@ -169,7 +169,7 @@ static void producer_thread(void* arg) {
}
gpr_log(GPR_INFO, "producer %d phase 2 done", opt->id);
- gpr_event_set(&opt->on_finished, (void*)(intptr_t)1);
+ gpr_event_set(&opt->on_finished, (void*)static_cast<intptr_t>(1));
}
static void consumer_thread(void* arg) {
@@ -177,13 +177,13 @@ static void consumer_thread(void* arg) {
grpc_event ev;
gpr_log(GPR_INFO, "consumer %d started", opt->id);
- gpr_event_set(&opt->on_started, (void*)(intptr_t)1);
+ gpr_event_set(&opt->on_started, (void*)static_cast<intptr_t>(1));
GPR_ASSERT(gpr_event_wait(opt->phase1, ten_seconds_time()));
gpr_log(GPR_INFO, "consumer %d phase 1", opt->id);
gpr_log(GPR_INFO, "consumer %d phase 1 done", opt->id);
- gpr_event_set(&opt->on_phase1_done, (void*)(intptr_t)1);
+ gpr_event_set(&opt->on_phase1_done, (void*)static_cast<intptr_t>(1));
GPR_ASSERT(gpr_event_wait(opt->phase2, ten_seconds_time()));
gpr_log(GPR_INFO, "consumer %d phase 2", opt->id);
@@ -197,7 +197,7 @@ static void consumer_thread(void* arg) {
break;
case GRPC_QUEUE_SHUTDOWN:
gpr_log(GPR_INFO, "consumer %d phase 2 done", opt->id);
- gpr_event_set(&opt->on_finished, (void*)(intptr_t)1);
+ gpr_event_set(&opt->on_finished, (void*)static_cast<intptr_t>(1));
return;
case GRPC_QUEUE_TIMEOUT:
gpr_log(GPR_ERROR, "Invalid timeout received");
@@ -240,7 +240,7 @@ static void test_threading(size_t producers, size_t consumers) {
/* start phase1: producers will pre-declare all operations they will
complete */
gpr_log(GPR_INFO, "start phase 1");
- gpr_event_set(&phase1, (void*)(intptr_t)1);
+ gpr_event_set(&phase1, (void*)static_cast<intptr_t>(1));
gpr_log(GPR_INFO, "wait phase 1");
for (i = 0; i < producers + consumers; i++) {
@@ -250,7 +250,7 @@ static void test_threading(size_t producers, size_t consumers) {
/* start phase2: operations will complete, and consumers will consume them */
gpr_log(GPR_INFO, "start phase 2");
- gpr_event_set(&phase2, (void*)(intptr_t)1);
+ gpr_event_set(&phase2, (void*)static_cast<intptr_t>(1));
/* in parallel, we shutdown the completion channel - all events should still
be consumed */
diff --git a/test/core/surface/concurrent_connectivity_test.cc b/test/core/surface/concurrent_connectivity_test.cc
index 235d136376..ffef966d86 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 @@ struct server_thread_args {
};
void server_thread(void* vargs) {
- struct server_thread_args* args = (struct server_thread_args*)vargs;
+ struct server_thread_args* args = static_cast<struct server_thread_args*>(vargs);
grpc_event ev;
gpr_timespec deadline =
grpc_timeout_milliseconds_to_deadline(SERVER_SHUTDOWN_TIMEOUT);
@@ -107,7 +107,7 @@ static void on_connect(void* vargs, grpc_endpoint* tcp,
grpc_pollset* accepting_pollset,
grpc_tcp_server_acceptor* acceptor) {
gpr_free(acceptor);
- struct server_thread_args* args = (struct server_thread_args*)vargs;
+ struct server_thread_args* args = static_cast<struct server_thread_args*>(vargs);
grpc_endpoint_shutdown(tcp,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Connected"));
grpc_endpoint_destroy(tcp);
@@ -117,11 +117,11 @@ static void on_connect(void* vargs, grpc_endpoint* tcp,
}
void bad_server_thread(void* vargs) {
- struct server_thread_args* args = (struct server_thread_args*)vargs;
+ struct server_thread_args* args = static_cast<struct server_thread_args*>(vargs);
grpc_core::ExecCtx exec_ctx;
grpc_resolved_address resolved_addr;
- struct sockaddr_storage* addr = (struct sockaddr_storage*)resolved_addr.addr;
+ struct sockaddr_storage* addr = reinterpret_cast<struct sockaddr_storage*>(resolved_addr.addr);
int port;
grpc_tcp_server* s;
grpc_error* error = grpc_tcp_server_create(nullptr, nullptr, &s);
@@ -245,7 +245,7 @@ void watches_with_short_timeouts(void* addr) {
for (int i = 0; i < NUM_OUTER_LOOPS_SHORT_TIMEOUTS; ++i) {
grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr);
grpc_channel* chan =
- grpc_insecure_channel_create((char*)addr, nullptr, nullptr);
+ grpc_insecure_channel_create(static_cast<char*>(addr), nullptr, nullptr);
for (int j = 0; j < NUM_INNER_LOOPS_SHORT_TIMEOUTS; ++j) {
gpr_timespec later_time =
diff --git a/test/core/surface/lame_client_test.cc b/test/core/surface/lame_client_test.cc
index 4bf40569e6..0ff17ba8d0 100644
--- a/test/core/surface/lame_client_test.cc
+++ b/test/core/surface/lame_client_test.cc
@@ -112,7 +112,7 @@ int main(int argc, char** argv) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(call, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(call, ops, static_cast<size_t>(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
/* the call should immediately fail */
@@ -128,7 +128,7 @@ int main(int argc, char** argv) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(call, ops, (size_t)(op - ops), tag(2), nullptr);
+ error = grpc_call_start_batch(call, ops, static_cast<size_t>(op - ops), tag(2), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
/* the call should immediately fail */