diff options
Diffstat (limited to 'test/cpp')
31 files changed, 216 insertions, 216 deletions
diff --git a/test/cpp/codegen/proto_utils_test.cc b/test/cpp/codegen/proto_utils_test.cc index fd05c90e9d..2b853b1bea 100644 --- a/test/cpp/codegen/proto_utils_test.cc +++ b/test/cpp/codegen/proto_utils_test.cc @@ -63,7 +63,7 @@ TEST_F(ProtoUtilsTest, BackupNext) { EXPECT_TRUE(!peer.have_backup()); // On the next allocation, the slice is non-inlined. ASSERT_TRUE(writer.Next(&data, &size)); - EXPECT_TRUE(peer.slice().refcount != NULL); + EXPECT_TRUE(peer.slice().refcount != nullptr); // Cleanup. g_core_codegen_interface->grpc_byte_buffer_destroy(bp); diff --git a/test/cpp/common/auth_property_iterator_test.cc b/test/cpp/common/auth_property_iterator_test.cc index 4a097e8739..fce409aa2f 100644 --- a/test/cpp/common/auth_property_iterator_test.cc +++ b/test/cpp/common/auth_property_iterator_test.cc @@ -40,7 +40,7 @@ class TestAuthPropertyIterator : public AuthPropertyIterator { class AuthPropertyIteratorTest : public ::testing::Test { protected: void SetUp() override { - ctx_ = grpc_auth_context_create(NULL); + ctx_ = grpc_auth_context_create(nullptr); grpc_auth_context_add_cstring_property(ctx_, "name", "chapi"); grpc_auth_context_add_cstring_property(ctx_, "name", "chapo"); grpc_auth_context_add_cstring_property(ctx_, "foo", "bar"); diff --git a/test/cpp/common/secure_auth_context_test.cc b/test/cpp/common/secure_auth_context_test.cc index 0cc32c1853..7a0530c20a 100644 --- a/test/cpp/common/secure_auth_context_test.cc +++ b/test/cpp/common/secure_auth_context_test.cc @@ -42,7 +42,7 @@ TEST_F(SecureAuthContextTest, EmptyContext) { } TEST_F(SecureAuthContextTest, Properties) { - grpc_auth_context* ctx = grpc_auth_context_create(NULL); + grpc_auth_context* ctx = grpc_auth_context_create(nullptr); SecureAuthContext context(ctx, true); context.AddProperty("name", "chapi"); context.AddProperty("name", "chapo"); @@ -60,7 +60,7 @@ TEST_F(SecureAuthContextTest, Properties) { } TEST_F(SecureAuthContextTest, Iterators) { - grpc_auth_context* ctx = grpc_auth_context_create(NULL); + grpc_auth_context* ctx = grpc_auth_context_create(nullptr); SecureAuthContext context(ctx, true); context.AddProperty("name", "chapi"); context.AddProperty("name", "chapo"); diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index 5b6e9aa312..1ea087e706 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -466,7 +466,7 @@ TEST_P(AsyncEnd2endTest, ReconnectChannel) { // It needs 2 pollset_works to reconnect the channel with polling engine // "poll" char* s = gpr_getenv("GRPC_POLL_STRATEGY"); - if (s != NULL && 0 == strcmp(s, "poll")) { + if (s != nullptr && 0 == strcmp(s, "poll")) { poller_slowdown_factor = 2; } gpr_free(s); diff --git a/test/cpp/end2end/client_lb_end2end_test.cc b/test/cpp/end2end/client_lb_end2end_test.cc index 95630a7714..894143cbc8 100644 --- a/test/cpp/end2end/client_lb_end2end_test.cc +++ b/test/cpp/end2end/client_lb_end2end_test.cc @@ -113,22 +113,22 @@ class ClientLbEnd2endTest : public ::testing::Test { void SetNextResolution(const std::vector<int>& ports) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_lb_addresses* addresses = grpc_lb_addresses_create(ports.size(), NULL); + grpc_lb_addresses* addresses = grpc_lb_addresses_create(ports.size(), nullptr); for (size_t i = 0; i < ports.size(); ++i) { char* lb_uri_str; gpr_asprintf(&lb_uri_str, "ipv4:127.0.0.1:%d", ports[i]); grpc_uri* lb_uri = grpc_uri_parse(&exec_ctx, lb_uri_str, true); - GPR_ASSERT(lb_uri != NULL); + GPR_ASSERT(lb_uri != nullptr); grpc_lb_addresses_set_address_from_uri(addresses, i, lb_uri, false /* is balancer */, - "" /* balancer name */, NULL); + "" /* balancer name */, nullptr); grpc_uri_destroy(lb_uri); gpr_free(lb_uri_str); } const grpc_arg fake_addresses = grpc_lb_addresses_create_channel_arg(addresses); grpc_channel_args* fake_result = - grpc_channel_args_copy_and_add(NULL, &fake_addresses, 1); + grpc_channel_args_copy_and_add(nullptr, &fake_addresses, 1); grpc_fake_resolver_response_generator_set_response( &exec_ctx, response_generator_, fake_result); grpc_channel_args_destroy(&exec_ctx, fake_result); diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index 82ca39466e..c71034bbe8 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -711,7 +711,7 @@ TEST_P(End2endTest, ReconnectChannel) { // It needs 2 pollset_works to reconnect the channel with polling engine // "poll" char* s = gpr_getenv("GRPC_POLL_STRATEGY"); - if (s != NULL && 0 == strcmp(s, "poll")) { + if (s != nullptr && 0 == strcmp(s, "poll")) { poller_slowdown_factor = 2; } gpr_free(s); @@ -1148,7 +1148,7 @@ TEST_P(End2endTest, ChannelState) { CompletionQueue cq; std::chrono::system_clock::time_point deadline = std::chrono::system_clock::now() + std::chrono::milliseconds(10); - channel_->NotifyOnStateChange(GRPC_CHANNEL_IDLE, deadline, &cq, NULL); + channel_->NotifyOnStateChange(GRPC_CHANNEL_IDLE, deadline, &cq, nullptr); void* tag; bool ok = true; cq.Next(&tag, &ok); diff --git a/test/cpp/grpclb/grpclb_api_test.cc b/test/cpp/grpclb/grpclb_api_test.cc index 6b0350e1f9..7b62080b49 100644 --- a/test/cpp/grpclb/grpclb_api_test.cc +++ b/test/cpp/grpclb/grpclb_api_test.cc @@ -48,7 +48,7 @@ grpc::string PackedStringToIp(const grpc_grpclb_ip_address& pb_ip) { } else { abort(); } - GPR_ASSERT(inet_ntop(af, (void*)pb_ip.bytes, ip_str, 46) != NULL); + GPR_ASSERT(inet_ntop(af, (void*)pb_ip.bytes, ip_str, 46) != nullptr); return ip_str; } diff --git a/test/cpp/grpclb/grpclb_test.cc b/test/cpp/grpclb/grpclb_test.cc index a7647344c0..1cc529991e 100644 --- a/test/cpp/grpclb/grpclb_test.cc +++ b/test/cpp/grpclb/grpclb_test.cc @@ -159,7 +159,7 @@ static void drain_cq(grpc_completion_queue* cq) { grpc_event ev; do { ev = grpc_completion_queue_next(cq, grpc_timeout_seconds_to_deadline(5), - NULL); + nullptr); } while (ev.type != GRPC_QUEUE_SHUTDOWN); } @@ -198,16 +198,16 @@ static void start_lb_server(server_fixture* sf, int* ports, size_t nports, // make sure we've received the initial metadata from the grpclb request. GPR_ASSERT(request_metadata_recv.count > 0); - GPR_ASSERT(request_metadata_recv.metadata != NULL); + GPR_ASSERT(request_metadata_recv.metadata != nullptr); // receive request for backends op = ops; op->op = GRPC_OP_RECV_MESSAGE; op->data.recv_message.recv_message = &request_payload_recv; op->flags = 0; - op->reserved = NULL; + op->reserved = nullptr; op++; - error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(202), NULL); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(202), nullptr); GPR_ASSERT(GRPC_CALL_OK == error); CQ_EXPECT_COMPLETION(cqv, tag(202), 1); cq_verify(cqv); @@ -232,14 +232,14 @@ static void start_lb_server(server_fixture* sf, int* ports, size_t nports, op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; op->flags = 0; - op->reserved = NULL; + op->reserved = nullptr; op++; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; op->data.recv_close_on_server.cancelled = &was_cancelled; op->flags = 0; - op->reserved = NULL; + op->reserved = nullptr; op++; - error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(201), NULL); + error = grpc_call_start_batch(s, ops, (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); @@ -262,9 +262,9 @@ static void start_lb_server(server_fixture* sf, int* ports, size_t nports, op->op = GRPC_OP_SEND_MESSAGE; op->data.send_message.send_message = response_payload; op->flags = 0; - op->reserved = NULL; + op->reserved = nullptr; op++; - error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(203), NULL); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(203), nullptr); GPR_ASSERT(GRPC_CALL_OK == error); CQ_EXPECT_COMPLETION(cqv, tag(203), 1); cq_verify(cqv); @@ -284,9 +284,9 @@ static void start_lb_server(server_fixture* sf, int* ports, size_t nports, grpc_slice status_details = grpc_slice_from_static_string("xyz"); op->data.send_status_from_server.status_details = &status_details; op->flags = 0; - op->reserved = NULL; + op->reserved = nullptr; op++; - error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(204), NULL); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(204), nullptr); GPR_ASSERT(GRPC_CALL_OK == error); CQ_EXPECT_COMPLETION(cqv, tag(201), 1); @@ -329,7 +329,7 @@ static void start_backend_server(server_fixture* sf) { GPR_ASSERT(GRPC_CALL_OK == error); gpr_log(GPR_INFO, "Server[%s] up", sf->servers_hostport); ev = grpc_completion_queue_next(sf->cq, - grpc_timeout_seconds_to_deadline(60), NULL); + grpc_timeout_seconds_to_deadline(60), nullptr); if (!ev.success) { gpr_log(GPR_INFO, "Server[%s] being torn down", sf->servers_hostport); cq_verifier_destroy(cqv); @@ -351,14 +351,14 @@ static void start_backend_server(server_fixture* sf) { op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; op->flags = 0; - op->reserved = NULL; + op->reserved = nullptr; op++; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; op->data.recv_close_on_server.cancelled = &was_cancelled; op->flags = 0; - op->reserved = NULL; + op->reserved = nullptr; op++; - error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(101), NULL); + error = grpc_call_start_batch(s, ops, (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); @@ -369,15 +369,15 @@ static void start_backend_server(server_fixture* sf) { op->op = GRPC_OP_RECV_MESSAGE; op->data.recv_message.recv_message = &request_payload_recv; op->flags = 0; - op->reserved = NULL; + op->reserved = nullptr; op++; - error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL); + error = grpc_call_start_batch(s, ops, (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), NULL); + sf->cq, grpc_timeout_seconds_to_deadline(3), nullptr); if (ev.type == GRPC_OP_COMPLETE && ev.success) { GPR_ASSERT(ev.tag = tag(102)); - if (request_payload_recv == NULL) { + if (request_payload_recv == nullptr) { exit = true; gpr_log(GPR_INFO, "Server[%s] recv \"close\" from client, exiting. Call #%d", @@ -398,13 +398,13 @@ static void start_backend_server(server_fixture* sf) { op->op = GRPC_OP_SEND_MESSAGE; op->data.send_message.send_message = response_payload; op->flags = 0; - op->reserved = NULL; + op->reserved = nullptr; op++; error = - grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL); + grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), nullptr); GPR_ASSERT(GRPC_CALL_OK == error); ev = grpc_completion_queue_next( - sf->cq, grpc_timeout_seconds_to_deadline(3), NULL); + sf->cq, grpc_timeout_seconds_to_deadline(3), nullptr); if (ev.type == GRPC_OP_COMPLETE && ev.success) { GPR_ASSERT(ev.tag = tag(103)); } else { @@ -432,9 +432,9 @@ static void start_backend_server(server_fixture* sf) { grpc_slice_from_static_string("Backend server out a-ok"); op->data.send_status_from_server.status_details = &status_details; op->flags = 0; - op->reserved = NULL; + op->reserved = nullptr; op++; - error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), NULL); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), nullptr); GPR_ASSERT(GRPC_CALL_OK == error); CQ_EXPECT_COMPLETION(cqv, tag(101), 1); @@ -469,10 +469,10 @@ static void perform_request(client_fixture* cf) { grpc_slice_from_copied_string("hello world"); grpc_slice host = grpc_slice_from_static_string("foo.test.google.fr:1234"); - c = grpc_channel_create_call(cf->client, NULL, GRPC_PROPAGATE_DEFAULTS, + c = grpc_channel_create_call(cf->client, nullptr, GRPC_PROPAGATE_DEFAULTS, cf->cq, grpc_slice_from_static_string("/foo"), &host, grpc_timeout_seconds_to_deadline(5), - NULL); + nullptr); gpr_log(GPR_INFO, "Call 0x%" PRIxPTR " created", (intptr_t)c); GPR_ASSERT(c); char* peer; @@ -484,21 +484,21 @@ static void perform_request(client_fixture* cf) { op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; op->flags = 0; - op->reserved = NULL; + op->reserved = nullptr; op++; op->op = GRPC_OP_RECV_INITIAL_METADATA; op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; op->flags = 0; - op->reserved = NULL; + op->reserved = nullptr; op++; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv; op->data.recv_status_on_client.status = &status; op->data.recv_status_on_client.status_details = &details; op->flags = 0; - op->reserved = NULL; + op->reserved = nullptr; op++; - error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL); + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), nullptr); GPR_ASSERT(GRPC_CALL_OK == error); for (i = 0; i < 4; i++) { @@ -508,14 +508,14 @@ static void perform_request(client_fixture* cf) { op->op = GRPC_OP_SEND_MESSAGE; op->data.send_message.send_message = request_payload; op->flags = 0; - op->reserved = NULL; + op->reserved = nullptr; op++; op->op = GRPC_OP_RECV_MESSAGE; op->data.recv_message.recv_message = &response_payload_recv; op->flags = 0; - op->reserved = NULL; + op->reserved = nullptr; op++; - error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), NULL); + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), nullptr); GPR_ASSERT(GRPC_CALL_OK == error); CQ_EXPECT_COMPLETION(cqv, tag(2), 1); @@ -532,9 +532,9 @@ static void perform_request(client_fixture* cf) { op = ops; op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; op->flags = 0; - op->reserved = NULL; + op->reserved = nullptr; op++; - error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), NULL); + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), nullptr); GPR_ASSERT(GRPC_CALL_OK == error); CQ_EXPECT_COMPLETION(cqv, tag(1), 1); @@ -560,20 +560,20 @@ static void setup_client(const server_fixture* lb_server, const server_fixture* backends, client_fixture* cf) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - char* expected_target_names = NULL; + char* expected_target_names = nullptr; const char* backends_name = lb_server->servers_hostport; gpr_asprintf(&expected_target_names, "%s;%s", backends_name, BALANCERS_NAME); grpc_fake_resolver_response_generator* response_generator = grpc_fake_resolver_response_generator_create(); - grpc_lb_addresses* addresses = grpc_lb_addresses_create(1, NULL); + grpc_lb_addresses* addresses = grpc_lb_addresses_create(1, nullptr); char* lb_uri_str; gpr_asprintf(&lb_uri_str, "ipv4:%s", lb_server->servers_hostport); grpc_uri* lb_uri = grpc_uri_parse(&exec_ctx, lb_uri_str, true); - GPR_ASSERT(lb_uri != NULL); + GPR_ASSERT(lb_uri != nullptr); grpc_lb_addresses_set_address_from_uri(addresses, 0, lb_uri, true, - lb_server->balancer_name, NULL); + lb_server->balancer_name, nullptr); grpc_uri_destroy(lb_uri); gpr_free(lb_uri_str); @@ -581,7 +581,7 @@ static void setup_client(const server_fixture* lb_server, const grpc_arg fake_addresses = grpc_lb_addresses_create_channel_arg(addresses); grpc_channel_args* fake_result = - grpc_channel_args_copy_and_add(NULL, &fake_addresses, 1); + grpc_channel_args_copy_and_add(nullptr, &fake_addresses, 1); grpc_lb_addresses_destroy(&exec_ctx, addresses); const grpc_arg new_args[] = { @@ -589,14 +589,14 @@ static void setup_client(const server_fixture* lb_server, grpc_fake_resolver_response_generator_arg(response_generator)}; grpc_channel_args* args = - grpc_channel_args_copy_and_add(NULL, new_args, GPR_ARRAY_SIZE(new_args)); + grpc_channel_args_copy_and_add(nullptr, new_args, GPR_ARRAY_SIZE(new_args)); gpr_free(expected_target_names); - cf->cq = grpc_completion_queue_create_for_next(NULL); + cf->cq = grpc_completion_queue_create_for_next(nullptr); grpc_channel_credentials* fake_creds = grpc_fake_transport_security_credentials_create(); cf->client = - grpc_secure_channel_create(fake_creds, cf->server_uri, args, NULL); + grpc_secure_channel_create(fake_creds, cf->server_uri, args, nullptr); grpc_fake_resolver_response_generator_set_response( &exec_ctx, response_generator, fake_result); grpc_channel_args_destroy(&exec_ctx, fake_result); @@ -610,16 +610,16 @@ static void teardown_client(client_fixture* cf) { grpc_completion_queue_shutdown(cf->cq); drain_cq(cf->cq); grpc_completion_queue_destroy(cf->cq); - cf->cq = NULL; + cf->cq = nullptr; grpc_channel_destroy(cf->client); - cf->client = NULL; + cf->client = nullptr; gpr_free(cf->server_uri); } static void setup_server(const char* host, server_fixture* sf) { int assigned_port; - sf->cq = grpc_completion_queue_create_for_next(NULL); + sf->cq = grpc_completion_queue_create_for_next(nullptr); const char* colon_idx = strchr(host, ':'); if (colon_idx) { const char* port_str = colon_idx + 1; @@ -633,8 +633,8 @@ static void setup_server(const char* host, server_fixture* sf) { grpc_server_credentials* server_creds = grpc_fake_transport_security_server_credentials_create(); - sf->server = grpc_server_create(NULL, NULL); - grpc_server_register_completion_queue(sf->server, sf->cq, NULL); + sf->server = grpc_server_create(nullptr, nullptr); + grpc_server_register_completion_queue(sf->server, sf->cq, nullptr); GPR_ASSERT((assigned_port = grpc_server_add_secure_http2_port( sf->server, sf->servers_hostport, server_creds)) > 0); grpc_server_credentials_release(server_creds); @@ -648,17 +648,17 @@ static void teardown_server(server_fixture* sf) { gpr_log(GPR_INFO, "Server[%s] shutting down", sf->servers_hostport); grpc_completion_queue* shutdown_cq = - grpc_completion_queue_create_for_pluck(NULL); + grpc_completion_queue_create_for_pluck(nullptr); grpc_server_shutdown_and_notify(sf->server, shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(shutdown_cq, tag(1000), grpc_timeout_seconds_to_deadline(5), - NULL) + nullptr) .type == GRPC_OP_COMPLETE); grpc_completion_queue_destroy(shutdown_cq); grpc_server_destroy(sf->server); gpr_thd_join(sf->tid); - sf->server = NULL; + sf->server = nullptr; grpc_completion_queue_shutdown(sf->cq); drain_cq(sf->cq); grpc_completion_queue_destroy(sf->cq); diff --git a/test/cpp/interop/http2_client.cc b/test/cpp/interop/http2_client.cc index 1e04e57d09..2de7abcf17 100644 --- a/test/cpp/interop/http2_client.cc +++ b/test/cpp/interop/http2_client.cc @@ -217,7 +217,7 @@ int main(int argc, char** argv) { "goaway", "max_streams", "ping", "rst_after_data", "rst_after_header", "rst_during_data"}; char* joined_testcases = - gpr_strjoin_sep(testcases, GPR_ARRAY_SIZE(testcases), "\n", NULL); + gpr_strjoin_sep(testcases, GPR_ARRAY_SIZE(testcases), "\n", nullptr); gpr_log(GPR_ERROR, "Unsupported test case %s. Valid options are\n%s", FLAGS_test_case.c_str(), joined_testcases); diff --git a/test/cpp/interop/stress_test.cc b/test/cpp/interop/stress_test.cc index 991fc88ad2..028ff11b20 100644 --- a/test/cpp/interop/stress_test.cc +++ b/test/cpp/interop/stress_test.cc @@ -230,7 +230,7 @@ int main(int argc, char** argv) { log_level = FLAGS_log_level; gpr_set_log_function(TestLogFunction); - srand(time(NULL)); + srand(time(nullptr)); // Parse the server addresses std::vector<grpc::string> server_addresses; diff --git a/test/cpp/microbenchmarks/bm_call_create.cc b/test/cpp/microbenchmarks/bm_call_create.cc index ec5c1275d1..8102470d54 100644 --- a/test/cpp/microbenchmarks/bm_call_create.cc +++ b/test/cpp/microbenchmarks/bm_call_create.cc @@ -91,7 +91,7 @@ class InsecureChannel : public BaseChannelFixture { public: InsecureChannel() : BaseChannelFixture( - grpc_insecure_channel_create("localhost:1234", NULL, NULL)) {} + grpc_insecure_channel_create("localhost:1234", nullptr, nullptr)) {} }; class LameChannel : public BaseChannelFixture { @@ -105,14 +105,14 @@ template <class Fixture> static void BM_CallCreateDestroy(benchmark::State& state) { TrackCounters track_counters; Fixture fixture; - grpc_completion_queue* cq = grpc_completion_queue_create_for_next(NULL); + grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr); gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); void* method_hdl = - grpc_channel_register_call(fixture.channel(), "/foo/bar", NULL, NULL); + grpc_channel_register_call(fixture.channel(), "/foo/bar", nullptr, nullptr); while (state.KeepRunning()) { grpc_call_unref(grpc_channel_create_registered_call( - fixture.channel(), NULL, GRPC_PROPAGATE_DEFAULTS, cq, method_hdl, - deadline, NULL)); + fixture.channel(), nullptr, GRPC_PROPAGATE_DEFAULTS, cq, method_hdl, + deadline, nullptr)); } grpc_completion_queue_destroy(cq); track_counters.Finish(state); @@ -161,7 +161,7 @@ static void BM_LameChannelCallCreateCore(benchmark::State& state) { grpc_completion_queue* cq; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; - grpc_byte_buffer* response_payload_recv = NULL; + grpc_byte_buffer* response_payload_recv = nullptr; grpc_status_code status; grpc_slice details; grpc::testing::EchoRequest send_request; @@ -170,14 +170,14 @@ static void BM_LameChannelCallCreateCore(benchmark::State& state) { channel = grpc_lame_client_channel_create( "localhost:1234", GRPC_STATUS_UNAUTHENTICATED, "blah"); - cq = grpc_completion_queue_create_for_next(NULL); + cq = grpc_completion_queue_create_for_next(nullptr); void* rc = grpc_channel_register_call( - channel, "/grpc.testing.EchoTestService/Echo", NULL, NULL); + channel, "/grpc.testing.EchoTestService/Echo", nullptr, nullptr); while (state.KeepRunning()) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); grpc_call* call = grpc_channel_create_registered_call( - channel, NULL, GRPC_PROPAGATE_DEFAULTS, cq, rc, - gpr_inf_future(GPR_CLOCK_REALTIME), NULL); + channel, nullptr, GRPC_PROPAGATE_DEFAULTS, cq, rc, + gpr_inf_future(GPR_CLOCK_REALTIME), nullptr); grpc_metadata_array_init(&initial_metadata_recv); grpc_metadata_array_init(&trailing_metadata_recv); grpc_byte_buffer* request_payload_send = @@ -210,9 +210,9 @@ static void BM_LameChannelCallCreateCore(benchmark::State& state) { GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call, ops, (size_t)(op - ops), - (void*)1, NULL)); + (void*)1, nullptr)); grpc_event ev = grpc_completion_queue_next( - cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); + cq, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr); GPR_ASSERT(ev.type != GRPC_QUEUE_SHUTDOWN); GPR_ASSERT(ev.success != 0); grpc_call_unref(call); @@ -235,7 +235,7 @@ static void BM_LameChannelCallCreateCoreSeparateBatch(benchmark::State& state) { grpc_completion_queue* cq; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; - grpc_byte_buffer* response_payload_recv = NULL; + grpc_byte_buffer* response_payload_recv = nullptr; grpc_status_code status; grpc_slice details; grpc::testing::EchoRequest send_request; @@ -244,14 +244,14 @@ static void BM_LameChannelCallCreateCoreSeparateBatch(benchmark::State& state) { channel = grpc_lame_client_channel_create( "localhost:1234", GRPC_STATUS_UNAUTHENTICATED, "blah"); - cq = grpc_completion_queue_create_for_next(NULL); + cq = grpc_completion_queue_create_for_next(nullptr); void* rc = grpc_channel_register_call( - channel, "/grpc.testing.EchoTestService/Echo", NULL, NULL); + channel, "/grpc.testing.EchoTestService/Echo", nullptr, nullptr); while (state.KeepRunning()) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); grpc_call* call = grpc_channel_create_registered_call( - channel, NULL, GRPC_PROPAGATE_DEFAULTS, cq, rc, - gpr_inf_future(GPR_CLOCK_REALTIME), NULL); + channel, nullptr, GRPC_PROPAGATE_DEFAULTS, cq, rc, + gpr_inf_future(GPR_CLOCK_REALTIME), nullptr); grpc_metadata_array_init(&initial_metadata_recv); grpc_metadata_array_init(&trailing_metadata_recv); grpc_byte_buffer* request_payload_send = @@ -271,7 +271,7 @@ static void BM_LameChannelCallCreateCoreSeparateBatch(benchmark::State& state) { op++; GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call, ops, (size_t)(op - ops), - (void*)0, NULL)); + (void*)nullptr, nullptr)); memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_INITIAL_METADATA; @@ -289,13 +289,13 @@ static void BM_LameChannelCallCreateCoreSeparateBatch(benchmark::State& state) { GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call, ops, (size_t)(op - ops), - (void*)1, NULL)); + (void*)1, nullptr)); grpc_event ev = grpc_completion_queue_next( - cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); + cq, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr); GPR_ASSERT(ev.type != GRPC_QUEUE_SHUTDOWN); GPR_ASSERT(ev.success == 0); ev = grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), - NULL); + nullptr); GPR_ASSERT(ev.type != GRPC_QUEUE_SHUTDOWN); GPR_ASSERT(ev.success != 0); grpc_call_unref(call); @@ -538,7 +538,7 @@ static void BM_IsolatedFilter(benchmark::State& state) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; size_t channel_size = grpc_channel_stack_size( - filters.size() == 0 ? NULL : &filters[0], filters.size()); + filters.size() == 0 ? nullptr : &filters[0], filters.size()); grpc_channel_stack* channel_stack = static_cast<grpc_channel_stack*>(gpr_zalloc(channel_size)); GPR_ASSERT(GRPC_LOG_IF_ERROR( @@ -559,8 +559,8 @@ static void BM_IsolatedFilter(benchmark::State& state) { TestOp test_op_data; grpc_call_element_args call_args; call_args.call_stack = call_stack; - call_args.server_transport_data = NULL; - call_args.context = NULL; + call_args.server_transport_data = nullptr; + call_args.context = nullptr; call_args.path = method; call_args.start_time = start_time; call_args.deadline = deadline; @@ -569,9 +569,9 @@ static void BM_IsolatedFilter(benchmark::State& state) { while (state.KeepRunning()) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); GRPC_ERROR_UNREF(grpc_call_stack_init(&exec_ctx, channel_stack, 1, - DoNothing, NULL, &call_args)); + DoNothing, nullptr, &call_args)); typename TestOp::Op op(&exec_ctx, &test_op_data, call_stack); - grpc_call_stack_destroy(&exec_ctx, call_stack, &final_info, NULL); + grpc_call_stack_destroy(&exec_ctx, call_stack, &final_info, nullptr); op.Finish(&exec_ctx); grpc_exec_ctx_flush(&exec_ctx); // recreate arena every 64k iterations to avoid oom @@ -708,14 +708,14 @@ class IsolatedCallFixture : public TrackCounters { grpc_channel_stack_builder_set_name(builder, "dummy"); grpc_channel_stack_builder_set_target(builder, "dummy_target"); GPR_ASSERT(grpc_channel_stack_builder_append_filter( - builder, &isolated_call_filter::isolated_call_filter, NULL, NULL)); + builder, &isolated_call_filter::isolated_call_filter, nullptr, nullptr)); { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; channel_ = grpc_channel_create_with_builder(&exec_ctx, builder, GRPC_CLIENT_CHANNEL); grpc_exec_ctx_finish(&exec_ctx); } - cq_ = grpc_completion_queue_create_for_next(NULL); + cq_ = grpc_completion_queue_create_for_next(nullptr); } void Finish(benchmark::State& state) { @@ -736,12 +736,12 @@ static void BM_IsolatedCall_NoOp(benchmark::State& state) { IsolatedCallFixture fixture; gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); void* method_hdl = - grpc_channel_register_call(fixture.channel(), "/foo/bar", NULL, NULL); + grpc_channel_register_call(fixture.channel(), "/foo/bar", nullptr, nullptr); while (state.KeepRunning()) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); grpc_call_unref(grpc_channel_create_registered_call( fixture.channel(), nullptr, GRPC_PROPAGATE_DEFAULTS, fixture.cq(), - method_hdl, deadline, NULL)); + method_hdl, deadline, nullptr)); } fixture.Finish(state); } @@ -751,10 +751,10 @@ static void BM_IsolatedCall_Unary(benchmark::State& state) { IsolatedCallFixture fixture; gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); void* method_hdl = - grpc_channel_register_call(fixture.channel(), "/foo/bar", NULL, NULL); + grpc_channel_register_call(fixture.channel(), "/foo/bar", nullptr, nullptr); grpc_slice slice = grpc_slice_from_static_string("hello world"); grpc_byte_buffer* send_message = grpc_raw_byte_buffer_create(&slice, 1); - grpc_byte_buffer* recv_message = NULL; + grpc_byte_buffer* recv_message = nullptr; grpc_status_code status_code; grpc_slice status_details = grpc_empty_slice(); grpc_metadata_array recv_initial_metadata; @@ -780,10 +780,10 @@ static void BM_IsolatedCall_Unary(benchmark::State& state) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); grpc_call* call = grpc_channel_create_registered_call( fixture.channel(), nullptr, GRPC_PROPAGATE_DEFAULTS, fixture.cq(), - method_hdl, deadline, NULL); - grpc_call_start_batch(call, ops, 6, tag(1), NULL); + method_hdl, deadline, nullptr); + grpc_call_start_batch(call, ops, 6, tag(1), nullptr); grpc_completion_queue_next(fixture.cq(), - gpr_inf_future(GPR_CLOCK_MONOTONIC), NULL); + gpr_inf_future(GPR_CLOCK_MONOTONIC), nullptr); grpc_call_unref(call); } fixture.Finish(state); @@ -797,7 +797,7 @@ static void BM_IsolatedCall_StreamingSend(benchmark::State& state) { IsolatedCallFixture fixture; gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); void* method_hdl = - grpc_channel_register_call(fixture.channel(), "/foo/bar", NULL, NULL); + grpc_channel_register_call(fixture.channel(), "/foo/bar", nullptr, nullptr); grpc_slice slice = grpc_slice_from_static_string("hello world"); grpc_byte_buffer* send_message = grpc_raw_byte_buffer_create(&slice, 1); grpc_metadata_array recv_initial_metadata; @@ -812,18 +812,18 @@ static void BM_IsolatedCall_StreamingSend(benchmark::State& state) { &recv_initial_metadata; grpc_call* call = grpc_channel_create_registered_call( fixture.channel(), nullptr, GRPC_PROPAGATE_DEFAULTS, fixture.cq(), - method_hdl, deadline, NULL); - grpc_call_start_batch(call, ops, 2, tag(1), NULL); + method_hdl, deadline, nullptr); + grpc_call_start_batch(call, ops, 2, tag(1), nullptr); grpc_completion_queue_next(fixture.cq(), gpr_inf_future(GPR_CLOCK_MONOTONIC), - NULL); + nullptr); memset(ops, 0, sizeof(ops)); ops[0].op = GRPC_OP_SEND_MESSAGE; ops[0].data.send_message.send_message = send_message; while (state.KeepRunning()) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); - grpc_call_start_batch(call, ops, 1, tag(2), NULL); + grpc_call_start_batch(call, ops, 1, tag(2), nullptr); grpc_completion_queue_next(fixture.cq(), - gpr_inf_future(GPR_CLOCK_MONOTONIC), NULL); + gpr_inf_future(GPR_CLOCK_MONOTONIC), nullptr); } grpc_call_unref(call); fixture.Finish(state); diff --git a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc index 45f5382fde..3fff8b02d6 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc @@ -85,7 +85,7 @@ static void BM_HpackEncoderEncodeDeadline(benchmark::State& state) { (size_t)1024, &stats, }; - grpc_chttp2_encode_header(&exec_ctx, &c, NULL, 0, &b, &hopt, &outbuf); + grpc_chttp2_encode_header(&exec_ctx, &c, nullptr, 0, &b, &hopt, &outbuf); grpc_slice_buffer_reset_and_unref_internal(&exec_ctx, &outbuf); grpc_exec_ctx_flush(&exec_ctx); } @@ -136,7 +136,7 @@ static void BM_HpackEncoderEncodeHeader(benchmark::State& state) { (size_t)state.range(1), &stats, }; - grpc_chttp2_encode_header(&exec_ctx, &c, NULL, 0, &b, &hopt, &outbuf); + grpc_chttp2_encode_header(&exec_ctx, &c, nullptr, 0, &b, &hopt, &outbuf); if (!logged_representative_output && state.iterations() > 3) { logged_representative_output = true; for (size_t i = 0; i < outbuf.count; i++) { @@ -775,7 +775,7 @@ static void OnHeaderNew(grpc_exec_ctx* exec_ctx, void* user_data, grpc_millis* cached_timeout = static_cast<grpc_millis*>(grpc_mdelem_get_user_data(md, free_timeout)); grpc_millis timeout; - if (cached_timeout != NULL) { + if (cached_timeout != nullptr) { timeout = *cached_timeout; } else { if (!grpc_http2_decode_timeout(GRPC_MDVALUE(md), &timeout)) { diff --git a/test/cpp/microbenchmarks/bm_chttp2_transport.cc b/test/cpp/microbenchmarks/bm_chttp2_transport.cc index 154cc91778..b95ee0cc01 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_transport.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_transport.cc @@ -100,7 +100,7 @@ class DummyEndpoint : public grpc_endpoint { GRPC_CLOSURE_SCHED(exec_ctx, cb, GRPC_ERROR_NONE); } - static grpc_workqueue* get_workqueue(grpc_endpoint* ep) { return NULL; } + static grpc_workqueue* get_workqueue(grpc_endpoint* ep) { return nullptr; } static void add_to_pollset(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, grpc_pollset* pollset) {} @@ -137,7 +137,7 @@ class Fixture { grpc_channel_args c_args = args.c_channel_args(); ep_ = new DummyEndpoint; t_ = grpc_create_chttp2_transport(exec_ctx(), &c_args, ep_, client); - grpc_chttp2_transport_start_reading(exec_ctx(), t_, NULL); + grpc_chttp2_transport_start_reading(exec_ctx(), t_, nullptr); FlushExecCtx(); } @@ -222,7 +222,7 @@ class Stream { } grpc_transport_init_stream(f_->exec_ctx(), f_->transport(), static_cast<grpc_stream*>(stream_), &refcount_, - NULL, arena_); + nullptr, arena_); } void DestroyThen(grpc_exec_ctx* exec_ctx, grpc_closure* closure) { @@ -586,7 +586,7 @@ static void BM_TransportStreamRecv(benchmark::State& state) { }); drain_start = MakeClosure([&](grpc_exec_ctx* exec_ctx, grpc_error* error) { - if (recv_stream == NULL) { + if (recv_stream == nullptr) { GPR_ASSERT(!state.KeepRunning()); return; } diff --git a/test/cpp/microbenchmarks/bm_closure.cc b/test/cpp/microbenchmarks/bm_closure.cc index 458a2ceb13..e603b70889 100644 --- a/test/cpp/microbenchmarks/bm_closure.cc +++ b/test/cpp/microbenchmarks/bm_closure.cc @@ -59,7 +59,7 @@ static void BM_ClosureInitAgainstExecCtx(benchmark::State& state) { grpc_closure c; while (state.KeepRunning()) { benchmark::DoNotOptimize( - GRPC_CLOSURE_INIT(&c, DoNothing, NULL, grpc_schedule_on_exec_ctx)); + GRPC_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_schedule_on_exec_ctx)); } track_counters.Finish(state); } @@ -72,7 +72,7 @@ static void BM_ClosureInitAgainstCombiner(benchmark::State& state) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; while (state.KeepRunning()) { benchmark::DoNotOptimize(GRPC_CLOSURE_INIT( - &c, DoNothing, NULL, grpc_combiner_scheduler(combiner))); + &c, DoNothing, nullptr, grpc_combiner_scheduler(combiner))); } GRPC_COMBINER_UNREF(&exec_ctx, combiner, "finished"); grpc_exec_ctx_finish(&exec_ctx); @@ -83,7 +83,7 @@ BENCHMARK(BM_ClosureInitAgainstCombiner); static void BM_ClosureRunOnExecCtx(benchmark::State& state) { TrackCounters track_counters; grpc_closure c; - GRPC_CLOSURE_INIT(&c, DoNothing, NULL, grpc_schedule_on_exec_ctx); + GRPC_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_schedule_on_exec_ctx); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; while (state.KeepRunning()) { GRPC_CLOSURE_RUN(&exec_ctx, &c, GRPC_ERROR_NONE); @@ -100,7 +100,7 @@ static void BM_ClosureCreateAndRun(benchmark::State& state) { while (state.KeepRunning()) { GRPC_CLOSURE_RUN( &exec_ctx, - GRPC_CLOSURE_CREATE(DoNothing, NULL, grpc_schedule_on_exec_ctx), + GRPC_CLOSURE_CREATE(DoNothing, nullptr, grpc_schedule_on_exec_ctx), GRPC_ERROR_NONE); } grpc_exec_ctx_finish(&exec_ctx); @@ -115,7 +115,7 @@ static void BM_ClosureInitAndRun(benchmark::State& state) { while (state.KeepRunning()) { GRPC_CLOSURE_RUN( &exec_ctx, - GRPC_CLOSURE_INIT(&c, DoNothing, NULL, grpc_schedule_on_exec_ctx), + GRPC_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_schedule_on_exec_ctx), GRPC_ERROR_NONE); } grpc_exec_ctx_finish(&exec_ctx); @@ -126,7 +126,7 @@ BENCHMARK(BM_ClosureInitAndRun); static void BM_ClosureSchedOnExecCtx(benchmark::State& state) { TrackCounters track_counters; grpc_closure c; - GRPC_CLOSURE_INIT(&c, DoNothing, NULL, grpc_schedule_on_exec_ctx); + GRPC_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_schedule_on_exec_ctx); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; while (state.KeepRunning()) { GRPC_CLOSURE_SCHED(&exec_ctx, &c, GRPC_ERROR_NONE); @@ -141,8 +141,8 @@ static void BM_ClosureSched2OnExecCtx(benchmark::State& state) { TrackCounters track_counters; grpc_closure c1; grpc_closure c2; - GRPC_CLOSURE_INIT(&c1, DoNothing, NULL, grpc_schedule_on_exec_ctx); - GRPC_CLOSURE_INIT(&c2, DoNothing, NULL, grpc_schedule_on_exec_ctx); + GRPC_CLOSURE_INIT(&c1, DoNothing, nullptr, grpc_schedule_on_exec_ctx); + GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr, grpc_schedule_on_exec_ctx); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; while (state.KeepRunning()) { GRPC_CLOSURE_SCHED(&exec_ctx, &c1, GRPC_ERROR_NONE); @@ -159,9 +159,9 @@ static void BM_ClosureSched3OnExecCtx(benchmark::State& state) { grpc_closure c1; grpc_closure c2; grpc_closure c3; - GRPC_CLOSURE_INIT(&c1, DoNothing, NULL, grpc_schedule_on_exec_ctx); - GRPC_CLOSURE_INIT(&c2, DoNothing, NULL, grpc_schedule_on_exec_ctx); - GRPC_CLOSURE_INIT(&c3, DoNothing, NULL, grpc_schedule_on_exec_ctx); + GRPC_CLOSURE_INIT(&c1, DoNothing, nullptr, grpc_schedule_on_exec_ctx); + GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr, grpc_schedule_on_exec_ctx); + GRPC_CLOSURE_INIT(&c3, DoNothing, nullptr, grpc_schedule_on_exec_ctx); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; while (state.KeepRunning()) { GRPC_CLOSURE_SCHED(&exec_ctx, &c1, GRPC_ERROR_NONE); @@ -182,7 +182,7 @@ static void BM_AcquireMutex(benchmark::State& state) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; while (state.KeepRunning()) { gpr_mu_lock(&mu); - DoNothing(&exec_ctx, NULL, GRPC_ERROR_NONE); + DoNothing(&exec_ctx, nullptr, GRPC_ERROR_NONE); gpr_mu_unlock(&mu); } grpc_exec_ctx_finish(&exec_ctx); @@ -198,7 +198,7 @@ static void BM_TryAcquireMutex(benchmark::State& state) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; while (state.KeepRunning()) { if (gpr_mu_trylock(&mu)) { - DoNothing(&exec_ctx, NULL, GRPC_ERROR_NONE); + DoNothing(&exec_ctx, nullptr, GRPC_ERROR_NONE); gpr_mu_unlock(&mu); } else { abort(); @@ -216,7 +216,7 @@ static void BM_AcquireSpinlock(benchmark::State& state) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; while (state.KeepRunning()) { gpr_spinlock_lock(&mu); - DoNothing(&exec_ctx, NULL, GRPC_ERROR_NONE); + DoNothing(&exec_ctx, nullptr, GRPC_ERROR_NONE); gpr_spinlock_unlock(&mu); } grpc_exec_ctx_finish(&exec_ctx); @@ -231,7 +231,7 @@ static void BM_TryAcquireSpinlock(benchmark::State& state) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; while (state.KeepRunning()) { if (gpr_spinlock_trylock(&mu)) { - DoNothing(&exec_ctx, NULL, GRPC_ERROR_NONE); + DoNothing(&exec_ctx, nullptr, GRPC_ERROR_NONE); gpr_spinlock_unlock(&mu); } else { abort(); @@ -246,7 +246,7 @@ static void BM_ClosureSchedOnCombiner(benchmark::State& state) { TrackCounters track_counters; grpc_combiner* combiner = grpc_combiner_create(); grpc_closure c; - GRPC_CLOSURE_INIT(&c, DoNothing, NULL, grpc_combiner_scheduler(combiner)); + GRPC_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_combiner_scheduler(combiner)); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; while (state.KeepRunning()) { GRPC_CLOSURE_SCHED(&exec_ctx, &c, GRPC_ERROR_NONE); @@ -263,8 +263,8 @@ static void BM_ClosureSched2OnCombiner(benchmark::State& state) { grpc_combiner* combiner = grpc_combiner_create(); grpc_closure c1; grpc_closure c2; - GRPC_CLOSURE_INIT(&c1, DoNothing, NULL, grpc_combiner_scheduler(combiner)); - GRPC_CLOSURE_INIT(&c2, DoNothing, NULL, grpc_combiner_scheduler(combiner)); + GRPC_CLOSURE_INIT(&c1, DoNothing, nullptr, grpc_combiner_scheduler(combiner)); + GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr, grpc_combiner_scheduler(combiner)); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; while (state.KeepRunning()) { GRPC_CLOSURE_SCHED(&exec_ctx, &c1, GRPC_ERROR_NONE); @@ -283,9 +283,9 @@ static void BM_ClosureSched3OnCombiner(benchmark::State& state) { grpc_closure c1; grpc_closure c2; grpc_closure c3; - GRPC_CLOSURE_INIT(&c1, DoNothing, NULL, grpc_combiner_scheduler(combiner)); - GRPC_CLOSURE_INIT(&c2, DoNothing, NULL, grpc_combiner_scheduler(combiner)); - GRPC_CLOSURE_INIT(&c3, DoNothing, NULL, grpc_combiner_scheduler(combiner)); + GRPC_CLOSURE_INIT(&c1, DoNothing, nullptr, grpc_combiner_scheduler(combiner)); + GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr, grpc_combiner_scheduler(combiner)); + GRPC_CLOSURE_INIT(&c3, DoNothing, nullptr, grpc_combiner_scheduler(combiner)); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; while (state.KeepRunning()) { GRPC_CLOSURE_SCHED(&exec_ctx, &c1, GRPC_ERROR_NONE); @@ -305,8 +305,8 @@ static void BM_ClosureSched2OnTwoCombiners(benchmark::State& state) { grpc_combiner* combiner2 = grpc_combiner_create(); grpc_closure c1; grpc_closure c2; - GRPC_CLOSURE_INIT(&c1, DoNothing, NULL, grpc_combiner_scheduler(combiner1)); - GRPC_CLOSURE_INIT(&c2, DoNothing, NULL, grpc_combiner_scheduler(combiner2)); + GRPC_CLOSURE_INIT(&c1, DoNothing, nullptr, grpc_combiner_scheduler(combiner1)); + GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr, grpc_combiner_scheduler(combiner2)); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; while (state.KeepRunning()) { GRPC_CLOSURE_SCHED(&exec_ctx, &c1, GRPC_ERROR_NONE); @@ -328,10 +328,10 @@ static void BM_ClosureSched4OnTwoCombiners(benchmark::State& state) { grpc_closure c2; grpc_closure c3; grpc_closure c4; - GRPC_CLOSURE_INIT(&c1, DoNothing, NULL, grpc_combiner_scheduler(combiner1)); - GRPC_CLOSURE_INIT(&c2, DoNothing, NULL, grpc_combiner_scheduler(combiner2)); - GRPC_CLOSURE_INIT(&c3, DoNothing, NULL, grpc_combiner_scheduler(combiner1)); - GRPC_CLOSURE_INIT(&c4, DoNothing, NULL, grpc_combiner_scheduler(combiner2)); + GRPC_CLOSURE_INIT(&c1, DoNothing, nullptr, grpc_combiner_scheduler(combiner1)); + GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr, grpc_combiner_scheduler(combiner2)); + GRPC_CLOSURE_INIT(&c3, DoNothing, nullptr, grpc_combiner_scheduler(combiner1)); + GRPC_CLOSURE_INIT(&c4, DoNothing, nullptr, grpc_combiner_scheduler(combiner2)); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; while (state.KeepRunning()) { GRPC_CLOSURE_SCHED(&exec_ctx, &c1, GRPC_ERROR_NONE); diff --git a/test/cpp/microbenchmarks/bm_cq.cc b/test/cpp/microbenchmarks/bm_cq.cc index dac702b08b..343681bb9b 100644 --- a/test/cpp/microbenchmarks/bm_cq.cc +++ b/test/cpp/microbenchmarks/bm_cq.cc @@ -47,7 +47,7 @@ static void BM_CreateDestroyCpp2(benchmark::State& state) { TrackCounters track_counters; while (state.KeepRunning()) { grpc_completion_queue* core_cq = - grpc_completion_queue_create_for_next(NULL); + grpc_completion_queue_create_for_next(nullptr); CompletionQueue cq(core_cq); } track_counters.Finish(state); @@ -59,7 +59,7 @@ static void BM_CreateDestroyCore(benchmark::State& state) { while (state.KeepRunning()) { // TODO: sreek Templatize this benchmark and pass completion type and // polling type as parameters - grpc_completion_queue_destroy(grpc_completion_queue_create_for_next(NULL)); + grpc_completion_queue_destroy(grpc_completion_queue_create_for_next(nullptr)); } track_counters.Finish(state); } @@ -83,7 +83,7 @@ static void BM_Pass1Cpp(benchmark::State& state) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; GPR_ASSERT(grpc_cq_begin_op(c_cq, &dummy_tag)); grpc_cq_end_op(&exec_ctx, c_cq, &dummy_tag, GRPC_ERROR_NONE, - DoneWithCompletionOnStack, NULL, &completion); + DoneWithCompletionOnStack, nullptr, &completion); grpc_exec_ctx_finish(&exec_ctx); void* tag; bool ok; @@ -96,16 +96,16 @@ BENCHMARK(BM_Pass1Cpp); static void BM_Pass1Core(benchmark::State& state) { TrackCounters track_counters; // TODO: sreek Templatize this benchmark and pass polling_type as a param - grpc_completion_queue* cq = grpc_completion_queue_create_for_next(NULL); + grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr); gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); while (state.KeepRunning()) { grpc_cq_completion completion; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - GPR_ASSERT(grpc_cq_begin_op(cq, NULL)); - grpc_cq_end_op(&exec_ctx, cq, NULL, GRPC_ERROR_NONE, - DoneWithCompletionOnStack, NULL, &completion); + GPR_ASSERT(grpc_cq_begin_op(cq, nullptr)); + grpc_cq_end_op(&exec_ctx, cq, nullptr, GRPC_ERROR_NONE, + DoneWithCompletionOnStack, nullptr, &completion); grpc_exec_ctx_finish(&exec_ctx); - grpc_completion_queue_next(cq, deadline, NULL); + grpc_completion_queue_next(cq, deadline, nullptr); } grpc_completion_queue_destroy(cq); track_counters.Finish(state); @@ -115,16 +115,16 @@ BENCHMARK(BM_Pass1Core); static void BM_Pluck1Core(benchmark::State& state) { TrackCounters track_counters; // TODO: sreek Templatize this benchmark and pass polling_type as a param - grpc_completion_queue* cq = grpc_completion_queue_create_for_pluck(NULL); + grpc_completion_queue* cq = grpc_completion_queue_create_for_pluck(nullptr); gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); while (state.KeepRunning()) { grpc_cq_completion completion; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - GPR_ASSERT(grpc_cq_begin_op(cq, NULL)); - grpc_cq_end_op(&exec_ctx, cq, NULL, GRPC_ERROR_NONE, - DoneWithCompletionOnStack, NULL, &completion); + GPR_ASSERT(grpc_cq_begin_op(cq, nullptr)); + grpc_cq_end_op(&exec_ctx, cq, nullptr, GRPC_ERROR_NONE, + DoneWithCompletionOnStack, nullptr, &completion); grpc_exec_ctx_finish(&exec_ctx); - grpc_completion_queue_pluck(cq, NULL, deadline, NULL); + grpc_completion_queue_pluck(cq, nullptr, deadline, nullptr); } grpc_completion_queue_destroy(cq); track_counters.Finish(state); @@ -134,10 +134,10 @@ BENCHMARK(BM_Pluck1Core); static void BM_EmptyCore(benchmark::State& state) { TrackCounters track_counters; // TODO: sreek Templatize this benchmark and pass polling_type as a param - grpc_completion_queue* cq = grpc_completion_queue_create_for_next(NULL); + grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr); gpr_timespec deadline = gpr_inf_past(GPR_CLOCK_MONOTONIC); while (state.KeepRunning()) { - grpc_completion_queue_next(cq, deadline, NULL); + grpc_completion_queue_next(cq, deadline, nullptr); } grpc_completion_queue_destroy(cq); track_counters.Finish(state); diff --git a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc index 8d4349a297..7ccebb55ee 100644 --- a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc +++ b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc @@ -80,7 +80,7 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* ps, gpr_mu_unlock(&ps->mu); GPR_ASSERT(grpc_cq_begin_op(g_cq, g_tag)); - grpc_cq_end_op(exec_ctx, g_cq, g_tag, GRPC_ERROR_NONE, cq_done_cb, NULL, + grpc_cq_end_op(exec_ctx, g_cq, g_tag, GRPC_ERROR_NONE, cq_done_cb, nullptr, (grpc_cq_completion*)gpr_malloc(sizeof(grpc_cq_completion))); grpc_exec_ctx_flush(exec_ctx); gpr_mu_lock(&ps->mu); @@ -108,7 +108,7 @@ static void setup() { g_old_vtable = grpc_get_event_engine_test_only(); grpc_set_event_engine_test_only(&g_vtable); - g_cq = grpc_completion_queue_create_for_next(NULL); + g_cq = grpc_completion_queue_create_for_next(nullptr); } static void teardown() { @@ -116,7 +116,7 @@ static void teardown() { /* Drain any events */ gpr_timespec deadline = gpr_time_0(GPR_CLOCK_MONOTONIC); - while (grpc_completion_queue_next(g_cq, deadline, NULL).type != + while (grpc_completion_queue_next(g_cq, deadline, nullptr).type != GRPC_QUEUE_SHUTDOWN) { /* Do nothing */ } @@ -151,7 +151,7 @@ static void BM_Cq_Throughput(benchmark::State& state) { } while (state.KeepRunning()) { - GPR_ASSERT(grpc_completion_queue_next(g_cq, deadline, NULL).type == + GPR_ASSERT(grpc_completion_queue_next(g_cq, deadline, nullptr).type == GRPC_OP_COMPLETE); } diff --git a/test/cpp/microbenchmarks/bm_error.cc b/test/cpp/microbenchmarks/bm_error.cc index aa7822653f..fa9af0ac5a 100644 --- a/test/cpp/microbenchmarks/bm_error.cc +++ b/test/cpp/microbenchmarks/bm_error.cc @@ -251,7 +251,7 @@ static void BM_ErrorGetStatus(benchmark::State& state) { grpc_status_code status; grpc_slice slice; grpc_error_get_status(&exec_ctx, fixture.error(), fixture.deadline(), - &status, &slice, NULL); + &status, &slice, nullptr); } grpc_exec_ctx_finish(&exec_ctx); track_counters.Finish(state); @@ -265,7 +265,7 @@ static void BM_ErrorGetStatusCode(benchmark::State& state) { while (state.KeepRunning()) { grpc_status_code status; grpc_error_get_status(&exec_ctx, fixture.error(), fixture.deadline(), - &status, NULL, NULL); + &status, nullptr, nullptr); } grpc_exec_ctx_finish(&exec_ctx); track_counters.Finish(state); @@ -278,8 +278,8 @@ static void BM_ErrorHttpError(benchmark::State& state) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; while (state.KeepRunning()) { grpc_http2_error_code error; - grpc_error_get_status(&exec_ctx, fixture.error(), fixture.deadline(), NULL, - NULL, &error); + grpc_error_get_status(&exec_ctx, fixture.error(), fixture.deadline(), nullptr, + nullptr, &error); } grpc_exec_ctx_finish(&exec_ctx); track_counters.Finish(state); diff --git a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc index f75c3e4436..bb974fad50 100644 --- a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc +++ b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc @@ -216,10 +216,10 @@ class TrickledCHTTP2 : public EndpointPairFixture { void UpdateStats(grpc_chttp2_transport* t, Stats* s, size_t backlog) GPR_ATTRIBUTE_NO_TSAN { if (backlog == 0) { - if (t->lists[GRPC_CHTTP2_LIST_STALLED_BY_STREAM].head != NULL) { + if (t->lists[GRPC_CHTTP2_LIST_STALLED_BY_STREAM].head != nullptr) { s->streams_stalled_due_to_stream_flow_control++; } - if (t->lists[GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT].head != NULL) { + if (t->lists[GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT].head != nullptr) { s->streams_stalled_due_to_transport_flow_control++; } } diff --git a/test/cpp/microbenchmarks/bm_metadata.cc b/test/cpp/microbenchmarks/bm_metadata.cc index 1ed05f7466..73bce08466 100644 --- a/test/cpp/microbenchmarks/bm_metadata.cc +++ b/test/cpp/microbenchmarks/bm_metadata.cc @@ -92,7 +92,7 @@ static void BM_MetadataFromNonInternedSlices(benchmark::State& state) { gpr_slice v = grpc_slice_from_static_string("value"); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; while (state.KeepRunning()) { - GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, NULL)); + GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, nullptr)); } grpc_exec_ctx_finish(&exec_ctx); track_counters.Finish(state); @@ -105,7 +105,7 @@ static void BM_MetadataFromInternedSlices(benchmark::State& state) { gpr_slice v = grpc_slice_intern(grpc_slice_from_static_string("value")); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; while (state.KeepRunning()) { - GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, NULL)); + GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, nullptr)); } grpc_exec_ctx_finish(&exec_ctx); grpc_slice_unref(k); @@ -120,9 +120,9 @@ static void BM_MetadataFromInternedSlicesAlreadyInIndex( gpr_slice k = grpc_slice_intern(grpc_slice_from_static_string("key")); gpr_slice v = grpc_slice_intern(grpc_slice_from_static_string("value")); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_mdelem seed = grpc_mdelem_create(&exec_ctx, k, v, NULL); + grpc_mdelem seed = grpc_mdelem_create(&exec_ctx, k, v, nullptr); while (state.KeepRunning()) { - GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, NULL)); + GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, nullptr)); } GRPC_MDELEM_UNREF(&exec_ctx, seed); grpc_exec_ctx_finish(&exec_ctx); @@ -138,7 +138,7 @@ static void BM_MetadataFromInternedKey(benchmark::State& state) { gpr_slice v = grpc_slice_from_static_string("value"); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; while (state.KeepRunning()) { - GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, NULL)); + GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, nullptr)); } grpc_exec_ctx_finish(&exec_ctx); grpc_slice_unref(k); @@ -209,7 +209,7 @@ static void BM_MetadataFromStaticMetadataStrings(benchmark::State& state) { gpr_slice v = GRPC_MDSTR_200; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; while (state.KeepRunning()) { - GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, NULL)); + GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, nullptr)); } grpc_exec_ctx_finish(&exec_ctx); grpc_slice_unref(k); @@ -224,7 +224,7 @@ static void BM_MetadataFromStaticMetadataStringsNotIndexed( gpr_slice v = GRPC_MDSTR_GZIP; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; while (state.KeepRunning()) { - GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, NULL)); + GRPC_MDELEM_UNREF(&exec_ctx, grpc_mdelem_create(&exec_ctx, k, v, nullptr)); } grpc_exec_ctx_finish(&exec_ctx); grpc_slice_unref(k); @@ -273,7 +273,7 @@ static void BM_MetadataRefUnrefAllocated(benchmark::State& state) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_mdelem el = grpc_mdelem_create(&exec_ctx, grpc_slice_from_static_string("a"), - grpc_slice_from_static_string("b"), NULL); + grpc_slice_from_static_string("b"), nullptr); while (state.KeepRunning()) { GRPC_MDELEM_UNREF(&exec_ctx, GRPC_MDELEM_REF(el)); } @@ -287,7 +287,7 @@ static void BM_MetadataRefUnrefStatic(benchmark::State& state) { TrackCounters track_counters; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_mdelem el = - grpc_mdelem_create(&exec_ctx, GRPC_MDSTR_STATUS, GRPC_MDSTR_200, NULL); + grpc_mdelem_create(&exec_ctx, GRPC_MDSTR_STATUS, GRPC_MDSTR_200, nullptr); while (state.KeepRunning()) { GRPC_MDELEM_UNREF(&exec_ctx, GRPC_MDELEM_REF(el)); } diff --git a/test/cpp/microbenchmarks/bm_pollset.cc b/test/cpp/microbenchmarks/bm_pollset.cc index 92d76f307e..0a04dde15f 100644 --- a/test/cpp/microbenchmarks/bm_pollset.cc +++ b/test/cpp/microbenchmarks/bm_pollset.cc @@ -117,7 +117,7 @@ static void BM_PollEmptyPollset(benchmark::State& state) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; gpr_mu_lock(mu); while (state.KeepRunning()) { - GRPC_ERROR_UNREF(grpc_pollset_work(&exec_ctx, ps, NULL, 0)); + GRPC_ERROR_UNREF(grpc_pollset_work(&exec_ctx, ps, nullptr, 0)); } grpc_closure shutdown_ps_closure; GRPC_CLOSURE_INIT(&shutdown_ps_closure, shutdown_ps, ps, @@ -145,7 +145,7 @@ static void BM_PollAddFd(benchmark::State& state) { grpc_pollset_add_fd(&exec_ctx, ps, fd); grpc_exec_ctx_flush(&exec_ctx); } - grpc_fd_orphan(&exec_ctx, fd, NULL, NULL, false /* already_closed */, "xxx"); + grpc_fd_orphan(&exec_ctx, fd, nullptr, nullptr, false /* already_closed */, "xxx"); grpc_closure shutdown_ps_closure; GRPC_CLOSURE_INIT(&shutdown_ps_closure, shutdown_ps, ps, grpc_schedule_on_exec_ctx); @@ -240,9 +240,9 @@ static void BM_SingleThreadPollOneFd(benchmark::State& state) { gpr_mu_lock(mu); while (!done) { GRPC_ERROR_UNREF( - grpc_pollset_work(&exec_ctx, ps, NULL, GRPC_MILLIS_INF_FUTURE)); + grpc_pollset_work(&exec_ctx, ps, nullptr, GRPC_MILLIS_INF_FUTURE)); } - grpc_fd_orphan(&exec_ctx, wakeup, NULL, NULL, false /* already_closed */, + grpc_fd_orphan(&exec_ctx, wakeup, nullptr, nullptr, false /* already_closed */, "done"); wakeup_fd.read_fd = 0; grpc_closure shutdown_ps_closure; diff --git a/test/cpp/microbenchmarks/fullstack_fixtures.h b/test/cpp/microbenchmarks/fullstack_fixtures.h index 71bbb393db..323ca1e5d7 100644 --- a/test/cpp/microbenchmarks/fullstack_fixtures.h +++ b/test/cpp/microbenchmarks/fullstack_fixtures.h @@ -185,8 +185,8 @@ class EndpointPairFixture : public BaseFixture { } grpc_server_setup_transport(&exec_ctx, server_->c_server(), - server_transport_, NULL, server_args); - grpc_chttp2_transport_start_reading(&exec_ctx, server_transport_, NULL); + server_transport_, nullptr, server_args); + grpc_chttp2_transport_start_reading(&exec_ctx, server_transport_, nullptr); } /* create channel */ @@ -202,7 +202,7 @@ class EndpointPairFixture : public BaseFixture { grpc_channel* channel = grpc_channel_create(&exec_ctx, "target", &c_args, GRPC_CLIENT_DIRECT_CHANNEL, client_transport_); - grpc_chttp2_transport_start_reading(&exec_ctx, client_transport_, NULL); + grpc_chttp2_transport_start_reading(&exec_ctx, client_transport_, nullptr); channel_ = CreateChannelInternal("", channel); } @@ -244,7 +244,7 @@ class SockPair : public EndpointPairFixture { SockPair(Service* service, const FixtureConfiguration& fixture_configuration = FixtureConfiguration()) : EndpointPairFixture(service, - grpc_iomgr_create_endpoint_pair("test", NULL), + grpc_iomgr_create_endpoint_pair("test", nullptr), fixture_configuration) {} }; diff --git a/test/cpp/naming/resolver_component_test.cc b/test/cpp/naming/resolver_component_test.cc index 94adbcbd35..9c1b4c7b73 100644 --- a/test/cpp/naming/resolver_component_test.cc +++ b/test/cpp/naming/resolver_component_test.cc @@ -157,7 +157,7 @@ void ArgsInit(grpc_exec_ctx* exec_ctx, ArgsStruct* args) { grpc_pollset_set_add_pollset(exec_ctx, args->pollset_set, args->pollset); args->lock = grpc_combiner_create(); gpr_atm_rel_store(&args->done_atm, 0); - args->channel_args = NULL; + args->channel_args = nullptr; } void DoNothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {} @@ -167,7 +167,7 @@ void ArgsFinish(grpc_exec_ctx* exec_ctx, ArgsStruct* args) { grpc_pollset_set_del_pollset(exec_ctx, args->pollset_set, args->pollset); grpc_pollset_set_destroy(exec_ctx, args->pollset_set); grpc_closure DoNothing_cb; - GRPC_CLOSURE_INIT(&DoNothing_cb, DoNothing, NULL, grpc_schedule_on_exec_ctx); + GRPC_CLOSURE_INIT(&DoNothing_cb, DoNothing, nullptr, grpc_schedule_on_exec_ctx); grpc_pollset_shutdown(exec_ctx, args->pollset, &DoNothing_cb); // exec_ctx needs to be flushed before calling grpc_pollset_destroy() grpc_channel_args_destroy(exec_ctx, args->channel_args); @@ -194,7 +194,7 @@ void PollPollsetUntilRequestDone(ArgsStruct* args) { gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRId64 ".%09d", done, time_left.tv_sec, time_left.tv_nsec); GPR_ASSERT(gpr_time_cmp(time_left, gpr_time_0(GPR_TIMESPAN)) >= 0); - grpc_pollset_worker* worker = NULL; + grpc_pollset_worker* worker = nullptr; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; gpr_mu_lock(args->mu); GRPC_LOG_IF_ERROR("pollset_work", @@ -212,12 +212,12 @@ void CheckServiceConfigResultLocked(grpc_channel_args* channel_args, const grpc_arg* service_config_arg = grpc_channel_args_find(channel_args, GRPC_ARG_SERVICE_CONFIG); if (args->expected_service_config_string != "") { - GPR_ASSERT(service_config_arg != NULL); + GPR_ASSERT(service_config_arg != nullptr); GPR_ASSERT(service_config_arg->type == GRPC_ARG_STRING); EXPECT_EQ(service_config_arg->value.string, args->expected_service_config_string); } else { - GPR_ASSERT(service_config_arg == NULL); + GPR_ASSERT(service_config_arg == nullptr); } } @@ -226,11 +226,11 @@ void CheckLBPolicyResultLocked(grpc_channel_args* channel_args, const grpc_arg* lb_policy_arg = grpc_channel_args_find(channel_args, GRPC_ARG_LB_POLICY_NAME); if (args->expected_lb_policy != "") { - GPR_ASSERT(lb_policy_arg != NULL); + GPR_ASSERT(lb_policy_arg != nullptr); GPR_ASSERT(lb_policy_arg->type == GRPC_ARG_STRING); EXPECT_EQ(lb_policy_arg->value.string, args->expected_lb_policy); } else { - GPR_ASSERT(lb_policy_arg == NULL); + GPR_ASSERT(lb_policy_arg == nullptr); } } @@ -240,7 +240,7 @@ void CheckResolverResultLocked(grpc_exec_ctx* exec_ctx, void* argsp, grpc_channel_args* channel_args = args->channel_args; const grpc_arg* channel_arg = grpc_channel_args_find(channel_args, GRPC_ARG_LB_ADDRESSES); - GPR_ASSERT(channel_arg != NULL); + GPR_ASSERT(channel_arg != nullptr); GPR_ASSERT(channel_arg->type == GRPC_ARG_POINTER); grpc_lb_addresses* addresses = (grpc_lb_addresses*)channel_arg->value.pointer.p; @@ -272,7 +272,7 @@ void CheckResolverResultLocked(grpc_exec_ctx* exec_ctx, void* argsp, gpr_atm_rel_store(&args->done_atm, 1); gpr_mu_lock(args->mu); GRPC_LOG_IF_ERROR("pollset_kick", - grpc_pollset_kick(exec_ctx, args->pollset, NULL)); + grpc_pollset_kick(exec_ctx, args->pollset, nullptr)); gpr_mu_unlock(args->mu); } @@ -284,12 +284,12 @@ TEST(ResolverComponentTest, TestResolvesRelevantRecords) { args.expected_service_config_string = FLAGS_expected_chosen_service_config; args.expected_lb_policy = FLAGS_expected_lb_policy; // maybe build the address with an authority - char* whole_uri = NULL; + char* whole_uri = nullptr; GPR_ASSERT(asprintf(&whole_uri, "dns://%s/%s", FLAGS_local_dns_server_address.c_str(), FLAGS_target_name.c_str())); // create resolver and resolve - grpc_resolver* resolver = grpc_resolver_create(&exec_ctx, whole_uri, NULL, + grpc_resolver* resolver = grpc_resolver_create(&exec_ctx, whole_uri, nullptr, args.pollset_set, args.lock); gpr_free(whole_uri); grpc_closure on_resolver_result_changed; diff --git a/test/cpp/naming/resolver_component_tests_runner_invoker.cc b/test/cpp/naming/resolver_component_tests_runner_invoker.cc index 7ea005cc1d..0beb27de1b 100644 --- a/test/cpp/naming/resolver_component_tests_runner_invoker.cc +++ b/test/cpp/naming/resolver_component_tests_runner_invoker.cc @@ -60,8 +60,8 @@ static void register_sighandler() { struct sigaction act; memset(&act, 0, sizeof(act)); act.sa_handler = sighandler; - sigaction(SIGINT, &act, NULL); - sigaction(SIGTERM, &act, NULL); + sigaction(SIGINT, &act, nullptr); + sigaction(SIGTERM, &act, nullptr); } namespace { diff --git a/test/cpp/performance/writes_per_rpc_test.cc b/test/cpp/performance/writes_per_rpc_test.cc index 6c23245021..23fff2ea8b 100644 --- a/test/cpp/performance/writes_per_rpc_test.cc +++ b/test/cpp/performance/writes_per_rpc_test.cc @@ -100,8 +100,8 @@ class EndpointPairFixture { } grpc_server_setup_transport(&exec_ctx, server_->c_server(), transport, - NULL, server_args); - grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL); + nullptr, server_args); + grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr); } /* create channel */ @@ -116,7 +116,7 @@ class EndpointPairFixture { GPR_ASSERT(transport); grpc_channel* channel = grpc_channel_create( &exec_ctx, "target", &c_args, GRPC_CLIENT_DIRECT_CHANNEL, transport); - grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL); + grpc_chttp2_transport_start_reading(&exec_ctx, transport, nullptr); channel_ = CreateChannelInternal("", channel); } diff --git a/test/cpp/qps/json_run_localhost.cc b/test/cpp/qps/json_run_localhost.cc index 4b788eae73..db8b2a3943 100644 --- a/test/cpp/qps/json_run_localhost.cc +++ b/test/cpp/qps/json_run_localhost.cc @@ -46,7 +46,7 @@ std::string as_string(const T& val) { static void sighandler(int sig) { const int errno_saved = errno; - if (g_driver != NULL) g_driver->Interrupt(); + if (g_driver != nullptr) g_driver->Interrupt(); for (int i = 0; i < kNumWorkers; ++i) { if (g_workers[i]) g_workers[i]->Interrupt(); } @@ -58,8 +58,8 @@ static void register_sighandler() { memset(&act, 0, sizeof(act)); act.sa_handler = sighandler; - sigaction(SIGINT, &act, NULL); - sigaction(SIGTERM, &act, NULL); + sigaction(SIGINT, &act, nullptr); + sigaction(SIGTERM, &act, nullptr); } static void LogStatus(int status, const char* label) { diff --git a/test/cpp/qps/qps_json_driver.cc b/test/cpp/qps/qps_json_driver.cc index 1672527426..b2449da69c 100644 --- a/test/cpp/qps/qps_json_driver.cc +++ b/test/cpp/qps/qps_json_driver.cc @@ -181,7 +181,7 @@ static bool QpsDriver() { if (scfile) { // Read the json data from disk FILE* json_file = fopen(FLAGS_scenarios_file.c_str(), "r"); - GPR_ASSERT(json_file != NULL); + GPR_ASSERT(json_file != nullptr); fseek(json_file, 0, SEEK_END); long len = ftell(json_file); char* data = new char[len]; diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc index 23c7e85283..72ae772147 100644 --- a/test/cpp/qps/server_async.cc +++ b/test/cpp/qps/server_async.cc @@ -79,7 +79,7 @@ class AsyncQpsServerTest final : public grpc::testing::Server { auto port_num = port(); // Negative port number means inproc server, so no listen port needed if (port_num >= 0) { - char* server_address = NULL; + char* server_address = nullptr; gpr_join_host_port(&server_address, "::", port_num); builder.AddListeningPort(server_address, Server::CreateServerCredentials(config)); diff --git a/test/cpp/qps/server_sync.cc b/test/cpp/qps/server_sync.cc index 4ef57bd08b..ea89a30e2e 100644 --- a/test/cpp/qps/server_sync.cc +++ b/test/cpp/qps/server_sync.cc @@ -159,7 +159,7 @@ class SynchronousServer final : public grpc::testing::Server { auto port_num = port(); // Negative port number means inproc server, so no listen port needed if (port_num >= 0) { - char* server_address = NULL; + char* server_address = nullptr; gpr_join_host_port(&server_address, "::", port_num); builder.AddListeningPort(server_address, Server::CreateServerCredentials(config)); diff --git a/test/cpp/thread_manager/thread_manager_test.cc b/test/cpp/thread_manager/thread_manager_test.cc index af90d44495..8282d46694 100644 --- a/test/cpp/thread_manager/thread_manager_test.cc +++ b/test/cpp/thread_manager/thread_manager_test.cc @@ -111,7 +111,7 @@ void ThreadManagerTest::PerformTest() { } // namespace grpc int main(int argc, char** argv) { - std::srand(std::time(NULL)); + std::srand(std::time(nullptr)); grpc::testing::InitTest(&argc, &argv, true); grpc::ThreadManagerTest test_rpc_manager; diff --git a/test/cpp/util/grpc_tool.cc b/test/cpp/util/grpc_tool.cc index cd6084ac6d..7d51c5f45f 100644 --- a/test/cpp/util/grpc_tool.cc +++ b/test/cpp/util/grpc_tool.cc @@ -230,7 +230,7 @@ const Command* FindCommand(const grpc::string& name) { return &ops[i]; } } - return NULL; + return nullptr; } } // namespace @@ -245,7 +245,7 @@ int GrpcToolMainLib(int argc, const char** argv, const CliCredentials& cred, argv += 2; const Command* cmd = FindCommand(command); - if (cmd != NULL) { + if (cmd != nullptr) { GrpcTool grpc_tool; if (argc < cmd->min_args || argc > cmd->max_args) { // Force the command to print its usage message @@ -281,7 +281,7 @@ bool GrpcTool::Help(int argc, const char** argv, const CliCredentials& cred, Usage(""); } else { const Command* cmd = FindCommand(argv[0]); - if (cmd == NULL) { + if (cmd == nullptr) { Usage("Unknown command '" + grpc::string(argv[0]) + "'"); } SetPrintCommandMode(0); diff --git a/test/cpp/util/grpc_tool_test.cc b/test/cpp/util/grpc_tool_test.cc index d0b3d7b81b..a8677eeba2 100644 --- a/test/cpp/util/grpc_tool_test.cc +++ b/test/cpp/util/grpc_tool_test.cc @@ -395,7 +395,7 @@ TEST_F(GrpcToolTest, CallCommand) { std::bind(PrintStream, &output_stream, std::placeholders::_1))); // Expected output: "message: \"Hello\"" - EXPECT_TRUE(NULL != + EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(), "message: \"Hello\"")); ShutdownServer(); } @@ -421,7 +421,7 @@ TEST_F(GrpcToolTest, CallCommandBatch) { // Expected output: "message: "Hello0"\nmessage: "Hello1"\nmessage: // "Hello2"\n" - EXPECT_TRUE(NULL != strstr(output_stream.str().c_str(), + EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(), "message: \"Hello0\"\nmessage: " "\"Hello1\"\nmessage: \"Hello2\"\n")); std::cin.rdbuf(orig); @@ -448,7 +448,7 @@ TEST_F(GrpcToolTest, CallCommandBatchWithBadRequest) { FLAGS_batch = false; // Expected output: "message: "Hello0"\nmessage: "Hello2"\n" - EXPECT_TRUE(NULL != strstr(output_stream.str().c_str(), + EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(), "message: \"Hello0\"\nmessage: \"Hello2\"\n")); std::cin.rdbuf(orig); ShutdownServer(); @@ -473,7 +473,7 @@ TEST_F(GrpcToolTest, CallCommandRequestStream) { std::placeholders::_1))); // Expected output: "message: \"Hello0Hello1Hello2\"" - EXPECT_TRUE(NULL != strstr(output_stream.str().c_str(), + EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(), "message: \"Hello0Hello1Hello2\"")); std::cin.rdbuf(orig); ShutdownServer(); @@ -498,7 +498,7 @@ TEST_F(GrpcToolTest, CallCommandRequestStreamWithBadRequest) { std::placeholders::_1))); // Expected output: "message: \"Hello0Hello2\"" - EXPECT_TRUE(NULL != + EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(), "message: \"Hello0Hello2\"")); std::cin.rdbuf(orig); ShutdownServer(); @@ -521,7 +521,7 @@ TEST_F(GrpcToolTest, CallCommandResponseStream) { for (int i = 0; i < kServerDefaultResponseStreamsToSend; i++) { grpc::string expected_response_text = "message: \"Hello" + grpc::to_string(i) + "\"\n"; - EXPECT_TRUE(NULL != strstr(output_stream.str().c_str(), + EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(), expected_response_text.c_str())); } @@ -547,7 +547,7 @@ TEST_F(GrpcToolTest, CallCommandBidiStream) { // Expected output: "message: \"Hello0\"\nmessage: \"Hello1\"\nmessage: // \"Hello2\"\n\n" - EXPECT_TRUE(NULL != strstr(output_stream.str().c_str(), + EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(), "message: \"Hello0\"\nmessage: " "\"Hello1\"\nmessage: \"Hello2\"\n")); std::cin.rdbuf(orig); @@ -573,7 +573,7 @@ TEST_F(GrpcToolTest, CallCommandBidiStreamWithBadRequest) { // Expected output: "message: \"Hello0\"\nmessage: \"Hello1\"\nmessage: // \"Hello2\"\n\n" - EXPECT_TRUE(NULL != strstr(output_stream.str().c_str(), + EXPECT_TRUE(nullptr != strstr(output_stream.str().c_str(), "message: \"Hello0\"\nmessage: \"Hello2\"\n")); std::cin.rdbuf(orig); |