aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp
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/cpp
parent194436342137924b4fb7429bede037a4b5ec7edb (diff)
Autofix c casts to c++ casts
Diffstat (limited to 'test/cpp')
-rw-r--r--test/cpp/codegen/proto_utils_test.cc4
-rw-r--r--test/cpp/common/alarm_test.cc20
-rw-r--r--test/cpp/end2end/async_end2end_test.cc2
-rw-r--r--test/cpp/end2end/end2end_test.cc2
-rw-r--r--test/cpp/end2end/filter_end2end_test.cc2
-rw-r--r--test/cpp/end2end/generic_end2end_test.cc2
-rw-r--r--test/cpp/end2end/hybrid_end2end_test.cc2
-rw-r--r--test/cpp/end2end/thread_stress_test.cc2
-rw-r--r--test/cpp/grpclb/grpclb_test.cc22
-rw-r--r--test/cpp/interop/interop_client.cc4
-rw-r--r--test/cpp/microbenchmarks/bm_chttp2_hpack.cc6
-rw-r--r--test/cpp/microbenchmarks/bm_cq_multiple_threads.cc4
-rw-r--r--test/cpp/microbenchmarks/fullstack_context_mutators.h4
-rw-r--r--test/cpp/microbenchmarks/fullstack_fixtures.h4
-rw-r--r--test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h24
-rw-r--r--test/cpp/microbenchmarks/fullstack_streaming_pump.h10
-rw-r--r--test/cpp/microbenchmarks/fullstack_unary_ping_pong.h2
-rw-r--r--test/cpp/microbenchmarks/helpers.cc6
-rw-r--r--test/cpp/performance/writes_per_rpc_test.cc4
-rw-r--r--test/cpp/qps/report.cc6
-rw-r--r--test/cpp/qps/server.h2
-rw-r--r--test/cpp/util/cli_call.cc2
-rw-r--r--test/cpp/util/proto_reflection_descriptor_database.cc2
23 files changed, 69 insertions, 69 deletions
diff --git a/test/cpp/codegen/proto_utils_test.cc b/test/cpp/codegen/proto_utils_test.cc
index cc355bb24a..d714e59b5d 100644
--- a/test/cpp/codegen/proto_utils_test.cc
+++ b/test/cpp/codegen/proto_utils_test.cc
@@ -103,7 +103,7 @@ void BufferWriterTest(int block_size, int total_size, int backup_size) {
ASSERT_GT(backup_size, 0);
}
for (int i = 0; i < write_size; i++) {
- ((uint8_t*)data)[i] = written_size % 128;
+ (static_cast<uint8_t*>(data))[i] = written_size % 128;
written_size++;
}
if (should_backup) {
@@ -130,7 +130,7 @@ void BufferWriterTest(int block_size, int total_size, int backup_size) {
}
TEST(WriterTest, TinyBlockTinyBackup) {
- for (int i = 2; i < (int)GRPC_SLICE_INLINED_SIZE; i++) {
+ for (int i = 2; i < static_cast<int>GRPC_SLICE_INLINED_SIZE; i++) {
BufferWriterTest(i, 256, 1);
}
}
diff --git a/test/cpp/common/alarm_test.cc b/test/cpp/common/alarm_test.cc
index 2a933a84c4..2dc2e4b36c 100644
--- a/test/cpp/common/alarm_test.cc
+++ b/test/cpp/common/alarm_test.cc
@@ -36,7 +36,7 @@ TEST(AlarmTest, RegularExpiry) {
void* output_tag;
bool ok;
const CompletionQueue::NextStatus status = cq.AsyncNext(
- (void**)&output_tag, &ok, grpc_timeout_seconds_to_deadline(2));
+ &output_tag, &ok, grpc_timeout_seconds_to_deadline(2));
EXPECT_EQ(status, CompletionQueue::GOT_EVENT);
EXPECT_TRUE(ok);
@@ -56,7 +56,7 @@ TEST(AlarmTest, MultithreadedRegularExpiry) {
});
std::thread t2([&cq, &ok, &output_tag, &status] {
- status = cq.AsyncNext((void**)&output_tag, &ok,
+ status = cq.AsyncNext(&output_tag, &ok,
grpc_timeout_seconds_to_deadline(2));
});
@@ -75,7 +75,7 @@ TEST(AlarmTest, DeprecatedRegularExpiry) {
void* output_tag;
bool ok;
const CompletionQueue::NextStatus status = cq.AsyncNext(
- (void**)&output_tag, &ok, grpc_timeout_seconds_to_deadline(2));
+ &output_tag, &ok, grpc_timeout_seconds_to_deadline(2));
EXPECT_EQ(status, CompletionQueue::GOT_EVENT);
EXPECT_TRUE(ok);
@@ -91,7 +91,7 @@ TEST(AlarmTest, MoveConstructor) {
void* output_tag;
bool ok;
const CompletionQueue::NextStatus status = cq.AsyncNext(
- (void**)&output_tag, &ok, grpc_timeout_seconds_to_deadline(2));
+ &output_tag, &ok, grpc_timeout_seconds_to_deadline(2));
EXPECT_EQ(status, CompletionQueue::GOT_EVENT);
EXPECT_TRUE(ok);
EXPECT_EQ(junk, output_tag);
@@ -108,7 +108,7 @@ TEST(AlarmTest, MoveAssignment) {
void* output_tag;
bool ok;
const CompletionQueue::NextStatus status = cq.AsyncNext(
- (void**)&output_tag, &ok, grpc_timeout_seconds_to_deadline(2));
+ &output_tag, &ok, grpc_timeout_seconds_to_deadline(2));
EXPECT_EQ(status, CompletionQueue::GOT_EVENT);
EXPECT_TRUE(ok);
@@ -126,7 +126,7 @@ TEST(AlarmTest, RegularExpiryChrono) {
void* output_tag;
bool ok;
const CompletionQueue::NextStatus status = cq.AsyncNext(
- (void**)&output_tag, &ok, grpc_timeout_seconds_to_deadline(2));
+ &output_tag, &ok, grpc_timeout_seconds_to_deadline(2));
EXPECT_EQ(status, CompletionQueue::GOT_EVENT);
EXPECT_TRUE(ok);
@@ -142,7 +142,7 @@ TEST(AlarmTest, ZeroExpiry) {
void* output_tag;
bool ok;
const CompletionQueue::NextStatus status = cq.AsyncNext(
- (void**)&output_tag, &ok, grpc_timeout_seconds_to_deadline(1));
+ &output_tag, &ok, grpc_timeout_seconds_to_deadline(1));
EXPECT_EQ(status, CompletionQueue::GOT_EVENT);
EXPECT_TRUE(ok);
@@ -158,7 +158,7 @@ TEST(AlarmTest, NegativeExpiry) {
void* output_tag;
bool ok;
const CompletionQueue::NextStatus status = cq.AsyncNext(
- (void**)&output_tag, &ok, grpc_timeout_seconds_to_deadline(1));
+ &output_tag, &ok, grpc_timeout_seconds_to_deadline(1));
EXPECT_EQ(status, CompletionQueue::GOT_EVENT);
EXPECT_TRUE(ok);
@@ -175,7 +175,7 @@ TEST(AlarmTest, Cancellation) {
void* output_tag;
bool ok;
const CompletionQueue::NextStatus status = cq.AsyncNext(
- (void**)&output_tag, &ok, grpc_timeout_seconds_to_deadline(1));
+ &output_tag, &ok, grpc_timeout_seconds_to_deadline(1));
EXPECT_EQ(status, CompletionQueue::GOT_EVENT);
EXPECT_FALSE(ok);
@@ -193,7 +193,7 @@ TEST(AlarmTest, SetDestruction) {
void* output_tag;
bool ok;
const CompletionQueue::NextStatus status = cq.AsyncNext(
- (void**)&output_tag, &ok, grpc_timeout_seconds_to_deadline(1));
+ &output_tag, &ok, grpc_timeout_seconds_to_deadline(1));
EXPECT_EQ(status, CompletionQueue::GOT_EVENT);
EXPECT_FALSE(ok);
diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc
index 482f0cb24f..7a4555edac 100644
--- a/test/cpp/end2end/async_end2end_test.cc
+++ b/test/cpp/end2end/async_end2end_test.cc
@@ -62,7 +62,7 @@ namespace testing {
namespace {
-void* tag(int i) { return (void*)(intptr_t)i; }
+void* tag(int i) { return (void*)static_cast<intptr_t>(i); }
int detag(void* p) { return static_cast<int>(reinterpret_cast<intptr_t>(p)); }
#ifdef GRPC_POSIX_SOCKET
diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc
index 967db4c57c..b658e7731a 100644
--- a/test/cpp/end2end/end2end_test.cc
+++ b/test/cpp/end2end/end2end_test.cc
@@ -347,7 +347,7 @@ static void SendRpc(grpc::testing::EchoTestService::Stub* stub, int num_rpcs,
for (int i = 0; i < num_rpcs; ++i) {
ClientContext context;
if (with_binary_metadata) {
- char bytes[8] = {'\0', '\1', '\2', '\3', '\4', '\5', '\6', (char)i};
+ char bytes[8] = {'\0', '\1', '\2', '\3', '\4', '\5', '\6', static_cast<char>(i)};
context.AddMetadata("custom-bin", grpc::string(bytes, 8));
}
context.set_compression_algorithm(GRPC_COMPRESS_GZIP);
diff --git a/test/cpp/end2end/filter_end2end_test.cc b/test/cpp/end2end/filter_end2end_test.cc
index 53e86addef..d11df3a143 100644
--- a/test/cpp/end2end/filter_end2end_test.cc
+++ b/test/cpp/end2end/filter_end2end_test.cc
@@ -50,7 +50,7 @@ namespace grpc {
namespace testing {
namespace {
-void* tag(int i) { return (void*)(intptr_t)i; }
+void* tag(int i) { return (void*)static_cast<intptr_t>(i); }
void verify_ok(CompletionQueue* cq, int i, bool expect_ok) {
bool ok;
diff --git a/test/cpp/end2end/generic_end2end_test.cc b/test/cpp/end2end/generic_end2end_test.cc
index dac5faed8f..c778b205e0 100644
--- a/test/cpp/end2end/generic_end2end_test.cc
+++ b/test/cpp/end2end/generic_end2end_test.cc
@@ -47,7 +47,7 @@ namespace grpc {
namespace testing {
namespace {
-void* tag(int i) { return (void*)(intptr_t)i; }
+void* tag(int i) { return (void*)static_cast<intptr_t>(i); }
void verify_ok(CompletionQueue* cq, int i, bool expect_ok) {
bool ok;
diff --git a/test/cpp/end2end/hybrid_end2end_test.cc b/test/cpp/end2end/hybrid_end2end_test.cc
index cb515533ed..38d6bfa83b 100644
--- a/test/cpp/end2end/hybrid_end2end_test.cc
+++ b/test/cpp/end2end/hybrid_end2end_test.cc
@@ -42,7 +42,7 @@ namespace testing {
namespace {
-void* tag(int i) { return (void*)(intptr_t)i; }
+void* tag(int i) { return (void*)static_cast<intptr_t>(i); }
bool VerifyReturnSuccess(CompletionQueue* cq, int i) {
void* got_tag;
diff --git a/test/cpp/end2end/thread_stress_test.cc b/test/cpp/end2end/thread_stress_test.cc
index 90b2eddbbb..79074d8e70 100644
--- a/test/cpp/end2end/thread_stress_test.cc
+++ b/test/cpp/end2end/thread_stress_test.cc
@@ -265,7 +265,7 @@ class CommonStressTestAsyncServer : public BaseClass {
service_.RequestEcho(contexts_[i].srv_ctx.get(),
&contexts_[i].recv_request,
contexts_[i].response_writer.get(), cq_.get(),
- cq_.get(), (void*)(intptr_t)i);
+ cq_.get(), (void*)static_cast<intptr_t>(i));
}
}
struct Context {
diff --git a/test/cpp/grpclb/grpclb_test.cc b/test/cpp/grpclb/grpclb_test.cc
index 06ab8c3ff8..e47842e526 100644
--- a/test/cpp/grpclb/grpclb_test.cc
+++ b/test/cpp/grpclb/grpclb_test.cc
@@ -198,7 +198,7 @@ static void start_lb_server(server_fixture* sf, int* ports, size_t nports,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(202), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(202), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(202), 1);
cq_verify(cqv);
@@ -230,7 +230,7 @@ static void start_lb_server(server_fixture* sf, int* ports, size_t nports,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(201), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(201), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
gpr_log(GPR_INFO, "LB Server[%s](%s) after tag 201", sf->servers_hostport,
sf->balancer_name);
@@ -256,7 +256,7 @@ static void start_lb_server(server_fixture* sf, int* ports, size_t nports,
op->reserved = nullptr;
op++;
error =
- grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(203), nullptr);
+ grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(203), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(203), 1);
cq_verify(cqv);
@@ -278,7 +278,7 @@ static void start_lb_server(server_fixture* sf, int* ports, size_t nports,
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(204), nullptr);
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(204), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(201), 1);
@@ -351,7 +351,7 @@ static void start_backend_server(server_fixture* sf) {
op->reserved = nullptr;
op++;
error =
- grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(101), nullptr);
+ grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(101), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
gpr_log(GPR_INFO, "Server[%s] after tag 101", sf->servers_hostport);
@@ -365,7 +365,7 @@ static void start_backend_server(server_fixture* sf) {
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);
ev = grpc_completion_queue_next(
sf->cq, grpc_timeout_seconds_to_deadline(3), nullptr);
@@ -394,7 +394,7 @@ static void start_backend_server(server_fixture* sf) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103),
+ error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(103),
nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
ev = grpc_completion_queue_next(
@@ -429,7 +429,7 @@ static void start_backend_server(server_fixture* sf) {
op->reserved = nullptr;
op++;
error =
- grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), nullptr);
+ grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), tag(104), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(101), 1);
@@ -493,7 +493,7 @@ static void perform_request(client_fixture* cf) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(1), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
for (i = 0; i < 4; i++) {
@@ -510,7 +510,7 @@ static void perform_request(client_fixture* cf) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(2), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(2), 1);
@@ -529,7 +529,7 @@ static void perform_request(client_fixture* cf) {
op->flags = 0;
op->reserved = nullptr;
op++;
- error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), nullptr);
+ error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), tag(3), nullptr);
GPR_ASSERT(GRPC_CALL_OK == error);
CQ_EXPECT_COMPLETION(cqv, tag(1), 1);
diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc
index 3051afa86b..2ea1d3f79a 100644
--- a/test/cpp/interop/interop_client.cc
+++ b/test/cpp/interop/interop_client.cc
@@ -875,7 +875,7 @@ bool InteropClient::DoCacheableUnary() {
// Create request with current timestamp
gpr_timespec ts = gpr_now(GPR_CLOCK_PRECISE);
- std::string timestamp = std::to_string((long long unsigned)ts.tv_nsec);
+ std::string timestamp = std::to_string(static_cast<long long unsigned>(ts.tv_nsec));
SimpleRequest request;
request.mutable_payload()->set_body(timestamp.c_str(), timestamp.size());
@@ -914,7 +914,7 @@ bool InteropClient::DoCacheableUnary() {
// Request 3
// Modify the request body so it will not get a cache hit
ts = gpr_now(GPR_CLOCK_PRECISE);
- timestamp = std::to_string((long long unsigned)ts.tv_nsec);
+ timestamp = std::to_string(static_cast<long long unsigned>(ts.tv_nsec));
SimpleRequest request1;
request1.mutable_payload()->set_body(timestamp.c_str(), timestamp.size());
ClientContext context3;
diff --git a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
index 4b7310389c..3fe709ff83 100644
--- a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
+++ b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
@@ -82,7 +82,7 @@ static void BM_HpackEncoderEncodeDeadline(benchmark::State& state) {
static_cast<uint32_t>(state.iterations()),
true,
false,
- (size_t)1024,
+ static_cast<size_t>(1024),
&stats,
};
grpc_chttp2_encode_header(&c, nullptr, 0, &b, &hopt, &outbuf);
@@ -131,7 +131,7 @@ static void BM_HpackEncoderEncodeHeader(benchmark::State& state) {
static_cast<uint32_t>(state.iterations()),
state.range(0) != 0,
Fixture::kEnableTrueBinary,
- (size_t)state.range(1),
+ static_cast<size_t>(state.range(1)),
&stats,
};
grpc_chttp2_encode_header(&c, nullptr, 0, &b, &hopt, &outbuf);
@@ -777,7 +777,7 @@ static void OnHeaderNew(void* user_data, grpc_mdelem md) {
if (GRPC_MDELEM_IS_INTERNED(md)) {
/* not already parsed: parse it now, and store the
* result away */
- cached_timeout = (grpc_millis*)gpr_malloc(sizeof(grpc_millis));
+ cached_timeout = static_cast<grpc_millis*>(gpr_malloc(sizeof(grpc_millis)));
*cached_timeout = timeout;
grpc_mdelem_set_user_data(md, free_timeout, cached_timeout);
}
diff --git a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
index 874c834931..7b236d94b6 100644
--- a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
+++ b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
@@ -38,7 +38,7 @@ namespace testing {
auto& force_library_initialization = Library::get();
-static void* g_tag = (void*)(intptr_t)10; // Some random number
+static void* g_tag = (void*)static_cast<intptr_t>(10); // Some random number
static grpc_completion_queue* g_cq;
static grpc_event_engine_vtable g_vtable;
static const grpc_event_engine_vtable* g_old_vtable;
@@ -75,7 +75,7 @@ static grpc_error* pollset_work(grpc_pollset* ps, grpc_pollset_worker** worker,
gpr_mu_unlock(&ps->mu);
GPR_ASSERT(grpc_cq_begin_op(g_cq, g_tag));
grpc_cq_end_op(g_cq, g_tag, GRPC_ERROR_NONE, cq_done_cb, nullptr,
- (grpc_cq_completion*)gpr_malloc(sizeof(grpc_cq_completion)));
+ static_cast<grpc_cq_completion*>(gpr_malloc(sizeof(grpc_cq_completion))));
grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(&ps->mu);
return GRPC_ERROR_NONE;
diff --git a/test/cpp/microbenchmarks/fullstack_context_mutators.h b/test/cpp/microbenchmarks/fullstack_context_mutators.h
index cafbeffdbe..3584280c48 100644
--- a/test/cpp/microbenchmarks/fullstack_context_mutators.h
+++ b/test/cpp/microbenchmarks/fullstack_context_mutators.h
@@ -72,7 +72,7 @@ class RandomBinaryMetadata {
grpc::string s;
s.reserve(length + 1);
for (int i = 0; i < length; i++) {
- s += (char)rand();
+ s += static_cast<char>(rand());
}
return s;
}
@@ -95,7 +95,7 @@ class RandomAsciiMetadata {
grpc::string s;
s.reserve(length + 1);
for (int i = 0; i < length; i++) {
- s += (char)(rand() % 26 + 'a');
+ s += static_cast<char>(rand() % 26 + 'a');
}
return s;
}
diff --git a/test/cpp/microbenchmarks/fullstack_fixtures.h b/test/cpp/microbenchmarks/fullstack_fixtures.h
index fdc04e51c6..ce9731b7a6 100644
--- a/test/cpp/microbenchmarks/fullstack_fixtures.h
+++ b/test/cpp/microbenchmarks/fullstack_fixtures.h
@@ -108,7 +108,7 @@ class FullstackFixture : public BaseFixture {
void AddToLabel(std::ostream& out, benchmark::State& state) {
BaseFixture::AddToLabel(out, state);
out << " polls/iter:"
- << (double)grpc_get_cq_poll_num(this->cq()->cq()) / state.iterations();
+ << static_cast<double>(grpc_get_cq_poll_num(this->cq()->cq())) / state.iterations();
}
ServerCompletionQueue* cq() { return cq_.get(); }
@@ -236,7 +236,7 @@ class EndpointPairFixture : public BaseFixture {
void AddToLabel(std::ostream& out, benchmark::State& state) {
BaseFixture::AddToLabel(out, state);
out << " polls/iter:"
- << (double)grpc_get_cq_poll_num(this->cq()->cq()) / state.iterations();
+ << static_cast<double>(grpc_get_cq_poll_num(this->cq()->cq())) / state.iterations();
}
ServerCompletionQueue* cq() { return cq_.get(); }
diff --git a/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h b/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h
index 0763d07855..f399949a32 100644
--- a/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h
+++ b/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h
@@ -83,7 +83,7 @@ static void BM_StreamingPingPong(benchmark::State& state) {
while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok);
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(need_tags & (1 << i));
need_tags &= ~(1 << i);
}
@@ -99,7 +99,7 @@ static void BM_StreamingPingPong(benchmark::State& state) {
while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok);
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
// If server recv is complete, start the server send operation
if (i == 1) {
@@ -122,7 +122,7 @@ static void BM_StreamingPingPong(benchmark::State& state) {
need_tags = (1 << 0) | (1 << 1) | (1 << 2);
while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(need_tags & (1 << i));
need_tags &= ~(1 << i);
}
@@ -175,7 +175,7 @@ static void BM_StreamingPingPongMsgs(benchmark::State& state) {
while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok);
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(need_tags & (1 << i));
need_tags &= ~(1 << i);
}
@@ -190,7 +190,7 @@ static void BM_StreamingPingPongMsgs(benchmark::State& state) {
while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok);
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
// If server recv is complete, start the server send operation
if (i == 1) {
@@ -210,7 +210,7 @@ static void BM_StreamingPingPongMsgs(benchmark::State& state) {
need_tags = (1 << 0) | (1 << 1) | (1 << 2);
while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(need_tags & (1 << i));
need_tags &= ~(1 << i);
}
@@ -297,10 +297,10 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) {
// established). It is necessary when client init metadata is
// coalesced
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
- while ((int)(intptr_t)t != 0) {
+ while (static_cast<int>((intptr_t)t) != 0) {
// In some cases tag:2 comes before tag:0 (write tag comes out
// first), this while loop is to make sure get tag:0.
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(await_tags & (1 << i));
await_tags &= ~(1 << i);
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
@@ -317,7 +317,7 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) {
while (await_tags != 0) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok);
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
// If server recv is complete, start the server send operation
if (i == 3) {
@@ -367,8 +367,8 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) {
// wait for server call data structure(call_hook, etc.) to be
// initialized, since initial metadata is corked.
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
- while ((int)(intptr_t)t != 0) {
- int i = (int)(intptr_t)t;
+ while (static_cast<int>((intptr_t)t) != 0) {
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(expect_tags & (1 << i));
expect_tags &= ~(1 << i);
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
@@ -385,7 +385,7 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) {
while (expect_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(expect_tags & (1 << i));
expect_tags &= ~(1 << i);
}
diff --git a/test/cpp/microbenchmarks/fullstack_streaming_pump.h b/test/cpp/microbenchmarks/fullstack_streaming_pump.h
index 9e826091ec..3623e373f6 100644
--- a/test/cpp/microbenchmarks/fullstack_streaming_pump.h
+++ b/test/cpp/microbenchmarks/fullstack_streaming_pump.h
@@ -62,7 +62,7 @@ static void BM_PumpStreamClientToServer(benchmark::State& state) {
while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok);
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(need_tags & (1 << i));
need_tags &= ~(1 << i);
}
@@ -85,7 +85,7 @@ static void BM_PumpStreamClientToServer(benchmark::State& state) {
need_tags = (1 << 0) | (1 << 1);
while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(need_tags & (1 << i));
need_tags &= ~(1 << i);
}
@@ -95,7 +95,7 @@ static void BM_PumpStreamClientToServer(benchmark::State& state) {
need_tags = (1 << 0) | (1 << 1);
while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(need_tags & (1 << i));
need_tags &= ~(1 << i);
}
@@ -131,7 +131,7 @@ static void BM_PumpStreamServerToClient(benchmark::State& state) {
while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok);
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(need_tags & (1 << i));
need_tags &= ~(1 << i);
}
@@ -154,7 +154,7 @@ static void BM_PumpStreamServerToClient(benchmark::State& state) {
need_tags = (1 << 0) | (1 << 1);
while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
- int i = (int)(intptr_t)t;
+ int i = static_cast<int>((intptr_t)t);
GPR_ASSERT(need_tags & (1 << i));
need_tags &= ~(1 << i);
}
diff --git a/test/cpp/microbenchmarks/fullstack_unary_ping_pong.h b/test/cpp/microbenchmarks/fullstack_unary_ping_pong.h
index d448938295..a85c33c320 100644
--- a/test/cpp/microbenchmarks/fullstack_unary_ping_pong.h
+++ b/test/cpp/microbenchmarks/fullstack_unary_ping_pong.h
@@ -91,7 +91,7 @@ static void BM_UnaryPingPong(benchmark::State& state) {
for (int i = (1 << 3) | (1 << 4); i != 0;) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok);
- int tagnum = (int)reinterpret_cast<intptr_t>(t);
+ int tagnum = static_cast<int>(reinterpret_cast<intptr_t>(t));
GPR_ASSERT(i & (1 << tagnum));
i -= 1 << tagnum;
}
diff --git a/test/cpp/microbenchmarks/helpers.cc b/test/cpp/microbenchmarks/helpers.cc
index a4c0a3a0ce..25a033f104 100644
--- a/test/cpp/microbenchmarks/helpers.cc
+++ b/test/cpp/microbenchmarks/helpers.cc
@@ -44,17 +44,17 @@ void TrackCounters::AddToLabel(std::ostream& out, benchmark::State& state) {
grpc_stats_diff(&stats_end, &stats_begin_, &stats);
for (int i = 0; i < GRPC_STATS_COUNTER_COUNT; i++) {
out << " " << grpc_stats_counter_name[i]
- << "/iter:" << ((double)stats.counters[i] / (double)state.iterations());
+ << "/iter:" << (static_cast<double>(stats.counters[i]) / static_cast<double>(state.iterations()));
}
for (int i = 0; i < GRPC_STATS_HISTOGRAM_COUNT; i++) {
std::ostringstream median_ss;
median_ss << grpc_stats_histogram_name[i] << "-median";
state.counters[median_ss.str()] = benchmark::Counter(
- grpc_stats_histo_percentile(&stats, (grpc_stats_histograms)i, 50.0));
+ grpc_stats_histo_percentile(&stats, static_cast<grpc_stats_histograms>(i), 50.0));
std::ostringstream tail_ss;
tail_ss << grpc_stats_histogram_name[i] << "-99p";
state.counters[tail_ss.str()] = benchmark::Counter(
- grpc_stats_histo_percentile(&stats, (grpc_stats_histograms)i, 99.0));
+ grpc_stats_histo_percentile(&stats, static_cast<grpc_stats_histograms>(i), 99.0));
}
#ifdef GPR_LOW_LEVEL_COUNTERS
grpc_memory_counters counters_at_end = grpc_memory_counters_snapshot();
diff --git a/test/cpp/performance/writes_per_rpc_test.cc b/test/cpp/performance/writes_per_rpc_test.cc
index b7d951a86e..0d0ab1891a 100644
--- a/test/cpp/performance/writes_per_rpc_test.cc
+++ b/test/cpp/performance/writes_per_rpc_test.cc
@@ -217,7 +217,7 @@ static double UnaryPingPong(int request_size, int response_size) {
for (int i = (1 << 3) | (1 << 4); i != 0;) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok);
- int tagnum = (int)reinterpret_cast<intptr_t>(t);
+ int tagnum = static_cast<int>(reinterpret_cast<intptr_t>(t));
GPR_ASSERT(i & (1 << tagnum));
i -= 1 << tagnum;
}
@@ -230,7 +230,7 @@ static double UnaryPingPong(int request_size, int response_size) {
}
double writes_per_iteration =
- (double)fixture->writes_performed() / (double)kIterations;
+ static_cast<double>(fixture->writes_performed()) / static_cast<double>(kIterations);
fixture.reset();
server_env[0]->~ServerEnv();
diff --git a/test/cpp/qps/report.cc b/test/cpp/qps/report.cc
index 42ebeff41d..863be40f2a 100644
--- a/test/cpp/qps/report.cc
+++ b/test/cpp/qps/report.cc
@@ -109,9 +109,9 @@ void GprLogReporter::ReportCoreStats(const char* name, int idx,
for (int i = 0; i < GRPC_STATS_HISTOGRAM_COUNT; i++) {
gpr_log(GPR_DEBUG, "%s[%d].%s = %.1lf/%.1lf/%.1lf (50/95/99%%-ile)", name,
idx, grpc_stats_histogram_name[i],
- grpc_stats_histo_percentile(&data, (grpc_stats_histograms)i, 50),
- grpc_stats_histo_percentile(&data, (grpc_stats_histograms)i, 95),
- grpc_stats_histo_percentile(&data, (grpc_stats_histograms)i, 99));
+ grpc_stats_histo_percentile(&data, static_cast<grpc_stats_histograms>(i), 50),
+ grpc_stats_histo_percentile(&data, static_cast<grpc_stats_histograms>(i), 95),
+ grpc_stats_histo_percentile(&data, static_cast<grpc_stats_histograms>(i), 99));
}
}
diff --git a/test/cpp/qps/server.h b/test/cpp/qps/server.h
index 9da33566dd..d772e709de 100644
--- a/test/cpp/qps/server.h
+++ b/test/cpp/qps/server.h
@@ -84,7 +84,7 @@ class Server {
}
payload->set_type(type);
// Don't waste time creating a new payload of identical size.
- if (payload->body().length() != (size_t)size) {
+ if (payload->body().length() != static_cast<size_t>(size)) {
std::unique_ptr<char[]> body(new char[size]());
payload->set_body(body.get(), size);
}
diff --git a/test/cpp/util/cli_call.cc b/test/cpp/util/cli_call.cc
index 3b0bb9eeba..6fc22f35ca 100644
--- a/test/cpp/util/cli_call.cc
+++ b/test/cpp/util/cli_call.cc
@@ -30,7 +30,7 @@
namespace grpc {
namespace testing {
namespace {
-void* tag(int i) { return (void*)(intptr_t)i; }
+void* tag(int i) { return (void*)static_cast<intptr_t>(i); }
} // namespace
Status CliCall::Call(std::shared_ptr<grpc::Channel> channel,
diff --git a/test/cpp/util/proto_reflection_descriptor_database.cc b/test/cpp/util/proto_reflection_descriptor_database.cc
index 42b1f4e75c..5c0bfb3727 100644
--- a/test/cpp/util/proto_reflection_descriptor_database.cc
+++ b/test/cpp/util/proto_reflection_descriptor_database.cc
@@ -50,7 +50,7 @@ ProtoReflectionDescriptorDatabase::~ProtoReflectionDescriptorDatabase() {
}
gpr_log(GPR_INFO,
"ServerReflectionInfo rpc failed. Error code: %d, details: %s",
- (int)status.error_code(), status.error_message().c_str());
+ static_cast<int>(status.error_code()), status.error_message().c_str());
}
}
}