aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar Vijay Pai <vpai@google.com>2018-03-05 09:58:05 -0800
committerGravatar Vijay Pai <vpai@google.com>2018-03-05 16:35:10 -0800
commit7fed69b7ad10a06c2eedaaf0279f44f2bab0d85c (patch)
treecab05136a7422d5ce317fe7e7aa4f959f7e9f125 /test
parent673439d5bd2d1711c10e8c4d29ceee3e67d585fd (diff)
Use static_cast rather than reinterpret_cast whenever possible
Diffstat (limited to 'test')
-rw-r--r--test/core/end2end/cq_verifier_uv.cc4
-rw-r--r--test/core/surface/completion_queue_threading_test.cc2
-rw-r--r--test/core/util/mock_endpoint.cc19
-rw-r--r--test/cpp/qps/client_async.cc4
-rw-r--r--test/cpp/qps/server_async.cc6
-rw-r--r--test/cpp/util/slice_test.cc4
6 files changed, 18 insertions, 21 deletions
diff --git a/test/core/end2end/cq_verifier_uv.cc b/test/core/end2end/cq_verifier_uv.cc
index e23b3ae2a0..45d827ef61 100644
--- a/test/core/end2end/cq_verifier_uv.cc
+++ b/test/core/end2end/cq_verifier_uv.cc
@@ -58,7 +58,7 @@ static void timer_close_cb(uv_handle_t* handle) {
void cq_verifier_destroy(cq_verifier* v) {
cq_verify(v);
uv_close((uv_handle_t*)&v->timer, timer_close_cb);
- while (reinterpret_cast<timer_state>(v->timer.data) != TIMER_CLOSED) {
+ while (static_cast<timer_state>(v->timer.data) != TIMER_CLOSED) {
uv_run(uv_default_loop(), UV_RUN_NOWAIT);
}
gpr_free(v);
@@ -85,7 +85,7 @@ grpc_event cq_verifier_next_event(cq_verifier* v, int timeout_seconds) {
ev = grpc_completion_queue_next(v->cq, gpr_inf_past(GPR_CLOCK_MONOTONIC),
NULL);
// Stop the loop if the timer goes off or we get a non-timeout event
- while ((reinterpret_cast<timer_state>(v->timer.data) != TIMER_TRIGGERED) &&
+ while ((static_cast<timer_state>(v->timer.data) != TIMER_TRIGGERED) &&
ev.type == GRPC_QUEUE_TIMEOUT) {
uv_run(uv_default_loop(), UV_RUN_ONCE);
ev = grpc_completion_queue_next(v->cq, gpr_inf_past(GPR_CLOCK_MONOTONIC),
diff --git a/test/core/surface/completion_queue_threading_test.cc b/test/core/surface/completion_queue_threading_test.cc
index 9c8d8d8395..0b82803af6 100644
--- a/test/core/surface/completion_queue_threading_test.cc
+++ b/test/core/surface/completion_queue_threading_test.cc
@@ -219,7 +219,7 @@ static void test_threading(size_t producers, size_t consumers) {
"test_threading", producers, consumers);
/* start all threads: they will wait for phase1 */
- grpc_core::Thread* threads = reinterpret_cast<grpc_core::Thread*>(
+ grpc_core::Thread* threads = static_cast<grpc_core::Thread*>(
gpr_malloc(sizeof(*threads) * (producers + consumers)));
for (i = 0; i < producers + consumers; i++) {
gpr_event_init(&options[i].on_started);
diff --git a/test/core/util/mock_endpoint.cc b/test/core/util/mock_endpoint.cc
index adeff18ef0..1156cd5fc5 100644
--- a/test/core/util/mock_endpoint.cc
+++ b/test/core/util/mock_endpoint.cc
@@ -30,7 +30,7 @@
#include <grpc/support/string_util.h>
#include "src/core/lib/iomgr/sockaddr.h"
-typedef struct grpc_mock_endpoint {
+typedef struct mock_endpoint {
grpc_endpoint base;
gpr_mu mu;
void (*on_write)(grpc_slice slice);
@@ -38,11 +38,11 @@ typedef struct grpc_mock_endpoint {
grpc_slice_buffer* on_read_out;
grpc_closure* on_read;
grpc_resource_user* resource_user;
-} grpc_mock_endpoint;
+} mock_endpoint;
static void me_read(grpc_endpoint* ep, grpc_slice_buffer* slices,
grpc_closure* cb) {
- grpc_mock_endpoint* m = reinterpret_cast<grpc_mock_endpoint*>(ep);
+ mock_endpoint* m = reinterpret_cast<mock_endpoint*>(ep);
gpr_mu_lock(&m->mu);
if (m->read_buffer.count > 0) {
grpc_slice_buffer_swap(&m->read_buffer, slices);
@@ -56,7 +56,7 @@ static void me_read(grpc_endpoint* ep, grpc_slice_buffer* slices,
static void me_write(grpc_endpoint* ep, grpc_slice_buffer* slices,
grpc_closure* cb) {
- grpc_mock_endpoint* m = reinterpret_cast<grpc_mock_endpoint*>(ep);
+ mock_endpoint* m = reinterpret_cast<mock_endpoint*>(ep);
for (size_t i = 0; i < slices->count; i++) {
m->on_write(slices->slices[i]);
}
@@ -72,7 +72,7 @@ static void me_delete_from_pollset_set(grpc_endpoint* ep,
grpc_pollset_set* pollset) {}
static void me_shutdown(grpc_endpoint* ep, grpc_error* why) {
- grpc_mock_endpoint* m = reinterpret_cast<grpc_mock_endpoint*>(ep);
+ mock_endpoint* m = reinterpret_cast<mock_endpoint*>(ep);
gpr_mu_lock(&m->mu);
if (m->on_read) {
GRPC_CLOSURE_SCHED(m->on_read,
@@ -86,7 +86,7 @@ static void me_shutdown(grpc_endpoint* ep, grpc_error* why) {
}
static void me_destroy(grpc_endpoint* ep) {
- grpc_mock_endpoint* m = reinterpret_cast<grpc_mock_endpoint*>(ep);
+ mock_endpoint* m = reinterpret_cast<mock_endpoint*>(ep);
grpc_slice_buffer_destroy(&m->read_buffer);
grpc_resource_user_unref(m->resource_user);
gpr_free(m);
@@ -97,7 +97,7 @@ static char* me_get_peer(grpc_endpoint* ep) {
}
static grpc_resource_user* me_get_resource_user(grpc_endpoint* ep) {
- grpc_mock_endpoint* m = reinterpret_cast<grpc_mock_endpoint*>(ep);
+ mock_endpoint* m = reinterpret_cast<mock_endpoint*>(ep);
return m->resource_user;
}
@@ -118,8 +118,7 @@ static const grpc_endpoint_vtable vtable = {
grpc_endpoint* grpc_mock_endpoint_create(void (*on_write)(grpc_slice slice),
grpc_resource_quota* resource_quota) {
- grpc_mock_endpoint* m =
- static_cast<grpc_mock_endpoint*>(gpr_malloc(sizeof(*m)));
+ mock_endpoint* m = static_cast<mock_endpoint*>(gpr_malloc(sizeof(*m)));
m->base.vtable = &vtable;
char* name;
gpr_asprintf(&name, "mock_endpoint_%" PRIxPTR, (intptr_t)m);
@@ -133,7 +132,7 @@ grpc_endpoint* grpc_mock_endpoint_create(void (*on_write)(grpc_slice slice),
}
void grpc_mock_endpoint_put_read(grpc_endpoint* ep, grpc_slice slice) {
- grpc_mock_endpoint* m = reinterpret_cast<grpc_mock_endpoint*>(ep);
+ mock_endpoint* m = reinterpret_cast<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/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc
index e3fba36a7a..8215ecbf55 100644
--- a/test/cpp/qps/client_async.cc
+++ b/test/cpp/qps/client_async.cc
@@ -50,9 +50,9 @@ class ClientRpcContext {
// next state, return false if done. Collect stats when appropriate
virtual bool RunNextState(bool, HistogramEntry* entry) = 0;
virtual void StartNewClone(CompletionQueue* cq) = 0;
- static void* tag(ClientRpcContext* c) { return reinterpret_cast<void*>(c); }
+ static void* tag(ClientRpcContext* c) { return static_cast<void*>(c); }
static ClientRpcContext* detag(void* t) {
- return reinterpret_cast<ClientRpcContext*>(t);
+ return static_cast<ClientRpcContext*>(t);
}
virtual void Start(CompletionQueue* cq, const ClientConfig& config) = 0;
diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc
index b88b88445c..f1dfea24d8 100644
--- a/test/cpp/qps/server_async.cc
+++ b/test/cpp/qps/server_async.cc
@@ -240,11 +240,9 @@ class AsyncQpsServerTest final : public grpc::testing::Server {
private:
std::mutex mu_;
};
- static void* tag(ServerRpcContext* func) {
- return reinterpret_cast<void*>(func);
- }
+ static void* tag(ServerRpcContext* func) { return static_cast<void*>(func); }
static ServerRpcContext* detag(void* tag) {
- return reinterpret_cast<ServerRpcContext*>(tag);
+ return static_cast<ServerRpcContext*>(tag);
}
class ServerRpcContextUnaryImpl final : public ServerRpcContext {
diff --git a/test/cpp/util/slice_test.cc b/test/cpp/util/slice_test.cc
index c2e55f3374..5f0b9c17cc 100644
--- a/test/cpp/util/slice_test.cc
+++ b/test/cpp/util/slice_test.cc
@@ -67,7 +67,7 @@ TEST_F(SliceTest, StaticBuf) {
TEST_F(SliceTest, SliceNew) {
char* x = new char[strlen(kContent) + 1];
strcpy(x, kContent);
- Slice spp(x, strlen(x), [](void* p) { delete[] reinterpret_cast<char*>(p); });
+ Slice spp(x, strlen(x), [](void* p) { delete[] static_cast<char*>(p); });
CheckSlice(spp, kContent);
}
@@ -86,7 +86,7 @@ TEST_F(SliceTest, SliceNewWithUserData) {
strcpy(t->x, kContent);
Slice spp(t->x, strlen(t->x),
[](void* p) {
- auto* t = reinterpret_cast<stest*>(p);
+ auto* t = static_cast<stest*>(p);
delete[] t->x;
delete t;
},