From 6014e8a945fa81fad7d0311a8a7cded0c2aaa827 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 16 Oct 2017 13:50:29 -0700 Subject: C++ize tracing --- .../client_channel/lb_policy/grpclb/grpclb.cc | 48 +++++++++++----------- 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc') diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index ffd58129c6..1b9e72bd24 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -126,7 +126,7 @@ #define GRPC_GRPCLB_RECONNECT_JITTER 0.2 #define GRPC_GRPCLB_DEFAULT_FALLBACK_TIMEOUT_MS 10000 -grpc_tracer_flag grpc_lb_glb_trace = GRPC_TRACER_INITIALIZER(false, "glb"); +grpc_core::Tracer grpc_lb_glb_trace(false, "glb"); /* add lb_token of selected subchannel (address) to the call's initial * metadata */ @@ -212,7 +212,7 @@ static void wrapped_rr_closure(grpc_exec_ctx *exec_ctx, void *arg, } else { grpc_grpclb_client_stats_unref(wc_arg->client_stats); } - if (GRPC_TRACER_ON(grpc_lb_glb_trace)) { + if (grpc_lb_glb_trace.enabled()) { gpr_log(GPR_INFO, "Unreffing RR %p", (void *)wc_arg->rr_policy); } GRPC_LB_POLICY_UNREF(exec_ctx, wc_arg->rr_policy, "wrapped_rr_closure"); @@ -618,7 +618,7 @@ static void update_lb_connectivity_status_locked( GPR_ASSERT(rr_state_error == GRPC_ERROR_NONE); } - if (GRPC_TRACER_ON(grpc_lb_glb_trace)) { + if (grpc_lb_glb_trace.enabled()) { gpr_log( GPR_INFO, "Setting grpclb's state to %s from new RR policy %p state.", grpc_connectivity_state_name(rr_state), (void *)glb_policy->rr_policy); @@ -647,7 +647,7 @@ static bool pick_from_internal_rr_locked( } if (server->drop) { // Not using the RR policy, so unref it. - if (GRPC_TRACER_ON(grpc_lb_glb_trace)) { + if (grpc_lb_glb_trace.enabled()) { gpr_log(GPR_INFO, "Unreffing RR for drop (0x%" PRIxPTR ")", (intptr_t)wc_arg->rr_policy); } @@ -676,7 +676,7 @@ static bool pick_from_internal_rr_locked( (void **)&wc_arg->lb_token, &wc_arg->wrapper_closure); if (pick_done) { /* synchronous grpc_lb_policy_pick call. Unref the RR policy. */ - if (GRPC_TRACER_ON(grpc_lb_glb_trace)) { + if (grpc_lb_glb_trace.enabled()) { gpr_log(GPR_INFO, "Unreffing RR (0x%" PRIxPTR ")", (intptr_t)wc_arg->rr_policy); } @@ -797,7 +797,7 @@ static void create_rr_locked(grpc_exec_ctx *exec_ctx, glb_lb_policy *glb_policy, pp->wrapped_on_complete_arg.rr_policy = glb_policy->rr_policy; pp->wrapped_on_complete_arg.client_stats = grpc_grpclb_client_stats_ref(glb_policy->client_stats); - if (GRPC_TRACER_ON(grpc_lb_glb_trace)) { + if (grpc_lb_glb_trace.enabled()) { gpr_log(GPR_INFO, "Pending pick about to (async) PICK from %p", (void *)glb_policy->rr_policy); } @@ -811,7 +811,7 @@ static void create_rr_locked(grpc_exec_ctx *exec_ctx, glb_lb_policy *glb_policy, glb_policy->pending_pings = pping->next; GRPC_LB_POLICY_REF(glb_policy->rr_policy, "rr_handover_pending_ping"); pping->wrapped_notify_arg.rr_policy = glb_policy->rr_policy; - if (GRPC_TRACER_ON(grpc_lb_glb_trace)) { + if (grpc_lb_glb_trace.enabled()) { gpr_log(GPR_INFO, "Pending ping about to PING from 0x%" PRIxPTR "", (intptr_t)glb_policy->rr_policy); } @@ -827,14 +827,14 @@ static void rr_handover_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy_args *args = lb_policy_args_create(exec_ctx, glb_policy); GPR_ASSERT(args != NULL); if (glb_policy->rr_policy != NULL) { - if (GRPC_TRACER_ON(grpc_lb_glb_trace)) { + if (grpc_lb_glb_trace.enabled()) { gpr_log(GPR_DEBUG, "Updating Round Robin policy (%p)", (void *)glb_policy->rr_policy); } grpc_lb_policy_update_locked(exec_ctx, glb_policy->rr_policy, args); } else { create_rr_locked(exec_ctx, glb_policy, args); - if (GRPC_TRACER_ON(grpc_lb_glb_trace)) { + if (grpc_lb_glb_trace.enabled()) { gpr_log(GPR_DEBUG, "Created new Round Robin policy (%p)", (void *)glb_policy->rr_policy); } @@ -1165,7 +1165,7 @@ static int glb_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol, bool pick_done; if (glb_policy->rr_policy != NULL) { - if (GRPC_TRACER_ON(grpc_lb_glb_trace)) { + if (grpc_lb_glb_trace.enabled()) { gpr_log(GPR_INFO, "grpclb %p about to PICK from RR %p", (void *)glb_policy, (void *)glb_policy->rr_policy); } @@ -1190,7 +1190,7 @@ static int glb_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol, pick_from_internal_rr_locked(exec_ctx, glb_policy, pick_args, false /* force_async */, target, wc_arg); } else { - if (GRPC_TRACER_ON(grpc_lb_glb_trace)) { + if (grpc_lb_glb_trace.enabled()) { gpr_log(GPR_DEBUG, "No RR policy in grpclb instance %p. Adding to grpclb's pending " "picks", @@ -1242,7 +1242,7 @@ static void lb_call_on_retry_timer_locked(grpc_exec_ctx *exec_ctx, void *arg, glb_lb_policy *glb_policy = (glb_lb_policy *)arg; glb_policy->retry_timer_active = false; if (!glb_policy->shutting_down && error == GRPC_ERROR_NONE) { - if (GRPC_TRACER_ON(grpc_lb_glb_trace)) { + if (grpc_lb_glb_trace.enabled()) { gpr_log(GPR_INFO, "Restaring call to LB server (grpclb %p)", (void *)glb_policy); } @@ -1264,7 +1264,7 @@ static void maybe_restart_lb_call(grpc_exec_ctx *exec_ctx, /* if we aren't shutting down, restart the LB client call after some time */ grpc_millis next_try = grpc_backoff_step(exec_ctx, &glb_policy->lb_call_backoff_state); - if (GRPC_TRACER_ON(grpc_lb_glb_trace)) { + if (grpc_lb_glb_trace.enabled()) { gpr_log(GPR_DEBUG, "Connection to LB server lost (grpclb: %p)...", (void *)glb_policy); grpc_millis timeout = next_try - grpc_exec_ctx_now(exec_ctx); @@ -1465,7 +1465,7 @@ static void query_for_backends_locked(grpc_exec_ctx *exec_ctx, lb_call_init_locked(exec_ctx, glb_policy); - if (GRPC_TRACER_ON(grpc_lb_glb_trace)) { + if (grpc_lb_glb_trace.enabled()) { gpr_log(GPR_INFO, "Query for backends (grpclb: %p, lb_channel: %p, lb_call: %p)", (void *)glb_policy, (void *)glb_policy->lb_channel, @@ -1557,7 +1557,7 @@ static void lb_on_response_received_locked(grpc_exec_ctx *exec_ctx, void *arg, glb_policy->client_stats_report_interval = GPR_MAX( GPR_MS_PER_SEC, grpc_grpclb_duration_to_millis( &response->client_stats_report_interval)); - if (GRPC_TRACER_ON(grpc_lb_glb_trace)) { + if (grpc_lb_glb_trace.enabled()) { gpr_log(GPR_INFO, "received initial LB response message; " "client load reporting interval = %" PRIdPTR " milliseconds", @@ -1569,7 +1569,7 @@ static void lb_on_response_received_locked(grpc_exec_ctx *exec_ctx, void *arg, glb_policy->client_load_report_timer_pending = true; GRPC_LB_POLICY_WEAK_REF(&glb_policy->base, "client_load_report"); schedule_next_client_load_report(exec_ctx, glb_policy); - } else if (GRPC_TRACER_ON(grpc_lb_glb_trace)) { + } else if (grpc_lb_glb_trace.enabled()) { gpr_log(GPR_INFO, "received initial LB response message; " "client load reporting NOT enabled"); @@ -1581,7 +1581,7 @@ static void lb_on_response_received_locked(grpc_exec_ctx *exec_ctx, void *arg, grpc_grpclb_response_parse_serverlist(response_slice); if (serverlist != NULL) { GPR_ASSERT(glb_policy->lb_call != NULL); - if (GRPC_TRACER_ON(grpc_lb_glb_trace)) { + if (grpc_lb_glb_trace.enabled()) { gpr_log(GPR_INFO, "Serverlist with %lu servers received", (unsigned long)serverlist->num_servers); for (size_t i = 0; i < serverlist->num_servers; ++i) { @@ -1597,7 +1597,7 @@ static void lb_on_response_received_locked(grpc_exec_ctx *exec_ctx, void *arg, if (serverlist->num_servers > 0) { if (grpc_grpclb_serverlist_equals(glb_policy->serverlist, serverlist)) { - if (GRPC_TRACER_ON(grpc_lb_glb_trace)) { + if (grpc_lb_glb_trace.enabled()) { gpr_log(GPR_INFO, "Incoming server list identical to current, ignoring."); } @@ -1624,7 +1624,7 @@ static void lb_on_response_received_locked(grpc_exec_ctx *exec_ctx, void *arg, rr_handover_locked(exec_ctx, glb_policy); } } else { - if (GRPC_TRACER_ON(grpc_lb_glb_trace)) { + if (grpc_lb_glb_trace.enabled()) { gpr_log(GPR_INFO, "Received empty server list, ignoring."); } grpc_grpclb_destroy_serverlist(serverlist); @@ -1668,7 +1668,7 @@ static void lb_on_fallback_timer_locked(grpc_exec_ctx *exec_ctx, void *arg, * actually runs, don't fall back. */ if (glb_policy->serverlist == NULL) { if (!glb_policy->shutting_down && error == GRPC_ERROR_NONE) { - if (GRPC_TRACER_ON(grpc_lb_glb_trace)) { + if (grpc_lb_glb_trace.enabled()) { gpr_log(GPR_INFO, "Falling back to use backends from resolver (grpclb %p)", (void *)glb_policy); @@ -1685,7 +1685,7 @@ static void lb_on_server_status_received_locked(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { glb_lb_policy *glb_policy = (glb_lb_policy *)arg; GPR_ASSERT(glb_policy->lb_call != NULL); - if (GRPC_TRACER_ON(grpc_lb_glb_trace)) { + if (grpc_lb_glb_trace.enabled()) { char *status_details = grpc_slice_to_c_string(glb_policy->lb_call_status_details); gpr_log(GPR_INFO, @@ -1869,7 +1869,7 @@ static grpc_lb_policy *glb_create(grpc_exec_ctx *exec_ctx, GPR_ASSERT(uri->path[0] != '\0'); glb_policy->server_name = gpr_strdup(uri->path[0] == '/' ? uri->path + 1 : uri->path); - if (GRPC_TRACER_ON(grpc_lb_glb_trace)) { + if (grpc_lb_glb_trace.enabled()) { gpr_log(GPR_INFO, "Will use '%s' as the server name for LB request.", glb_policy->server_name); } @@ -1962,9 +1962,9 @@ static bool maybe_add_client_load_reporting_filter( extern "C" void grpc_lb_policy_grpclb_init() { grpc_register_lb_policy(grpc_glb_lb_factory_create()); - grpc_register_tracer(&grpc_lb_glb_trace); + #ifndef NDEBUG - grpc_register_tracer(&grpc_trace_lb_policy_refcount); + #endif grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, -- cgit v1.2.3 From cdaf6d8e0660f83b708e4e73e90a4deaeab7ea2b Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 16 Oct 2017 13:51:45 -0700 Subject: clang-format --- .../ext/filters/client_channel/client_channel.cc | 3 +- .../client_channel/client_channel_plugin.cc | 4 +-- src/core/ext/filters/client_channel/lb_policy.cc | 3 +- .../client_channel/lb_policy/grpclb/grpclb.cc | 4 +-- .../lb_policy/pick_first/pick_first.cc | 4 +-- .../lb_policy/round_robin/round_robin.cc | 4 +-- src/core/ext/filters/client_channel/resolver.cc | 3 +- src/core/ext/filters/http/http_filters_plugin.cc | 1 - .../transport/chttp2/transport/chttp2_plugin.cc | 5 +-- .../transport/chttp2/transport/chttp2_transport.cc | 6 ++-- .../transport/chttp2/transport/frame_settings.cc | 3 +- src/core/ext/transport/chttp2/transport/internal.h | 16 ++++----- .../ext/transport/chttp2/transport/stream_lists.cc | 3 +- src/core/ext/transport/chttp2/transport/writing.cc | 12 +++---- src/core/ext/transport/inproc/inproc_transport.cc | 4 +-- src/core/lib/channel/channel_stack_builder.cc | 4 +-- src/core/lib/iomgr/call_combiner.cc | 3 +- src/core/lib/iomgr/combiner.cc | 13 ++++--- src/core/lib/iomgr/error.cc | 3 +- src/core/lib/iomgr/ev_epollsig_linux.cc | 4 +-- src/core/lib/iomgr/ev_posix.cc | 9 ++--- src/core/lib/iomgr/ev_windows.cc | 4 +-- src/core/lib/iomgr/executor.cc | 4 +-- src/core/lib/iomgr/iomgr_posix.cc | 1 - src/core/lib/iomgr/iomgr_uv.cc | 2 +- src/core/lib/iomgr/pollset_uv.cc | 3 +- src/core/lib/iomgr/pollset_windows.cc | 3 +- src/core/lib/iomgr/resource_quota.cc | 3 +- src/core/lib/iomgr/timer_generic.cc | 5 +-- src/core/lib/iomgr/timer_uv.cc | 3 +- src/core/lib/security/context/security_context.cc | 4 +-- .../credentials/plugin/plugin_credentials.cc | 3 +- src/core/lib/security/transport/secure_endpoint.cc | 3 +- .../lib/security/transport/security_connector.cc | 4 +-- src/core/lib/surface/alarm.cc | 3 +- src/core/lib/surface/api_trace.h | 2 +- src/core/lib/surface/call.cc | 6 ++-- src/core/lib/surface/call.h | 3 +- src/core/lib/surface/completion_queue.cc | 42 +++++++++------------- src/core/lib/surface/init.cc | 24 ++----------- src/core/lib/surface/init_secure.cc | 10 ++---- src/core/lib/surface/server.cc | 3 +- src/core/lib/transport/bdp_estimator.cc | 3 +- src/core/lib/transport/connectivity_state.cc | 3 +- src/core/lib/transport/metadata.cc | 3 +- src/core/lib/transport/transport.cc | 3 +- 46 files changed, 88 insertions(+), 170 deletions(-) (limited to 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc') diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 21ad3d9a26..8a8e76ff12 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -55,8 +55,7 @@ /* Client channel implementation */ -grpc_core::Tracer grpc_client_channel_trace - (false, "client_channel"); +grpc_core::Tracer grpc_client_channel_trace(false, "client_channel"); /************************************************************************* * METHOD-CONFIG TABLE diff --git a/src/core/ext/filters/client_channel/client_channel_plugin.cc b/src/core/ext/filters/client_channel/client_channel_plugin.cc index d67e11e976..407b8349d8 100644 --- a/src/core/ext/filters/client_channel/client_channel_plugin.cc +++ b/src/core/ext/filters/client_channel/client_channel_plugin.cc @@ -78,9 +78,9 @@ extern "C" void grpc_client_channel_init(void) { GRPC_CLIENT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, append_filter, (void *)&grpc_client_channel_filter); grpc_http_connect_register_handshaker_factory(); - + #ifndef NDEBUG - + #endif } diff --git a/src/core/ext/filters/client_channel/lb_policy.cc b/src/core/ext/filters/client_channel/lb_policy.cc index 6ce49b17e9..738486adbb 100644 --- a/src/core/ext/filters/client_channel/lb_policy.cc +++ b/src/core/ext/filters/client_channel/lb_policy.cc @@ -22,8 +22,7 @@ #define WEAK_REF_BITS 16 #ifndef NDEBUG -grpc_core::Tracer grpc_trace_lb_policy_refcount - (false, "lb_policy_refcount"); +grpc_core::Tracer grpc_trace_lb_policy_refcount(false, "lb_policy_refcount"); #endif void grpc_lb_policy_init(grpc_lb_policy *policy, diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index 1b9e72bd24..9ad54fabf5 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -1962,9 +1962,9 @@ static bool maybe_add_client_load_reporting_filter( extern "C" void grpc_lb_policy_grpclb_init() { grpc_register_lb_policy(grpc_glb_lb_factory_create()); - + #ifndef NDEBUG - + #endif grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, diff --git a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc index 8c5065cd9e..3454ff0cbd 100644 --- a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +++ b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc @@ -28,8 +28,7 @@ #include "src/core/lib/iomgr/sockaddr_utils.h" #include "src/core/lib/transport/connectivity_state.h" -grpc_core::Tracer grpc_lb_pick_first_trace - (false, "pick_first"); +grpc_core::Tracer grpc_lb_pick_first_trace(false, "pick_first"); typedef struct pending_pick { struct pending_pick *next; @@ -708,7 +707,6 @@ static grpc_lb_policy_factory *pick_first_lb_factory_create() { extern "C" void grpc_lb_policy_pick_first_init() { grpc_register_lb_policy(pick_first_lb_factory_create()); - } extern "C" void grpc_lb_policy_pick_first_shutdown() {} diff --git a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc index f8c6830792..e7cf8ce6f7 100644 --- a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +++ b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc @@ -38,8 +38,7 @@ #include "src/core/lib/transport/connectivity_state.h" #include "src/core/lib/transport/static_metadata.h" -grpc_core::Tracer grpc_lb_round_robin_trace - (false, "round_robin"); +grpc_core::Tracer grpc_lb_round_robin_trace(false, "round_robin"); /** List of entities waiting for a pick. * @@ -918,7 +917,6 @@ static grpc_lb_policy_factory *round_robin_lb_factory_create() { extern "C" void grpc_lb_policy_round_robin_init() { grpc_register_lb_policy(round_robin_lb_factory_create()); - } extern "C" void grpc_lb_policy_round_robin_shutdown() {} diff --git a/src/core/ext/filters/client_channel/resolver.cc b/src/core/ext/filters/client_channel/resolver.cc index 1863a94162..9ce4f80e63 100644 --- a/src/core/ext/filters/client_channel/resolver.cc +++ b/src/core/ext/filters/client_channel/resolver.cc @@ -20,8 +20,7 @@ #include "src/core/lib/iomgr/combiner.h" #ifndef NDEBUG -grpc_core::Tracer grpc_trace_resolver_refcount - (false, "resolver_refcount"); +grpc_core::Tracer grpc_trace_resolver_refcount(false, "resolver_refcount"); #endif void grpc_resolver_init(grpc_resolver *resolver, diff --git a/src/core/ext/filters/http/http_filters_plugin.cc b/src/core/ext/filters/http/http_filters_plugin.cc index 24d46a60ae..cbcbca1efc 100644 --- a/src/core/ext/filters/http/http_filters_plugin.cc +++ b/src/core/ext/filters/http/http_filters_plugin.cc @@ -65,7 +65,6 @@ static bool maybe_add_required_filter(grpc_exec_ctx *exec_ctx, } extern "C" void grpc_http_filters_init(void) { - grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, maybe_add_optional_filter, &compress_filter); diff --git a/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc b/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc index 06059cb92a..13c3966762 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc @@ -21,11 +21,8 @@ #include "src/core/lib/transport/metadata.h" extern "C" void grpc_chttp2_plugin_init(void) { - - - #ifndef NDEBUG - + #endif } diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index 664fb72e57..a103038893 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -95,8 +95,7 @@ grpc_core::Tracer grpc_http_trace(false, "http"); grpc_core::Tracer grpc_flowctl_trace(false, "flowctl"); #ifndef NDEBUG -grpc_core::Tracer grpc_trace_chttp2_refcount - (false, "chttp2_refcount"); +grpc_core::Tracer grpc_trace_chttp2_refcount(false, "chttp2_refcount"); #endif /* forward declarations of various callbacks that we'll build closures around */ @@ -3062,8 +3061,7 @@ static void benign_reclaimer_locked(grpc_exec_ctx *exec_ctx, void *arg, grpc_error_set_int( GRPC_ERROR_CREATE_FROM_STATIC_STRING("Buffers full"), GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_ENHANCE_YOUR_CALM)); - } else if (error == GRPC_ERROR_NONE && - grpc_resource_quota_trace.enabled()) { + } else if (error == GRPC_ERROR_NONE && grpc_resource_quota_trace.enabled()) { gpr_log(GPR_DEBUG, "HTTP2: %s - skip benign reclamation, there are still %" PRIdPTR " streams", diff --git a/src/core/ext/transport/chttp2/transport/frame_settings.cc b/src/core/ext/transport/chttp2/transport/frame_settings.cc index b3fc08041f..8ee12aeceb 100644 --- a/src/core/ext/transport/chttp2/transport/frame_settings.cc +++ b/src/core/ext/transport/chttp2/transport/frame_settings.cc @@ -204,8 +204,7 @@ grpc_error *grpc_chttp2_settings_parser_parse(grpc_exec_ctx *exec_ctx, void *p, parser->incoming_settings[id] != parser->value) { t->flow_control.initial_window_update += (int64_t)parser->value - parser->incoming_settings[id]; - if (grpc_http_trace.enabled() || - grpc_flowctl_trace.enabled()) { + if (grpc_http_trace.enabled() || grpc_flowctl_trace.enabled()) { gpr_log(GPR_DEBUG, "%p[%s] adding %d for initial_window change", t, t->is_client ? "cli" : "svr", (int)t->flow_control.initial_window_update); diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 07dc381e0a..55cb55de56 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -797,19 +797,19 @@ extern grpc_core::Tracer grpc_http_trace; extern grpc_core::Tracer grpc_flowctl_trace; #ifndef NDEBUG -#define GRPC_FLOW_CONTROL_IF_TRACING(stmt) \ - if (!(grpc_flowctl_trace.enabled())) \ - ; \ - else \ +#define GRPC_FLOW_CONTROL_IF_TRACING(stmt) \ + if (!(grpc_flowctl_trace.enabled())) \ + ; \ + else \ stmt #else #define GRPC_FLOW_CONTROL_IF_TRACING(stmt) #endif -#define GRPC_CHTTP2_IF_TRACING(stmt) \ - if (!(grpc_http_trace.enabled())) \ - ; \ - else \ +#define GRPC_CHTTP2_IF_TRACING(stmt) \ + if (!(grpc_http_trace.enabled())) \ + ; \ + else \ stmt void grpc_chttp2_fake_status(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, diff --git a/src/core/ext/transport/chttp2/transport/stream_lists.cc b/src/core/ext/transport/chttp2/transport/stream_lists.cc index 3595d09a8f..76538976b6 100644 --- a/src/core/ext/transport/chttp2/transport/stream_lists.cc +++ b/src/core/ext/transport/chttp2/transport/stream_lists.cc @@ -39,8 +39,7 @@ static const char *stream_list_id_string(grpc_chttp2_stream_list_id id) { GPR_UNREACHABLE_CODE(return "unknown"); } -grpc_core::Tracer grpc_trace_http2_stream_state - (false, "http2_stream_state"); +grpc_core::Tracer grpc_trace_http2_stream_state(false, "http2_stream_state"); /* core list management */ diff --git a/src/core/ext/transport/chttp2/transport/writing.cc b/src/core/ext/transport/chttp2/transport/writing.cc index e3ee506e87..34c9bc334a 100644 --- a/src/core/ext/transport/chttp2/transport/writing.cc +++ b/src/core/ext/transport/chttp2/transport/writing.cc @@ -51,8 +51,7 @@ static void maybe_initiate_ping(grpc_exec_ctx *exec_ctx, } if (!grpc_closure_list_empty(pq->lists[GRPC_CHTTP2_PCL_INFLIGHT])) { /* ping already in-flight: wait */ - if (grpc_http_trace.enabled() || - grpc_bdp_estimator_trace.enabled()) { + if (grpc_http_trace.enabled() || grpc_bdp_estimator_trace.enabled()) { gpr_log(GPR_DEBUG, "%s: Ping delayed [%p]: already pinging", t->is_client ? "CLIENT" : "SERVER", t->peer_string); } @@ -61,8 +60,7 @@ static void maybe_initiate_ping(grpc_exec_ctx *exec_ctx, if (t->ping_state.pings_before_data_required == 0 && t->ping_policy.max_pings_without_data != 0) { /* need to receive something of substance before sending a ping again */ - if (grpc_http_trace.enabled() || - grpc_bdp_estimator_trace.enabled()) { + if (grpc_http_trace.enabled() || grpc_bdp_estimator_trace.enabled()) { gpr_log(GPR_DEBUG, "%s: Ping delayed [%p]: too many recent pings: %d/%d", t->is_client ? "CLIENT" : "SERVER", t->peer_string, t->ping_state.pings_before_data_required, @@ -81,8 +79,7 @@ static void maybe_initiate_ping(grpc_exec_ctx *exec_ctx, } if (next_allowed_ping > now) { /* not enough elapsed time between successive pings */ - if (grpc_http_trace.enabled() || - grpc_bdp_estimator_trace.enabled()) { + if (grpc_http_trace.enabled() || grpc_bdp_estimator_trace.enabled()) { gpr_log(GPR_DEBUG, "%s: Ping delayed [%p]: not enough time elapsed since last ping", t->is_client ? "CLIENT" : "SERVER", t->peer_string); @@ -103,8 +100,7 @@ static void maybe_initiate_ping(grpc_exec_ctx *exec_ctx, grpc_chttp2_ping_create(false, pq->inflight_id)); GRPC_STATS_INC_HTTP2_PINGS_SENT(exec_ctx); t->ping_state.last_ping_sent_time = now; - if (grpc_http_trace.enabled() || - grpc_bdp_estimator_trace.enabled()) { + if (grpc_http_trace.enabled() || grpc_bdp_estimator_trace.enabled()) { gpr_log(GPR_DEBUG, "%s: Ping sent [%p]: %d/%d", t->is_client ? "CLIENT" : "SERVER", t->peer_string, t->ping_state.pings_before_data_required, diff --git a/src/core/ext/transport/inproc/inproc_transport.cc b/src/core/ext/transport/inproc/inproc_transport.cc index 047a24c145..c2af5fb9cd 100644 --- a/src/core/ext/transport/inproc/inproc_transport.cc +++ b/src/core/ext/transport/inproc/inproc_transport.cc @@ -32,8 +32,8 @@ #include "src/core/lib/transport/error_utils.h" #include "src/core/lib/transport/transport_impl.h" -#define INPROC_LOG(...) \ - do { \ +#define INPROC_LOG(...) \ + do { \ if (grpc_inproc_trace.enabled()) gpr_log(__VA_ARGS__); \ } while (0) diff --git a/src/core/lib/channel/channel_stack_builder.cc b/src/core/lib/channel/channel_stack_builder.cc index 83f8113a35..3ee70a85be 100644 --- a/src/core/lib/channel/channel_stack_builder.cc +++ b/src/core/lib/channel/channel_stack_builder.cc @@ -23,8 +23,8 @@ #include #include -grpc_core::Tracer grpc_trace_channel_stack_builder - (false, "channel_stack_builder"); +grpc_core::Tracer grpc_trace_channel_stack_builder(false, + "channel_stack_builder"); typedef struct filter_node { struct filter_node *next; diff --git a/src/core/lib/iomgr/call_combiner.cc b/src/core/lib/iomgr/call_combiner.cc index d36e2c5bef..48122d6b55 100644 --- a/src/core/lib/iomgr/call_combiner.cc +++ b/src/core/lib/iomgr/call_combiner.cc @@ -24,8 +24,7 @@ #include "src/core/lib/debug/stats.h" #include "src/core/lib/profiling/timers.h" -grpc_core::Tracer grpc_call_combiner_trace - (false, "call_combiner"); +grpc_core::Tracer grpc_call_combiner_trace(false, "call_combiner"); static grpc_error* decode_cancel_state_error(gpr_atm cancel_state) { if (cancel_state & 1) { diff --git a/src/core/lib/iomgr/combiner.cc b/src/core/lib/iomgr/combiner.cc index 2d1c652041..b77ddbffa1 100644 --- a/src/core/lib/iomgr/combiner.cc +++ b/src/core/lib/iomgr/combiner.cc @@ -29,14 +29,13 @@ #include "src/core/lib/iomgr/executor.h" #include "src/core/lib/profiling/timers.h" -grpc_core::Tracer grpc_combiner_trace - (false, "combiner"); +grpc_core::Tracer grpc_combiner_trace(false, "combiner"); -#define GRPC_COMBINER_TRACE(fn) \ - do { \ +#define GRPC_COMBINER_TRACE(fn) \ + do { \ if (grpc_combiner_trace.enabled()) { \ - fn; \ - } \ + fn; \ + } \ } while (0) #define STATE_UNORPHANED 1 @@ -106,7 +105,7 @@ static void start_destroy(grpc_exec_ctx *exec_ctx, grpc_combiner *lock) { #ifndef NDEBUG #define GRPC_COMBINER_DEBUG_SPAM(op, delta) \ - if (grpc_combiner_trace.enabled()) { \ + if (grpc_combiner_trace.enabled()) { \ gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, \ "C:%p %s %" PRIdPTR " --> %" PRIdPTR " %s", lock, (op), \ gpr_atm_no_barrier_load(&lock->refs.count), \ diff --git a/src/core/lib/iomgr/error.cc b/src/core/lib/iomgr/error.cc index cbb27f442e..578d35764f 100644 --- a/src/core/lib/iomgr/error.cc +++ b/src/core/lib/iomgr/error.cc @@ -38,8 +38,7 @@ #include "src/core/lib/slice/slice_internal.h" #ifndef NDEBUG -grpc_core::Tracer grpc_trace_error_refcount - (false, "error_refcount"); +grpc_core::Tracer grpc_trace_error_refcount(false, "error_refcount"); #endif static const char *error_int_name(grpc_error_ints key) { diff --git a/src/core/lib/iomgr/ev_epollsig_linux.cc b/src/core/lib/iomgr/ev_epollsig_linux.cc index 648de4f7e1..ad7b27b279 100644 --- a/src/core/lib/iomgr/ev_epollsig_linux.cc +++ b/src/core/lib/iomgr/ev_epollsig_linux.cc @@ -53,9 +53,9 @@ #define GRPC_POLLSET_KICK_BROADCAST ((grpc_pollset_worker *)1) -#define GRPC_POLLING_TRACE(...) \ +#define GRPC_POLLING_TRACE(...) \ if (grpc_polling_trace.enabled()) { \ - gpr_log(GPR_INFO, __VA_ARGS__); \ + gpr_log(GPR_INFO, __VA_ARGS__); \ } static int grpc_wakeup_signal = -1; diff --git a/src/core/lib/iomgr/ev_posix.cc b/src/core/lib/iomgr/ev_posix.cc index 166801e229..45403c3037 100644 --- a/src/core/lib/iomgr/ev_posix.cc +++ b/src/core/lib/iomgr/ev_posix.cc @@ -36,12 +36,11 @@ #include "src/core/lib/iomgr/ev_poll_posix.h" #include "src/core/lib/support/env.h" -grpc_core::Tracer grpc_polling_trace - (false, "polling"); /* Disabled by default */ +grpc_core::Tracer grpc_polling_trace(false, + "polling"); /* Disabled by default */ #ifndef NDEBUG -grpc_core::Tracer grpc_trace_fd_refcount - (false, "fd_refcount"); +grpc_core::Tracer grpc_trace_fd_refcount(false, "fd_refcount"); #endif /** Default poll() function - a pointer so that it can be overridden by some @@ -156,8 +155,6 @@ const grpc_event_engine_vtable *grpc_get_event_engine_test_only() { const char *grpc_get_poll_strategy_name() { return g_poll_strategy_name; } void grpc_event_engine_init(void) { - - char *s = gpr_getenv("GRPC_POLL_STRATEGY"); if (s == NULL) { s = gpr_strdup("all"); diff --git a/src/core/lib/iomgr/ev_windows.cc b/src/core/lib/iomgr/ev_windows.cc index c9d83c0949..c2e5d55df8 100644 --- a/src/core/lib/iomgr/ev_windows.cc +++ b/src/core/lib/iomgr/ev_windows.cc @@ -22,7 +22,7 @@ #include "src/core/lib/debug/trace.h" -grpc_core::Tracer grpc_polling_trace - (false, "polling"); /* Disabled by default */ +grpc_core::Tracer grpc_polling_trace(false, + "polling"); /* Disabled by default */ #endif // GRPC_WINSOCK_SOCKET diff --git a/src/core/lib/iomgr/executor.cc b/src/core/lib/iomgr/executor.cc index bf233087d5..085c2127a1 100644 --- a/src/core/lib/iomgr/executor.cc +++ b/src/core/lib/iomgr/executor.cc @@ -51,8 +51,7 @@ static gpr_spinlock g_adding_thread_lock = GPR_SPINLOCK_STATIC_INITIALIZER; GPR_TLS_DECL(g_this_thread_state); -static grpc_core::Tracer executor_trace - (false, "executor"); +static grpc_core::Tracer executor_trace(false, "executor"); static void executor_thread(void *arg); @@ -134,7 +133,6 @@ void grpc_executor_set_threading(grpc_exec_ctx *exec_ctx, bool threading) { } void grpc_executor_init(grpc_exec_ctx *exec_ctx) { - gpr_atm_no_barrier_store(&g_cur_threads, 0); grpc_executor_set_threading(exec_ctx, true); } diff --git a/src/core/lib/iomgr/iomgr_posix.cc b/src/core/lib/iomgr/iomgr_posix.cc index 3135b1d563..f8f6fe2353 100644 --- a/src/core/lib/iomgr/iomgr_posix.cc +++ b/src/core/lib/iomgr/iomgr_posix.cc @@ -28,7 +28,6 @@ void grpc_iomgr_platform_init(void) { grpc_wakeup_fd_global_init(); grpc_event_engine_init(); - } void grpc_iomgr_platform_flush(void) {} diff --git a/src/core/lib/iomgr/iomgr_uv.cc b/src/core/lib/iomgr/iomgr_uv.cc index d63829b8b1..b8a10f2ae8 100644 --- a/src/core/lib/iomgr/iomgr_uv.cc +++ b/src/core/lib/iomgr/iomgr_uv.cc @@ -31,7 +31,7 @@ gpr_thd_id g_init_thread; void grpc_iomgr_platform_init(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_pollset_global_init(); - + grpc_executor_set_threading(&exec_ctx, false); g_init_thread = gpr_thd_currentid(); grpc_exec_ctx_finish(&exec_ctx); diff --git a/src/core/lib/iomgr/pollset_uv.cc b/src/core/lib/iomgr/pollset_uv.cc index 336379b457..cf3566d08f 100644 --- a/src/core/lib/iomgr/pollset_uv.cc +++ b/src/core/lib/iomgr/pollset_uv.cc @@ -35,8 +35,7 @@ #include "src/core/lib/debug/trace.h" #ifndef NDEBUG -grpc_core::Tracer grpc_trace_fd_refcount - (false, "fd_refcount"); +grpc_core::Tracer grpc_trace_fd_refcount(false, "fd_refcount"); #endif struct grpc_pollset { diff --git a/src/core/lib/iomgr/pollset_windows.cc b/src/core/lib/iomgr/pollset_windows.cc index a7df9f27bf..d0d299b6b7 100644 --- a/src/core/lib/iomgr/pollset_windows.cc +++ b/src/core/lib/iomgr/pollset_windows.cc @@ -31,8 +31,7 @@ #define GRPC_POLLSET_KICK_BROADCAST ((grpc_pollset_worker *)1) #ifndef NDEBUG -grpc_core::Tracer grpc_trace_fd_refcount - (false, "fd_refcount"); +grpc_core::Tracer grpc_trace_fd_refcount(false, "fd_refcount"); #endif gpr_mu grpc_polling_mu; diff --git a/src/core/lib/iomgr/resource_quota.cc b/src/core/lib/iomgr/resource_quota.cc index 966b05fd5b..d3ed87a1c0 100644 --- a/src/core/lib/iomgr/resource_quota.cc +++ b/src/core/lib/iomgr/resource_quota.cc @@ -31,8 +31,7 @@ #include "src/core/lib/iomgr/combiner.h" -grpc_core::Tracer grpc_resource_quota_trace - (false, "resource_quota"); +grpc_core::Tracer grpc_resource_quota_trace(false, "resource_quota"); #define MEMORY_USAGE_ESTIMATION_MAX 65536 diff --git a/src/core/lib/iomgr/timer_generic.cc b/src/core/lib/iomgr/timer_generic.cc index 05984c4f90..98b4ca22ab 100644 --- a/src/core/lib/iomgr/timer_generic.cc +++ b/src/core/lib/iomgr/timer_generic.cc @@ -45,8 +45,7 @@ extern "C" { grpc_core::Tracer grpc_timer_trace(false, "timer"); -grpc_core::Tracer grpc_timer_check_trace - (false, "timer_check"); +grpc_core::Tracer grpc_timer_check_trace(false, "timer_check"); } /* A "timer shard". Contains a 'heap' and a 'list' of timers. All timers with @@ -247,8 +246,6 @@ void grpc_timer_list_init(grpc_exec_ctx *exec_ctx) { g_shared_mutables.min_timer = grpc_exec_ctx_now(exec_ctx); gpr_tls_init(&g_last_seen_min_timer); gpr_tls_set(&g_last_seen_min_timer, 0); - - for (i = 0; i < NUM_SHARDS; i++) { timer_shard *shard = &g_shards[i]; diff --git a/src/core/lib/iomgr/timer_uv.cc b/src/core/lib/iomgr/timer_uv.cc index 7ddfafd002..a64269585c 100644 --- a/src/core/lib/iomgr/timer_uv.cc +++ b/src/core/lib/iomgr/timer_uv.cc @@ -31,8 +31,7 @@ extern "C" { grpc_core::Tracer grpc_timer_trace(false, "timer"); -grpc_core::Tracer grpc_timer_check_trace - (false, "timer_check"); +grpc_core::Tracer grpc_timer_check_trace(false, "timer_check"); } static void timer_close_callback(uv_handle_t *handle) { gpr_free(handle); } diff --git a/src/core/lib/security/context/security_context.cc b/src/core/lib/security/context/security_context.cc index 96bec5a4c7..39f92fe595 100644 --- a/src/core/lib/security/context/security_context.cc +++ b/src/core/lib/security/context/security_context.cc @@ -30,8 +30,8 @@ #include #ifndef NDEBUG -grpc_core::Tracer grpc_trace_auth_context_refcount - (false, "auth_context_refcount"); +grpc_core::Tracer grpc_trace_auth_context_refcount(false, + "auth_context_refcount"); #endif /* --- grpc_call --- */ diff --git a/src/core/lib/security/credentials/plugin/plugin_credentials.cc b/src/core/lib/security/credentials/plugin/plugin_credentials.cc index acff5ae7d2..cf03241016 100644 --- a/src/core/lib/security/credentials/plugin/plugin_credentials.cc +++ b/src/core/lib/security/credentials/plugin/plugin_credentials.cc @@ -31,8 +31,7 @@ #include "src/core/lib/surface/api_trace.h" #include "src/core/lib/surface/validate_metadata.h" -grpc_core::Tracer grpc_plugin_credentials_trace - (false, "plugin_credentials"); +grpc_core::Tracer grpc_plugin_credentials_trace(false, "plugin_credentials"); static void plugin_destruct(grpc_exec_ctx *exec_ctx, grpc_call_credentials *creds) { diff --git a/src/core/lib/security/transport/secure_endpoint.cc b/src/core/lib/security/transport/secure_endpoint.cc index 901675f7a0..e2772980cd 100644 --- a/src/core/lib/security/transport/secure_endpoint.cc +++ b/src/core/lib/security/transport/secure_endpoint.cc @@ -61,8 +61,7 @@ typedef struct { gpr_refcount ref; } secure_endpoint; -grpc_core::Tracer grpc_trace_secure_endpoint - (false, "secure_endpoint"); +grpc_core::Tracer grpc_trace_secure_endpoint(false, "secure_endpoint"); static void destroy(grpc_exec_ctx *exec_ctx, secure_endpoint *secure_ep) { secure_endpoint *ep = secure_ep; diff --git a/src/core/lib/security/transport/security_connector.cc b/src/core/lib/security/transport/security_connector.cc index 3d205ddefe..3c19d5e60a 100644 --- a/src/core/lib/security/transport/security_connector.cc +++ b/src/core/lib/security/transport/security_connector.cc @@ -44,8 +44,8 @@ #include "src/core/tsi/transport_security_adapter.h" #ifndef NDEBUG -grpc_core::Tracer grpc_trace_security_connector_refcount - (false, "security_connector_refcount"); +grpc_core::Tracer grpc_trace_security_connector_refcount( + false, "security_connector_refcount"); #endif /* -- Constants. -- */ diff --git a/src/core/lib/surface/alarm.cc b/src/core/lib/surface/alarm.cc index 721c2fcd1e..6bab0be849 100644 --- a/src/core/lib/surface/alarm.cc +++ b/src/core/lib/surface/alarm.cc @@ -28,8 +28,7 @@ #include "src/core/lib/surface/completion_queue.h" #ifndef NDEBUG -grpc_core::Tracer grpc_trace_alarm_refcount - (false, "alarm_refcount"); +grpc_core::Tracer grpc_trace_alarm_refcount(false, "alarm_refcount"); #endif struct grpc_alarm { diff --git a/src/core/lib/surface/api_trace.h b/src/core/lib/surface/api_trace.h index 8433175f9b..044ed9b6ec 100644 --- a/src/core/lib/surface/api_trace.h +++ b/src/core/lib/surface/api_trace.h @@ -47,7 +47,7 @@ extern grpc_core::Tracer grpc_api_trace; /* Due to the limitations of C89's preprocessor, the arity of the var-arg list 'nargs' must be specified. */ #define GRPC_API_TRACE(fmt, nargs, args) \ - if (grpc_api_trace.enabled()) { \ + if (grpc_api_trace.enabled()) { \ gpr_log(GPR_INFO, fmt GRPC_API_TRACE_UNWRAP##nargs args); \ } diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index e2cf832c7f..21a0285e1c 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -259,10 +259,8 @@ struct grpc_call { gpr_atm recv_state; }; -grpc_core::Tracer grpc_call_error_trace - (false, "call_error"); -grpc_core::Tracer grpc_compression_trace - (false, "compression"); +grpc_core::Tracer grpc_call_error_trace(false, "call_error"); +grpc_core::Tracer grpc_compression_trace(false, "compression"); #define CALL_STACK_FROM_CALL(call) ((grpc_call_stack *)((call) + 1)) #define CALL_FROM_CALL_STACK(call_stack) (((grpc_call *)(call_stack)) - 1) diff --git a/src/core/lib/surface/call.h b/src/core/lib/surface/call.h index ee7dc5cc16..f00cf0503b 100644 --- a/src/core/lib/surface/call.h +++ b/src/core/lib/surface/call.h @@ -102,8 +102,7 @@ void grpc_call_context_set(grpc_call *call, grpc_context_index elem, void *grpc_call_context_get(grpc_call *call, grpc_context_index elem); #define GRPC_CALL_LOG_BATCH(sev, call, ops, nops, tag) \ - if (grpc_api_trace.enabled()) \ - grpc_call_log_batch(sev, call, ops, nops, tag) + if (grpc_api_trace.enabled()) grpc_call_log_batch(sev, call, ops, nops, tag) uint8_t grpc_call_is_client(grpc_call *call); diff --git a/src/core/lib/surface/completion_queue.cc b/src/core/lib/surface/completion_queue.cc index 33378516ff..c0ef8a8a1c 100644 --- a/src/core/lib/surface/completion_queue.cc +++ b/src/core/lib/surface/completion_queue.cc @@ -39,13 +39,10 @@ #include "src/core/lib/surface/call.h" #include "src/core/lib/surface/event_string.h" -grpc_core::Tracer grpc_trace_operation_failures - (false, "op_failure"); +grpc_core::Tracer grpc_trace_operation_failures(false, "op_failure"); #ifndef NDEBUG -grpc_core::Tracer grpc_trace_pending_tags - (false, "pending_tags"); -grpc_core::Tracer grpc_trace_cq_refcount - (false, "cq_refcount"); +grpc_core::Tracer grpc_trace_pending_tags(false, "pending_tags"); +grpc_core::Tracer grpc_trace_cq_refcount(false, "cq_refcount"); #endif typedef struct { @@ -328,18 +325,15 @@ static const cq_vtable g_cq_vtable[] = { #define POLLSET_FROM_CQ(cq) \ ((grpc_pollset *)(cq->vtable->data_size + (char *)DATA_FROM_CQ(cq))) -grpc_core::Tracer grpc_cq_pluck_trace - (true, "queue_pluck"); -grpc_core::Tracer grpc_cq_event_timeout_trace - (true, "queue_timeout"); - -#define GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, event) \ - if (grpc_api_trace.enabled() && \ - (grpc_cq_pluck_trace.enabled() || \ - (event)->type != GRPC_QUEUE_TIMEOUT)) { \ - char *_ev = grpc_event_string(event); \ - gpr_log(GPR_INFO, "RETURN_EVENT[%p]: %s", cq, _ev); \ - gpr_free(_ev); \ +grpc_core::Tracer grpc_cq_pluck_trace(true, "queue_pluck"); +grpc_core::Tracer grpc_cq_event_timeout_trace(true, "queue_timeout"); + +#define GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, event) \ + if (grpc_api_trace.enabled() && (grpc_cq_pluck_trace.enabled() || \ + (event)->type != GRPC_QUEUE_TIMEOUT)) { \ + char *_ev = grpc_event_string(event); \ + gpr_log(GPR_INFO, "RETURN_EVENT[%p]: %s", cq, _ev); \ + gpr_free(_ev); \ } static void on_pollset_shutdown_done(grpc_exec_ctx *exec_ctx, void *cq, @@ -605,15 +599,13 @@ static void cq_end_op_for_next(grpc_exec_ctx *exec_ctx, GPR_TIMER_BEGIN("cq_end_op_for_next", 0); if (grpc_api_trace.enabled() || - (grpc_trace_operation_failures.enabled() && - error != GRPC_ERROR_NONE)) { + (grpc_trace_operation_failures.enabled() && error != GRPC_ERROR_NONE)) { const char *errmsg = grpc_error_string(error); GRPC_API_TRACE( "cq_end_op_for_next(exec_ctx=%p, cq=%p, tag=%p, error=%s, " "done=%p, done_arg=%p, storage=%p)", 7, (exec_ctx, cq, tag, errmsg, done, done_arg, storage)); - if (grpc_trace_operation_failures.enabled() && - error != GRPC_ERROR_NONE) { + if (grpc_trace_operation_failures.enabled() && error != GRPC_ERROR_NONE) { gpr_log(GPR_ERROR, "Operation failed: tag=%p, error=%s", tag, errmsg); } } @@ -689,15 +681,13 @@ static void cq_end_op_for_pluck(grpc_exec_ctx *exec_ctx, GPR_TIMER_BEGIN("cq_end_op_for_pluck", 0); if (grpc_api_trace.enabled() || - (grpc_trace_operation_failures.enabled() && - error != GRPC_ERROR_NONE)) { + (grpc_trace_operation_failures.enabled() && error != GRPC_ERROR_NONE)) { const char *errmsg = grpc_error_string(error); GRPC_API_TRACE( "cq_end_op_for_pluck(exec_ctx=%p, cq=%p, tag=%p, error=%s, " "done=%p, done_arg=%p, storage=%p)", 7, (exec_ctx, cq, tag, errmsg, done, done_arg, storage)); - if (grpc_trace_operation_failures.enabled() && - error != GRPC_ERROR_NONE) { + if (grpc_trace_operation_failures.enabled() && error != GRPC_ERROR_NONE) { gpr_log(GPR_ERROR, "Operation failed: tag=%p, error=%s", tag, errmsg); } } diff --git a/src/core/lib/surface/init.cc b/src/core/lib/surface/init.cc index 9ad8214a18..2db761b4dc 100644 --- a/src/core/lib/surface/init.cc +++ b/src/core/lib/surface/init.cc @@ -125,29 +125,9 @@ void grpc_init(void) { grpc_slice_intern_init(); grpc_mdctx_global_init(); grpc_channel_init_init(); - - - - - - - - - - - - - - + #ifndef NDEBUG - - - - - - - - + #endif grpc_security_pre_init(); grpc_iomgr_init(&exec_ctx); diff --git a/src/core/lib/surface/init_secure.cc b/src/core/lib/surface/init_secure.cc index 97adc9fdda..80b1fe022f 100644 --- a/src/core/lib/surface/init_secure.cc +++ b/src/core/lib/surface/init_secure.cc @@ -38,11 +38,8 @@ #endif void grpc_security_pre_init(void) { - - #ifndef NDEBUG - - + #endif } @@ -85,7 +82,4 @@ void grpc_register_security_filters(void) { maybe_prepend_server_auth_filter, NULL); } -void grpc_security_init() { - grpc_security_register_handshaker_factories(); - -} +void grpc_security_init() { grpc_security_register_handshaker_factories(); } diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc index b2a35f9848..081fa54f16 100644 --- a/src/core/lib/surface/server.cc +++ b/src/core/lib/surface/server.cc @@ -59,8 +59,7 @@ typedef struct registered_method registered_method; typedef enum { BATCH_CALL, REGISTERED_CALL } requested_call_type; -grpc_core::Tracer grpc_server_channel_trace - (false, "server_channel"); +grpc_core::Tracer grpc_server_channel_trace(false, "server_channel"); typedef struct requested_call { requested_call_type type; diff --git a/src/core/lib/transport/bdp_estimator.cc b/src/core/lib/transport/bdp_estimator.cc index 82fcb9e562..6eb2f54864 100644 --- a/src/core/lib/transport/bdp_estimator.cc +++ b/src/core/lib/transport/bdp_estimator.cc @@ -23,8 +23,7 @@ #include -grpc_core::Tracer grpc_bdp_estimator_trace - (false, "bdp_estimator"); +grpc_core::Tracer grpc_bdp_estimator_trace(false, "bdp_estimator"); namespace grpc_core { diff --git a/src/core/lib/transport/connectivity_state.cc b/src/core/lib/transport/connectivity_state.cc index cf95a3c469..f9e8185555 100644 --- a/src/core/lib/transport/connectivity_state.cc +++ b/src/core/lib/transport/connectivity_state.cc @@ -24,8 +24,7 @@ #include #include -grpc_core::Tracer grpc_connectivity_state_trace - (false, "connectivity_state"); +grpc_core::Tracer grpc_connectivity_state_trace(false, "connectivity_state"); const char *grpc_connectivity_state_name(grpc_connectivity_state state) { switch (state) { diff --git a/src/core/lib/transport/metadata.cc b/src/core/lib/transport/metadata.cc index a138d59f9d..99eccba34e 100644 --- a/src/core/lib/transport/metadata.cc +++ b/src/core/lib/transport/metadata.cc @@ -49,8 +49,7 @@ */ #ifndef NDEBUG -grpc_core::Tracer grpc_trace_metadata - (false, "metadata"); +grpc_core::Tracer grpc_trace_metadata(false, "metadata"); #define DEBUG_ARGS , const char *file, int line #define FWD_DEBUG_ARGS , file, line #define REF_MD_LOCKED(shard, s) ref_md_locked((shard), (s), __FILE__, __LINE__) diff --git a/src/core/lib/transport/transport.cc b/src/core/lib/transport/transport.cc index e75524d07d..4055e9c881 100644 --- a/src/core/lib/transport/transport.cc +++ b/src/core/lib/transport/transport.cc @@ -32,8 +32,7 @@ #include "src/core/lib/transport/transport_impl.h" #ifndef NDEBUG -grpc_core::Tracer grpc_trace_stream_refcount - (false, "stream_refcount"); +grpc_core::Tracer grpc_trace_stream_refcount(false, "stream_refcount"); #endif #ifndef NDEBUG -- cgit v1.2.3 From 694580faee3a3bb91f9922a1d04125aa48f50bd5 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 18 Oct 2017 14:48:14 -0700 Subject: Better name --- include/grpc/grpc.h | 2 +- src/core/ext/filters/client_channel/client_channel.cc | 2 +- src/core/ext/filters/client_channel/client_channel.h | 2 +- src/core/ext/filters/client_channel/lb_policy.cc | 2 +- src/core/ext/filters/client_channel/lb_policy.h | 2 +- .../filters/client_channel/lb_policy/grpclb/grpclb.cc | 2 +- .../client_channel/lb_policy/pick_first/pick_first.cc | 2 +- .../client_channel/lb_policy/round_robin/round_robin.cc | 2 +- src/core/ext/filters/client_channel/resolver.cc | 2 +- src/core/ext/filters/client_channel/resolver.h | 2 +- .../ext/transport/chttp2/transport/chttp2_transport.cc | 6 +++--- .../ext/transport/chttp2/transport/chttp2_transport.h | 8 ++++---- src/core/ext/transport/chttp2/transport/hpack_encoder.cc | 2 +- src/core/ext/transport/chttp2/transport/hpack_table.cc | 2 +- src/core/ext/transport/chttp2/transport/internal.h | 4 ++-- src/core/ext/transport/chttp2/transport/stream_lists.cc | 2 +- src/core/ext/transport/inproc/inproc_plugin.cc | 2 +- src/core/ext/transport/inproc/inproc_transport.h | 2 +- src/core/lib/channel/channel_stack.cc | 2 +- src/core/lib/channel/channel_stack.h | 2 +- src/core/lib/channel/channel_stack_builder.cc | 2 +- src/core/lib/channel/channel_stack_builder.h | 2 +- src/core/lib/debug/trace.cc | 16 ++++++++-------- src/core/lib/debug/trace.h | 10 +++++----- src/core/lib/http/parser.cc | 2 +- src/core/lib/http/parser.h | 2 +- src/core/lib/iomgr/call_combiner.cc | 2 +- src/core/lib/iomgr/call_combiner.h | 2 +- src/core/lib/iomgr/closure.cc | 2 +- src/core/lib/iomgr/closure.h | 2 +- src/core/lib/iomgr/combiner.cc | 2 +- src/core/lib/iomgr/combiner.h | 2 +- src/core/lib/iomgr/error.cc | 2 +- src/core/lib/iomgr/error.h | 2 +- src/core/lib/iomgr/ev_epollex_linux.cc | 2 +- src/core/lib/iomgr/ev_posix.cc | 4 ++-- src/core/lib/iomgr/ev_posix.h | 2 +- src/core/lib/iomgr/ev_windows.cc | 2 +- src/core/lib/iomgr/executor.cc | 2 +- src/core/lib/iomgr/lockfree_event.cc | 2 +- src/core/lib/iomgr/pollset.h | 2 +- src/core/lib/iomgr/pollset_uv.cc | 2 +- src/core/lib/iomgr/pollset_windows.cc | 2 +- src/core/lib/iomgr/resource_quota.cc | 2 +- src/core/lib/iomgr/resource_quota.h | 2 +- src/core/lib/iomgr/tcp_client_posix.cc | 2 +- src/core/lib/iomgr/tcp_client_uv.cc | 2 +- src/core/lib/iomgr/tcp_posix.cc | 2 +- src/core/lib/iomgr/tcp_posix.h | 2 +- src/core/lib/iomgr/tcp_uv.cc | 2 +- src/core/lib/iomgr/tcp_uv.h | 2 +- src/core/lib/iomgr/tcp_windows.cc | 2 +- src/core/lib/iomgr/timer_generic.cc | 4 ++-- src/core/lib/iomgr/timer_manager.cc | 2 +- src/core/lib/iomgr/timer_uv.cc | 4 ++-- src/core/lib/security/context/security_context.cc | 2 +- src/core/lib/security/context/security_context.h | 2 +- .../security/credentials/plugin/plugin_credentials.cc | 2 +- .../lib/security/credentials/plugin/plugin_credentials.h | 2 +- src/core/lib/security/transport/secure_endpoint.cc | 2 +- src/core/lib/security/transport/secure_endpoint.h | 2 +- src/core/lib/security/transport/security_connector.cc | 2 +- src/core/lib/security/transport/security_connector.h | 2 +- src/core/lib/surface/alarm.cc | 2 +- src/core/lib/surface/alarm_internal.h | 2 +- src/core/lib/surface/api_trace.cc | 2 +- src/core/lib/surface/api_trace.h | 2 +- src/core/lib/surface/call.cc | 4 ++-- src/core/lib/surface/call.h | 4 ++-- src/core/lib/surface/completion_queue.cc | 10 +++++----- src/core/lib/surface/completion_queue.h | 10 +++++----- src/core/lib/surface/server.cc | 2 +- src/core/lib/surface/server.h | 2 +- src/core/lib/transport/bdp_estimator.cc | 2 +- src/core/lib/transport/bdp_estimator.h | 2 +- src/core/lib/transport/connectivity_state.cc | 2 +- src/core/lib/transport/connectivity_state.h | 2 +- src/core/lib/transport/metadata.cc | 2 +- src/core/lib/transport/metadata.h | 2 +- src/core/lib/transport/transport.cc | 2 +- src/core/lib/transport/transport.h | 2 +- src/core/tsi/transport_security.cc | 2 +- src/core/tsi/transport_security.h | 2 +- src/core/tsi/transport_security_interface.h | 2 +- 84 files changed, 114 insertions(+), 114 deletions(-) (limited to 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc') diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index 1de289fba4..bc8d95fa4c 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -411,7 +411,7 @@ GRPCAPI void grpc_server_destroy(grpc_server *server); /** Enable or disable a tracer. - Tracers (usually controlled by the environment variable GRPC_TRACE) + TraceFlags (usually controlled by the environment variable GRPC_TRACE) allow printf-style debugging on GRPC internals, and are useful for tracking down problems in the field. diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 8a8e76ff12..70209a5020 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -55,7 +55,7 @@ /* Client channel implementation */ -grpc_core::Tracer grpc_client_channel_trace(false, "client_channel"); +grpc_core::TraceFlag grpc_client_channel_trace(false, "client_channel"); /************************************************************************* * METHOD-CONFIG TABLE diff --git a/src/core/ext/filters/client_channel/client_channel.h b/src/core/ext/filters/client_channel/client_channel.h index b5d095fe5f..d78e7a798c 100644 --- a/src/core/ext/filters/client_channel/client_channel.h +++ b/src/core/ext/filters/client_channel/client_channel.h @@ -23,7 +23,7 @@ #include "src/core/ext/filters/client_channel/resolver.h" #include "src/core/lib/channel/channel_stack.h" -extern grpc_core::Tracer grpc_client_channel_trace; +extern grpc_core::TraceFlag grpc_client_channel_trace; // Channel arg key for server URI string. #define GRPC_ARG_SERVER_URI "grpc.server_uri" diff --git a/src/core/ext/filters/client_channel/lb_policy.cc b/src/core/ext/filters/client_channel/lb_policy.cc index 738486adbb..316377b845 100644 --- a/src/core/ext/filters/client_channel/lb_policy.cc +++ b/src/core/ext/filters/client_channel/lb_policy.cc @@ -22,7 +22,7 @@ #define WEAK_REF_BITS 16 #ifndef NDEBUG -grpc_core::Tracer grpc_trace_lb_policy_refcount(false, "lb_policy_refcount"); +grpc_core::TraceFlag grpc_trace_lb_policy_refcount(false, "lb_policy_refcount"); #endif void grpc_lb_policy_init(grpc_lb_policy *policy, diff --git a/src/core/ext/filters/client_channel/lb_policy.h b/src/core/ext/filters/client_channel/lb_policy.h index 0fcb2ef17b..710c9d9f38 100644 --- a/src/core/ext/filters/client_channel/lb_policy.h +++ b/src/core/ext/filters/client_channel/lb_policy.h @@ -34,7 +34,7 @@ typedef struct grpc_lb_policy_vtable grpc_lb_policy_vtable; typedef struct grpc_lb_policy_args grpc_lb_policy_args; #ifndef NDEBUG -extern grpc_core::Tracer grpc_trace_lb_policy_refcount; +extern grpc_core::TraceFlag grpc_trace_lb_policy_refcount; #endif struct grpc_lb_policy { diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index 9ad54fabf5..eb699af6da 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -126,7 +126,7 @@ #define GRPC_GRPCLB_RECONNECT_JITTER 0.2 #define GRPC_GRPCLB_DEFAULT_FALLBACK_TIMEOUT_MS 10000 -grpc_core::Tracer grpc_lb_glb_trace(false, "glb"); +grpc_core::TraceFlag grpc_lb_glb_trace(false, "glb"); /* add lb_token of selected subchannel (address) to the call's initial * metadata */ diff --git a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc index 3454ff0cbd..831b78f345 100644 --- a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +++ b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc @@ -28,7 +28,7 @@ #include "src/core/lib/iomgr/sockaddr_utils.h" #include "src/core/lib/transport/connectivity_state.h" -grpc_core::Tracer grpc_lb_pick_first_trace(false, "pick_first"); +grpc_core::TraceFlag grpc_lb_pick_first_trace(false, "pick_first"); typedef struct pending_pick { struct pending_pick *next; diff --git a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc index e7cf8ce6f7..911df134cb 100644 --- a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +++ b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc @@ -38,7 +38,7 @@ #include "src/core/lib/transport/connectivity_state.h" #include "src/core/lib/transport/static_metadata.h" -grpc_core::Tracer grpc_lb_round_robin_trace(false, "round_robin"); +grpc_core::TraceFlag grpc_lb_round_robin_trace(false, "round_robin"); /** List of entities waiting for a pick. * diff --git a/src/core/ext/filters/client_channel/resolver.cc b/src/core/ext/filters/client_channel/resolver.cc index 9ce4f80e63..93dd834fb2 100644 --- a/src/core/ext/filters/client_channel/resolver.cc +++ b/src/core/ext/filters/client_channel/resolver.cc @@ -20,7 +20,7 @@ #include "src/core/lib/iomgr/combiner.h" #ifndef NDEBUG -grpc_core::Tracer grpc_trace_resolver_refcount(false, "resolver_refcount"); +grpc_core::TraceFlag grpc_trace_resolver_refcount(false, "resolver_refcount"); #endif void grpc_resolver_init(grpc_resolver *resolver, diff --git a/src/core/ext/filters/client_channel/resolver.h b/src/core/ext/filters/client_channel/resolver.h index 990e9737e9..3ff787acca 100644 --- a/src/core/ext/filters/client_channel/resolver.h +++ b/src/core/ext/filters/client_channel/resolver.h @@ -30,7 +30,7 @@ typedef struct grpc_resolver grpc_resolver; typedef struct grpc_resolver_vtable grpc_resolver_vtable; #ifndef NDEBUG -extern grpc_core::Tracer grpc_trace_resolver_refcount; +extern grpc_core::TraceFlag grpc_trace_resolver_refcount; #endif /** \a grpc_resolver provides \a grpc_channel_args objects to its caller */ diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index ae352d5d7a..19fdcc9150 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -90,11 +90,11 @@ static int g_default_max_pings_without_data = DEFAULT_MAX_PINGS_BETWEEN_DATA; static int g_default_max_ping_strikes = DEFAULT_MAX_PING_STRIKES; #define MAX_CLIENT_STREAM_ID 0x7fffffffu -grpc_core::Tracer grpc_http_trace(false, "http"); -grpc_core::Tracer grpc_flowctl_trace(false, "flowctl"); +grpc_core::TraceFlag grpc_http_trace(false, "http"); +grpc_core::TraceFlag grpc_flowctl_trace(false, "flowctl"); #ifndef NDEBUG -grpc_core::Tracer grpc_trace_chttp2_refcount(false, "chttp2_refcount"); +grpc_core::TraceFlag grpc_trace_chttp2_refcount(false, "chttp2_refcount"); #endif /* forward declarations of various callbacks that we'll build closures around */ diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.h b/src/core/ext/transport/chttp2/transport/chttp2_transport.h index 08c22181a7..408759a292 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.h +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.h @@ -27,12 +27,12 @@ extern "C" { #endif -extern grpc_core::Tracer grpc_http_trace; -extern grpc_core::Tracer grpc_flowctl_trace; -extern grpc_core::Tracer grpc_trace_http2_stream_state; +extern grpc_core::TraceFlag grpc_http_trace; +extern grpc_core::TraceFlag grpc_flowctl_trace; +extern grpc_core::TraceFlag grpc_trace_http2_stream_state; #ifndef NDEBUG -extern grpc_core::Tracer grpc_trace_chttp2_refcount; +extern grpc_core::TraceFlag grpc_trace_chttp2_refcount; #endif grpc_transport *grpc_create_chttp2_transport( diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc index ddb75fc9e7..c380869fc6 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc @@ -57,7 +57,7 @@ static const grpc_slice terminal_slice = { {{0, 0}} /* data.refcounted */ }; -extern grpc_core::Tracer grpc_http_trace; +extern grpc_core::TraceFlag grpc_http_trace; typedef struct { int is_first_frame; diff --git a/src/core/ext/transport/chttp2/transport/hpack_table.cc b/src/core/ext/transport/chttp2/transport/hpack_table.cc index 66bd87c94e..1cb8c0a85b 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_table.cc +++ b/src/core/ext/transport/chttp2/transport/hpack_table.cc @@ -28,7 +28,7 @@ #include "src/core/lib/debug/trace.h" #include "src/core/lib/support/murmur_hash.h" -extern grpc_core::Tracer grpc_http_trace; +extern grpc_core::TraceFlag grpc_http_trace; static struct { const char *key; diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index f1d1334e84..6ef32958e0 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -678,8 +678,8 @@ void grpc_chttp2_complete_closure_step(grpc_exec_ctx *exec_ctx, #define GRPC_CHTTP2_CLIENT_CONNECT_STRLEN \ (sizeof(GRPC_CHTTP2_CLIENT_CONNECT_STRING) - 1) -extern grpc_core::Tracer grpc_http_trace; -extern grpc_core::Tracer grpc_flowctl_trace; +extern grpc_core::TraceFlag grpc_http_trace; +extern grpc_core::TraceFlag grpc_flowctl_trace; #define GRPC_CHTTP2_IF_TRACING(stmt) \ if (!(GRPC_TRACER_ON(grpc_http_trace))) \ diff --git a/src/core/ext/transport/chttp2/transport/stream_lists.cc b/src/core/ext/transport/chttp2/transport/stream_lists.cc index 76538976b6..f2acdd4165 100644 --- a/src/core/ext/transport/chttp2/transport/stream_lists.cc +++ b/src/core/ext/transport/chttp2/transport/stream_lists.cc @@ -39,7 +39,7 @@ static const char *stream_list_id_string(grpc_chttp2_stream_list_id id) { GPR_UNREACHABLE_CODE(return "unknown"); } -grpc_core::Tracer grpc_trace_http2_stream_state(false, "http2_stream_state"); +grpc_core::TraceFlag grpc_trace_http2_stream_state(false, "http2_stream_state"); /* core list management */ diff --git a/src/core/ext/transport/inproc/inproc_plugin.cc b/src/core/ext/transport/inproc/inproc_plugin.cc index 8e0203b5ed..2526dbfa06 100644 --- a/src/core/ext/transport/inproc/inproc_plugin.cc +++ b/src/core/ext/transport/inproc/inproc_plugin.cc @@ -19,7 +19,7 @@ #include "src/core/ext/transport/inproc/inproc_transport.h" #include "src/core/lib/debug/trace.h" -grpc_core::Tracer grpc_inproc_trace(false, "inproc"); +grpc_core::TraceFlag grpc_inproc_trace(false, "inproc"); extern "C" void grpc_inproc_plugin_init(void) { grpc_inproc_transport_init(); } diff --git a/src/core/ext/transport/inproc/inproc_transport.h b/src/core/ext/transport/inproc/inproc_transport.h index 8fd8caf402..248a9dd54e 100644 --- a/src/core/ext/transport/inproc/inproc_transport.h +++ b/src/core/ext/transport/inproc/inproc_transport.h @@ -29,7 +29,7 @@ grpc_channel *grpc_inproc_channel_create(grpc_server *server, grpc_channel_args *args, void *reserved); -extern grpc_core::Tracer grpc_inproc_trace; +extern grpc_core::TraceFlag grpc_inproc_trace; void grpc_inproc_transport_init(void); void grpc_inproc_transport_shutdown(void); diff --git a/src/core/lib/channel/channel_stack.cc b/src/core/lib/channel/channel_stack.cc index 5201d6bf3d..1e48d1c5e9 100644 --- a/src/core/lib/channel/channel_stack.cc +++ b/src/core/lib/channel/channel_stack.cc @@ -23,7 +23,7 @@ #include #include -grpc_core::Tracer grpc_trace_channel(false, "channel"); +grpc_core::TraceFlag grpc_trace_channel(false, "channel"); /* Memory layouts. diff --git a/src/core/lib/channel/channel_stack.h b/src/core/lib/channel/channel_stack.h index 01d6310428..0796d6f17c 100644 --- a/src/core/lib/channel/channel_stack.h +++ b/src/core/lib/channel/channel_stack.h @@ -285,7 +285,7 @@ void grpc_call_log_op(const char *file, int line, gpr_log_severity severity, grpc_call_element *elem, grpc_transport_stream_op_batch *op); -extern grpc_core::Tracer grpc_trace_channel; +extern grpc_core::TraceFlag grpc_trace_channel; #define GRPC_CALL_LOG_OP(sev, elem, op) \ if (grpc_trace_channel.enabled()) grpc_call_log_op(sev, elem, op) diff --git a/src/core/lib/channel/channel_stack_builder.cc b/src/core/lib/channel/channel_stack_builder.cc index 3ee70a85be..f01650bd1b 100644 --- a/src/core/lib/channel/channel_stack_builder.cc +++ b/src/core/lib/channel/channel_stack_builder.cc @@ -23,7 +23,7 @@ #include #include -grpc_core::Tracer grpc_trace_channel_stack_builder(false, +grpc_core::TraceFlag grpc_trace_channel_stack_builder(false, "channel_stack_builder"); typedef struct filter_node { diff --git a/src/core/lib/channel/channel_stack_builder.h b/src/core/lib/channel/channel_stack_builder.h index d790cf9a63..981be90f68 100644 --- a/src/core/lib/channel/channel_stack_builder.h +++ b/src/core/lib/channel/channel_stack_builder.h @@ -160,7 +160,7 @@ grpc_error *grpc_channel_stack_builder_finish( void grpc_channel_stack_builder_destroy(grpc_exec_ctx *exec_ctx, grpc_channel_stack_builder *builder); -extern grpc_core::Tracer grpc_trace_channel_stack_builder; +extern grpc_core::TraceFlag grpc_trace_channel_stack_builder; #ifdef __cplusplus } diff --git a/src/core/lib/debug/trace.cc b/src/core/lib/debug/trace.cc index 5953be641a..52cfbe52ea 100644 --- a/src/core/lib/debug/trace.cc +++ b/src/core/lib/debug/trace.cc @@ -29,21 +29,21 @@ int grpc_tracer_set_enabled(const char *name, int enabled); namespace grpc_core { -Tracer::Tracer(bool default_enabled, const char *name) +TraceFlag::TraceFlag(bool default_enabled, const char *name) : next_tracer_(root_tracer_), name_(name), value_(default_enabled) { root_tracer_ = this; } -void Tracer::List() { +void TraceFlag::List() { gpr_log(GPR_DEBUG, "available tracers:"); - Tracer *t; + TraceFlag *t; for (t = root_tracer_; t != nullptr; t = t->next_tracer_) { gpr_log(GPR_DEBUG, "\t%s", t->name_); } } -bool Tracer::Set(const char *name, bool enabled) { - Tracer *t; +bool TraceFlag::Set(const char *name, bool enabled) { + TraceFlag *t; if (0 == strcmp(name, "all")) { for (t = root_tracer_; t; t = t->next_tracer_) { t->set_enabled(enabled); @@ -107,9 +107,9 @@ static void parse(const char *s) { for (i = 0; i < nstrings; i++) { if (strings[i][0] == '-') { - grpc_core::Tracer::Set(strings[i] + 1, false); + grpc_core::TraceFlag::Set(strings[i] + 1, false); } else { - grpc_core::Tracer::Set(strings[i], true); + grpc_core::TraceFlag::Set(strings[i], true); } } @@ -130,5 +130,5 @@ void grpc_tracer_init(const char *env_var) { void grpc_tracer_shutdown(void) {} int grpc_tracer_set_enabled(const char *name, int enabled) { - return grpc_core::Tracer::Set(name, enabled != 0); + return grpc_core::TraceFlag::Set(name, enabled != 0); } diff --git a/src/core/lib/debug/trace.h b/src/core/lib/debug/trace.h index c9ce850d3f..c09aa01703 100644 --- a/src/core/lib/debug/trace.h +++ b/src/core/lib/debug/trace.h @@ -44,10 +44,10 @@ void grpc_tracer_shutdown(void); namespace grpc_core { -class Tracer { +class TraceFlag { public: - Tracer(bool default_enabled, const char *name); - ~Tracer(); + TraceFlag(bool default_enabled, const char *name); + ~TraceFlag(); static bool Set(const char *tracer, bool enabled); @@ -70,8 +70,8 @@ class Tracer { #endif } - static Tracer *root_tracer_; - Tracer *next_tracer_; + static TraceFlag *root_tracer_; + TraceFlag *next_tracer_; const char *const name_; #ifdef GRPC_THREADSAFE_TRACER gpr_atm value_; diff --git a/src/core/lib/http/parser.cc b/src/core/lib/http/parser.cc index f272df11dd..720e8e85ee 100644 --- a/src/core/lib/http/parser.cc +++ b/src/core/lib/http/parser.cc @@ -25,7 +25,7 @@ #include #include -grpc_core::Tracer grpc_http1_trace(false, "http1"); +grpc_core::TraceFlag grpc_http1_trace(false, "http1"); static char *buf2str(void *buffer, size_t length) { char *out = (char *)gpr_malloc(length + 1); diff --git a/src/core/lib/http/parser.h b/src/core/lib/http/parser.h index b6efeda28a..044f159f73 100644 --- a/src/core/lib/http/parser.h +++ b/src/core/lib/http/parser.h @@ -111,7 +111,7 @@ grpc_error *grpc_http_parser_eof(grpc_http_parser *parser); void grpc_http_request_destroy(grpc_http_request *request); void grpc_http_response_destroy(grpc_http_response *response); -extern grpc_core::Tracer grpc_http1_trace; +extern grpc_core::TraceFlag grpc_http1_trace; #ifdef __cplusplus } diff --git a/src/core/lib/iomgr/call_combiner.cc b/src/core/lib/iomgr/call_combiner.cc index 48122d6b55..752303e260 100644 --- a/src/core/lib/iomgr/call_combiner.cc +++ b/src/core/lib/iomgr/call_combiner.cc @@ -24,7 +24,7 @@ #include "src/core/lib/debug/stats.h" #include "src/core/lib/profiling/timers.h" -grpc_core::Tracer grpc_call_combiner_trace(false, "call_combiner"); +grpc_core::TraceFlag grpc_call_combiner_trace(false, "call_combiner"); static grpc_error* decode_cancel_state_error(gpr_atm cancel_state) { if (cancel_state & 1) { diff --git a/src/core/lib/iomgr/call_combiner.h b/src/core/lib/iomgr/call_combiner.h index 463501a660..77420fa3e0 100644 --- a/src/core/lib/iomgr/call_combiner.h +++ b/src/core/lib/iomgr/call_combiner.h @@ -40,7 +40,7 @@ extern "C" { // when it is done with the action that was kicked off by the original // callback. -extern grpc_core::Tracer grpc_call_combiner_trace; +extern grpc_core::TraceFlag grpc_call_combiner_trace; typedef struct { gpr_atm size; // size_t, num closures in queue or currently executing diff --git a/src/core/lib/iomgr/closure.cc b/src/core/lib/iomgr/closure.cc index b2dfdbc207..8639c2b7d2 100644 --- a/src/core/lib/iomgr/closure.cc +++ b/src/core/lib/iomgr/closure.cc @@ -25,7 +25,7 @@ #include "src/core/lib/profiling/timers.h" #ifndef NDEBUG -grpc_core::Tracer grpc_trace_closure(false, "closure"); +grpc_core::TraceFlag grpc_trace_closure(false, "closure"); #endif #ifndef NDEBUG diff --git a/src/core/lib/iomgr/closure.h b/src/core/lib/iomgr/closure.h index ae946072ce..66484a210f 100644 --- a/src/core/lib/iomgr/closure.h +++ b/src/core/lib/iomgr/closure.h @@ -34,7 +34,7 @@ struct grpc_closure; typedef struct grpc_closure grpc_closure; #ifndef NDEBUG -extern grpc_core::Tracer grpc_trace_closure; +extern grpc_core::TraceFlag grpc_trace_closure; #endif typedef struct grpc_closure_list { diff --git a/src/core/lib/iomgr/combiner.cc b/src/core/lib/iomgr/combiner.cc index b77ddbffa1..30e3b9111f 100644 --- a/src/core/lib/iomgr/combiner.cc +++ b/src/core/lib/iomgr/combiner.cc @@ -29,7 +29,7 @@ #include "src/core/lib/iomgr/executor.h" #include "src/core/lib/profiling/timers.h" -grpc_core::Tracer grpc_combiner_trace(false, "combiner"); +grpc_core::TraceFlag grpc_combiner_trace(false, "combiner"); #define GRPC_COMBINER_TRACE(fn) \ do { \ diff --git a/src/core/lib/iomgr/combiner.h b/src/core/lib/iomgr/combiner.h index 5f80e1de27..8eeb0df06a 100644 --- a/src/core/lib/iomgr/combiner.h +++ b/src/core/lib/iomgr/combiner.h @@ -65,7 +65,7 @@ grpc_closure_scheduler *grpc_combiner_finally_scheduler(grpc_combiner *lock); bool grpc_combiner_continue_exec_ctx(grpc_exec_ctx *exec_ctx); -extern grpc_core::Tracer grpc_combiner_trace; +extern grpc_core::TraceFlag grpc_combiner_trace; #ifdef __cplusplus } diff --git a/src/core/lib/iomgr/error.cc b/src/core/lib/iomgr/error.cc index 578d35764f..898a18cb9e 100644 --- a/src/core/lib/iomgr/error.cc +++ b/src/core/lib/iomgr/error.cc @@ -38,7 +38,7 @@ #include "src/core/lib/slice/slice_internal.h" #ifndef NDEBUG -grpc_core::Tracer grpc_trace_error_refcount(false, "error_refcount"); +grpc_core::TraceFlag grpc_trace_error_refcount(false, "error_refcount"); #endif static const char *error_int_name(grpc_error_ints key) { diff --git a/src/core/lib/iomgr/error.h b/src/core/lib/iomgr/error.h index 0d91006a90..d4050c1138 100644 --- a/src/core/lib/iomgr/error.h +++ b/src/core/lib/iomgr/error.h @@ -39,7 +39,7 @@ extern "C" { typedef struct grpc_error grpc_error; #ifndef NDEBUG -extern grpc_core::Tracer grpc_trace_error_refcount; +extern grpc_core::TraceFlag grpc_trace_error_refcount; #endif typedef enum { diff --git a/src/core/lib/iomgr/ev_epollex_linux.cc b/src/core/lib/iomgr/ev_epollex_linux.cc index d30ca3fd5e..bdcaf926b4 100644 --- a/src/core/lib/iomgr/ev_epollex_linux.cc +++ b/src/core/lib/iomgr/ev_epollex_linux.cc @@ -58,7 +58,7 @@ #define MAX_EPOLL_EVENTS_HANDLED_EACH_POLL_CALL 5 #ifndef NDEBUG -grpc_core::Tracer grpc_trace_pollable_refcount(false, "pollable_refcount"); +grpc_core::TraceFlag grpc_trace_pollable_refcount(false, "pollable_refcount"); #endif /******************************************************************************* diff --git a/src/core/lib/iomgr/ev_posix.cc b/src/core/lib/iomgr/ev_posix.cc index 28e4efa011..87fcfd2e04 100644 --- a/src/core/lib/iomgr/ev_posix.cc +++ b/src/core/lib/iomgr/ev_posix.cc @@ -36,11 +36,11 @@ #include "src/core/lib/iomgr/ev_poll_posix.h" #include "src/core/lib/support/env.h" -grpc_core::Tracer grpc_polling_trace(false, +grpc_core::TraceFlag grpc_polling_trace(false, "polling"); /* Disabled by default */ #ifndef NDEBUG -grpc_core::Tracer grpc_trace_fd_refcount(false, "fd_refcount"); +grpc_core::TraceFlag grpc_trace_fd_refcount(false, "fd_refcount"); #endif /** Default poll() function - a pointer so that it can be overridden by some diff --git a/src/core/lib/iomgr/ev_posix.h b/src/core/lib/iomgr/ev_posix.h index 1f585259c1..d4d6d98cae 100644 --- a/src/core/lib/iomgr/ev_posix.h +++ b/src/core/lib/iomgr/ev_posix.h @@ -31,7 +31,7 @@ extern "C" { #endif -extern grpc_core::Tracer grpc_polling_trace; /* Disabled by default */ +extern grpc_core::TraceFlag grpc_polling_trace; /* Disabled by default */ typedef struct grpc_fd grpc_fd; diff --git a/src/core/lib/iomgr/ev_windows.cc b/src/core/lib/iomgr/ev_windows.cc index c2e5d55df8..cb66de0a06 100644 --- a/src/core/lib/iomgr/ev_windows.cc +++ b/src/core/lib/iomgr/ev_windows.cc @@ -22,7 +22,7 @@ #include "src/core/lib/debug/trace.h" -grpc_core::Tracer grpc_polling_trace(false, +grpc_core::TraceFlag grpc_polling_trace(false, "polling"); /* Disabled by default */ #endif // GRPC_WINSOCK_SOCKET diff --git a/src/core/lib/iomgr/executor.cc b/src/core/lib/iomgr/executor.cc index 085c2127a1..59c7818347 100644 --- a/src/core/lib/iomgr/executor.cc +++ b/src/core/lib/iomgr/executor.cc @@ -51,7 +51,7 @@ static gpr_spinlock g_adding_thread_lock = GPR_SPINLOCK_STATIC_INITIALIZER; GPR_TLS_DECL(g_this_thread_state); -static grpc_core::Tracer executor_trace(false, "executor"); +static grpc_core::TraceFlag executor_trace(false, "executor"); static void executor_thread(void *arg); diff --git a/src/core/lib/iomgr/lockfree_event.cc b/src/core/lib/iomgr/lockfree_event.cc index 27e720d219..a4aeacccf9 100644 --- a/src/core/lib/iomgr/lockfree_event.cc +++ b/src/core/lib/iomgr/lockfree_event.cc @@ -22,7 +22,7 @@ #include "src/core/lib/debug/trace.h" -extern grpc_core::Tracer grpc_polling_trace; +extern grpc_core::TraceFlag grpc_polling_trace; /* 'state' holds the to call when the fd is readable or writable respectively. It can contain one of the following values: diff --git a/src/core/lib/iomgr/pollset.h b/src/core/lib/iomgr/pollset.h index 33bfcf824c..d48f7f8574 100644 --- a/src/core/lib/iomgr/pollset.h +++ b/src/core/lib/iomgr/pollset.h @@ -30,7 +30,7 @@ extern "C" { #endif #ifndef NDEBUG -extern grpc_core::Tracer grpc_trace_fd_refcount; +extern grpc_core::TraceFlag grpc_trace_fd_refcount; #endif /* A grpc_pollset is a set of file descriptors that a higher level item is diff --git a/src/core/lib/iomgr/pollset_uv.cc b/src/core/lib/iomgr/pollset_uv.cc index cf3566d08f..2016d5d808 100644 --- a/src/core/lib/iomgr/pollset_uv.cc +++ b/src/core/lib/iomgr/pollset_uv.cc @@ -35,7 +35,7 @@ #include "src/core/lib/debug/trace.h" #ifndef NDEBUG -grpc_core::Tracer grpc_trace_fd_refcount(false, "fd_refcount"); +grpc_core::TraceFlag grpc_trace_fd_refcount(false, "fd_refcount"); #endif struct grpc_pollset { diff --git a/src/core/lib/iomgr/pollset_windows.cc b/src/core/lib/iomgr/pollset_windows.cc index d0d299b6b7..88354991d5 100644 --- a/src/core/lib/iomgr/pollset_windows.cc +++ b/src/core/lib/iomgr/pollset_windows.cc @@ -31,7 +31,7 @@ #define GRPC_POLLSET_KICK_BROADCAST ((grpc_pollset_worker *)1) #ifndef NDEBUG -grpc_core::Tracer grpc_trace_fd_refcount(false, "fd_refcount"); +grpc_core::TraceFlag grpc_trace_fd_refcount(false, "fd_refcount"); #endif gpr_mu grpc_polling_mu; diff --git a/src/core/lib/iomgr/resource_quota.cc b/src/core/lib/iomgr/resource_quota.cc index d3ed87a1c0..28098ecd08 100644 --- a/src/core/lib/iomgr/resource_quota.cc +++ b/src/core/lib/iomgr/resource_quota.cc @@ -31,7 +31,7 @@ #include "src/core/lib/iomgr/combiner.h" -grpc_core::Tracer grpc_resource_quota_trace(false, "resource_quota"); +grpc_core::TraceFlag grpc_resource_quota_trace(false, "resource_quota"); #define MEMORY_USAGE_ESTIMATION_MAX 65536 diff --git a/src/core/lib/iomgr/resource_quota.h b/src/core/lib/iomgr/resource_quota.h index 04c80c692c..fdebe89b86 100644 --- a/src/core/lib/iomgr/resource_quota.h +++ b/src/core/lib/iomgr/resource_quota.h @@ -65,7 +65,7 @@ extern "C" { maintain lists of users (which users arrange to leave before they are destroyed) */ -extern grpc_core::Tracer grpc_resource_quota_trace; +extern grpc_core::TraceFlag grpc_resource_quota_trace; grpc_resource_quota *grpc_resource_quota_ref_internal( grpc_resource_quota *resource_quota); diff --git a/src/core/lib/iomgr/tcp_client_posix.cc b/src/core/lib/iomgr/tcp_client_posix.cc index 4ef13dd1f5..05c2adae20 100644 --- a/src/core/lib/iomgr/tcp_client_posix.cc +++ b/src/core/lib/iomgr/tcp_client_posix.cc @@ -43,7 +43,7 @@ #include "src/core/lib/iomgr/unix_sockets_posix.h" #include "src/core/lib/support/string.h" -extern grpc_core::Tracer grpc_tcp_trace; +extern grpc_core::TraceFlag grpc_tcp_trace; typedef struct { gpr_mu mu; diff --git a/src/core/lib/iomgr/tcp_client_uv.cc b/src/core/lib/iomgr/tcp_client_uv.cc index bebb7634b6..b2aefc282e 100644 --- a/src/core/lib/iomgr/tcp_client_uv.cc +++ b/src/core/lib/iomgr/tcp_client_uv.cc @@ -32,7 +32,7 @@ #include "src/core/lib/iomgr/tcp_uv.h" #include "src/core/lib/iomgr/timer.h" -extern grpc_core::Tracer grpc_tcp_trace; +extern grpc_core::TraceFlag grpc_tcp_trace; typedef struct grpc_uv_tcp_connect { uv_connect_t connect_req; diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc index cfdacaf988..3fa175df95 100644 --- a/src/core/lib/iomgr/tcp_posix.cc +++ b/src/core/lib/iomgr/tcp_posix.cc @@ -61,7 +61,7 @@ typedef GRPC_MSG_IOVLEN_TYPE msg_iovlen_type; typedef size_t msg_iovlen_type; #endif -grpc_core::Tracer grpc_tcp_trace(false, "tcp"); +grpc_core::TraceFlag grpc_tcp_trace(false, "tcp"); typedef struct { grpc_endpoint base; diff --git a/src/core/lib/iomgr/tcp_posix.h b/src/core/lib/iomgr/tcp_posix.h index 3a51529874..d9963c2f2f 100644 --- a/src/core/lib/iomgr/tcp_posix.h +++ b/src/core/lib/iomgr/tcp_posix.h @@ -37,7 +37,7 @@ extern "C" { #endif -extern grpc_core::Tracer grpc_tcp_trace; +extern grpc_core::TraceFlag grpc_tcp_trace; /* Create a tcp endpoint given a file desciptor and a read slice size. Takes ownership of fd. */ diff --git a/src/core/lib/iomgr/tcp_uv.cc b/src/core/lib/iomgr/tcp_uv.cc index ece494065a..b245ce4ecf 100644 --- a/src/core/lib/iomgr/tcp_uv.cc +++ b/src/core/lib/iomgr/tcp_uv.cc @@ -38,7 +38,7 @@ #include "src/core/lib/slice/slice_string_helpers.h" #include "src/core/lib/support/string.h" -grpc_core::Tracer grpc_tcp_trace(false, "tcp"); +grpc_core::TraceFlag grpc_tcp_trace(false, "tcp"); typedef struct { grpc_endpoint base; diff --git a/src/core/lib/iomgr/tcp_uv.h b/src/core/lib/iomgr/tcp_uv.h index 63f028173e..3d4afe0fb8 100644 --- a/src/core/lib/iomgr/tcp_uv.h +++ b/src/core/lib/iomgr/tcp_uv.h @@ -34,7 +34,7 @@ #include -extern grpc_core::Tracer grpc_tcp_trace; +extern grpc_core::TraceFlag grpc_tcp_trace; #define GRPC_TCP_DEFAULT_READ_SLICE_SIZE 8192 diff --git a/src/core/lib/iomgr/tcp_windows.cc b/src/core/lib/iomgr/tcp_windows.cc index 9024f2b743..99304bb764 100644 --- a/src/core/lib/iomgr/tcp_windows.cc +++ b/src/core/lib/iomgr/tcp_windows.cc @@ -49,7 +49,7 @@ #define GRPC_FIONBIO FIONBIO #endif -grpc_core::Tracer grpc_tcp_trace(false, "tcp"); +grpc_core::TraceFlag grpc_tcp_trace(false, "tcp"); static grpc_error *set_non_block(SOCKET sock) { int status; diff --git a/src/core/lib/iomgr/timer_generic.cc b/src/core/lib/iomgr/timer_generic.cc index 98b4ca22ab..1735aeb19f 100644 --- a/src/core/lib/iomgr/timer_generic.cc +++ b/src/core/lib/iomgr/timer_generic.cc @@ -44,8 +44,8 @@ #define MAX_QUEUE_WINDOW_DURATION 1 extern "C" { -grpc_core::Tracer grpc_timer_trace(false, "timer"); -grpc_core::Tracer grpc_timer_check_trace(false, "timer_check"); +grpc_core::TraceFlag grpc_timer_trace(false, "timer"); +grpc_core::TraceFlag grpc_timer_check_trace(false, "timer_check"); } /* A "timer shard". Contains a 'heap' and a 'list' of timers. All timers with diff --git a/src/core/lib/iomgr/timer_manager.cc b/src/core/lib/iomgr/timer_manager.cc index 951059d43e..9f2dcb52d3 100644 --- a/src/core/lib/iomgr/timer_manager.cc +++ b/src/core/lib/iomgr/timer_manager.cc @@ -33,7 +33,7 @@ typedef struct completed_thread { struct completed_thread *next; } completed_thread; -extern grpc_core::Tracer grpc_timer_check_trace; +extern grpc_core::TraceFlag grpc_timer_check_trace; // global mutex static gpr_mu g_mu; diff --git a/src/core/lib/iomgr/timer_uv.cc b/src/core/lib/iomgr/timer_uv.cc index a64269585c..c4d46ff48f 100644 --- a/src/core/lib/iomgr/timer_uv.cc +++ b/src/core/lib/iomgr/timer_uv.cc @@ -30,8 +30,8 @@ #include extern "C" { -grpc_core::Tracer grpc_timer_trace(false, "timer"); -grpc_core::Tracer grpc_timer_check_trace(false, "timer_check"); +grpc_core::TraceFlag grpc_timer_trace(false, "timer"); +grpc_core::TraceFlag grpc_timer_check_trace(false, "timer_check"); } static void timer_close_callback(uv_handle_t *handle) { gpr_free(handle); } diff --git a/src/core/lib/security/context/security_context.cc b/src/core/lib/security/context/security_context.cc index 39f92fe595..b0868950e1 100644 --- a/src/core/lib/security/context/security_context.cc +++ b/src/core/lib/security/context/security_context.cc @@ -30,7 +30,7 @@ #include #ifndef NDEBUG -grpc_core::Tracer grpc_trace_auth_context_refcount(false, +grpc_core::TraceFlag grpc_trace_auth_context_refcount(false, "auth_context_refcount"); #endif diff --git a/src/core/lib/security/context/security_context.h b/src/core/lib/security/context/security_context.h index f8ea0bad12..cc03bd6084 100644 --- a/src/core/lib/security/context/security_context.h +++ b/src/core/lib/security/context/security_context.h @@ -23,7 +23,7 @@ #include "src/core/lib/security/credentials/credentials.h" #ifndef NDEBUG -extern grpc_core::Tracer grpc_trace_auth_context_refcount; +extern grpc_core::TraceFlag grpc_trace_auth_context_refcount; #endif #ifdef __cplusplus diff --git a/src/core/lib/security/credentials/plugin/plugin_credentials.cc b/src/core/lib/security/credentials/plugin/plugin_credentials.cc index cf03241016..47007988d2 100644 --- a/src/core/lib/security/credentials/plugin/plugin_credentials.cc +++ b/src/core/lib/security/credentials/plugin/plugin_credentials.cc @@ -31,7 +31,7 @@ #include "src/core/lib/surface/api_trace.h" #include "src/core/lib/surface/validate_metadata.h" -grpc_core::Tracer grpc_plugin_credentials_trace(false, "plugin_credentials"); +grpc_core::TraceFlag grpc_plugin_credentials_trace(false, "plugin_credentials"); static void plugin_destruct(grpc_exec_ctx *exec_ctx, grpc_call_credentials *creds) { diff --git a/src/core/lib/security/credentials/plugin/plugin_credentials.h b/src/core/lib/security/credentials/plugin/plugin_credentials.h index 9c8bc18e27..f0d757e04d 100644 --- a/src/core/lib/security/credentials/plugin/plugin_credentials.h +++ b/src/core/lib/security/credentials/plugin/plugin_credentials.h @@ -21,7 +21,7 @@ #include "src/core/lib/security/credentials/credentials.h" -extern grpc_core::Tracer grpc_plugin_credentials_trace; +extern grpc_core::TraceFlag grpc_plugin_credentials_trace; struct grpc_plugin_credentials; diff --git a/src/core/lib/security/transport/secure_endpoint.cc b/src/core/lib/security/transport/secure_endpoint.cc index e2772980cd..5964f3ba70 100644 --- a/src/core/lib/security/transport/secure_endpoint.cc +++ b/src/core/lib/security/transport/secure_endpoint.cc @@ -61,7 +61,7 @@ typedef struct { gpr_refcount ref; } secure_endpoint; -grpc_core::Tracer grpc_trace_secure_endpoint(false, "secure_endpoint"); +grpc_core::TraceFlag grpc_trace_secure_endpoint(false, "secure_endpoint"); static void destroy(grpc_exec_ctx *exec_ctx, secure_endpoint *secure_ep) { secure_endpoint *ep = secure_ep; diff --git a/src/core/lib/security/transport/secure_endpoint.h b/src/core/lib/security/transport/secure_endpoint.h index cfa1d49d8f..4748c8809c 100644 --- a/src/core/lib/security/transport/secure_endpoint.h +++ b/src/core/lib/security/transport/secure_endpoint.h @@ -29,7 +29,7 @@ extern "C" { struct tsi_frame_protector; struct tsi_zero_copy_grpc_protector; -extern grpc_core::Tracer grpc_trace_secure_endpoint; +extern grpc_core::TraceFlag grpc_trace_secure_endpoint; /* Takes ownership of protector, zero_copy_protector, and to_wrap, and refs * leftover_slices. If zero_copy_protector is not NULL, protector will never be diff --git a/src/core/lib/security/transport/security_connector.cc b/src/core/lib/security/transport/security_connector.cc index 31e2fd0107..9c5c53e67e 100644 --- a/src/core/lib/security/transport/security_connector.cc +++ b/src/core/lib/security/transport/security_connector.cc @@ -44,7 +44,7 @@ #include "src/core/tsi/transport_security_adapter.h" #ifndef NDEBUG -grpc_core::Tracer grpc_trace_security_connector_refcount( +grpc_core::TraceFlag grpc_trace_security_connector_refcount( false, "security_connector_refcount"); #endif diff --git a/src/core/lib/security/transport/security_connector.h b/src/core/lib/security/transport/security_connector.h index 38b53a2b8e..f401349fde 100644 --- a/src/core/lib/security/transport/security_connector.h +++ b/src/core/lib/security/transport/security_connector.h @@ -34,7 +34,7 @@ extern "C" { #endif #ifndef NDEBUG -extern grpc_core::Tracer grpc_trace_security_connector_refcount; +extern grpc_core::TraceFlag grpc_trace_security_connector_refcount; #endif /* --- status enum. --- */ diff --git a/src/core/lib/surface/alarm.cc b/src/core/lib/surface/alarm.cc index 6bab0be849..4ebdba71d9 100644 --- a/src/core/lib/surface/alarm.cc +++ b/src/core/lib/surface/alarm.cc @@ -28,7 +28,7 @@ #include "src/core/lib/surface/completion_queue.h" #ifndef NDEBUG -grpc_core::Tracer grpc_trace_alarm_refcount(false, "alarm_refcount"); +grpc_core::TraceFlag grpc_trace_alarm_refcount(false, "alarm_refcount"); #endif struct grpc_alarm { diff --git a/src/core/lib/surface/alarm_internal.h b/src/core/lib/surface/alarm_internal.h index 85d5b85988..fa86815ed0 100644 --- a/src/core/lib/surface/alarm_internal.h +++ b/src/core/lib/surface/alarm_internal.h @@ -28,7 +28,7 @@ extern "C" { #ifndef NDEBUG -extern grpc_core::Tracer grpc_trace_alarm_refcount; +extern grpc_core::TraceFlag grpc_trace_alarm_refcount; #define GRPC_ALARM_REF(a, reason) alarm_ref_dbg(a, reason, __FILE__, __LINE__) #define GRPC_ALARM_UNREF(a, reason) \ diff --git a/src/core/lib/surface/api_trace.cc b/src/core/lib/surface/api_trace.cc index dfddbba178..7ab836a9ba 100644 --- a/src/core/lib/surface/api_trace.cc +++ b/src/core/lib/surface/api_trace.cc @@ -19,4 +19,4 @@ #include "src/core/lib/surface/api_trace.h" #include "src/core/lib/debug/trace.h" -grpc_core::Tracer grpc_api_trace(false, "api"); +grpc_core::TraceFlag grpc_api_trace(false, "api"); diff --git a/src/core/lib/surface/api_trace.h b/src/core/lib/surface/api_trace.h index 044ed9b6ec..9838bccacf 100644 --- a/src/core/lib/surface/api_trace.h +++ b/src/core/lib/surface/api_trace.h @@ -26,7 +26,7 @@ extern "C" { #endif -extern grpc_core::Tracer grpc_api_trace; +extern grpc_core::TraceFlag grpc_api_trace; /* Provide unwrapping macros because we're in C89 and variadic macros weren't introduced until C99... */ diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index 21a0285e1c..a003439da4 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -259,8 +259,8 @@ struct grpc_call { gpr_atm recv_state; }; -grpc_core::Tracer grpc_call_error_trace(false, "call_error"); -grpc_core::Tracer grpc_compression_trace(false, "compression"); +grpc_core::TraceFlag grpc_call_error_trace(false, "call_error"); +grpc_core::TraceFlag grpc_compression_trace(false, "compression"); #define CALL_STACK_FROM_CALL(call) ((grpc_call_stack *)((call) + 1)) #define CALL_FROM_CALL_STACK(call_stack) (((grpc_call *)(call_stack)) - 1) diff --git a/src/core/lib/surface/call.h b/src/core/lib/surface/call.h index f00cf0503b..0fbdf9812b 100644 --- a/src/core/lib/surface/call.h +++ b/src/core/lib/surface/call.h @@ -111,8 +111,8 @@ uint8_t grpc_call_is_client(grpc_call *call); grpc_compression_algorithm grpc_call_compression_for_level( grpc_call *call, grpc_compression_level level); -extern grpc_core::Tracer grpc_call_error_trace; -extern grpc_core::Tracer grpc_compression_trace; +extern grpc_core::TraceFlag grpc_call_error_trace; +extern grpc_core::TraceFlag grpc_compression_trace; #ifdef __cplusplus } diff --git a/src/core/lib/surface/completion_queue.cc b/src/core/lib/surface/completion_queue.cc index c0ef8a8a1c..5c35e44bcc 100644 --- a/src/core/lib/surface/completion_queue.cc +++ b/src/core/lib/surface/completion_queue.cc @@ -39,10 +39,10 @@ #include "src/core/lib/surface/call.h" #include "src/core/lib/surface/event_string.h" -grpc_core::Tracer grpc_trace_operation_failures(false, "op_failure"); +grpc_core::TraceFlag grpc_trace_operation_failures(false, "op_failure"); #ifndef NDEBUG -grpc_core::Tracer grpc_trace_pending_tags(false, "pending_tags"); -grpc_core::Tracer grpc_trace_cq_refcount(false, "cq_refcount"); +grpc_core::TraceFlag grpc_trace_pending_tags(false, "pending_tags"); +grpc_core::TraceFlag grpc_trace_cq_refcount(false, "cq_refcount"); #endif typedef struct { @@ -325,8 +325,8 @@ static const cq_vtable g_cq_vtable[] = { #define POLLSET_FROM_CQ(cq) \ ((grpc_pollset *)(cq->vtable->data_size + (char *)DATA_FROM_CQ(cq))) -grpc_core::Tracer grpc_cq_pluck_trace(true, "queue_pluck"); -grpc_core::Tracer grpc_cq_event_timeout_trace(true, "queue_timeout"); +grpc_core::TraceFlag grpc_cq_pluck_trace(true, "queue_pluck"); +grpc_core::TraceFlag grpc_cq_event_timeout_trace(true, "queue_timeout"); #define GRPC_SURFACE_TRACE_RETURNED_EVENT(cq, event) \ if (grpc_api_trace.enabled() && (grpc_cq_pluck_trace.enabled() || \ diff --git a/src/core/lib/surface/completion_queue.h b/src/core/lib/surface/completion_queue.h index 3020091f21..cb390fe753 100644 --- a/src/core/lib/surface/completion_queue.h +++ b/src/core/lib/surface/completion_queue.h @@ -27,13 +27,13 @@ /* These trace flags default to 1. The corresponding lines are only traced if grpc_api_trace is also truthy */ -extern grpc_core::Tracer grpc_cq_pluck_trace; -extern grpc_core::Tracer grpc_cq_event_timeout_trace; -extern grpc_core::Tracer grpc_trace_operation_failures; +extern grpc_core::TraceFlag grpc_cq_pluck_trace; +extern grpc_core::TraceFlag grpc_cq_event_timeout_trace; +extern grpc_core::TraceFlag grpc_trace_operation_failures; #ifndef NDEBUG -extern grpc_core::Tracer grpc_trace_pending_tags; -extern grpc_core::Tracer grpc_trace_cq_refcount; +extern grpc_core::TraceFlag grpc_trace_pending_tags; +extern grpc_core::TraceFlag grpc_trace_cq_refcount; #endif #ifdef __cplusplus diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc index 081fa54f16..97e00eed55 100644 --- a/src/core/lib/surface/server.cc +++ b/src/core/lib/surface/server.cc @@ -59,7 +59,7 @@ typedef struct registered_method registered_method; typedef enum { BATCH_CALL, REGISTERED_CALL } requested_call_type; -grpc_core::Tracer grpc_server_channel_trace(false, "server_channel"); +grpc_core::TraceFlag grpc_server_channel_trace(false, "server_channel"); typedef struct requested_call { requested_call_type type; diff --git a/src/core/lib/surface/server.h b/src/core/lib/surface/server.h index 20e6ec4eec..a7c3405288 100644 --- a/src/core/lib/surface/server.h +++ b/src/core/lib/surface/server.h @@ -31,7 +31,7 @@ extern "C" { extern const grpc_channel_filter grpc_server_top_filter; /** Lightweight tracing of server channel state */ -extern grpc_core::Tracer grpc_server_channel_trace; +extern grpc_core::TraceFlag grpc_server_channel_trace; /* Add a listener to the server: when the server starts, it will call start, and when it shuts down, it will call destroy */ diff --git a/src/core/lib/transport/bdp_estimator.cc b/src/core/lib/transport/bdp_estimator.cc index 36826f45ca..a9db572c5b 100644 --- a/src/core/lib/transport/bdp_estimator.cc +++ b/src/core/lib/transport/bdp_estimator.cc @@ -23,7 +23,7 @@ #include -grpc_core::Tracer grpc_bdp_estimator_trace(false, "bdp_estimator"); +grpc_core::TraceFlag grpc_bdp_estimator_trace(false, "bdp_estimator"); namespace grpc_core { diff --git a/src/core/lib/transport/bdp_estimator.h b/src/core/lib/transport/bdp_estimator.h index 3558eb49e7..872cfaad8c 100644 --- a/src/core/lib/transport/bdp_estimator.h +++ b/src/core/lib/transport/bdp_estimator.h @@ -31,7 +31,7 @@ #include "src/core/lib/debug/trace.h" #include "src/core/lib/iomgr/exec_ctx.h" -extern grpc_core::Tracer grpc_bdp_estimator_trace; +extern grpc_core::TraceFlag grpc_bdp_estimator_trace; namespace grpc_core { diff --git a/src/core/lib/transport/connectivity_state.cc b/src/core/lib/transport/connectivity_state.cc index f9e8185555..eb3bbeb588 100644 --- a/src/core/lib/transport/connectivity_state.cc +++ b/src/core/lib/transport/connectivity_state.cc @@ -24,7 +24,7 @@ #include #include -grpc_core::Tracer grpc_connectivity_state_trace(false, "connectivity_state"); +grpc_core::TraceFlag grpc_connectivity_state_trace(false, "connectivity_state"); const char *grpc_connectivity_state_name(grpc_connectivity_state state) { switch (state) { diff --git a/src/core/lib/transport/connectivity_state.h b/src/core/lib/transport/connectivity_state.h index d70c9a8480..3127f56ec7 100644 --- a/src/core/lib/transport/connectivity_state.h +++ b/src/core/lib/transport/connectivity_state.h @@ -47,7 +47,7 @@ typedef struct { char *name; } grpc_connectivity_state_tracker; -extern grpc_core::Tracer grpc_connectivity_state_trace; +extern grpc_core::TraceFlag grpc_connectivity_state_trace; /** enum --> string conversion */ const char *grpc_connectivity_state_name(grpc_connectivity_state state); diff --git a/src/core/lib/transport/metadata.cc b/src/core/lib/transport/metadata.cc index 1eddb6f0d6..9adf43d019 100644 --- a/src/core/lib/transport/metadata.cc +++ b/src/core/lib/transport/metadata.cc @@ -49,7 +49,7 @@ */ #ifndef NDEBUG -grpc_core::Tracer grpc_trace_metadata(false, "metadata"); +grpc_core::TraceFlag grpc_trace_metadata(false, "metadata"); #define DEBUG_ARGS , const char *file, int line #define FWD_DEBUG_ARGS , file, line #define REF_MD_LOCKED(shard, s) ref_md_locked((shard), (s), __FILE__, __LINE__) diff --git a/src/core/lib/transport/metadata.h b/src/core/lib/transport/metadata.h index 66780d925b..678c213be1 100644 --- a/src/core/lib/transport/metadata.h +++ b/src/core/lib/transport/metadata.h @@ -26,7 +26,7 @@ #include "src/core/lib/iomgr/exec_ctx.h" #ifndef NDEBUG -extern grpc_core::Tracer grpc_trace_metadata; +extern grpc_core::TraceFlag grpc_trace_metadata; #endif #ifdef __cplusplus diff --git a/src/core/lib/transport/transport.cc b/src/core/lib/transport/transport.cc index 4055e9c881..d0c4e04f85 100644 --- a/src/core/lib/transport/transport.cc +++ b/src/core/lib/transport/transport.cc @@ -32,7 +32,7 @@ #include "src/core/lib/transport/transport_impl.h" #ifndef NDEBUG -grpc_core::Tracer grpc_trace_stream_refcount(false, "stream_refcount"); +grpc_core::TraceFlag grpc_trace_stream_refcount(false, "stream_refcount"); #endif #ifndef NDEBUG diff --git a/src/core/lib/transport/transport.h b/src/core/lib/transport/transport.h index 8046402724..ae0dea362c 100644 --- a/src/core/lib/transport/transport.h +++ b/src/core/lib/transport/transport.h @@ -44,7 +44,7 @@ typedef struct grpc_transport grpc_transport; typedef struct grpc_stream grpc_stream; #ifndef NDEBUG -extern grpc_core::Tracer grpc_trace_stream_refcount; +extern grpc_core::TraceFlag grpc_trace_stream_refcount; #endif typedef struct grpc_stream_refcount { diff --git a/src/core/tsi/transport_security.cc b/src/core/tsi/transport_security.cc index c452a0f1bf..a2f45f5e0b 100644 --- a/src/core/tsi/transport_security.cc +++ b/src/core/tsi/transport_security.cc @@ -26,7 +26,7 @@ /* --- Tracing. --- */ -grpc_core::Tracer tsi_tracing_enabled(false, "tsi"); +grpc_core::TraceFlag tsi_tracing_enabled(false, "tsi"); /* --- tsi_result common implementation. --- */ diff --git a/src/core/tsi/transport_security.h b/src/core/tsi/transport_security.h index 0a3c45c474..c5fbba1522 100644 --- a/src/core/tsi/transport_security.h +++ b/src/core/tsi/transport_security.h @@ -28,7 +28,7 @@ extern "C" { #endif -extern grpc_core::Tracer tsi_tracing_enabled; +extern grpc_core::TraceFlag tsi_tracing_enabled; /* Base for tsi_frame_protector implementations. See transport_security_interface.h for documentation. */ diff --git a/src/core/tsi/transport_security_interface.h b/src/core/tsi/transport_security_interface.h index ebf75f36fc..40a5a596d6 100644 --- a/src/core/tsi/transport_security_interface.h +++ b/src/core/tsi/transport_security_interface.h @@ -60,7 +60,7 @@ const char *tsi_result_to_string(tsi_result result); /* --- tsi tracing --- */ -extern grpc_core::Tracer tsi_tracing_enabled; +extern grpc_core::TraceFlag tsi_tracing_enabled; /* -- tsi_zero_copy_grpc_protector object -- -- cgit v1.2.3 From 882dfeddd5e4503493a3a88733ed9a0fc4af436e Mon Sep 17 00:00:00 2001 From: Noah Eisen Date: Tue, 14 Nov 2017 14:58:20 -0800 Subject: clang tidy --- .../ext/filters/client_channel/client_channel.cc | 2 +- .../client_channel/lb_policy/grpclb/grpclb.cc | 216 ++++++++++----------- .../lb_policy/pick_first/pick_first.cc | 70 +++---- .../lb_policy/round_robin/round_robin.cc | 58 +++--- .../client_channel/lb_policy/subchannel_list.cc | 22 +-- src/core/ext/transport/chttp2/transport/parsing.cc | 34 ++-- src/core/ext/transport/inproc/inproc_transport.cc | 122 ++++++------ src/core/lib/iomgr/ev_epollex_linux.cc | 98 +++++----- src/core/lib/iomgr/resource_quota.cc | 56 +++--- src/core/lib/iomgr/tcp_posix.cc | 38 ++-- src/core/lib/security/context/security_context.cc | 50 ++--- .../lib/security/transport/security_connector.cc | 22 +-- src/core/lib/surface/call.cc | 16 +- src/core/lib/transport/connectivity_state.cc | 18 +- 14 files changed, 411 insertions(+), 411 deletions(-) (limited to 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc') diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index 8a3d09eb1d..03c1b6f4bd 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -1492,7 +1492,7 @@ static void cc_destroy_call_elem(grpc_exec_ctx* exec_ctx, "picked"); } for (size_t i = 0; i < GRPC_CONTEXT_COUNT; ++i) { - if (calld->subchannel_call_context[i].value != NULL) { + if (calld->subchannel_call_context[i].value != nullptr) { calld->subchannel_call_context[i].destroy( calld->subchannel_call_context[i].value); } diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index e64ba53604..005df3c6d1 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -133,7 +133,7 @@ grpc_core::TraceFlag grpc_lb_glb_trace(false, "glb"); static grpc_error* initial_metadata_add_lb_token( grpc_exec_ctx* exec_ctx, grpc_metadata_batch* initial_metadata, grpc_linked_mdelem* lb_token_mdelem_storage, grpc_mdelem lb_token) { - GPR_ASSERT(lb_token_mdelem_storage != NULL); + GPR_ASSERT(lb_token_mdelem_storage != nullptr); GPR_ASSERT(!GRPC_MDISNULL(lb_token)); return grpc_metadata_batch_add_tail(exec_ctx, initial_metadata, lb_token_mdelem_storage, lb_token); @@ -190,14 +190,14 @@ static void wrapped_rr_closure(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { wrapped_rr_closure_arg* wc_arg = (wrapped_rr_closure_arg*)arg; - GPR_ASSERT(wc_arg->wrapped_closure != NULL); + GPR_ASSERT(wc_arg->wrapped_closure != nullptr); GRPC_CLOSURE_SCHED(exec_ctx, wc_arg->wrapped_closure, GRPC_ERROR_REF(error)); - if (wc_arg->rr_policy != NULL) { + if (wc_arg->rr_policy != nullptr) { /* if *target is NULL, no pick has been made by the RR policy (eg, all * addresses failed to connect). There won't be any user_data/token * available */ - if (*wc_arg->target != NULL) { + if (*wc_arg->target != nullptr) { if (!GRPC_MDISNULL(wc_arg->lb_token)) { initial_metadata_add_lb_token(exec_ctx, wc_arg->initial_metadata, wc_arg->lb_token_mdelem_storage, @@ -211,7 +211,7 @@ static void wrapped_rr_closure(grpc_exec_ctx* exec_ctx, void* arg, abort(); } // Pass on client stats via context. Passes ownership of the reference. - GPR_ASSERT(wc_arg->client_stats != NULL); + GPR_ASSERT(wc_arg->client_stats != nullptr); wc_arg->context[GRPC_GRPCLB_CLIENT_STATS].value = wc_arg->client_stats; wc_arg->context[GRPC_GRPCLB_CLIENT_STATS].destroy = destroy_client_stats; } else { @@ -223,7 +223,7 @@ static void wrapped_rr_closure(grpc_exec_ctx* exec_ctx, void* arg, } GRPC_LB_POLICY_UNREF(exec_ctx, wc_arg->rr_policy, "wrapped_rr_closure"); } - GPR_ASSERT(wc_arg->free_when_done != NULL); + GPR_ASSERT(wc_arg->free_when_done != nullptr); gpr_free(wc_arg->free_when_done); } @@ -455,12 +455,12 @@ static bool is_server_valid(const grpc_grpclb_server* server, size_t idx, /* vtable for LB tokens in grpc_lb_addresses. */ static void* lb_token_copy(void* token) { - return token == NULL - ? NULL + return token == nullptr + ? nullptr : (void*)GRPC_MDELEM_REF(grpc_mdelem{(uintptr_t)token}).payload; } static void lb_token_destroy(grpc_exec_ctx* exec_ctx, void* token) { - if (token != NULL) { + if (token != nullptr) { GRPC_MDELEM_UNREF(exec_ctx, grpc_mdelem{(uintptr_t)token}); } } @@ -543,7 +543,7 @@ static grpc_lb_addresses* process_serverlist_locked( grpc_lb_addresses_set_address(lb_addresses, addr_idx, &addr.addr, addr.len, false /* is_balancer */, - NULL /* balancer_name */, user_data); + nullptr /* balancer_name */, user_data); ++addr_idx; } GPR_ASSERT(addr_idx == num_valid); @@ -569,7 +569,7 @@ static grpc_lb_addresses* extract_backend_addresses_locked( const grpc_resolved_address* addr = &addresses->addresses[i].address; grpc_lb_addresses_set_address(backend_addresses, num_copied, &addr->addr, addr->len, false /* is_balancer */, - NULL /* balancer_name */, + nullptr /* balancer_name */, (void*)GRPC_MDELEM_LB_TOKEN_EMPTY.payload); ++num_copied; } @@ -645,7 +645,7 @@ static bool pick_from_internal_rr_locked( const grpc_lb_policy_pick_args* pick_args, bool force_async, grpc_connected_subchannel** target, wrapped_rr_closure_arg* wc_arg) { // Check for drops if we are not using fallback backend addresses. - if (glb_policy->serverlist != NULL) { + if (glb_policy->serverlist != nullptr) { // Look at the index into the serverlist to see if we should drop this call. grpc_grpclb_server* server = glb_policy->serverlist->servers[glb_policy->serverlist_index++]; @@ -664,12 +664,12 @@ static bool pick_from_internal_rr_locked( // the client_load_reporting filter, because we do not create a // subchannel call (and therefore no client_load_reporting filter) // for dropped calls. - GPR_ASSERT(wc_arg->client_stats != NULL); + GPR_ASSERT(wc_arg->client_stats != nullptr); grpc_grpclb_client_stats_add_call_dropped_locked( server->load_balance_token, wc_arg->client_stats); grpc_grpclb_client_stats_unref(wc_arg->client_stats); if (force_async) { - GPR_ASSERT(wc_arg->wrapped_closure != NULL); + GPR_ASSERT(wc_arg->wrapped_closure != nullptr); GRPC_CLOSURE_SCHED(exec_ctx, wc_arg->wrapped_closure, GRPC_ERROR_NONE); gpr_free(wc_arg->free_when_done); return false; @@ -694,11 +694,11 @@ static bool pick_from_internal_rr_locked( pick_args->lb_token_mdelem_storage, GRPC_MDELEM_REF(wc_arg->lb_token)); // Pass on client stats via context. Passes ownership of the reference. - GPR_ASSERT(wc_arg->client_stats != NULL); + GPR_ASSERT(wc_arg->client_stats != nullptr); wc_arg->context[GRPC_GRPCLB_CLIENT_STATS].value = wc_arg->client_stats; wc_arg->context[GRPC_GRPCLB_CLIENT_STATS].destroy = destroy_client_stats; if (force_async) { - GPR_ASSERT(wc_arg->wrapped_closure != NULL); + GPR_ASSERT(wc_arg->wrapped_closure != nullptr); GRPC_CLOSURE_SCHED(exec_ctx, wc_arg->wrapped_closure, GRPC_ERROR_NONE); gpr_free(wc_arg->free_when_done); return false; @@ -715,7 +715,7 @@ static bool pick_from_internal_rr_locked( static grpc_lb_policy_args* lb_policy_args_create(grpc_exec_ctx* exec_ctx, glb_lb_policy* glb_policy) { grpc_lb_addresses* addresses; - if (glb_policy->serverlist != NULL) { + if (glb_policy->serverlist != nullptr) { GPR_ASSERT(glb_policy->serverlist->num_servers > 0); addresses = process_serverlist_locked(exec_ctx, glb_policy->serverlist); } else { @@ -723,10 +723,10 @@ static grpc_lb_policy_args* lb_policy_args_create(grpc_exec_ctx* exec_ctx, // serverlist from the balancer, we use the fallback backends returned by // the resolver. Note that the fallback backend list may be empty, in which // case the new round_robin policy will keep the requested picks pending. - GPR_ASSERT(glb_policy->fallback_backend_addresses != NULL); + GPR_ASSERT(glb_policy->fallback_backend_addresses != nullptr); addresses = grpc_lb_addresses_copy(glb_policy->fallback_backend_addresses); } - GPR_ASSERT(addresses != NULL); + GPR_ASSERT(addresses != nullptr); grpc_lb_policy_args* args = (grpc_lb_policy_args*)gpr_zalloc(sizeof(*args)); args->client_channel_factory = glb_policy->cc_factory; args->combiner = glb_policy->base.combiner; @@ -751,11 +751,11 @@ static void glb_rr_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error); static void create_rr_locked(grpc_exec_ctx* exec_ctx, glb_lb_policy* glb_policy, grpc_lb_policy_args* args) { - GPR_ASSERT(glb_policy->rr_policy == NULL); + GPR_ASSERT(glb_policy->rr_policy == nullptr); grpc_lb_policy* new_rr_policy = grpc_lb_policy_create(exec_ctx, "round_robin", args); - if (new_rr_policy == NULL) { + if (new_rr_policy == nullptr) { gpr_log(GPR_ERROR, "[grpclb %p] Failure creating a RoundRobin policy for serverlist " "update with %" PRIuPTR @@ -767,7 +767,7 @@ static void create_rr_locked(grpc_exec_ctx* exec_ctx, glb_lb_policy* glb_policy, return; } glb_policy->rr_policy = new_rr_policy; - grpc_error* rr_state_error = NULL; + grpc_error* rr_state_error = nullptr; const grpc_connectivity_state rr_state = grpc_lb_policy_check_connectivity_locked(exec_ctx, glb_policy->rr_policy, &rr_state_error); @@ -835,8 +835,8 @@ static void rr_handover_locked(grpc_exec_ctx* exec_ctx, glb_lb_policy* glb_policy) { if (glb_policy->shutting_down) return; grpc_lb_policy_args* args = lb_policy_args_create(exec_ctx, glb_policy); - GPR_ASSERT(args != NULL); - if (glb_policy->rr_policy != NULL) { + GPR_ASSERT(args != nullptr); + if (glb_policy->rr_policy != nullptr) { if (grpc_lb_glb_trace.enabled()) { gpr_log(GPR_DEBUG, "[grpclb %p] Updating RR policy %p", glb_policy, glb_policy->rr_policy); @@ -868,7 +868,7 @@ static void glb_rr_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, * sink, policies can't transition back from it. .*/ GRPC_LB_POLICY_UNREF(exec_ctx, glb_policy->rr_policy, "rr_connectivity_shutdown"); - glb_policy->rr_policy = NULL; + glb_policy->rr_policy = nullptr; GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &glb_policy->base, "glb_rr_connectivity_cb"); gpr_free(rr_connectivity); @@ -923,7 +923,7 @@ static grpc_channel_args* build_lb_channel_args( * instantiated and used in that case. Otherwise, something has gone wrong. */ GPR_ASSERT(num_grpclb_addrs > 0); grpc_lb_addresses* lb_addresses = - grpc_lb_addresses_create(num_grpclb_addrs, NULL); + grpc_lb_addresses_create(num_grpclb_addrs, nullptr); grpc_slice_hash_table_entry* targets_info_entries = (grpc_slice_hash_table_entry*)gpr_zalloc(sizeof(*targets_info_entries) * num_grpclb_addrs); @@ -931,7 +931,7 @@ static grpc_channel_args* build_lb_channel_args( size_t lb_addresses_idx = 0; for (size_t i = 0; i < addresses->num_addresses; ++i) { if (!addresses->addresses[i].is_balancer) continue; - if (addresses->addresses[i].user_data != NULL) { + if (addresses->addresses[i].user_data != nullptr) { gpr_log(GPR_ERROR, "This LB policy doesn't support user data. It will be ignored"); } @@ -945,7 +945,7 @@ static grpc_channel_args* build_lb_channel_args( grpc_lb_addresses_set_address( lb_addresses, lb_addresses_idx++, addresses->addresses[i].address.addr, addresses->addresses[i].address.len, false /* is balancer */, - addresses->addresses[i].balancer_name, NULL /* user data */); + addresses->addresses[i].balancer_name, nullptr /* user data */); } GPR_ASSERT(num_grpclb_addrs == lb_addresses_idx); grpc_slice_hash_table* targets_info = @@ -970,18 +970,18 @@ static grpc_channel_args* build_lb_channel_args( static void glb_destroy(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol) { glb_lb_policy* glb_policy = (glb_lb_policy*)pol; - GPR_ASSERT(glb_policy->pending_picks == NULL); - GPR_ASSERT(glb_policy->pending_pings == NULL); + GPR_ASSERT(glb_policy->pending_picks == nullptr); + GPR_ASSERT(glb_policy->pending_pings == nullptr); gpr_free((void*)glb_policy->server_name); grpc_channel_args_destroy(exec_ctx, glb_policy->args); - if (glb_policy->client_stats != NULL) { + if (glb_policy->client_stats != nullptr) { grpc_grpclb_client_stats_unref(glb_policy->client_stats); } grpc_connectivity_state_destroy(exec_ctx, &glb_policy->state_tracker); - if (glb_policy->serverlist != NULL) { + if (glb_policy->serverlist != nullptr) { grpc_grpclb_destroy_serverlist(glb_policy->serverlist); } - if (glb_policy->fallback_backend_addresses != NULL) { + if (glb_policy->fallback_backend_addresses != nullptr) { grpc_lb_addresses_destroy(exec_ctx, glb_policy->fallback_backend_addresses); } grpc_fake_resolver_response_generator_unref(glb_policy->response_generator); @@ -1002,8 +1002,8 @@ static void glb_shutdown_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol) { * because glb_policy->lb_call is only assigned in lb_call_init_locked as part * of query_for_backends_locked, which can only be invoked while * glb_policy->shutting_down is false. */ - if (lb_call != NULL) { - grpc_call_cancel(lb_call, NULL); + if (lb_call != nullptr) { + grpc_call_cancel(lb_call, nullptr); /* lb_on_server_status_received will pick up the cancel and clean up */ } if (glb_policy->retry_timer_active) { @@ -1016,27 +1016,27 @@ static void glb_shutdown_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol) { } pending_pick* pp = glb_policy->pending_picks; - glb_policy->pending_picks = NULL; + glb_policy->pending_picks = nullptr; pending_ping* pping = glb_policy->pending_pings; - glb_policy->pending_pings = NULL; - if (glb_policy->rr_policy != NULL) { + glb_policy->pending_pings = nullptr; + if (glb_policy->rr_policy != nullptr) { GRPC_LB_POLICY_UNREF(exec_ctx, glb_policy->rr_policy, "glb_shutdown"); } // We destroy the LB channel here because // glb_lb_channel_on_connectivity_changed_cb needs a valid glb_policy // instance. Destroying the lb channel in glb_destroy would likely result in // a callback invocation without a valid glb_policy arg. - if (glb_policy->lb_channel != NULL) { + if (glb_policy->lb_channel != nullptr) { grpc_channel_destroy(glb_policy->lb_channel); - glb_policy->lb_channel = NULL; + glb_policy->lb_channel = nullptr; } grpc_connectivity_state_set( exec_ctx, &glb_policy->state_tracker, GRPC_CHANNEL_SHUTDOWN, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Channel Shutdown"), "glb_shutdown"); - while (pp != NULL) { + while (pp != nullptr) { pending_pick* next = pp->next; - *pp->target = NULL; + *pp->target = nullptr; GRPC_CLOSURE_SCHED( exec_ctx, &pp->wrapped_on_complete_arg.wrapper_closure, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Channel Shutdown")); @@ -1044,7 +1044,7 @@ static void glb_shutdown_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol) { pp = next; } - while (pping != NULL) { + while (pping != nullptr) { pending_ping* next = pping->next; GRPC_CLOSURE_SCHED( exec_ctx, &pping->wrapped_notify_arg.wrapper_closure, @@ -1069,11 +1069,11 @@ static void glb_cancel_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol, grpc_error* error) { glb_lb_policy* glb_policy = (glb_lb_policy*)pol; pending_pick* pp = glb_policy->pending_picks; - glb_policy->pending_picks = NULL; - while (pp != NULL) { + glb_policy->pending_picks = nullptr; + while (pp != nullptr) { pending_pick* next = pp->next; if (pp->target == target) { - *target = NULL; + *target = nullptr; GRPC_CLOSURE_SCHED(exec_ctx, &pp->wrapped_on_complete_arg.wrapper_closure, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( "Pick Cancelled", &error, 1)); @@ -1083,7 +1083,7 @@ static void glb_cancel_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol, } pp = next; } - if (glb_policy->rr_policy != NULL) { + if (glb_policy->rr_policy != nullptr) { grpc_lb_policy_cancel_pick_locked(exec_ctx, glb_policy->rr_policy, target, GRPC_ERROR_REF(error)); } @@ -1107,8 +1107,8 @@ static void glb_cancel_picks_locked(grpc_exec_ctx* exec_ctx, grpc_error* error) { glb_lb_policy* glb_policy = (glb_lb_policy*)pol; pending_pick* pp = glb_policy->pending_picks; - glb_policy->pending_picks = NULL; - while (pp != NULL) { + glb_policy->pending_picks = nullptr; + while (pp != nullptr) { pending_pick* next = pp->next; if ((pp->pick_args.initial_metadata_flags & initial_metadata_flags_mask) == initial_metadata_flags_eq) { @@ -1121,7 +1121,7 @@ static void glb_cancel_picks_locked(grpc_exec_ctx* exec_ctx, } pp = next; } - if (glb_policy->rr_policy != NULL) { + if (glb_policy->rr_policy != nullptr) { grpc_lb_policy_cancel_picks_locked( exec_ctx, glb_policy->rr_policy, initial_metadata_flags_mask, initial_metadata_flags_eq, GRPC_ERROR_REF(error)); @@ -1137,7 +1137,7 @@ static void start_picking_locked(grpc_exec_ctx* exec_ctx, glb_lb_policy* glb_policy) { /* start a timer to fall back */ if (glb_policy->lb_fallback_timeout_ms > 0 && - glb_policy->serverlist == NULL && !glb_policy->fallback_timer_active) { + glb_policy->serverlist == nullptr && !glb_policy->fallback_timer_active) { grpc_millis deadline = grpc_exec_ctx_now(exec_ctx) + glb_policy->lb_fallback_timeout_ms; GRPC_LB_POLICY_WEAK_REF(&glb_policy->base, "grpclb_fallback_timer"); @@ -1166,8 +1166,8 @@ static int glb_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol, grpc_connected_subchannel** target, grpc_call_context_element* context, void** user_data, grpc_closure* on_complete) { - if (pick_args->lb_token_mdelem_storage == NULL) { - *target = NULL; + if (pick_args->lb_token_mdelem_storage == nullptr) { + *target = nullptr; GRPC_CLOSURE_SCHED(exec_ctx, on_complete, GRPC_ERROR_CREATE_FROM_STATIC_STRING( "No mdelem storage for the LB token. Load reporting " @@ -1176,10 +1176,10 @@ static int glb_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol, } glb_lb_policy* glb_policy = (glb_lb_policy*)pol; bool pick_done = false; - if (glb_policy->rr_policy != NULL) { + if (glb_policy->rr_policy != nullptr) { const grpc_connectivity_state rr_connectivity_state = grpc_lb_policy_check_connectivity_locked(exec_ctx, - glb_policy->rr_policy, NULL); + glb_policy->rr_policy, nullptr); // The glb_policy->rr_policy may have transitioned to SHUTDOWN but the // callback registered to capture this event // (glb_rr_connectivity_changed_locked) may not have been invoked yet. We @@ -1208,7 +1208,7 @@ static int glb_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol, wc_arg->rr_policy = glb_policy->rr_policy; wc_arg->target = target; wc_arg->context = context; - GPR_ASSERT(glb_policy->client_stats != NULL); + GPR_ASSERT(glb_policy->client_stats != nullptr); wc_arg->client_stats = grpc_grpclb_client_stats_ref(glb_policy->client_stats); wc_arg->wrapped_closure = on_complete; @@ -1270,7 +1270,7 @@ static void lb_call_on_retry_timer_locked(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { glb_lb_policy* glb_policy = (glb_lb_policy*)arg; glb_policy->retry_timer_active = false; - if (!glb_policy->shutting_down && glb_policy->lb_call == NULL && + if (!glb_policy->shutting_down && glb_policy->lb_call == nullptr && error == GRPC_ERROR_NONE) { if (grpc_lb_glb_trace.enabled()) { gpr_log(GPR_INFO, "[grpclb %p] Restarting call to LB server", glb_policy); @@ -1337,8 +1337,8 @@ static void client_load_report_done_locked(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { glb_lb_policy* glb_policy = (glb_lb_policy*)arg; grpc_byte_buffer_destroy(glb_policy->client_load_report_payload); - glb_policy->client_load_report_payload = NULL; - if (error != GRPC_ERROR_NONE || glb_policy->lb_call == NULL) { + glb_policy->client_load_report_payload = nullptr; + if (error != GRPC_ERROR_NONE || glb_policy->lb_call == nullptr) { glb_policy->client_load_report_timer_pending = false; GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &glb_policy->base, "client_load_report"); @@ -1356,23 +1356,23 @@ static bool load_report_counters_are_zero(grpc_grpclb_request* request) { request->client_stats.num_calls_finished_with_client_failed_to_send == 0 && request->client_stats.num_calls_finished_known_received == 0 && - (drop_entries == NULL || drop_entries->num_entries == 0); + (drop_entries == nullptr || drop_entries->num_entries == 0); } static void send_client_load_report_locked(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { glb_lb_policy* glb_policy = (glb_lb_policy*)arg; - if (error == GRPC_ERROR_CANCELLED || glb_policy->lb_call == NULL) { + if (error == GRPC_ERROR_CANCELLED || glb_policy->lb_call == nullptr) { glb_policy->client_load_report_timer_pending = false; GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &glb_policy->base, "client_load_report"); - if (glb_policy->lb_call == NULL) { + if (glb_policy->lb_call == nullptr) { maybe_restart_lb_call(exec_ctx, glb_policy); } return; } // Construct message payload. - GPR_ASSERT(glb_policy->client_load_report_payload == NULL); + GPR_ASSERT(glb_policy->client_load_report_payload == nullptr); grpc_grpclb_request* request = grpc_grpclb_load_report_request_create_locked(glb_policy->client_stats); // Skip client load report if the counters were all zero in the last @@ -1415,9 +1415,9 @@ static void lb_on_response_received_locked(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error); static void lb_call_init_locked(grpc_exec_ctx* exec_ctx, glb_lb_policy* glb_policy) { - GPR_ASSERT(glb_policy->server_name != NULL); + GPR_ASSERT(glb_policy->server_name != nullptr); GPR_ASSERT(glb_policy->server_name[0] != '\0'); - GPR_ASSERT(glb_policy->lb_call == NULL); + GPR_ASSERT(glb_policy->lb_call == nullptr); GPR_ASSERT(!glb_policy->shutting_down); /* Note the following LB call progresses every time there's activity in \a @@ -1429,13 +1429,13 @@ static void lb_call_init_locked(grpc_exec_ctx* exec_ctx, ? GRPC_MILLIS_INF_FUTURE : grpc_exec_ctx_now(exec_ctx) + glb_policy->lb_call_timeout_ms; glb_policy->lb_call = grpc_channel_create_pollset_set_call( - exec_ctx, glb_policy->lb_channel, NULL, GRPC_PROPAGATE_DEFAULTS, + exec_ctx, glb_policy->lb_channel, nullptr, GRPC_PROPAGATE_DEFAULTS, glb_policy->base.interested_parties, GRPC_MDSTR_SLASH_GRPC_DOT_LB_DOT_V1_DOT_LOADBALANCER_SLASH_BALANCELOAD, - &host, deadline, NULL); + &host, deadline, nullptr); grpc_slice_unref_internal(exec_ctx, host); - if (glb_policy->client_stats != NULL) { + if (glb_policy->client_stats != nullptr) { grpc_grpclb_client_stats_unref(glb_policy->client_stats); } glb_policy->client_stats = grpc_grpclb_client_stats_create(); @@ -1471,9 +1471,9 @@ static void lb_call_init_locked(grpc_exec_ctx* exec_ctx, static void lb_call_destroy_locked(grpc_exec_ctx* exec_ctx, glb_lb_policy* glb_policy) { - GPR_ASSERT(glb_policy->lb_call != NULL); + GPR_ASSERT(glb_policy->lb_call != nullptr); grpc_call_unref(glb_policy->lb_call); - glb_policy->lb_call = NULL; + glb_policy->lb_call = nullptr; grpc_metadata_array_destroy(&glb_policy->lb_initial_metadata_recv); grpc_metadata_array_destroy(&glb_policy->lb_trailing_metadata_recv); @@ -1491,7 +1491,7 @@ static void lb_call_destroy_locked(grpc_exec_ctx* exec_ctx, */ static void query_for_backends_locked(grpc_exec_ctx* exec_ctx, glb_lb_policy* glb_policy) { - GPR_ASSERT(glb_policy->lb_channel != NULL); + GPR_ASSERT(glb_policy->lb_channel != nullptr); if (glb_policy->shutting_down) return; lb_call_init_locked(exec_ctx, glb_policy); @@ -1501,7 +1501,7 @@ static void query_for_backends_locked(grpc_exec_ctx* exec_ctx, "[grpclb %p] Query for backends (lb_channel: %p, lb_call: %p)", glb_policy, glb_policy->lb_channel, glb_policy->lb_call); } - GPR_ASSERT(glb_policy->lb_call != NULL); + GPR_ASSERT(glb_policy->lb_call != nullptr); grpc_call_error call_error; grpc_op ops[3]; @@ -1511,22 +1511,22 @@ static void query_for_backends_locked(grpc_exec_ctx* exec_ctx, 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 = &glb_policy->lb_initial_metadata_recv; op->flags = 0; - op->reserved = NULL; + op->reserved = nullptr; op++; - GPR_ASSERT(glb_policy->lb_request_payload != NULL); + GPR_ASSERT(glb_policy->lb_request_payload != nullptr); op->op = GRPC_OP_SEND_MESSAGE; op->data.send_message.send_message = glb_policy->lb_request_payload; op->flags = 0; - op->reserved = NULL; + op->reserved = nullptr; op++; call_error = grpc_call_start_batch_and_execute(exec_ctx, glb_policy->lb_call, - ops, (size_t)(op - ops), NULL); + ops, (size_t)(op - ops), nullptr); GPR_ASSERT(GRPC_CALL_OK == call_error); op = ops; @@ -1537,7 +1537,7 @@ static void query_for_backends_locked(grpc_exec_ctx* exec_ctx, op->data.recv_status_on_client.status_details = &glb_policy->lb_call_status_details; op->flags = 0; - op->reserved = NULL; + op->reserved = nullptr; op++; /* take a weak ref (won't prevent calling of \a glb_shutdown if the strong ref * count goes to zero) to be unref'd in lb_on_server_status_received_locked */ @@ -1552,7 +1552,7 @@ static void query_for_backends_locked(grpc_exec_ctx* exec_ctx, op->op = GRPC_OP_RECV_MESSAGE; op->data.recv_message.recv_message = &glb_policy->lb_response_payload; op->flags = 0; - op->reserved = NULL; + op->reserved = nullptr; op++; /* take another weak ref to be unref'd/reused in * lb_on_response_received_locked */ @@ -1569,7 +1569,7 @@ static void lb_on_response_received_locked(grpc_exec_ctx* exec_ctx, void* arg, grpc_op ops[2]; memset(ops, 0, sizeof(ops)); grpc_op* op = ops; - if (glb_policy->lb_response_payload != NULL) { + if (glb_policy->lb_response_payload != nullptr) { grpc_backoff_reset(&glb_policy->lb_call_backoff_state); /* Received data from the LB server. Look inside * glb_policy->lb_response_payload, for a serverlist. */ @@ -1579,10 +1579,10 @@ static void lb_on_response_received_locked(grpc_exec_ctx* exec_ctx, void* arg, grpc_byte_buffer_reader_destroy(&bbr); grpc_byte_buffer_destroy(glb_policy->lb_response_payload); - grpc_grpclb_initial_response* response = NULL; + grpc_grpclb_initial_response* response = nullptr; if (!glb_policy->seen_initial_response && (response = grpc_grpclb_initial_response_parse(response_slice)) != - NULL) { + nullptr) { if (response->has_client_stats_report_interval) { glb_policy->client_stats_report_interval = GPR_MAX( GPR_MS_PER_SEC, grpc_grpclb_duration_to_millis( @@ -1610,8 +1610,8 @@ static void lb_on_response_received_locked(grpc_exec_ctx* exec_ctx, void* arg, } else { grpc_grpclb_serverlist* serverlist = grpc_grpclb_response_parse_serverlist(response_slice); - if (serverlist != NULL) { - GPR_ASSERT(glb_policy->lb_call != NULL); + if (serverlist != nullptr) { + GPR_ASSERT(glb_policy->lb_call != nullptr); if (grpc_lb_glb_trace.enabled()) { gpr_log(GPR_INFO, "[grpclb %p] Serverlist with %" PRIuPTR " servers received", @@ -1638,14 +1638,14 @@ static void lb_on_response_received_locked(grpc_exec_ctx* exec_ctx, void* arg, } grpc_grpclb_destroy_serverlist(serverlist); } else { /* new serverlist */ - if (glb_policy->serverlist != NULL) { + if (glb_policy->serverlist != nullptr) { /* dispose of the old serverlist */ grpc_grpclb_destroy_serverlist(glb_policy->serverlist); } else { /* or dispose of the fallback */ grpc_lb_addresses_destroy(exec_ctx, glb_policy->fallback_backend_addresses); - glb_policy->fallback_backend_addresses = NULL; + glb_policy->fallback_backend_addresses = nullptr; if (glb_policy->fallback_timer_active) { grpc_timer_cancel(exec_ctx, &glb_policy->lb_fallback_timer); glb_policy->fallback_timer_active = false; @@ -1679,7 +1679,7 @@ static void lb_on_response_received_locked(grpc_exec_ctx* exec_ctx, void* arg, op->op = GRPC_OP_RECV_MESSAGE; op->data.recv_message.recv_message = &glb_policy->lb_response_payload; op->flags = 0; - op->reserved = NULL; + op->reserved = nullptr; op++; /* reuse the "lb_on_response_received_locked" weak ref taken in * query_for_backends_locked() */ @@ -1705,14 +1705,14 @@ static void lb_on_fallback_timer_locked(grpc_exec_ctx* exec_ctx, void* arg, glb_policy->fallback_timer_active = false; /* If we receive a serverlist after the timer fires but before this callback * actually runs, don't fall back. */ - if (glb_policy->serverlist == NULL) { + if (glb_policy->serverlist == nullptr) { if (!glb_policy->shutting_down && error == GRPC_ERROR_NONE) { if (grpc_lb_glb_trace.enabled()) { gpr_log(GPR_INFO, "[grpclb %p] Falling back to use backends from resolver", glb_policy); } - GPR_ASSERT(glb_policy->fallback_backend_addresses != NULL); + GPR_ASSERT(glb_policy->fallback_backend_addresses != nullptr); rr_handover_locked(exec_ctx, glb_policy); } } @@ -1723,7 +1723,7 @@ static void lb_on_fallback_timer_locked(grpc_exec_ctx* exec_ctx, void* arg, static void lb_on_server_status_received_locked(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { glb_lb_policy* glb_policy = (glb_lb_policy*)arg; - GPR_ASSERT(glb_policy->lb_call != NULL); + GPR_ASSERT(glb_policy->lb_call != nullptr); if (grpc_lb_glb_trace.enabled()) { char* status_details = grpc_slice_to_c_string(glb_policy->lb_call_status_details); @@ -1747,7 +1747,7 @@ static void lb_on_server_status_received_locked(grpc_exec_ctx* exec_ctx, static void fallback_update_locked(grpc_exec_ctx* exec_ctx, glb_lb_policy* glb_policy, const grpc_lb_addresses* addresses) { - GPR_ASSERT(glb_policy->fallback_backend_addresses != NULL); + GPR_ASSERT(glb_policy->fallback_backend_addresses != nullptr); grpc_lb_addresses_destroy(exec_ctx, glb_policy->fallback_backend_addresses); glb_policy->fallback_backend_addresses = extract_backend_addresses_locked(exec_ctx, addresses); @@ -1762,8 +1762,8 @@ static void glb_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy, glb_lb_policy* glb_policy = (glb_lb_policy*)policy; const grpc_arg* arg = grpc_channel_args_find(args->args, GRPC_ARG_LB_ADDRESSES); - if (arg == NULL || arg->type != GRPC_ARG_POINTER) { - if (glb_policy->lb_channel == NULL) { + if (arg == nullptr || arg->type != GRPC_ARG_POINTER) { + if (glb_policy->lb_channel == nullptr) { // If we don't have a current channel to the LB, go into TRANSIENT // FAILURE. grpc_connectivity_state_set( @@ -1783,10 +1783,10 @@ static void glb_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy, (const grpc_lb_addresses*)arg->value.pointer.p; // If a non-empty serverlist hasn't been received from the balancer, // propagate the update to fallback_backend_addresses. - if (glb_policy->serverlist == NULL) { + if (glb_policy->serverlist == nullptr) { fallback_update_locked(exec_ctx, glb_policy, addresses); } - GPR_ASSERT(glb_policy->lb_channel != NULL); + GPR_ASSERT(glb_policy->lb_channel != nullptr); // Propagate updates to the LB channel (pick_first) through the fake // resolver. grpc_channel_args* lb_channel_args = build_lb_channel_args( @@ -1809,7 +1809,7 @@ static void glb_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy, grpc_polling_entity_create_from_pollset_set( glb_policy->base.interested_parties), &glb_policy->lb_channel_connectivity, - &glb_policy->lb_channel_on_connectivity_changed, NULL); + &glb_policy->lb_channel_on_connectivity_changed, nullptr); } } @@ -1837,7 +1837,7 @@ static void glb_lb_channel_on_connectivity_changed_cb(grpc_exec_ctx* exec_ctx, grpc_polling_entity_create_from_pollset_set( glb_policy->base.interested_parties), &glb_policy->lb_channel_connectivity, - &glb_policy->lb_channel_on_connectivity_changed, NULL); + &glb_policy->lb_channel_on_connectivity_changed, nullptr); break; } case GRPC_CHANNEL_IDLE: @@ -1845,9 +1845,9 @@ static void glb_lb_channel_on_connectivity_changed_cb(grpc_exec_ctx* exec_ctx, // call to kick the lb channel into gear. /* fallthrough */ case GRPC_CHANNEL_READY: - if (glb_policy->lb_call != NULL) { + if (glb_policy->lb_call != nullptr) { glb_policy->updating_lb_call = true; - grpc_call_cancel(glb_policy->lb_call, NULL); + grpc_call_cancel(glb_policy->lb_call, nullptr); // lb_on_server_status_received() will pick up the cancel and reinit // lb_call. } else if (glb_policy->started_picking && !glb_policy->shutting_down) { @@ -1886,21 +1886,21 @@ static grpc_lb_policy* glb_create(grpc_exec_ctx* exec_ctx, /* Count the number of gRPC-LB addresses. There must be at least one. */ const grpc_arg* arg = grpc_channel_args_find(args->args, GRPC_ARG_LB_ADDRESSES); - if (arg == NULL || arg->type != GRPC_ARG_POINTER) { - return NULL; + if (arg == nullptr || arg->type != GRPC_ARG_POINTER) { + return nullptr; } grpc_lb_addresses* addresses = (grpc_lb_addresses*)arg->value.pointer.p; size_t num_grpclb_addrs = 0; for (size_t i = 0; i < addresses->num_addresses; ++i) { if (addresses->addresses[i].is_balancer) ++num_grpclb_addrs; } - if (num_grpclb_addrs == 0) return NULL; + if (num_grpclb_addrs == 0) return nullptr; glb_lb_policy* glb_policy = (glb_lb_policy*)gpr_zalloc(sizeof(*glb_policy)); /* Get server name. */ arg = grpc_channel_args_find(args->args, GRPC_ARG_SERVER_URI); - GPR_ASSERT(arg != NULL); + GPR_ASSERT(arg != nullptr); GPR_ASSERT(arg->type == GRPC_ARG_STRING); grpc_uri* uri = grpc_uri_parse(exec_ctx, arg->value.string, true); GPR_ASSERT(uri->path[0] != '\0'); @@ -1914,7 +1914,7 @@ static grpc_lb_policy* glb_create(grpc_exec_ctx* exec_ctx, grpc_uri_destroy(uri); glb_policy->cc_factory = args->client_channel_factory; - GPR_ASSERT(glb_policy->cc_factory != NULL); + GPR_ASSERT(glb_policy->cc_factory != nullptr); arg = grpc_channel_args_find(args->args, GRPC_ARG_GRPCLB_CALL_TIMEOUT_MS); glb_policy->lb_call_timeout_ms = @@ -1952,11 +1952,11 @@ static grpc_lb_policy* glb_create(grpc_exec_ctx* exec_ctx, exec_ctx, glb_policy->response_generator, lb_channel_args); grpc_channel_args_destroy(exec_ctx, lb_channel_args); gpr_free(uri_str); - if (glb_policy->lb_channel == NULL) { + if (glb_policy->lb_channel == nullptr) { gpr_free((void*)glb_policy->server_name); grpc_channel_args_destroy(exec_ctx, glb_policy->args); gpr_free(glb_policy); - return NULL; + return nullptr; } grpc_subchannel_index_ref(); GRPC_CLOSURE_INIT(&glb_policy->lb_channel_on_connectivity_changed, @@ -1990,10 +1990,10 @@ static bool maybe_add_client_load_reporting_filter( grpc_channel_stack_builder_get_channel_arguments(builder); const grpc_arg* channel_arg = grpc_channel_args_find(args, GRPC_ARG_LB_POLICY_NAME); - if (channel_arg != NULL && channel_arg->type == GRPC_ARG_STRING && + if (channel_arg != nullptr && channel_arg->type == GRPC_ARG_STRING && strcmp(channel_arg->value.string, "grpclb") == 0) { return grpc_channel_stack_builder_append_filter( - builder, (const grpc_channel_filter*)arg, NULL, NULL); + builder, (const grpc_channel_filter*)arg, nullptr, nullptr); } return true; } diff --git a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc index 4388d6a83e..0f0d245f82 100644 --- a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +++ b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc @@ -59,9 +59,9 @@ typedef struct { static void pf_destroy(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol) { pick_first_lb_policy* p = (pick_first_lb_policy*)pol; - GPR_ASSERT(p->subchannel_list == NULL); - GPR_ASSERT(p->latest_pending_subchannel_list == NULL); - GPR_ASSERT(p->pending_picks == NULL); + GPR_ASSERT(p->subchannel_list == nullptr); + GPR_ASSERT(p->latest_pending_subchannel_list == nullptr); + GPR_ASSERT(p->pending_picks == nullptr); grpc_connectivity_state_destroy(exec_ctx, &p->state_tracker); gpr_free(p); grpc_subchannel_index_unref(); @@ -77,24 +77,24 @@ static void shutdown_locked(grpc_exec_ctx* exec_ctx, pick_first_lb_policy* p, } p->shutdown = true; pending_pick* pp; - while ((pp = p->pending_picks) != NULL) { + while ((pp = p->pending_picks) != nullptr) { p->pending_picks = pp->next; - *pp->target = NULL; + *pp->target = nullptr; GRPC_CLOSURE_SCHED(exec_ctx, pp->on_complete, GRPC_ERROR_REF(error)); gpr_free(pp); } grpc_connectivity_state_set(exec_ctx, &p->state_tracker, GRPC_CHANNEL_SHUTDOWN, GRPC_ERROR_REF(error), "shutdown"); - if (p->subchannel_list != NULL) { + if (p->subchannel_list != nullptr) { grpc_lb_subchannel_list_shutdown_and_unref(exec_ctx, p->subchannel_list, "pf_shutdown"); - p->subchannel_list = NULL; + p->subchannel_list = nullptr; } - if (p->latest_pending_subchannel_list != NULL) { + if (p->latest_pending_subchannel_list != nullptr) { grpc_lb_subchannel_list_shutdown_and_unref( exec_ctx, p->latest_pending_subchannel_list, "pf_shutdown"); - p->latest_pending_subchannel_list = NULL; + p->latest_pending_subchannel_list = nullptr; } GRPC_ERROR_UNREF(error); } @@ -109,11 +109,11 @@ static void pf_cancel_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol, grpc_error* error) { pick_first_lb_policy* p = (pick_first_lb_policy*)pol; pending_pick* pp = p->pending_picks; - p->pending_picks = NULL; - while (pp != NULL) { + p->pending_picks = nullptr; + while (pp != nullptr) { pending_pick* next = pp->next; if (pp->target == target) { - *target = NULL; + *target = nullptr; GRPC_CLOSURE_SCHED(exec_ctx, pp->on_complete, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( "Pick Cancelled", &error, 1)); @@ -133,8 +133,8 @@ static void pf_cancel_picks_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol, grpc_error* error) { pick_first_lb_policy* p = (pick_first_lb_policy*)pol; pending_pick* pp = p->pending_picks; - p->pending_picks = NULL; - while (pp != NULL) { + p->pending_picks = nullptr; + while (pp != nullptr) { pending_pick* next = pp->next; if ((pp->initial_metadata_flags & initial_metadata_flags_mask) == initial_metadata_flags_eq) { @@ -154,7 +154,7 @@ static void pf_cancel_picks_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol, static void start_picking_locked(grpc_exec_ctx* exec_ctx, pick_first_lb_policy* p) { p->started_picking = true; - if (p->subchannel_list != NULL && p->subchannel_list->num_subchannels > 0) { + if (p->subchannel_list != nullptr && p->subchannel_list->num_subchannels > 0) { p->subchannel_list->checking_subchannel = 0; grpc_lb_subchannel_list_ref_for_connectivity_watch( p->subchannel_list, "connectivity_watch+start_picking"); @@ -177,7 +177,7 @@ static int pf_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol, grpc_closure* on_complete) { pick_first_lb_policy* p = (pick_first_lb_policy*)pol; // If we have a selected subchannel already, return synchronously. - if (p->selected != NULL) { + if (p->selected != nullptr) { *target = GRPC_CONNECTED_SUBCHANNEL_REF(p->selected->connected_subchannel, "picked"); return 1; @@ -241,8 +241,8 @@ static void pf_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy, pick_first_lb_policy* p = (pick_first_lb_policy*)policy; const grpc_arg* arg = grpc_channel_args_find(args->args, GRPC_ARG_LB_ADDRESSES); - if (arg == NULL || arg->type != GRPC_ARG_POINTER) { - if (p->subchannel_list == NULL) { + if (arg == nullptr || arg->type != GRPC_ARG_POINTER) { + if (p->subchannel_list == nullptr) { // If we don't have a current subchannel list, go into TRANSIENT FAILURE. grpc_connectivity_state_set( exec_ctx, &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE, @@ -273,18 +273,18 @@ static void pf_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy, exec_ctx, &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Empty update"), "pf_update_empty"); - if (p->subchannel_list != NULL) { + if (p->subchannel_list != nullptr) { grpc_lb_subchannel_list_shutdown_and_unref(exec_ctx, p->subchannel_list, "sl_shutdown_empty_update"); } p->subchannel_list = subchannel_list; // Empty list. - p->selected = NULL; + p->selected = nullptr; return; } - if (p->selected == NULL) { + if (p->selected == nullptr) { // We don't yet have a selected subchannel, so replace the current // subchannel list immediately. - if (p->subchannel_list != NULL) { + if (p->subchannel_list != nullptr) { grpc_lb_subchannel_list_shutdown_and_unref(exec_ctx, p->subchannel_list, "pf_update_before_selected"); } @@ -306,12 +306,12 @@ static void pf_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy, grpc_lb_subchannel_list_ref_for_connectivity_watch( subchannel_list, "connectivity_watch+replace_selected"); grpc_lb_subchannel_data_start_connectivity_watch(exec_ctx, sd); - if (p->subchannel_list != NULL) { + if (p->subchannel_list != nullptr) { grpc_lb_subchannel_list_shutdown_and_unref( exec_ctx, p->subchannel_list, "pf_update_includes_selected"); } p->subchannel_list = subchannel_list; - if (p->selected->connected_subchannel != NULL) { + if (p->selected->connected_subchannel != nullptr) { sd->connected_subchannel = GRPC_CONNECTED_SUBCHANNEL_REF( p->selected->connected_subchannel, "pf_update_includes_selected"); } @@ -320,11 +320,11 @@ static void pf_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy, // If there was a previously pending update (which may or may // not have contained the currently selected subchannel), drop // it, so that it doesn't override what we've done here. - if (p->latest_pending_subchannel_list != NULL) { + if (p->latest_pending_subchannel_list != nullptr) { grpc_lb_subchannel_list_shutdown_and_unref( exec_ctx, p->latest_pending_subchannel_list, "pf_update_includes_selected+outdated"); - p->latest_pending_subchannel_list = NULL; + p->latest_pending_subchannel_list = nullptr; } return; } @@ -333,7 +333,7 @@ static void pf_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy, // pending subchannel list to the new subchannel list. We will wait // for it to report READY before swapping it into the current // subchannel list. - if (p->latest_pending_subchannel_list != NULL) { + if (p->latest_pending_subchannel_list != nullptr) { if (grpc_lb_pick_first_trace.enabled()) { gpr_log(GPR_DEBUG, "Pick First %p Shutting down latest pending subchannel list " @@ -401,12 +401,12 @@ static void pf_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg, // If the new state is anything other than READY and there is a // pending update, switch to the pending update. if (sd->curr_connectivity_state != GRPC_CHANNEL_READY && - p->latest_pending_subchannel_list != NULL) { - p->selected = NULL; + p->latest_pending_subchannel_list != nullptr) { + p->selected = nullptr; grpc_lb_subchannel_list_shutdown_and_unref( exec_ctx, p->subchannel_list, "selected_not_ready+switch_to_update"); p->subchannel_list = p->latest_pending_subchannel_list; - p->latest_pending_subchannel_list = NULL; + p->latest_pending_subchannel_list = nullptr; grpc_connectivity_state_set( exec_ctx, &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE, GRPC_ERROR_REF(error), "selected_not_ready+switch_to_update"); @@ -444,11 +444,11 @@ static void pf_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg, // Case 2. Promote p->latest_pending_subchannel_list to // p->subchannel_list. if (sd->subchannel_list == p->latest_pending_subchannel_list) { - GPR_ASSERT(p->subchannel_list != NULL); + GPR_ASSERT(p->subchannel_list != nullptr); grpc_lb_subchannel_list_shutdown_and_unref(exec_ctx, p->subchannel_list, "finish_update"); p->subchannel_list = p->latest_pending_subchannel_list; - p->latest_pending_subchannel_list = NULL; + p->latest_pending_subchannel_list = nullptr; } // Cases 1 and 2. grpc_connectivity_state_set(exec_ctx, &p->state_tracker, @@ -490,7 +490,7 @@ static void pf_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg, sd->subchannel_list->num_subchannels; sd = &sd->subchannel_list ->subchannels[sd->subchannel_list->checking_subchannel]; - } while (sd->subchannel == NULL); + } while (sd->subchannel == nullptr); // Case 1: Only set state to TRANSIENT_FAILURE if we've tried // all subchannels. if (sd->subchannel_list->checking_subchannel == 0 && @@ -527,7 +527,7 @@ static void pf_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg, sd->subchannel_list->num_subchannels; sd = &sd->subchannel_list ->subchannels[sd->subchannel_list->checking_subchannel]; - } while (sd->subchannel == NULL && sd != original_sd); + } while (sd->subchannel == nullptr && sd != original_sd); if (sd == original_sd) { grpc_lb_subchannel_list_unref_for_connectivity_watch( exec_ctx, sd->subchannel_list, "pf_candidate_shutdown"); @@ -567,7 +567,7 @@ static void pick_first_factory_unref(grpc_lb_policy_factory* factory) {} static grpc_lb_policy* create_pick_first(grpc_exec_ctx* exec_ctx, grpc_lb_policy_factory* factory, grpc_lb_policy_args* args) { - GPR_ASSERT(args->client_channel_factory != NULL); + GPR_ASSERT(args->client_channel_factory != nullptr); pick_first_lb_policy* p = (pick_first_lb_policy*)gpr_zalloc(sizeof(*p)); if (grpc_lb_pick_first_trace.enabled()) { gpr_log(GPR_DEBUG, "Pick First %p created.", (void*)p); diff --git a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc index f4ad746157..5e54d1fc77 100644 --- a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +++ b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc @@ -99,7 +99,7 @@ typedef struct round_robin_lb_policy { * The caller must do that if it returns a pick. */ static size_t get_next_ready_subchannel_index_locked( const round_robin_lb_policy* p) { - GPR_ASSERT(p->subchannel_list != NULL); + GPR_ASSERT(p->subchannel_list != nullptr); if (grpc_lb_round_robin_trace.enabled()) { gpr_log(GPR_INFO, "[RR %p] getting next ready subchannel (out of %lu), " @@ -160,8 +160,8 @@ static void rr_destroy(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol) { gpr_log(GPR_DEBUG, "[RR %p] Destroying Round Robin policy at %p", (void*)pol, (void*)pol); } - GPR_ASSERT(p->subchannel_list == NULL); - GPR_ASSERT(p->latest_pending_subchannel_list == NULL); + GPR_ASSERT(p->subchannel_list == nullptr); + GPR_ASSERT(p->latest_pending_subchannel_list == nullptr); grpc_connectivity_state_destroy(exec_ctx, &p->state_tracker); grpc_subchannel_index_unref(); gpr_free(p); @@ -174,25 +174,25 @@ static void shutdown_locked(grpc_exec_ctx* exec_ctx, round_robin_lb_policy* p, } p->shutdown = true; pending_pick* pp; - while ((pp = p->pending_picks) != NULL) { + while ((pp = p->pending_picks) != nullptr) { p->pending_picks = pp->next; - *pp->target = NULL; + *pp->target = nullptr; GRPC_CLOSURE_SCHED(exec_ctx, pp->on_complete, GRPC_ERROR_REF(error)); gpr_free(pp); } grpc_connectivity_state_set(exec_ctx, &p->state_tracker, GRPC_CHANNEL_SHUTDOWN, GRPC_ERROR_REF(error), "rr_shutdown"); - if (p->subchannel_list != NULL) { + if (p->subchannel_list != nullptr) { grpc_lb_subchannel_list_shutdown_and_unref(exec_ctx, p->subchannel_list, "sl_shutdown_rr_shutdown"); - p->subchannel_list = NULL; + p->subchannel_list = nullptr; } - if (p->latest_pending_subchannel_list != NULL) { + if (p->latest_pending_subchannel_list != nullptr) { grpc_lb_subchannel_list_shutdown_and_unref( exec_ctx, p->latest_pending_subchannel_list, "sl_shutdown_pending_rr_shutdown"); - p->latest_pending_subchannel_list = NULL; + p->latest_pending_subchannel_list = nullptr; } GRPC_ERROR_UNREF(error); } @@ -208,11 +208,11 @@ static void rr_cancel_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol, grpc_error* error) { round_robin_lb_policy* p = (round_robin_lb_policy*)pol; pending_pick* pp = p->pending_picks; - p->pending_picks = NULL; - while (pp != NULL) { + p->pending_picks = nullptr; + while (pp != nullptr) { pending_pick* next = pp->next; if (pp->target == target) { - *target = NULL; + *target = nullptr; GRPC_CLOSURE_SCHED(exec_ctx, pp->on_complete, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( "Pick cancelled", &error, 1)); @@ -232,12 +232,12 @@ static void rr_cancel_picks_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol, grpc_error* error) { round_robin_lb_policy* p = (round_robin_lb_policy*)pol; pending_pick* pp = p->pending_picks; - p->pending_picks = NULL; - while (pp != NULL) { + p->pending_picks = nullptr; + while (pp != nullptr) { pending_pick* next = pp->next; if ((pp->initial_metadata_flags & initial_metadata_flags_mask) == initial_metadata_flags_eq) { - *pp->target = NULL; + *pp->target = nullptr; GRPC_CLOSURE_SCHED(exec_ctx, pp->on_complete, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( "Pick cancelled", &error, 1)); @@ -280,7 +280,7 @@ static int rr_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol, p->shutdown); } GPR_ASSERT(!p->shutdown); - if (p->subchannel_list != NULL) { + if (p->subchannel_list != nullptr) { const size_t next_ready_index = get_next_ready_subchannel_index_locked(p); if (next_ready_index < p->subchannel_list->num_subchannels) { /* readily available, report right away */ @@ -288,7 +288,7 @@ static int rr_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol, &p->subchannel_list->subchannels[next_ready_index]; *target = GRPC_CONNECTED_SUBCHANNEL_REF(sd->connected_subchannel, "rr_picked"); - if (user_data != NULL) { + if (user_data != nullptr) { *user_data = sd->user_data; } if (grpc_lb_round_robin_trace.enabled()) { @@ -471,7 +471,7 @@ static void rr_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg, } } else { // sd not in SHUTDOWN if (sd->curr_connectivity_state == GRPC_CHANNEL_READY) { - if (sd->connected_subchannel == NULL) { + if (sd->connected_subchannel == nullptr) { sd->connected_subchannel = GRPC_CONNECTED_SUBCHANNEL_REF( grpc_subchannel_get_connected_subchannel(sd->subchannel), "connected"); @@ -485,7 +485,7 @@ static void rr_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg, GPR_ASSERT(!sd->subchannel_list->shutting_down); if (grpc_lb_round_robin_trace.enabled()) { const unsigned long num_subchannels = - p->subchannel_list != NULL + p->subchannel_list != nullptr ? (unsigned long)p->subchannel_list->num_subchannels : 0; gpr_log(GPR_DEBUG, @@ -494,13 +494,13 @@ static void rr_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg, (void*)p, (void*)p->subchannel_list, num_subchannels, (void*)sd->subchannel_list, num_subchannels); } - if (p->subchannel_list != NULL) { + if (p->subchannel_list != nullptr) { // dispose of the current subchannel_list grpc_lb_subchannel_list_shutdown_and_unref( exec_ctx, p->subchannel_list, "sl_phase_out_shutdown"); } p->subchannel_list = p->latest_pending_subchannel_list; - p->latest_pending_subchannel_list = NULL; + p->latest_pending_subchannel_list = nullptr; } /* at this point we know there's at least one suitable subchannel. Go * ahead and pick one and notify the pending suitors in @@ -509,7 +509,7 @@ static void rr_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg, GPR_ASSERT(next_ready_index < p->subchannel_list->num_subchannels); grpc_lb_subchannel_data* selected = &p->subchannel_list->subchannels[next_ready_index]; - if (p->pending_picks != NULL) { + if (p->pending_picks != nullptr) { // if the selected subchannel is going to be used for the pending // picks, update the last picked pointer update_last_ready_subchannel_index_locked(p, next_ready_index); @@ -519,7 +519,7 @@ static void rr_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg, p->pending_picks = pp->next; *pp->target = GRPC_CONNECTED_SUBCHANNEL_REF( selected->connected_subchannel, "rr_picked"); - if (pp->user_data != NULL) { + if (pp->user_data != nullptr) { *pp->user_data = selected->user_data; } if (grpc_lb_round_robin_trace.enabled()) { @@ -576,11 +576,11 @@ static void rr_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy, round_robin_lb_policy* p = (round_robin_lb_policy*)policy; const grpc_arg* arg = grpc_channel_args_find(args->args, GRPC_ARG_LB_ADDRESSES); - if (arg == NULL || arg->type != GRPC_ARG_POINTER) { + if (arg == nullptr || arg->type != GRPC_ARG_POINTER) { gpr_log(GPR_ERROR, "[RR %p] update provided no addresses; ignoring", p); // If we don't have a current subchannel list, go into TRANSIENT_FAILURE. // Otherwise, keep using the current subchannel list (ignore this update). - if (p->subchannel_list == NULL) { + if (p->subchannel_list == nullptr) { grpc_connectivity_state_set( exec_ctx, &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Missing update in args"), @@ -601,7 +601,7 @@ static void rr_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy, exec_ctx, &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Empty update"), "rr_update_empty"); - if (p->subchannel_list != NULL) { + if (p->subchannel_list != nullptr) { grpc_lb_subchannel_list_shutdown_and_unref(exec_ctx, p->subchannel_list, "sl_shutdown_empty_update"); } @@ -609,7 +609,7 @@ static void rr_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy, return; } if (p->started_picking) { - if (p->latest_pending_subchannel_list != NULL) { + if (p->latest_pending_subchannel_list != nullptr) { if (grpc_lb_round_robin_trace.enabled()) { gpr_log(GPR_DEBUG, "[RR %p] Shutting down latest pending subchannel list %p, " @@ -634,7 +634,7 @@ static void rr_update_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* policy, } else { // The policy isn't picking yet. Save the update for later, disposing of // previous version if any. - if (p->subchannel_list != NULL) { + if (p->subchannel_list != nullptr) { grpc_lb_subchannel_list_shutdown_and_unref( exec_ctx, p->subchannel_list, "rr_update_before_started_picking"); } @@ -661,7 +661,7 @@ static void round_robin_factory_unref(grpc_lb_policy_factory* factory) {} static grpc_lb_policy* round_robin_create(grpc_exec_ctx* exec_ctx, grpc_lb_policy_factory* factory, grpc_lb_policy_args* args) { - GPR_ASSERT(args->client_channel_factory != NULL); + GPR_ASSERT(args->client_channel_factory != nullptr); round_robin_lb_policy* p = (round_robin_lb_policy*)gpr_zalloc(sizeof(*p)); grpc_lb_policy_init(&p->base, &round_robin_lb_policy_vtable, args->combiner); grpc_subchannel_index_ref(); diff --git a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc index ec3fb4e7a2..7d39cc009f 100644 --- a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc +++ b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc @@ -31,7 +31,7 @@ void grpc_lb_subchannel_data_unref_subchannel(grpc_exec_ctx* exec_ctx, grpc_lb_subchannel_data* sd, const char* reason) { - if (sd->subchannel != NULL) { + if (sd->subchannel != nullptr) { if (sd->subchannel_list->tracer->enabled()) { gpr_log(GPR_DEBUG, "[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR @@ -42,16 +42,16 @@ void grpc_lb_subchannel_data_unref_subchannel(grpc_exec_ctx* exec_ctx, sd->subchannel_list->num_subchannels, sd->subchannel); } GRPC_SUBCHANNEL_UNREF(exec_ctx, sd->subchannel, reason); - sd->subchannel = NULL; - if (sd->connected_subchannel != NULL) { + sd->subchannel = nullptr; + if (sd->connected_subchannel != nullptr) { GRPC_CONNECTED_SUBCHANNEL_UNREF(exec_ctx, sd->connected_subchannel, reason); - sd->connected_subchannel = NULL; + sd->connected_subchannel = nullptr; } - if (sd->user_data != NULL) { - GPR_ASSERT(sd->user_data_vtable != NULL); + if (sd->user_data != nullptr) { + GPR_ASSERT(sd->user_data_vtable != nullptr); sd->user_data_vtable->destroy(exec_ctx, sd->user_data); - sd->user_data = NULL; + sd->user_data = nullptr; } } } @@ -126,7 +126,7 @@ grpc_lb_subchannel_list* grpc_lb_subchannel_list_create( grpc_subchannel* subchannel = grpc_client_channel_factory_create_subchannel( exec_ctx, args->client_channel_factory, &sc_args); grpc_channel_args_destroy(exec_ctx, new_args); - if (subchannel == NULL) { + if (subchannel == nullptr) { // Subchannel could not be created. if (tracer->enabled()) { char* address_uri = @@ -162,7 +162,7 @@ grpc_lb_subchannel_list* grpc_lb_subchannel_list_create( sd->curr_connectivity_state = GRPC_CHANNEL_IDLE; sd->pending_connectivity_state_unsafe = GRPC_CHANNEL_IDLE; sd->user_data_vtable = addresses->user_data_vtable; - if (sd->user_data_vtable != NULL) { + if (sd->user_data_vtable != nullptr) { sd->user_data = sd->user_data_vtable->copy(addresses->addresses[i].user_data); } @@ -240,7 +240,7 @@ static void subchannel_data_cancel_connectivity_watch( (size_t)(sd - sd->subchannel_list->subchannels), sd->subchannel_list->num_subchannels, sd->subchannel, reason); } - grpc_subchannel_notify_on_state_change(exec_ctx, sd->subchannel, NULL, NULL, + grpc_subchannel_notify_on_state_change(exec_ctx, sd->subchannel, nullptr, nullptr, &sd->connectivity_changed_closure); } @@ -261,7 +261,7 @@ void grpc_lb_subchannel_list_shutdown_and_unref( // Otherwise, unref the subchannel directly. if (sd->connectivity_notification_pending) { subchannel_data_cancel_connectivity_watch(exec_ctx, sd, reason); - } else if (sd->subchannel != NULL) { + } else if (sd->subchannel != nullptr) { grpc_lb_subchannel_data_unref_subchannel(exec_ctx, sd, reason); } } diff --git a/src/core/ext/transport/chttp2/transport/parsing.cc b/src/core/ext/transport/chttp2/transport/parsing.cc index f8775d5926..46ec3fbaa6 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.cc +++ b/src/core/ext/transport/chttp2/transport/parsing.cc @@ -191,7 +191,7 @@ grpc_error* grpc_chttp2_perform_read(grpc_exec_ctx* exec_ctx, if (err != GRPC_ERROR_NONE) { return err; } - t->incoming_stream = NULL; + t->incoming_stream = nullptr; if (++cur == end) { t->deframe_state = GRPC_DTS_FH_0; return GRPC_ERROR_NONE; @@ -225,7 +225,7 @@ grpc_error* grpc_chttp2_perform_read(grpc_exec_ctx* exec_ctx, return err; } t->deframe_state = GRPC_DTS_FH_0; - t->incoming_stream = NULL; + t->incoming_stream = nullptr; return GRPC_ERROR_NONE; } else if ((uint32_t)(end - cur) > t->incoming_frame_size) { size_t cur_offset = (size_t)(cur - beg); @@ -238,7 +238,7 @@ grpc_error* grpc_chttp2_perform_read(grpc_exec_ctx* exec_ctx, return err; } cur += t->incoming_frame_size; - t->incoming_stream = NULL; + t->incoming_stream = nullptr; goto dts_fh_0; /* loop */ } else { err = @@ -337,7 +337,7 @@ static grpc_error* init_skip_frame_parser(grpc_exec_ctx* exec_ctx, t->parser = grpc_chttp2_header_parser_parse; t->parser_data = &t->hpack_parser; t->hpack_parser.on_header = skip_header; - t->hpack_parser.on_header_user_data = NULL; + t->hpack_parser.on_header_user_data = nullptr; t->hpack_parser.is_boundary = is_eoh; t->hpack_parser.is_eof = (uint8_t)(is_eoh ? t->header_eof : 0); } else { @@ -369,7 +369,7 @@ static grpc_error* init_data_frame_parser(grpc_exec_ctx* exec_ctx, if (err != GRPC_ERROR_NONE) { goto error_handler; } - if (s == NULL) { + if (s == nullptr) { return init_skip_frame_parser(exec_ctx, t, 0); } s->received_bytes += t->incoming_frame_size; @@ -391,9 +391,9 @@ error_handler: t->ping_policy.max_pings_without_data; t->ping_state.last_ping_sent_time = GRPC_MILLIS_INF_PAST; return GRPC_ERROR_NONE; - } else if (grpc_error_get_int(err, GRPC_ERROR_INT_STREAM_ID, NULL)) { + } else if (grpc_error_get_int(err, GRPC_ERROR_INT_STREAM_ID, nullptr)) { /* handle stream errors by closing the stream */ - if (s != NULL) { + if (s != nullptr) { grpc_chttp2_mark_stream_closed(exec_ctx, t, s, true, false, err); } grpc_slice_buffer_add( @@ -415,7 +415,7 @@ static void on_initial_header(grpc_exec_ctx* exec_ctx, void* tp, GPR_TIMER_BEGIN("on_initial_header", 0); - GPR_ASSERT(s != NULL); + GPR_ASSERT(s != nullptr); if (grpc_http_trace.enabled()) { char* key = grpc_slice_to_c_string(GRPC_MDKEY(md)); @@ -437,7 +437,7 @@ static void on_initial_header(grpc_exec_ctx* exec_ctx, void* tp, grpc_millis* cached_timeout = static_cast(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)) { @@ -499,7 +499,7 @@ static void on_trailing_header(grpc_exec_ctx* exec_ctx, void* tp, GPR_TIMER_BEGIN("on_trailing_header", 0); - GPR_ASSERT(s != NULL); + GPR_ASSERT(s != nullptr); if (grpc_http_trace.enabled()) { char* key = grpc_slice_to_c_string(GRPC_MDKEY(md)); @@ -575,7 +575,7 @@ static grpc_error* init_header_frame_parser(grpc_exec_ctx* exec_ctx, /* could be a new grpc_chttp2_stream or an existing grpc_chttp2_stream */ s = grpc_chttp2_parsing_lookup_stream(t, t->incoming_stream_id); - if (s == NULL) { + if (s == nullptr) { if (is_continuation) { GRPC_CHTTP2_IF_TRACING( gpr_log(GPR_ERROR, @@ -617,7 +617,7 @@ static grpc_error* init_header_frame_parser(grpc_exec_ctx* exec_ctx, t->last_new_stream_id = t->incoming_stream_id; s = t->incoming_stream = grpc_chttp2_parsing_accept_stream(exec_ctx, t, t->incoming_stream_id); - if (s == NULL) { + if (s == nullptr) { GRPC_CHTTP2_IF_TRACING( gpr_log(GPR_ERROR, "grpc_chttp2_stream not accepted")); return init_skip_frame_parser(exec_ctx, t, 1); @@ -625,12 +625,12 @@ static grpc_error* init_header_frame_parser(grpc_exec_ctx* exec_ctx, } else { t->incoming_stream = s; } - GPR_ASSERT(s != NULL); + GPR_ASSERT(s != nullptr); s->stats.incoming.framing_bytes += 9; if (s->read_closed) { GRPC_CHTTP2_IF_TRACING(gpr_log( GPR_ERROR, "skipping already closed grpc_chttp2_stream header")); - t->incoming_stream = NULL; + t->incoming_stream = nullptr; return init_skip_frame_parser(exec_ctx, t, 1); } t->parser = grpc_chttp2_header_parser_parse; @@ -639,7 +639,7 @@ static grpc_error* init_header_frame_parser(grpc_exec_ctx* exec_ctx, case 0: if (t->is_client && t->header_eof) { GRPC_CHTTP2_IF_TRACING(gpr_log(GPR_INFO, "parsing Trailers-Only")); - if (s->trailing_metadata_available != NULL) { + if (s->trailing_metadata_available != nullptr) { *s->trailing_metadata_available = true; } t->hpack_parser.on_header = on_trailing_header; @@ -677,7 +677,7 @@ static grpc_error* init_window_update_frame_parser(grpc_exec_ctx* exec_ctx, if (t->incoming_stream_id != 0) { grpc_chttp2_stream* s = t->incoming_stream = grpc_chttp2_parsing_lookup_stream(t, t->incoming_stream_id); - if (s == NULL) { + if (s == nullptr) { return init_skip_frame_parser(exec_ctx, t, 0); } s->stats.incoming.framing_bytes += 9; @@ -757,7 +757,7 @@ static grpc_error* parse_frame_slice(grpc_exec_ctx* exec_ctx, grpc_error* err = t->parser(exec_ctx, t->parser_data, t, s, slice, is_last); if (err == GRPC_ERROR_NONE) { return err; - } else if (grpc_error_get_int(err, GRPC_ERROR_INT_STREAM_ID, NULL)) { + } else if (grpc_error_get_int(err, GRPC_ERROR_INT_STREAM_ID, nullptr)) { if (grpc_http_trace.enabled()) { const char* msg = grpc_error_string(err); gpr_log(GPR_ERROR, "%s", msg); diff --git a/src/core/ext/transport/inproc/inproc_transport.cc b/src/core/ext/transport/inproc/inproc_transport.cc index c18f8781aa..cf6418a66c 100644 --- a/src/core/ext/transport/inproc/inproc_transport.cc +++ b/src/core/ext/transport/inproc/inproc_transport.cc @@ -184,7 +184,7 @@ static void really_destroy_stream(grpc_exec_ctx* exec_ctx, inproc_stream* s) { static void log_metadata(const grpc_metadata_batch* md_batch, bool is_client, bool is_initial) { - for (grpc_linked_mdelem* md = md_batch->list.head; md != NULL; + for (grpc_linked_mdelem* md = md_batch->list.head; md != nullptr; md = md->next) { char* key = grpc_slice_to_c_string(GRPC_MDKEY(md->md)); char* value = grpc_slice_to_c_string(GRPC_MDVALUE(md->md)); @@ -200,18 +200,18 @@ static grpc_error* fill_in_metadata(grpc_exec_ctx* exec_ctx, inproc_stream* s, uint32_t flags, grpc_metadata_batch* out_md, uint32_t* outflags, bool* markfilled) { if (grpc_inproc_trace.enabled()) { - log_metadata(metadata, s->t->is_client, outflags != NULL); + log_metadata(metadata, s->t->is_client, outflags != nullptr); } - if (outflags != NULL) { + if (outflags != nullptr) { *outflags = flags; } - if (markfilled != NULL) { + if (markfilled != nullptr) { *markfilled = true; } grpc_error* error = GRPC_ERROR_NONE; for (grpc_linked_mdelem* elem = metadata->list.head; - (elem != NULL) && (error == GRPC_ERROR_NONE); elem = elem->next) { + (elem != nullptr) && (error == GRPC_ERROR_NONE); elem = elem->next) { grpc_linked_mdelem* nelem = (grpc_linked_mdelem*)gpr_arena_alloc(s->arena, sizeof(*nelem)); nelem->md = grpc_mdelem_from_slices( @@ -250,7 +250,7 @@ static int init_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt, GRPC_CLOSURE_INIT(&s->op_closure, op_state_machine, s, grpc_schedule_on_exec_ctx); s->t = t; - s->closure_at_destroy = NULL; + s->closure_at_destroy = nullptr; s->other_side_closed = false; s->initial_md_sent = s->trailing_md_sent = s->initial_md_recvd = @@ -264,7 +264,7 @@ static int init_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt, s->deadline = GRPC_MILLIS_INF_FUTURE; s->write_buffer_deadline = GRPC_MILLIS_INF_FUTURE; - s->stream_list_prev = NULL; + s->stream_list_prev = nullptr; gpr_mu_lock(&t->mu->mu); s->listed = true; ref_stream(s, "inproc_init_stream:list"); @@ -279,7 +279,7 @@ static int init_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt, ref_transport(t); inproc_transport* st = t->other_side; ref_transport(st); - s->other_side = NULL; // will get filled in soon + s->other_side = nullptr; // will get filled in soon // Pass the client-side stream address to the server-side for a ref ref_stream(s, "inproc_init_stream:clt"); // ref it now on behalf of server // side to avoid destruction @@ -311,7 +311,7 @@ static int init_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt, } if (cs->write_buffer_trailing_md_filled) { fill_in_metadata(exec_ctx, s, &cs->write_buffer_trailing_md, 0, - &s->to_read_trailing_md, NULL, + &s->to_read_trailing_md, nullptr, &s->to_read_trailing_md_filled); grpc_metadata_batch_clear(exec_ctx, &cs->write_buffer_trailing_md); cs->write_buffer_trailing_md_filled = false; @@ -335,12 +335,12 @@ static void close_stream_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s) { if (s->listed) { inproc_stream* p = s->stream_list_prev; inproc_stream* n = s->stream_list_next; - if (p != NULL) { + if (p != nullptr) { p->stream_list_next = n; } else { s->t->stream_list = n; } - if (n != NULL) { + if (n != nullptr) { n->stream_list_prev = p; } s->listed = false; @@ -354,14 +354,14 @@ static void close_stream_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s) { // This function means that we are done talking/listening to the other side static void close_other_side_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s, const char* reason) { - if (s->other_side != NULL) { + if (s->other_side != nullptr) { // First release the metadata that came from the other side's arena grpc_metadata_batch_destroy(exec_ctx, &s->to_read_initial_md); grpc_metadata_batch_destroy(exec_ctx, &s->to_read_trailing_md); unref_stream(exec_ctx, s->other_side, reason); s->other_side_closed = true; - s->other_side = NULL; + s->other_side = nullptr; } else if (!s->other_side_closed) { s->write_buffer_other_side_closed = true; } @@ -410,14 +410,14 @@ static void fail_helper_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s, grpc_metadata_batch_init(&fake_md); inproc_stream* other = s->other_side; - grpc_metadata_batch* dest = (other == NULL) ? &s->write_buffer_trailing_md + grpc_metadata_batch* dest = (other == nullptr) ? &s->write_buffer_trailing_md : &other->to_read_trailing_md; - bool* destfilled = (other == NULL) ? &s->write_buffer_trailing_md_filled + bool* destfilled = (other == nullptr) ? &s->write_buffer_trailing_md_filled : &other->to_read_trailing_md_filled; - fill_in_metadata(exec_ctx, s, &fake_md, 0, dest, NULL, destfilled); + fill_in_metadata(exec_ctx, s, &fake_md, 0, dest, nullptr, destfilled); grpc_metadata_batch_destroy(exec_ctx, &fake_md); - if (other != NULL) { + if (other != nullptr) { if (other->cancel_other_error == GRPC_ERROR_NONE) { other->cancel_other_error = GRPC_ERROR_REF(error); } @@ -451,7 +451,7 @@ static void fail_helper_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s, s->recv_initial_md_op->payload->recv_initial_metadata .recv_initial_metadata, s->recv_initial_md_op->payload->recv_initial_metadata.recv_flags, - NULL); + nullptr); grpc_metadata_batch_destroy(exec_ctx, &fake_md); err = GRPC_ERROR_NONE; } else { @@ -469,7 +469,7 @@ static void fail_helper_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s, complete_if_batch_end_locked( exec_ctx, s, error, s->recv_initial_md_op, "fail_helper scheduling recv-initial-metadata-on-complete"); - s->recv_initial_md_op = NULL; + s->recv_initial_md_op = nullptr; } if (s->recv_message_op) { INPROC_LOG(GPR_DEBUG, "fail_helper %p scheduling message-ready %p", s, @@ -480,19 +480,19 @@ static void fail_helper_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s, complete_if_batch_end_locked( exec_ctx, s, error, s->recv_message_op, "fail_helper scheduling recv-message-on-complete"); - s->recv_message_op = NULL; + s->recv_message_op = nullptr; } if (s->send_message_op) { complete_if_batch_end_locked( exec_ctx, s, error, s->send_message_op, "fail_helper scheduling send-message-on-complete"); - s->send_message_op = NULL; + s->send_message_op = nullptr; } if (s->send_trailing_md_op) { complete_if_batch_end_locked( exec_ctx, s, error, s->send_trailing_md_op, "fail_helper scheduling send-trailng-md-on-complete"); - s->send_trailing_md_op = NULL; + s->send_trailing_md_op = nullptr; } if (s->recv_trailing_md_op) { INPROC_LOG(GPR_DEBUG, @@ -501,7 +501,7 @@ static void fail_helper_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s, complete_if_batch_end_locked( exec_ctx, s, error, s->recv_trailing_md_op, "fail_helper scheduling recv-trailing-metadata-on-complete"); - s->recv_trailing_md_op = NULL; + s->recv_trailing_md_op = nullptr; } close_other_side_locked(exec_ctx, s, "fail_helper:other_side"); close_stream_locked(exec_ctx, s); @@ -554,8 +554,8 @@ static void message_transfer_locked(grpc_exec_ctx* exec_ctx, exec_ctx, receiver, GRPC_ERROR_NONE, receiver->recv_message_op, "message_transfer scheduling receiver on_complete"); - receiver->recv_message_op = NULL; - sender->send_message_op = NULL; + receiver->recv_message_op = nullptr; + sender->send_message_op = nullptr; } static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg, @@ -601,7 +601,7 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg, complete_if_batch_end_locked( exec_ctx, s, GRPC_ERROR_NONE, s->send_message_op, "op_state_machine scheduling send-message-on-complete"); - s->send_message_op = NULL; + s->send_message_op = nullptr; } } // Pause a send trailing metadata if there is still an outstanding @@ -612,9 +612,9 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg, (!s->send_message_op || (s->t->is_client && (s->trailing_md_recvd || s->to_read_trailing_md_filled)))) { - grpc_metadata_batch* dest = (other == NULL) ? &s->write_buffer_trailing_md + grpc_metadata_batch* dest = (other == nullptr) ? &s->write_buffer_trailing_md : &other->to_read_trailing_md; - bool* destfilled = (other == NULL) ? &s->write_buffer_trailing_md_filled + bool* destfilled = (other == nullptr) ? &s->write_buffer_trailing_md_filled : &other->to_read_trailing_md_filled; if (*destfilled || s->trailing_md_sent) { // The buffer is already in use; that's an error! @@ -627,7 +627,7 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg, fill_in_metadata(exec_ctx, s, s->send_trailing_md_op->payload->send_trailing_metadata .send_trailing_metadata, - 0, dest, NULL, destfilled); + 0, dest, nullptr, destfilled); } s->trailing_md_sent = true; if (!s->t->is_client && s->trailing_md_recvd && s->recv_trailing_md_op) { @@ -635,7 +635,7 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg, "op_state_machine %p scheduling trailing-md-on-complete", s); GRPC_CLOSURE_SCHED(exec_ctx, s->recv_trailing_md_op->on_complete, GRPC_ERROR_NONE); - s->recv_trailing_md_op = NULL; + s->recv_trailing_md_op = nullptr; needs_close = true; } } @@ -643,7 +643,7 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg, complete_if_batch_end_locked( exec_ctx, s, GRPC_ERROR_NONE, s->send_trailing_md_op, "op_state_machine scheduling send-trailing-metadata-on-complete"); - s->send_trailing_md_op = NULL; + s->send_trailing_md_op = nullptr; } if (s->recv_initial_md_op) { if (s->initial_md_recvd) { @@ -665,7 +665,7 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg, s->recv_initial_md_op->payload->recv_initial_metadata .recv_initial_metadata, s->recv_initial_md_op->payload->recv_initial_metadata.recv_flags, - NULL); + nullptr); s->recv_initial_md_op->payload->recv_initial_metadata .recv_initial_metadata->deadline = s->deadline; grpc_metadata_batch_clear(exec_ctx, &s->to_read_initial_md); @@ -680,7 +680,7 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg, complete_if_batch_end_locked( exec_ctx, s, new_err, s->recv_initial_md_op, "op_state_machine scheduling recv-initial-metadata-on-complete"); - s->recv_initial_md_op = NULL; + s->recv_initial_md_op = nullptr; if (new_err != GRPC_ERROR_NONE) { INPROC_LOG(GPR_DEBUG, @@ -713,7 +713,7 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg, fail_helper_locked(exec_ctx, s, GRPC_ERROR_REF(new_err)); goto done; } - if (s->recv_message_op != NULL) { + if (s->recv_message_op != nullptr) { // This message needs to be wrapped up because it will never be // satisfied INPROC_LOG(GPR_DEBUG, "op_state_machine %p scheduling message-ready", s); @@ -724,7 +724,7 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg, complete_if_batch_end_locked( exec_ctx, s, new_err, s->recv_message_op, "op_state_machine scheduling recv-message-on-complete"); - s->recv_message_op = NULL; + s->recv_message_op = nullptr; } if ((s->trailing_md_sent || s->t->is_client) && s->send_message_op) { // Nothing further will try to receive from this stream, so finish off @@ -732,16 +732,16 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg, complete_if_batch_end_locked( exec_ctx, s, new_err, s->send_message_op, "op_state_machine scheduling send-message-on-complete"); - s->send_message_op = NULL; + s->send_message_op = nullptr; } - if (s->recv_trailing_md_op != NULL) { + if (s->recv_trailing_md_op != nullptr) { // We wanted trailing metadata and we got it s->trailing_md_recvd = true; new_err = fill_in_metadata(exec_ctx, s, &s->to_read_trailing_md, 0, s->recv_trailing_md_op->payload ->recv_trailing_metadata.recv_trailing_metadata, - NULL, NULL); + nullptr, nullptr); grpc_metadata_batch_clear(exec_ctx, &s->to_read_trailing_md); s->to_read_trailing_md_filled = false; @@ -756,7 +756,7 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg, s, new_err); GRPC_CLOSURE_SCHED(exec_ctx, s->recv_trailing_md_op->on_complete, GRPC_ERROR_REF(new_err)); - s->recv_trailing_md_op = NULL; + s->recv_trailing_md_op = nullptr; needs_close = true; } else { INPROC_LOG(GPR_DEBUG, @@ -780,7 +780,7 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg, complete_if_batch_end_locked( exec_ctx, s, new_err, s->recv_message_op, "op_state_machine scheduling recv-message-on-complete"); - s->recv_message_op = NULL; + s->recv_message_op = nullptr; } if (s->trailing_md_recvd && (s->trailing_md_sent || s->t->is_client) && s->send_message_op) { @@ -789,7 +789,7 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg, complete_if_batch_end_locked( exec_ctx, s, new_err, s->send_message_op, "op_state_machine scheduling send-message-on-complete"); - s->send_message_op = NULL; + s->send_message_op = nullptr; } if (s->send_message_op || s->send_trailing_md_op || s->recv_initial_md_op || s->recv_message_op || s->recv_trailing_md_op) { @@ -827,14 +827,14 @@ static bool cancel_stream_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s, grpc_metadata_batch_init(&cancel_md); inproc_stream* other = s->other_side; - grpc_metadata_batch* dest = (other == NULL) ? &s->write_buffer_trailing_md + grpc_metadata_batch* dest = (other == nullptr) ? &s->write_buffer_trailing_md : &other->to_read_trailing_md; - bool* destfilled = (other == NULL) ? &s->write_buffer_trailing_md_filled + bool* destfilled = (other == nullptr) ? &s->write_buffer_trailing_md_filled : &other->to_read_trailing_md_filled; - fill_in_metadata(exec_ctx, s, &cancel_md, 0, dest, NULL, destfilled); + fill_in_metadata(exec_ctx, s, &cancel_md, 0, dest, nullptr, destfilled); grpc_metadata_batch_destroy(exec_ctx, &cancel_md); - if (other != NULL) { + if (other != nullptr) { if (other->cancel_other_error == GRPC_ERROR_NONE) { other->cancel_other_error = GRPC_ERROR_REF(s->cancel_self_error); } @@ -851,7 +851,7 @@ static bool cancel_stream_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s, complete_if_batch_end_locked( exec_ctx, s, s->cancel_self_error, s->recv_trailing_md_op, "cancel_stream scheduling trailing-md-on-complete"); - s->recv_trailing_md_op = NULL; + s->recv_trailing_md_op = nullptr; } } @@ -882,7 +882,7 @@ static void perform_stream_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt, } grpc_error* error = GRPC_ERROR_NONE; grpc_closure* on_complete = op->on_complete; - if (on_complete == NULL) { + if (on_complete == nullptr) { on_complete = &do_nothing_closure; } @@ -914,11 +914,11 @@ static void perform_stream_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt, error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Endpoint already shutdown"); } if (error == GRPC_ERROR_NONE && op->send_initial_metadata) { - grpc_metadata_batch* dest = (other == NULL) ? &s->write_buffer_initial_md + grpc_metadata_batch* dest = (other == nullptr) ? &s->write_buffer_initial_md : &other->to_read_initial_md; - uint32_t* destflags = (other == NULL) ? &s->write_buffer_initial_md_flags + uint32_t* destflags = (other == nullptr) ? &s->write_buffer_initial_md_flags : &other->to_read_initial_md_flags; - bool* destfilled = (other == NULL) ? &s->write_buffer_initial_md_filled + bool* destfilled = (other == nullptr) ? &s->write_buffer_initial_md_filled : &other->to_read_initial_md_filled; if (*destfilled || s->initial_md_sent) { // The buffer is already in use; that's an error! @@ -934,7 +934,7 @@ static void perform_stream_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt, } if (s->t->is_client) { grpc_millis* dl = - (other == NULL) ? &s->write_buffer_deadline : &other->deadline; + (other == nullptr) ? &s->write_buffer_deadline : &other->deadline; *dl = GPR_MIN(*dl, op->payload->send_initial_metadata .send_initial_metadata->deadline); s->initial_md_sent = true; @@ -973,11 +973,11 @@ static void perform_stream_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt, // 5. There is trailing metadata, even if nothing specifically wants // that because that can shut down the receive message as well if ((op->send_message && other && - ((other->recv_message_op != NULL) || - (other->recv_trailing_md_op != NULL))) || + ((other->recv_message_op != nullptr) || + (other->recv_trailing_md_op != nullptr))) || (op->send_trailing_metadata && !op->send_message) || (op->recv_initial_metadata && s->to_read_initial_md_filled) || - (op->recv_message && other && (other->send_message_op != NULL)) || + (op->recv_message && other && (other->send_message_op != nullptr)) || (s->to_read_trailing_md_filled || s->trailing_md_recvd)) { if (!s->op_closure_scheduled) { GRPC_CLOSURE_SCHED(exec_ctx, &s->op_closure, GRPC_ERROR_NONE); @@ -1031,7 +1031,7 @@ static void close_transport_locked(grpc_exec_ctx* exec_ctx, if (!t->is_closed) { t->is_closed = true; /* Also end all streams on this transport */ - while (t->stream_list != NULL) { + while (t->stream_list != nullptr) { // cancel_stream_locked also adjusts stream list cancel_stream_locked( exec_ctx, t->stream_list, @@ -1110,7 +1110,7 @@ static void set_pollset_set(grpc_exec_ctx* exec_ctx, grpc_transport* gt, } static grpc_endpoint* get_endpoint(grpc_exec_ctx* exec_ctx, grpc_transport* t) { - return NULL; + return nullptr; } /******************************************************************************* @@ -1120,9 +1120,9 @@ static void do_nothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {} void grpc_inproc_transport_init(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - GRPC_CLOSURE_INIT(&do_nothing_closure, do_nothing, NULL, + GRPC_CLOSURE_INIT(&do_nothing_closure, do_nothing, nullptr, grpc_schedule_on_exec_ctx); - g_empty_slice = grpc_slice_from_static_buffer(NULL, 0); + g_empty_slice = grpc_slice_from_static_buffer(nullptr, 0); grpc_slice key_tmp = grpc_slice_from_static_string(":path"); g_fake_path_key = grpc_slice_intern(key_tmp); @@ -1173,8 +1173,8 @@ static void inproc_transports_create(grpc_exec_ctx* exec_ctx, "inproc_client"); st->other_side = ct; ct->other_side = st; - st->stream_list = NULL; - ct->stream_list = NULL; + st->stream_list = nullptr; + ct->stream_list = nullptr; *server_transport = (grpc_transport*)st; *client_transport = (grpc_transport*)ct; } @@ -1203,7 +1203,7 @@ grpc_channel* grpc_inproc_channel_create(grpc_server* server, inproc_transports_create(&exec_ctx, &server_transport, server_args, &client_transport, client_args); - grpc_server_setup_transport(&exec_ctx, server, server_transport, NULL, + grpc_server_setup_transport(&exec_ctx, server, server_transport, nullptr, server_args); grpc_channel* channel = grpc_channel_create(&exec_ctx, "inproc", client_args, diff --git a/src/core/lib/iomgr/ev_epollex_linux.cc b/src/core/lib/iomgr/ev_epollex_linux.cc index 246634a76f..10b84401fa 100644 --- a/src/core/lib/iomgr/ev_epollex_linux.cc +++ b/src/core/lib/iomgr/ev_epollex_linux.cc @@ -252,7 +252,7 @@ static bool append_error(grpc_error** composite, grpc_error* error, * becomes a spurious read notification on a reused fd. */ -static grpc_fd* fd_freelist = NULL; +static grpc_fd* fd_freelist = nullptr; static gpr_mu fd_freelist_mu; #ifndef NDEBUG @@ -320,7 +320,7 @@ static void fd_global_init(void) { gpr_mu_init(&fd_freelist_mu); } static void fd_global_shutdown(void) { gpr_mu_lock(&fd_freelist_mu); gpr_mu_unlock(&fd_freelist_mu); - while (fd_freelist != NULL) { + while (fd_freelist != nullptr) { grpc_fd* fd = fd_freelist; fd_freelist = fd_freelist->freelist_next; gpr_free(fd); @@ -329,30 +329,30 @@ static void fd_global_shutdown(void) { } static grpc_fd* fd_create(int fd, const char* name) { - grpc_fd* new_fd = NULL; + grpc_fd* new_fd = nullptr; gpr_mu_lock(&fd_freelist_mu); - if (fd_freelist != NULL) { + if (fd_freelist != nullptr) { new_fd = fd_freelist; fd_freelist = fd_freelist->freelist_next; } gpr_mu_unlock(&fd_freelist_mu); - if (new_fd == NULL) { + if (new_fd == nullptr) { new_fd = (grpc_fd*)gpr_malloc(sizeof(grpc_fd)); } gpr_mu_init(&new_fd->pollable_mu); gpr_mu_init(&new_fd->orphan_mu); - new_fd->pollable_obj = NULL; + new_fd->pollable_obj = nullptr; gpr_atm_rel_store(&new_fd->refst, (gpr_atm)1); new_fd->fd = fd; new_fd->read_closure.Init(); new_fd->write_closure.Init(); gpr_atm_no_barrier_store(&new_fd->read_notifier_pollset, (gpr_atm)NULL); - new_fd->freelist_next = NULL; - new_fd->on_done_closure = NULL; + new_fd->freelist_next = nullptr; + new_fd->on_done_closure = nullptr; char* fd_name; gpr_asprintf(&fd_name, "%s fd=%d", name, fd); @@ -382,7 +382,7 @@ static void fd_orphan(grpc_exec_ctx* exec_ctx, grpc_fd* fd, /* If release_fd is not NULL, we should be relinquishing control of the file descriptor fd->fd (but we still own the grpc_fd structure). */ - if (release_fd != NULL) { + if (release_fd != nullptr) { *release_fd = fd->fd; } else if (!is_fd_closed) { close(fd->fd); @@ -438,7 +438,7 @@ static void fd_notify_on_write(grpc_exec_ctx* exec_ctx, grpc_fd* fd, */ static grpc_error* pollable_create(pollable_type type, pollable** p) { - *p = NULL; + *p = nullptr; int epfd = epoll_create1(EPOLL_CLOEXEC); if (epfd == -1) { @@ -449,7 +449,7 @@ static grpc_error* pollable_create(pollable_type type, pollable** p) { if (err != GRPC_ERROR_NONE) { close(epfd); gpr_free(*p); - *p = NULL; + *p = nullptr; return err; } struct epoll_event ev; @@ -460,7 +460,7 @@ static grpc_error* pollable_create(pollable_type type, pollable** p) { close(epfd); grpc_wakeup_fd_destroy(&(*p)->wakeup); gpr_free(*p); - *p = NULL; + *p = nullptr; return err; } @@ -468,10 +468,10 @@ static grpc_error* pollable_create(pollable_type type, pollable** p) { gpr_ref_init(&(*p)->refs, 1); gpr_mu_init(&(*p)->mu); (*p)->epfd = epfd; - (*p)->owner_fd = NULL; - (*p)->pollset_set = NULL; + (*p)->owner_fd = nullptr; + (*p)->pollset_set = nullptr; (*p)->next = (*p)->prev = *p; - (*p)->root_worker = NULL; + (*p)->root_worker = nullptr; (*p)->event_cursor = 0; (*p)->event_count = 0; return GRPC_ERROR_NONE; @@ -495,14 +495,14 @@ static pollable* pollable_ref(pollable* p, int line, const char* reason) { static void pollable_unref(pollable* p) { #else static void pollable_unref(pollable* p, int line, const char* reason) { - if (p == NULL) return; + if (p == nullptr) return; if (grpc_trace_pollable_refcount.enabled()) { int r = (int)gpr_atm_no_barrier_load(&p->refs.count); gpr_log(__FILE__, line, GPR_LOG_SEVERITY_DEBUG, "POLLABLE:%p unref %d->%d %s", p, r, r - 1, reason); } #endif - if (p != NULL && gpr_unref(&p->refs)) { + if (p != nullptr && gpr_unref(&p->refs)) { close(p->epfd); grpc_wakeup_fd_destroy(&p->wakeup); gpr_free(p); @@ -563,10 +563,10 @@ static void pollset_maybe_finish_shutdown(grpc_exec_ctx* exec_ctx, pollset, pollset->active_pollable, pollset->shutdown_closure, pollset->root_worker, pollset->containing_pollset_set_count); } - if (pollset->shutdown_closure != NULL && pollset->root_worker == NULL && + if (pollset->shutdown_closure != nullptr && pollset->root_worker == nullptr && pollset->containing_pollset_set_count == 0) { GRPC_CLOSURE_SCHED(exec_ctx, pollset->shutdown_closure, GRPC_ERROR_NONE); - pollset->shutdown_closure = NULL; + pollset->shutdown_closure = nullptr; } } @@ -577,7 +577,7 @@ static grpc_error* kick_one_worker(grpc_exec_ctx* exec_ctx, grpc_pollset_worker* specific_worker) { pollable* p = specific_worker->pollable_obj; grpc_core::mu_guard lock(&p->mu); - GPR_ASSERT(specific_worker != NULL); + GPR_ASSERT(specific_worker != nullptr); if (specific_worker->kicked) { if (grpc_polling_trace.enabled()) { gpr_log(GPR_DEBUG, "PS:%p kicked_specific_but_already_kicked", p); @@ -626,9 +626,9 @@ static grpc_error* pollset_kick(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset, (void*)gpr_tls_get(&g_current_thread_pollset), (void*)gpr_tls_get(&g_current_thread_worker), pollset->root_worker); } - if (specific_worker == NULL) { + if (specific_worker == nullptr) { if (gpr_tls_get(&g_current_thread_pollset) != (intptr_t)pollset) { - if (pollset->root_worker == NULL) { + if (pollset->root_worker == nullptr) { if (grpc_polling_trace.enabled()) { gpr_log(GPR_DEBUG, "PS:%p kicked_any_without_poller", pollset); } @@ -671,7 +671,7 @@ static grpc_error* pollset_kick_all(grpc_exec_ctx* exec_ctx, grpc_error* error = GRPC_ERROR_NONE; const char* err_desc = "pollset_kick_all"; grpc_pollset_worker* w = pollset->root_worker; - if (w != NULL) { + if (w != nullptr) { do { GRPC_STATS_INC_POLLSET_KICK(exec_ctx); append_error(&error, kick_one_worker(exec_ctx, w), err_desc); @@ -720,23 +720,23 @@ static grpc_error* fd_get_or_become_pollable(grpc_fd* fd, pollable** p) { gpr_mu_lock(&fd->pollable_mu); grpc_error* error = GRPC_ERROR_NONE; static const char* err_desc = "fd_get_or_become_pollable"; - if (fd->pollable_obj == NULL) { + if (fd->pollable_obj == nullptr) { if (append_error(&error, pollable_create(PO_FD, &fd->pollable_obj), err_desc)) { fd->pollable_obj->owner_fd = fd; if (!append_error(&error, pollable_add_fd(fd->pollable_obj, fd), err_desc)) { POLLABLE_UNREF(fd->pollable_obj, "fd_pollable"); - fd->pollable_obj = NULL; + fd->pollable_obj = nullptr; } } } if (error == GRPC_ERROR_NONE) { - GPR_ASSERT(fd->pollable_obj != NULL); + GPR_ASSERT(fd->pollable_obj != nullptr); *p = POLLABLE_REF(fd->pollable_obj, "pollset"); } else { - GPR_ASSERT(fd->pollable_obj == NULL); - *p = NULL; + GPR_ASSERT(fd->pollable_obj == nullptr); + *p = nullptr; } gpr_mu_unlock(&fd->pollable_mu); return error; @@ -745,7 +745,7 @@ static grpc_error* fd_get_or_become_pollable(grpc_fd* fd, pollable** p) { /* pollset->po.mu lock must be held by the caller before calling this */ static void pollset_shutdown(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset, grpc_closure* closure) { - GPR_ASSERT(pollset->shutdown_closure == NULL); + GPR_ASSERT(pollset->shutdown_closure == nullptr); pollset->shutdown_closure = closure; GRPC_LOG_IF_ERROR("pollset_shutdown", pollset_kick_all(exec_ctx, pollset)); pollset_maybe_finish_shutdown(exec_ctx, pollset); @@ -796,7 +796,7 @@ static grpc_error* pollable_process_events(grpc_exec_ctx* exec_ctx, /* pollset_shutdown is guaranteed to be called before pollset_destroy. */ static void pollset_destroy(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset) { POLLABLE_UNREF(pollset->active_pollable, "pollset"); - pollset->active_pollable = NULL; + pollset->active_pollable = nullptr; } static grpc_error* pollable_epoll(grpc_exec_ctx* exec_ctx, pollable* p, @@ -836,7 +836,7 @@ static grpc_error* pollable_epoll(grpc_exec_ctx* exec_ctx, pollable* p, /* Return true if first in list */ static bool worker_insert(grpc_pollset_worker** root_worker, grpc_pollset_worker* worker, pwlinks link) { - if (*root_worker == NULL) { + if (*root_worker == nullptr) { *root_worker = worker; worker->links[link].next = worker->links[link].prev = worker; return true; @@ -857,7 +857,7 @@ static worker_remove_result worker_remove(grpc_pollset_worker** root_worker, pwlinks link) { if (worker == *root_worker) { if (worker == worker->links[link].next) { - *root_worker = NULL; + *root_worker = nullptr; return WRR_EMPTIED; } else { *root_worker = worker->links[link].next; @@ -878,7 +878,7 @@ static bool begin_worker(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset, grpc_pollset_worker** worker_hdl, grpc_millis deadline) { bool do_poll = (pollset->shutdown_closure == nullptr); - if (worker_hdl != NULL) *worker_hdl = worker; + if (worker_hdl != nullptr) *worker_hdl = worker; worker->initialized_cv = false; worker->kicked = false; worker->pollset = pollset; @@ -1051,12 +1051,12 @@ static grpc_error* pollset_transition_pollable_from_fd_to_multi_locked( append_error(&error, pollset_kick_all(exec_ctx, pollset), err_desc); grpc_fd* initial_fd = pollset->active_pollable->owner_fd; POLLABLE_UNREF(pollset->active_pollable, "pollset"); - pollset->active_pollable = NULL; + pollset->active_pollable = nullptr; if (append_error(&error, pollable_create(PO_MULTI, &pollset->active_pollable), err_desc)) { append_error(&error, pollable_add_fd(pollset->active_pollable, initial_fd), err_desc); - if (and_add_fd != NULL) { + if (and_add_fd != nullptr) { append_error(&error, pollable_add_fd(pollset->active_pollable, and_add_fd), err_desc); @@ -1122,7 +1122,7 @@ static grpc_error* pollset_as_multipollable_locked(grpc_exec_ctx* exec_ctx, error = pollable_create(PO_MULTI, &pollset->active_pollable); } else { error = pollset_transition_pollable_from_fd_to_multi_locked( - exec_ctx, pollset, NULL); + exec_ctx, pollset, nullptr); } gpr_mu_unlock(&po_at_start->owner_fd->orphan_mu); break; @@ -1132,7 +1132,7 @@ static grpc_error* pollset_as_multipollable_locked(grpc_exec_ctx* exec_ctx, if (error != GRPC_ERROR_NONE) { POLLABLE_UNREF(pollset->active_pollable, "pollset"); pollset->active_pollable = po_at_start; - *pollable_obj = NULL; + *pollable_obj = nullptr; } else { *pollable_obj = POLLABLE_REF(pollset->active_pollable, "pollset_set"); POLLABLE_UNREF(po_at_start, "pollset_as_multipollable"); @@ -1154,7 +1154,7 @@ static void pollset_add_fd(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset, static grpc_pollset_set* pss_lock_adam(grpc_pollset_set* pss) { gpr_mu_lock(&pss->mu); - while (pss->parent != NULL) { + while (pss->parent != nullptr) { gpr_mu_unlock(&pss->mu); pss = pss->parent; gpr_mu_lock(&pss->mu); @@ -1170,7 +1170,7 @@ static grpc_pollset_set* pollset_set_create(void) { } static void pollset_set_unref(grpc_exec_ctx* exec_ctx, grpc_pollset_set* pss) { - if (pss == NULL) return; + if (pss == nullptr) return; if (!gpr_unref(&pss->refs)) return; pollset_set_unref(exec_ctx, pss->parent); gpr_mu_destroy(&pss->mu); @@ -1292,11 +1292,11 @@ static void pollset_set_add_pollset(grpc_exec_ctx* exec_ctx, } grpc_error* error = GRPC_ERROR_NONE; static const char* err_desc = "pollset_set_add_pollset"; - pollable* pollable_obj = NULL; + pollable* pollable_obj = nullptr; gpr_mu_lock(&ps->mu); if (!GRPC_LOG_IF_ERROR(err_desc, pollset_as_multipollable_locked( exec_ctx, ps, &pollable_obj))) { - GPR_ASSERT(pollable_obj == NULL); + GPR_ASSERT(pollable_obj == nullptr); gpr_mu_unlock(&ps->mu); return; } @@ -1341,9 +1341,9 @@ static void pollset_set_add_pollset_set(grpc_exec_ctx* exec_ctx, gpr_mu* b_mu = &b->mu; gpr_mu_lock(a_mu); gpr_mu_lock(b_mu); - if (a->parent != NULL) { + if (a->parent != nullptr) { a = a->parent; - } else if (b->parent != NULL) { + } else if (b->parent != nullptr) { b = b->parent; } else { break; // exit loop, both pollsets locked @@ -1392,8 +1392,8 @@ static void pollset_set_add_pollset_set(grpc_exec_ctx* exec_ctx, a->pollset_count += b->pollset_count; gpr_free(b->fds); gpr_free(b->pollsets); - b->fds = NULL; - b->pollsets = NULL; + b->fds = nullptr; + b->pollsets = nullptr; b->fd_count = b->fd_capacity = b->pollset_count = b->pollset_capacity = 0; gpr_mu_unlock(&a->mu); gpr_mu_unlock(&b->mu); @@ -1446,17 +1446,17 @@ static const grpc_event_engine_vtable vtable = { const grpc_event_engine_vtable* grpc_init_epollex_linux( bool explicitly_requested) { if (!explicitly_requested) { - return NULL; + return nullptr; } if (!grpc_has_wakeup_fd()) { gpr_log(GPR_ERROR, "Skipping epollex because of no wakeup fd."); - return NULL; + return nullptr; } if (!grpc_is_epollexclusive_available()) { gpr_log(GPR_INFO, "Skipping epollex because it is not supported."); - return NULL; + return nullptr; } fd_global_init(); @@ -1464,7 +1464,7 @@ const grpc_event_engine_vtable* grpc_init_epollex_linux( if (!GRPC_LOG_IF_ERROR("pollset_global_init", pollset_global_init())) { pollset_global_shutdown(); fd_global_shutdown(); - return NULL; + return nullptr; } return &vtable; diff --git a/src/core/lib/iomgr/resource_quota.cc b/src/core/lib/iomgr/resource_quota.cc index 9cce80cae7..40bde7ccff 100644 --- a/src/core/lib/iomgr/resource_quota.cc +++ b/src/core/lib/iomgr/resource_quota.cc @@ -165,7 +165,7 @@ static void rulist_add_head(grpc_resource_user* resource_user, grpc_rulist list) { grpc_resource_quota* resource_quota = resource_user->resource_quota; grpc_resource_user** root = &resource_quota->roots[list]; - if (*root == NULL) { + if (*root == nullptr) { *root = resource_user; resource_user->links[list].next = resource_user->links[list].prev = resource_user; @@ -182,7 +182,7 @@ static void rulist_add_tail(grpc_resource_user* resource_user, grpc_rulist list) { grpc_resource_quota* resource_quota = resource_user->resource_quota; grpc_resource_user** root = &resource_quota->roots[list]; - if (*root == NULL) { + if (*root == nullptr) { *root = resource_user; resource_user->links[list].next = resource_user->links[list].prev = resource_user; @@ -196,18 +196,18 @@ static void rulist_add_tail(grpc_resource_user* resource_user, static bool rulist_empty(grpc_resource_quota* resource_quota, grpc_rulist list) { - return resource_quota->roots[list] == NULL; + return resource_quota->roots[list] == nullptr; } static grpc_resource_user* rulist_pop_head(grpc_resource_quota* resource_quota, grpc_rulist list) { grpc_resource_user** root = &resource_quota->roots[list]; grpc_resource_user* resource_user = *root; - if (resource_user == NULL) { - return NULL; + if (resource_user == nullptr) { + return nullptr; } if (resource_user->links[list].next == resource_user) { - *root = NULL; + *root = nullptr; } else { resource_user->links[list].next->links[list].prev = resource_user->links[list].prev; @@ -215,24 +215,24 @@ static grpc_resource_user* rulist_pop_head(grpc_resource_quota* resource_quota, resource_user->links[list].next; *root = resource_user->links[list].next; } - resource_user->links[list].next = resource_user->links[list].prev = NULL; + resource_user->links[list].next = resource_user->links[list].prev = nullptr; return resource_user; } static void rulist_remove(grpc_resource_user* resource_user, grpc_rulist list) { - if (resource_user->links[list].next == NULL) return; + if (resource_user->links[list].next == nullptr) return; grpc_resource_quota* resource_quota = resource_user->resource_quota; if (resource_quota->roots[list] == resource_user) { resource_quota->roots[list] = resource_user->links[list].next; if (resource_quota->roots[list] == resource_user) { - resource_quota->roots[list] = NULL; + resource_quota->roots[list] = nullptr; } } resource_user->links[list].next->links[list].prev = resource_user->links[list].prev; resource_user->links[list].prev->links[list].next = resource_user->links[list].next; - resource_user->links[list].next = resource_user->links[list].prev = NULL; + resource_user->links[list].next = resource_user->links[list].prev = nullptr; } /******************************************************************************* @@ -379,7 +379,7 @@ static bool rq_reclaim(grpc_exec_ctx* exec_ctx, grpc_rulist list = destructive ? GRPC_RULIST_RECLAIMER_DESTRUCTIVE : GRPC_RULIST_RECLAIMER_BENIGN; grpc_resource_user* resource_user = rulist_pop_head(resource_quota, list); - if (resource_user == NULL) return false; + if (resource_user == nullptr) return false; if (grpc_resource_quota_trace.enabled()) { gpr_log(GPR_DEBUG, "RQ %s %s: initiate %s reclamation", resource_quota->name, resource_user->name, @@ -391,7 +391,7 @@ static bool rq_reclaim(grpc_exec_ctx* exec_ctx, GPR_ASSERT(c); resource_quota->debug_only_last_reclaimer_resource_user = resource_user; resource_quota->debug_only_last_initiated_reclaimer = c; - resource_user->reclaimers[destructive] = NULL; + resource_user->reclaimers[destructive] = nullptr; GRPC_CLOSURE_RUN(exec_ctx, c, GRPC_ERROR_NONE); return true; } @@ -470,9 +470,9 @@ static bool ru_post_reclaimer(grpc_exec_ctx* exec_ctx, grpc_resource_user* resource_user, bool destructive) { grpc_closure* closure = resource_user->new_reclaimers[destructive]; - GPR_ASSERT(closure != NULL); - resource_user->new_reclaimers[destructive] = NULL; - GPR_ASSERT(resource_user->reclaimers[destructive] == NULL); + GPR_ASSERT(closure != nullptr); + resource_user->new_reclaimers[destructive] = nullptr; + GPR_ASSERT(resource_user->reclaimers[destructive] == nullptr); if (gpr_atm_acq_load(&resource_user->shutdown) > 0) { GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_ERROR_CANCELLED); return false; @@ -522,8 +522,8 @@ static void ru_shutdown(grpc_exec_ctx* exec_ctx, void* ru, grpc_error* error) { GRPC_ERROR_CANCELLED); GRPC_CLOSURE_SCHED(exec_ctx, resource_user->reclaimers[1], GRPC_ERROR_CANCELLED); - resource_user->reclaimers[0] = NULL; - resource_user->reclaimers[1] = NULL; + resource_user->reclaimers[0] = nullptr; + resource_user->reclaimers[1] = nullptr; rulist_remove(resource_user, GRPC_RULIST_RECLAIMER_BENIGN); rulist_remove(resource_user, GRPC_RULIST_RECLAIMER_DESTRUCTIVE); if (resource_user->allocating) { @@ -611,7 +611,7 @@ grpc_resource_quota* grpc_resource_quota_create(const char* name) { resource_quota->step_scheduled = false; resource_quota->reclaiming = false; gpr_atm_no_barrier_store(&resource_quota->memory_usage_estimation, 0); - if (name != NULL) { + if (name != nullptr) { resource_quota->name = gpr_strdup(name); } else { gpr_asprintf(&resource_quota->name, "anonymous_pool_%" PRIxPTR, @@ -623,7 +623,7 @@ grpc_resource_quota* grpc_resource_quota_create(const char* name) { rq_reclamation_done, resource_quota, grpc_combiner_scheduler(resource_quota->combiner)); for (int i = 0; i < GRPC_RULIST_COUNT; i++) { - resource_quota->roots[i] = NULL; + resource_quota->roots[i] = nullptr; } return resource_quota; } @@ -696,7 +696,7 @@ grpc_resource_quota* grpc_resource_quota_from_channel_args( } } } - return grpc_resource_quota_create(NULL); + return grpc_resource_quota_create(nullptr); } static void* rq_copy(void* rq) { @@ -746,15 +746,15 @@ grpc_resource_user* grpc_resource_user_create( grpc_closure_list_init(&resource_user->on_allocated); resource_user->allocating = false; resource_user->added_to_free_pool = false; - resource_user->reclaimers[0] = NULL; - resource_user->reclaimers[1] = NULL; - resource_user->new_reclaimers[0] = NULL; - resource_user->new_reclaimers[1] = NULL; + resource_user->reclaimers[0] = nullptr; + resource_user->reclaimers[1] = nullptr; + resource_user->new_reclaimers[0] = nullptr; + resource_user->new_reclaimers[1] = nullptr; resource_user->outstanding_allocations = 0; for (int i = 0; i < GRPC_RULIST_COUNT; i++) { - resource_user->links[i].next = resource_user->links[i].prev = NULL; + resource_user->links[i].next = resource_user->links[i].prev = nullptr; } - if (name != NULL) { + if (name != nullptr) { resource_user->name = gpr_strdup(name); } else { gpr_asprintf(&resource_user->name, "anonymous_resource_user_%" PRIxPTR, @@ -857,7 +857,7 @@ void grpc_resource_user_post_reclaimer(grpc_exec_ctx* exec_ctx, grpc_resource_user* resource_user, bool destructive, grpc_closure* closure) { - GPR_ASSERT(resource_user->new_reclaimers[destructive] == NULL); + GPR_ASSERT(resource_user->new_reclaimers[destructive] == nullptr); resource_user->new_reclaimers[destructive] = closure; GRPC_CLOSURE_SCHED(exec_ctx, &resource_user->post_reclaimer_closure[destructive], @@ -899,6 +899,6 @@ void grpc_resource_user_alloc_slices( grpc_slice grpc_resource_user_slice_malloc(grpc_exec_ctx* exec_ctx, grpc_resource_user* resource_user, size_t size) { - grpc_resource_user_alloc(exec_ctx, resource_user, size, NULL); + grpc_resource_user_alloc(exec_ctx, resource_user, size, nullptr); return ru_slice_create(resource_user, size); } diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc index d40007a74b..ff78480a1a 100644 --- a/src/core/lib/iomgr/tcp_posix.cc +++ b/src/core/lib/iomgr/tcp_posix.cc @@ -139,7 +139,7 @@ static void run_poller(grpc_exec_ctx* exec_ctx, void* bp, GRPC_STATS_INC_TCP_BACKUP_POLLER_POLLS(exec_ctx); GRPC_LOG_IF_ERROR( "backup_poller:pollset_work", - grpc_pollset_work(exec_ctx, BACKUP_POLLER_POLLSET(p), NULL, deadline)); + grpc_pollset_work(exec_ctx, BACKUP_POLLER_POLLSET(p), nullptr, deadline)); gpr_mu_unlock(p->pollset_mu); /* last "uncovered" notification is the ref that keeps us polling, if we get * there try a cas to release it */ @@ -198,7 +198,7 @@ static void cover_self(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) { grpc_executor_scheduler(GRPC_EXECUTOR_LONG)), GRPC_ERROR_NONE); } else { - while ((p = (backup_poller*)gpr_atm_acq_load(&g_backup_poller)) == NULL) { + while ((p = (backup_poller*)gpr_atm_acq_load(&g_backup_poller)) == nullptr) { // spin waiting for backup poller } } @@ -368,8 +368,8 @@ static void call_read_cb(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp, } } - tcp->read_cb = NULL; - tcp->incoming_buffer = NULL; + tcp->read_cb = nullptr; + tcp->incoming_buffer = nullptr; GRPC_CLOSURE_RUN(exec_ctx, cb, error); } @@ -389,11 +389,11 @@ static void tcp_do_read(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) { iov[i].iov_len = GRPC_SLICE_LENGTH(tcp->incoming_buffer->slices[i]); } - msg.msg_name = NULL; + msg.msg_name = nullptr; msg.msg_namelen = 0; msg.msg_iov = iov; msg.msg_iovlen = (msg_iovlen_type)tcp->incoming_buffer->count; - msg.msg_control = NULL; + msg.msg_control = nullptr; msg.msg_controllen = 0; msg.msg_flags = 0; @@ -504,7 +504,7 @@ static void tcp_handle_read(grpc_exec_ctx* exec_ctx, void* arg /* grpc_tcp */, static void tcp_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, grpc_slice_buffer* incoming_buffer, grpc_closure* cb) { grpc_tcp* tcp = (grpc_tcp*)ep; - GPR_ASSERT(tcp->read_cb == NULL); + GPR_ASSERT(tcp->read_cb == nullptr); tcp->read_cb = cb; tcp->incoming_buffer = incoming_buffer; grpc_slice_buffer_reset_and_unref_internal(exec_ctx, incoming_buffer); @@ -552,11 +552,11 @@ static bool tcp_flush(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp, } GPR_ASSERT(iov_size > 0); - msg.msg_name = NULL; + msg.msg_name = nullptr; msg.msg_namelen = 0; msg.msg_iov = iov; msg.msg_iovlen = iov_size; - msg.msg_control = NULL; + msg.msg_control = nullptr; msg.msg_controllen = 0; msg.msg_flags = 0; @@ -617,7 +617,7 @@ static void tcp_handle_write(grpc_exec_ctx* exec_ctx, void* arg /* grpc_tcp */, if (error != GRPC_ERROR_NONE) { cb = tcp->write_cb; - tcp->write_cb = NULL; + tcp->write_cb = nullptr; cb->cb(exec_ctx, cb->cb_arg, error); TCP_UNREF(exec_ctx, tcp, "write"); return; @@ -630,7 +630,7 @@ static void tcp_handle_write(grpc_exec_ctx* exec_ctx, void* arg /* grpc_tcp */, notify_on_write(exec_ctx, tcp); } else { cb = tcp->write_cb; - tcp->write_cb = NULL; + tcp->write_cb = nullptr; if (grpc_tcp_trace.enabled()) { const char* str = grpc_error_string(error); gpr_log(GPR_DEBUG, "write: %s", str); @@ -658,7 +658,7 @@ static void tcp_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, } GPR_TIMER_BEGIN("tcp_write", 0); - GPR_ASSERT(tcp->write_cb == NULL); + GPR_ASSERT(tcp->write_cb == nullptr); if (buf->length == 0) { GPR_TIMER_END("tcp_write", 0); @@ -745,8 +745,8 @@ grpc_endpoint* grpc_tcp_create(grpc_exec_ctx* exec_ctx, grpc_fd* em_fd, int tcp_read_chunk_size = GRPC_TCP_DEFAULT_READ_SLICE_SIZE; int tcp_max_read_chunk_size = 4 * 1024 * 1024; int tcp_min_read_chunk_size = 256; - grpc_resource_quota* resource_quota = grpc_resource_quota_create(NULL); - if (channel_args != NULL) { + grpc_resource_quota* resource_quota = grpc_resource_quota_create(nullptr); + if (channel_args != nullptr) { for (size_t i = 0; i < channel_args->num_args; i++) { if (0 == strcmp(channel_args->args[i].key, GRPC_ARG_TCP_READ_CHUNK_SIZE)) { @@ -785,11 +785,11 @@ grpc_endpoint* grpc_tcp_create(grpc_exec_ctx* exec_ctx, grpc_fd* em_fd, tcp->base.vtable = &vtable; tcp->peer_string = gpr_strdup(peer_string); tcp->fd = grpc_fd_wrapped_fd(em_fd); - tcp->read_cb = NULL; - tcp->write_cb = NULL; - tcp->release_fd_cb = NULL; - tcp->release_fd = NULL; - tcp->incoming_buffer = NULL; + tcp->read_cb = nullptr; + tcp->write_cb = nullptr; + tcp->release_fd_cb = nullptr; + tcp->release_fd = nullptr; + tcp->incoming_buffer = nullptr; tcp->target_length = (double)tcp_read_chunk_size; tcp->min_read_chunk_size = tcp_min_read_chunk_size; tcp->max_read_chunk_size = tcp_max_read_chunk_size; diff --git a/src/core/lib/security/context/security_context.cc b/src/core/lib/security/context/security_context.cc index e44fcdd65e..19c6148e43 100644 --- a/src/core/lib/security/context/security_context.cc +++ b/src/core/lib/security/context/security_context.cc @@ -37,7 +37,7 @@ grpc_core::DebugOnlyTraceFlag grpc_trace_auth_context_refcount( grpc_call_error grpc_call_set_credentials(grpc_call* call, grpc_call_credentials* creds) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_client_security_context* ctx = NULL; + grpc_client_security_context* ctx = nullptr; GRPC_API_TRACE("grpc_call_set_credentials(call=%p, creds=%p)", 2, (call, creds)); if (!grpc_call_is_client(call)) { @@ -46,7 +46,7 @@ grpc_call_error grpc_call_set_credentials(grpc_call* call, } ctx = (grpc_client_security_context*)grpc_call_context_get( call, GRPC_CONTEXT_SECURITY); - if (ctx == NULL) { + if (ctx == nullptr) { ctx = grpc_client_security_context_create(); ctx->creds = grpc_call_credentials_ref(creds); grpc_call_context_set(call, GRPC_CONTEXT_SECURITY, ctx, @@ -62,7 +62,7 @@ grpc_call_error grpc_call_set_credentials(grpc_call* call, grpc_auth_context* grpc_call_auth_context(grpc_call* call) { void* sec_ctx = grpc_call_context_get(call, GRPC_CONTEXT_SECURITY); GRPC_API_TRACE("grpc_call_auth_context(call=%p)", 1, (call)); - if (sec_ctx == NULL) return NULL; + if (sec_ctx == nullptr) return nullptr; return grpc_call_is_client(call) ? GRPC_AUTH_CONTEXT_REF( ((grpc_client_security_context*)sec_ctx)->auth_context, @@ -89,7 +89,7 @@ void grpc_client_security_context_destroy(void* ctx) { grpc_client_security_context* c = (grpc_client_security_context*)ctx; grpc_call_credentials_unref(&exec_ctx, c->creds); GRPC_AUTH_CONTEXT_UNREF(c->auth_context, "client_security_context"); - if (c->extension.instance != NULL && c->extension.destroy != NULL) { + if (c->extension.instance != nullptr && c->extension.destroy != nullptr) { c->extension.destroy(c->extension.instance); } gpr_free(ctx); @@ -106,7 +106,7 @@ grpc_server_security_context* grpc_server_security_context_create(void) { void grpc_server_security_context_destroy(void* ctx) { grpc_server_security_context* c = (grpc_server_security_context*)ctx; GRPC_AUTH_CONTEXT_UNREF(c->auth_context, "server_security_context"); - if (c->extension.instance != NULL && c->extension.destroy != NULL) { + if (c->extension.instance != nullptr && c->extension.destroy != nullptr) { c->extension.destroy(c->extension.instance); } gpr_free(ctx); @@ -114,13 +114,13 @@ void grpc_server_security_context_destroy(void* ctx) { /* --- grpc_auth_context --- */ -static grpc_auth_property_iterator empty_iterator = {NULL, 0, NULL}; +static grpc_auth_property_iterator empty_iterator = {nullptr, 0, nullptr}; grpc_auth_context* grpc_auth_context_create(grpc_auth_context* chained) { grpc_auth_context* ctx = (grpc_auth_context*)gpr_zalloc(sizeof(grpc_auth_context)); gpr_ref_init(&ctx->refcount, 1); - if (chained != NULL) { + if (chained != nullptr) { ctx->chained = GRPC_AUTH_CONTEXT_REF(chained, "chained"); ctx->peer_identity_property_name = ctx->chained->peer_identity_property_name; @@ -132,7 +132,7 @@ grpc_auth_context* grpc_auth_context_create(grpc_auth_context* chained) { grpc_auth_context* grpc_auth_context_ref(grpc_auth_context* ctx, const char* file, int line, const char* reason) { - if (ctx == NULL) return NULL; + if (ctx == nullptr) return nullptr; if (grpc_trace_auth_context_refcount.enabled()) { gpr_atm val = gpr_atm_no_barrier_load(&ctx->refcount.count); gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, @@ -150,7 +150,7 @@ grpc_auth_context* grpc_auth_context_ref(grpc_auth_context* ctx) { #ifndef NDEBUG void grpc_auth_context_unref(grpc_auth_context* ctx, const char* file, int line, const char* reason) { - if (ctx == NULL) return; + if (ctx == nullptr) return; if (grpc_trace_auth_context_refcount.enabled()) { gpr_atm val = gpr_atm_no_barrier_load(&ctx->refcount.count); gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, @@ -164,7 +164,7 @@ void grpc_auth_context_unref(grpc_auth_context* ctx) { if (gpr_unref(&ctx->refcount)) { size_t i; GRPC_AUTH_CONTEXT_UNREF(ctx->chained, "chained"); - if (ctx->properties.array != NULL) { + if (ctx->properties.array != nullptr) { for (i = 0; i < ctx->properties.count; i++) { grpc_auth_property_reset(&ctx->properties.array[i]); } @@ -189,9 +189,9 @@ int grpc_auth_context_set_peer_identity_property_name(grpc_auth_context* ctx, GRPC_API_TRACE( "grpc_auth_context_set_peer_identity_property_name(ctx=%p, name=%s)", 2, (ctx, name)); - if (prop == NULL) { + if (prop == nullptr) { gpr_log(GPR_ERROR, "Property name %s not found in auth context.", - name != NULL ? name : "NULL"); + name != nullptr ? name : "NULL"); return 0; } ctx->peer_identity_property_name = prop->name; @@ -200,14 +200,14 @@ int grpc_auth_context_set_peer_identity_property_name(grpc_auth_context* ctx, int grpc_auth_context_peer_is_authenticated(const grpc_auth_context* ctx) { GRPC_API_TRACE("grpc_auth_context_peer_is_authenticated(ctx=%p)", 1, (ctx)); - return ctx->peer_identity_property_name == NULL ? 0 : 1; + return ctx->peer_identity_property_name == nullptr ? 0 : 1; } grpc_auth_property_iterator grpc_auth_context_property_iterator( const grpc_auth_context* ctx) { grpc_auth_property_iterator it = empty_iterator; GRPC_API_TRACE("grpc_auth_context_property_iterator(ctx=%p)", 1, (ctx)); - if (ctx == NULL) return it; + if (ctx == nullptr) return it; it.ctx = ctx; return it; } @@ -215,18 +215,18 @@ grpc_auth_property_iterator grpc_auth_context_property_iterator( const grpc_auth_property* grpc_auth_property_iterator_next( grpc_auth_property_iterator* it) { GRPC_API_TRACE("grpc_auth_property_iterator_next(it=%p)", 1, (it)); - if (it == NULL || it->ctx == NULL) return NULL; + if (it == nullptr || it->ctx == nullptr) return nullptr; while (it->index == it->ctx->properties.count) { - if (it->ctx->chained == NULL) return NULL; + if (it->ctx->chained == nullptr) return nullptr; it->ctx = it->ctx->chained; it->index = 0; } - if (it->name == NULL) { + if (it->name == nullptr) { return &it->ctx->properties.array[it->index++]; } else { while (it->index < it->ctx->properties.count) { const grpc_auth_property* prop = &it->ctx->properties.array[it->index++]; - GPR_ASSERT(prop->name != NULL); + GPR_ASSERT(prop->name != nullptr); if (strcmp(it->name, prop->name) == 0) { return prop; } @@ -241,7 +241,7 @@ grpc_auth_property_iterator grpc_auth_context_find_properties_by_name( grpc_auth_property_iterator it = empty_iterator; GRPC_API_TRACE("grpc_auth_context_find_properties_by_name(ctx=%p, name=%s)", 2, (ctx, name)); - if (ctx == NULL || name == NULL) return empty_iterator; + if (ctx == nullptr || name == nullptr) return empty_iterator; it.ctx = ctx; it.name = name; return it; @@ -250,7 +250,7 @@ grpc_auth_property_iterator grpc_auth_context_find_properties_by_name( grpc_auth_property_iterator grpc_auth_context_peer_identity( const grpc_auth_context* ctx) { GRPC_API_TRACE("grpc_auth_context_peer_identity(ctx=%p)", 1, (ctx)); - if (ctx == NULL) return empty_iterator; + if (ctx == nullptr) return empty_iterator; return grpc_auth_context_find_properties_by_name( ctx, ctx->peer_identity_property_name); } @@ -324,11 +324,11 @@ grpc_arg grpc_auth_context_to_arg(grpc_auth_context* p) { } grpc_auth_context* grpc_auth_context_from_arg(const grpc_arg* arg) { - if (strcmp(arg->key, GRPC_AUTH_CONTEXT_ARG) != 0) return NULL; + if (strcmp(arg->key, GRPC_AUTH_CONTEXT_ARG) != 0) return nullptr; if (arg->type != GRPC_ARG_POINTER) { gpr_log(GPR_ERROR, "Invalid type %d for arg %s", arg->type, GRPC_AUTH_CONTEXT_ARG); - return NULL; + return nullptr; } return (grpc_auth_context*)arg->value.pointer.p; } @@ -336,10 +336,10 @@ grpc_auth_context* grpc_auth_context_from_arg(const grpc_arg* arg) { grpc_auth_context* grpc_find_auth_context_in_args( const grpc_channel_args* args) { size_t i; - if (args == NULL) return NULL; + if (args == nullptr) return nullptr; for (i = 0; i < args->num_args; i++) { grpc_auth_context* p = grpc_auth_context_from_arg(&args->args[i]); - if (p != NULL) return p; + if (p != nullptr) return p; } - return NULL; + return nullptr; } diff --git a/src/core/lib/security/transport/security_connector.cc b/src/core/lib/security/transport/security_connector.cc index 5c508fabea..c56e459aeb 100644 --- a/src/core/lib/security/transport/security_connector.cc +++ b/src/core/lib/security/transport/security_connector.cc @@ -93,10 +93,10 @@ const tsi_peer_property* tsi_peer_get_property_by_name(const tsi_peer* peer, if (peer == nullptr) return nullptr; for (i = 0; i < peer->property_count; i++) { const tsi_peer_property* property = &peer->properties[i]; - if (name == NULL && property->name == NULL) { + if (name == nullptr && property->name == nullptr) { return property; } - if (name != NULL && property->name != NULL && + if (name != nullptr && property->name != nullptr && strcmp(property->name, name) == 0) { return property; } @@ -271,7 +271,7 @@ grpc_security_connector* grpc_security_connector_find_in_args( for (i = 0; i < args->num_args; i++) { grpc_security_connector* sc = grpc_security_connector_from_arg(&args->args[i]); - if (sc != NULL) return sc; + if (sc != nullptr) return sc; } return nullptr; } @@ -333,7 +333,7 @@ static bool fake_check_target(const char* target_type, const char* target, gpr_string_split(set_str, ",", &set, &set_size); bool found = false; for (size_t i = 0; i < set_size; ++i) { - if (set[i] != NULL && strcmp(target, set[i]) == 0) found = true; + if (set[i] != nullptr && strcmp(target, set[i]) == 0) found = true; } for (size_t i = 0; i < set_size; ++i) { gpr_free(set[i]); @@ -613,7 +613,7 @@ static void ssl_channel_add_handshakers(grpc_exec_ctx* exec_ctx, } static const char** fill_alpn_protocol_strings(size_t* num_alpn_protocols) { - GPR_ASSERT(num_alpn_protocols != NULL); + GPR_ASSERT(num_alpn_protocols != nullptr); *num_alpn_protocols = grpc_chttp2_num_alpn_versions(); const char** alpn_protocol_strings = (const char**)gpr_malloc(sizeof(const char*) * (*num_alpn_protocols)); @@ -752,10 +752,10 @@ grpc_auth_context* tsi_ssl_peer_to_auth_context(const tsi_peer* peer) { GRPC_SSL_TRANSPORT_SECURITY_TYPE); for (i = 0; i < peer->property_count; i++) { const tsi_peer_property* prop = &peer->properties[i]; - if (prop->name == NULL) continue; + if (prop->name == nullptr) continue; if (strcmp(prop->name, TSI_X509_SUBJECT_COMMON_NAME_PEER_PROPERTY) == 0) { /* If there is no subject alt name, have the CN as the identity. */ - if (peer_identity_property_name == NULL) { + if (peer_identity_property_name == nullptr) { peer_identity_property_name = GRPC_X509_CN_PROPERTY_NAME; } grpc_auth_context_add_property(ctx, GRPC_X509_CN_PROPERTY_NAME, @@ -869,7 +869,7 @@ tsi_peer tsi_shallow_peer_from_ssl_auth_context( memset(&peer, 0, sizeof(peer)); it = grpc_auth_context_property_iterator(auth_context); - while (grpc_auth_property_iterator_next(&it) != NULL) max_num_props++; + while (grpc_auth_property_iterator_next(&it) != nullptr) max_num_props++; if (max_num_props > 0) { peer.properties = (tsi_peer_property*)gpr_malloc(max_num_props * @@ -948,7 +948,7 @@ static grpc_slice compute_default_pem_root_certs_once(void) { /* Try overridden roots if needed. */ grpc_ssl_roots_override_result ovrd_res = GRPC_SSL_ROOTS_OVERRIDE_FAIL; - if (GRPC_SLICE_IS_EMPTY(result) && ssl_roots_override_cb != NULL) { + if (GRPC_SLICE_IS_EMPTY(result) && ssl_roots_override_cb != nullptr) { char* pem_root_certs = nullptr; ovrd_res = ssl_roots_override_cb(&pem_root_certs); if (ovrd_res == GRPC_SSL_ROOTS_OVERRIDE_OK) { @@ -985,7 +985,7 @@ const char* grpc_get_default_ssl_roots(void) { static gpr_once once = GPR_ONCE_INIT; gpr_once_init(&once, init_default_pem_root_certs); return GRPC_SLICE_IS_EMPTY(default_pem_root_certs) - ? NULL + ? nullptr : (const char*)GRPC_SLICE_START_PTR(default_pem_root_certs); } @@ -1039,7 +1039,7 @@ grpc_security_status grpc_ssl_channel_security_connector_create( config->pem_key_cert_pair->private_key != nullptr && config->pem_key_cert_pair->cert_chain != nullptr; result = tsi_create_ssl_client_handshaker_factory( - has_key_cert_pair ? config->pem_key_cert_pair : NULL, pem_root_certs, + has_key_cert_pair ? config->pem_key_cert_pair : nullptr, pem_root_certs, ssl_cipher_suites(), alpn_protocol_strings, (uint16_t)num_alpn_protocols, &c->client_handshaker_factory); if (result != TSI_OK) { diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index 52aaf723b3..4aec324797 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -1277,7 +1277,7 @@ static grpc_error* consolidate_batch_errors(batch_control* bctl) { "Call batch failed", bctl->errors, n); for (size_t i = 0; i < n; i++) { GRPC_ERROR_UNREF(bctl->errors[i]); - bctl->errors[i] = NULL; + bctl->errors[i] = nullptr; } return error; } @@ -1452,9 +1452,9 @@ static void process_data_after_md(grpc_exec_ctx* exec_ctx, if ((call->receiving_stream->flags & GRPC_WRITE_INTERNAL_COMPRESS) && (call->incoming_compression_algorithm > GRPC_COMPRESS_NONE)) { *call->receiving_buffer = grpc_raw_compressed_byte_buffer_create( - NULL, 0, call->incoming_compression_algorithm); + nullptr, 0, call->incoming_compression_algorithm); } else { - *call->receiving_buffer = grpc_raw_byte_buffer_create(NULL, 0); + *call->receiving_buffer = grpc_raw_byte_buffer_create(nullptr, 0); } GRPC_CLOSURE_INIT(&call->receiving_slice_ready, receiving_slice_ready, bctl, grpc_schedule_on_exec_ctx); @@ -1686,7 +1686,7 @@ static grpc_call_error call_start_batch(grpc_exec_ctx* exec_ctx, GPR_ASSERT(grpc_cq_begin_op(call->cq, notify_tag)); grpc_cq_end_op( exec_ctx, call->cq, notify_tag, GRPC_ERROR_NONE, - free_no_op_completion, NULL, + free_no_op_completion, nullptr, (grpc_cq_completion*)gpr_malloc(sizeof(grpc_cq_completion))); } else { GRPC_CLOSURE_SCHED(exec_ctx, (grpc_closure*)notify_tag, GRPC_ERROR_NONE); @@ -1709,7 +1709,7 @@ static grpc_call_error call_start_batch(grpc_exec_ctx* exec_ctx, /* rewrite batch ops into a transport op */ for (i = 0; i < nops; i++) { op = &ops[i]; - if (op->reserved != NULL) { + if (op->reserved != nullptr) { error = GRPC_CALL_ERROR; goto done_with_error; } @@ -1814,7 +1814,7 @@ static grpc_call_error call_start_batch(grpc_exec_ctx* exec_ctx, error = GRPC_CALL_ERROR_INVALID_FLAGS; goto done_with_error; } - if (op->data.send_message.send_message == NULL) { + if (op->data.send_message.send_message == nullptr) { error = GRPC_CALL_ERROR_INVALID_MESSAGE; goto done_with_error; } @@ -1890,7 +1890,7 @@ static grpc_call_error call_start_batch(grpc_exec_ctx* exec_ctx, override_error = GRPC_ERROR_CREATE_FROM_STATIC_STRING( "Error from server send status"); } - if (op->data.send_status_from_server.status_details != NULL) { + if (op->data.send_status_from_server.status_details != nullptr) { call->send_extra_metadata[1].md = grpc_mdelem_from_slices( exec_ctx, GRPC_MDSTR_GRPC_MESSAGE, grpc_slice_ref_internal( @@ -1909,7 +1909,7 @@ static grpc_call_error call_start_batch(grpc_exec_ctx* exec_ctx, if (!prepare_application_metadata( exec_ctx, call, (int)op->data.send_status_from_server.trailing_metadata_count, - op->data.send_status_from_server.trailing_metadata, 1, 1, NULL, + op->data.send_status_from_server.trailing_metadata, 1, 1, nullptr, 0)) { for (int n = 0; n < call->send_extra_metadata_count; n++) { GRPC_MDELEM_UNREF(exec_ctx, call->send_extra_metadata[n].md); diff --git a/src/core/lib/transport/connectivity_state.cc b/src/core/lib/transport/connectivity_state.cc index e6f3b0429e..e7e5dbd1f1 100644 --- a/src/core/lib/transport/connectivity_state.cc +++ b/src/core/lib/transport/connectivity_state.cc @@ -47,7 +47,7 @@ void grpc_connectivity_state_init(grpc_connectivity_state_tracker* tracker, const char* name) { gpr_atm_no_barrier_store(&tracker->current_state_atm, init_state); tracker->current_error = GRPC_ERROR_NONE; - tracker->watchers = NULL; + tracker->watchers = nullptr; tracker->name = gpr_strdup(name); } @@ -93,7 +93,7 @@ grpc_connectivity_state grpc_connectivity_state_get( gpr_log(GPR_DEBUG, "CONWATCH: %p %s: get %s", tracker, tracker->name, grpc_connectivity_state_name(cur)); } - if (error != NULL) { + if (error != nullptr) { *error = GRPC_ERROR_REF(tracker->current_error); } return cur; @@ -101,7 +101,7 @@ grpc_connectivity_state grpc_connectivity_state_get( bool grpc_connectivity_state_has_watchers( grpc_connectivity_state_tracker* connectivity_state) { - return connectivity_state->watchers != NULL; + return connectivity_state->watchers != nullptr; } bool grpc_connectivity_state_notify_on_state_change( @@ -111,7 +111,7 @@ bool grpc_connectivity_state_notify_on_state_change( (grpc_connectivity_state)gpr_atm_no_barrier_load( &tracker->current_state_atm); if (grpc_connectivity_state_trace.enabled()) { - if (current == NULL) { + if (current == nullptr) { gpr_log(GPR_DEBUG, "CONWATCH: %p %s: unsubscribe notify=%p", tracker, tracker->name, notify); } else { @@ -120,17 +120,17 @@ bool grpc_connectivity_state_notify_on_state_change( grpc_connectivity_state_name(cur), notify); } } - if (current == NULL) { + if (current == nullptr) { grpc_connectivity_state_watcher* w = tracker->watchers; - if (w != NULL && w->notify == notify) { + if (w != nullptr && w->notify == notify) { GRPC_CLOSURE_SCHED(exec_ctx, notify, GRPC_ERROR_CANCELLED); tracker->watchers = w->next; gpr_free(w); return false; } - while (w != NULL) { + while (w != nullptr) { grpc_connectivity_state_watcher* rm_candidate = w->next; - if (rm_candidate != NULL && rm_candidate->notify == notify) { + if (rm_candidate != nullptr && rm_candidate->notify == notify) { GRPC_CLOSURE_SCHED(exec_ctx, notify, GRPC_ERROR_CANCELLED); w->next = w->next->next; gpr_free(rm_candidate); @@ -188,7 +188,7 @@ void grpc_connectivity_state_set(grpc_exec_ctx* exec_ctx, } GPR_ASSERT(cur != GRPC_CHANNEL_SHUTDOWN); gpr_atm_no_barrier_store(&tracker->current_state_atm, state); - while ((w = tracker->watchers) != NULL) { + while ((w = tracker->watchers) != nullptr) { *w->current = state; tracker->watchers = w->next; if (grpc_connectivity_state_trace.enabled()) { -- cgit v1.2.3 From 467e8369a896397d40abf7c3e9141c1e7440a2e4 Mon Sep 17 00:00:00 2001 From: Noah Eisen Date: Tue, 14 Nov 2017 14:59:37 -0800 Subject: clang fmt --- .../client_channel/lb_policy/grpclb/grpclb.cc | 8 +++--- .../lb_policy/pick_first/pick_first.cc | 3 +- .../client_channel/lb_policy/subchannel_list.cc | 3 +- src/core/ext/transport/inproc/inproc_transport.cc | 33 +++++++++++++--------- src/core/lib/iomgr/tcp_posix.cc | 3 +- src/core/lib/surface/call.cc | 4 +-- 6 files changed, 31 insertions(+), 23 deletions(-) (limited to 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc') diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index 005df3c6d1..9b0cf58511 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -1178,8 +1178,8 @@ static int glb_pick_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol, bool pick_done = false; if (glb_policy->rr_policy != nullptr) { const grpc_connectivity_state rr_connectivity_state = - grpc_lb_policy_check_connectivity_locked(exec_ctx, - glb_policy->rr_policy, nullptr); + grpc_lb_policy_check_connectivity_locked( + exec_ctx, glb_policy->rr_policy, nullptr); // The glb_policy->rr_policy may have transitioned to SHUTDOWN but the // callback registered to capture this event // (glb_rr_connectivity_changed_locked) may not have been invoked yet. We @@ -1525,8 +1525,8 @@ static void query_for_backends_locked(grpc_exec_ctx* exec_ctx, op->flags = 0; op->reserved = nullptr; op++; - call_error = grpc_call_start_batch_and_execute(exec_ctx, glb_policy->lb_call, - ops, (size_t)(op - ops), nullptr); + call_error = grpc_call_start_batch_and_execute( + exec_ctx, glb_policy->lb_call, ops, (size_t)(op - ops), nullptr); GPR_ASSERT(GRPC_CALL_OK == call_error); op = ops; diff --git a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc index 0f0d245f82..54866f2a5d 100644 --- a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +++ b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc @@ -154,7 +154,8 @@ static void pf_cancel_picks_locked(grpc_exec_ctx* exec_ctx, grpc_lb_policy* pol, static void start_picking_locked(grpc_exec_ctx* exec_ctx, pick_first_lb_policy* p) { p->started_picking = true; - if (p->subchannel_list != nullptr && p->subchannel_list->num_subchannels > 0) { + if (p->subchannel_list != nullptr && + p->subchannel_list->num_subchannels > 0) { p->subchannel_list->checking_subchannel = 0; grpc_lb_subchannel_list_ref_for_connectivity_watch( p->subchannel_list, "connectivity_watch+start_picking"); diff --git a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc index 7d39cc009f..b6fce4d207 100644 --- a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc +++ b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc @@ -240,7 +240,8 @@ static void subchannel_data_cancel_connectivity_watch( (size_t)(sd - sd->subchannel_list->subchannels), sd->subchannel_list->num_subchannels, sd->subchannel, reason); } - grpc_subchannel_notify_on_state_change(exec_ctx, sd->subchannel, nullptr, nullptr, + grpc_subchannel_notify_on_state_change(exec_ctx, sd->subchannel, nullptr, + nullptr, &sd->connectivity_changed_closure); } diff --git a/src/core/ext/transport/inproc/inproc_transport.cc b/src/core/ext/transport/inproc/inproc_transport.cc index cf6418a66c..2579060811 100644 --- a/src/core/ext/transport/inproc/inproc_transport.cc +++ b/src/core/ext/transport/inproc/inproc_transport.cc @@ -410,10 +410,11 @@ static void fail_helper_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s, grpc_metadata_batch_init(&fake_md); inproc_stream* other = s->other_side; - grpc_metadata_batch* dest = (other == nullptr) ? &s->write_buffer_trailing_md - : &other->to_read_trailing_md; + grpc_metadata_batch* dest = (other == nullptr) + ? &s->write_buffer_trailing_md + : &other->to_read_trailing_md; bool* destfilled = (other == nullptr) ? &s->write_buffer_trailing_md_filled - : &other->to_read_trailing_md_filled; + : &other->to_read_trailing_md_filled; fill_in_metadata(exec_ctx, s, &fake_md, 0, dest, nullptr, destfilled); grpc_metadata_batch_destroy(exec_ctx, &fake_md); @@ -612,10 +613,11 @@ static void op_state_machine(grpc_exec_ctx* exec_ctx, void* arg, (!s->send_message_op || (s->t->is_client && (s->trailing_md_recvd || s->to_read_trailing_md_filled)))) { - grpc_metadata_batch* dest = (other == nullptr) ? &s->write_buffer_trailing_md - : &other->to_read_trailing_md; + grpc_metadata_batch* dest = (other == nullptr) + ? &s->write_buffer_trailing_md + : &other->to_read_trailing_md; bool* destfilled = (other == nullptr) ? &s->write_buffer_trailing_md_filled - : &other->to_read_trailing_md_filled; + : &other->to_read_trailing_md_filled; if (*destfilled || s->trailing_md_sent) { // The buffer is already in use; that's an error! INPROC_LOG(GPR_DEBUG, "Extra trailing metadata %p", s); @@ -827,10 +829,11 @@ static bool cancel_stream_locked(grpc_exec_ctx* exec_ctx, inproc_stream* s, grpc_metadata_batch_init(&cancel_md); inproc_stream* other = s->other_side; - grpc_metadata_batch* dest = (other == nullptr) ? &s->write_buffer_trailing_md - : &other->to_read_trailing_md; + grpc_metadata_batch* dest = (other == nullptr) + ? &s->write_buffer_trailing_md + : &other->to_read_trailing_md; bool* destfilled = (other == nullptr) ? &s->write_buffer_trailing_md_filled - : &other->to_read_trailing_md_filled; + : &other->to_read_trailing_md_filled; fill_in_metadata(exec_ctx, s, &cancel_md, 0, dest, nullptr, destfilled); grpc_metadata_batch_destroy(exec_ctx, &cancel_md); @@ -914,12 +917,14 @@ static void perform_stream_op(grpc_exec_ctx* exec_ctx, grpc_transport* gt, error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Endpoint already shutdown"); } if (error == GRPC_ERROR_NONE && op->send_initial_metadata) { - grpc_metadata_batch* dest = (other == nullptr) ? &s->write_buffer_initial_md - : &other->to_read_initial_md; - uint32_t* destflags = (other == nullptr) ? &s->write_buffer_initial_md_flags - : &other->to_read_initial_md_flags; + grpc_metadata_batch* dest = (other == nullptr) + ? &s->write_buffer_initial_md + : &other->to_read_initial_md; + uint32_t* destflags = (other == nullptr) + ? &s->write_buffer_initial_md_flags + : &other->to_read_initial_md_flags; bool* destfilled = (other == nullptr) ? &s->write_buffer_initial_md_filled - : &other->to_read_initial_md_filled; + : &other->to_read_initial_md_filled; if (*destfilled || s->initial_md_sent) { // The buffer is already in use; that's an error! INPROC_LOG(GPR_DEBUG, "Extra initial metadata %p", s); diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc index ff78480a1a..6d9e044fa2 100644 --- a/src/core/lib/iomgr/tcp_posix.cc +++ b/src/core/lib/iomgr/tcp_posix.cc @@ -198,7 +198,8 @@ static void cover_self(grpc_exec_ctx* exec_ctx, grpc_tcp* tcp) { grpc_executor_scheduler(GRPC_EXECUTOR_LONG)), GRPC_ERROR_NONE); } else { - while ((p = (backup_poller*)gpr_atm_acq_load(&g_backup_poller)) == nullptr) { + while ((p = (backup_poller*)gpr_atm_acq_load(&g_backup_poller)) == + nullptr) { // spin waiting for backup poller } } diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index 4aec324797..a83c95c8dc 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -1909,8 +1909,8 @@ static grpc_call_error call_start_batch(grpc_exec_ctx* exec_ctx, if (!prepare_application_metadata( exec_ctx, call, (int)op->data.send_status_from_server.trailing_metadata_count, - op->data.send_status_from_server.trailing_metadata, 1, 1, nullptr, - 0)) { + op->data.send_status_from_server.trailing_metadata, 1, 1, + nullptr, 0)) { for (int n = 0; n < call->send_extra_metadata_count; n++) { GRPC_MDELEM_UNREF(exec_ctx, call->send_extra_metadata[n].md); } -- cgit v1.2.3