reviewable/pr13109/r9
Noah Eisen 7 years ago
parent 68bb1bf748
commit 6870e6f1fd
  1. 224
      src/core/ext/filters/client_channel/client_channel.cc
  2. 4
      src/core/ext/transport/chttp2/transport/parsing.cc
  3. 8
      src/core/lib/debug/trace.cc
  4. 154
      src/core/lib/security/transport/security_connector.cc
  5. 122
      src/core/lib/surface/call.cc

@ -114,7 +114,7 @@ static bool parse_timeout(grpc_json* field, grpc_millis* timeout) {
buf[len - 1] = '\0'; // Remove trailing 's'.
char* decimal_point = strchr(buf, '.');
int nanos = 0;
if (decimal_point != NULL) {
if (decimal_point != nullptr) {
*decimal_point = '\0';
nanos = gpr_parse_nonnegative_int(decimal_point + 1);
if (nanos == -1) {
@ -140,14 +140,14 @@ static bool parse_timeout(grpc_json* field, grpc_millis* timeout) {
static void* method_parameters_create_from_json(const grpc_json* json) {
wait_for_ready_value wait_for_ready = WAIT_FOR_READY_UNSET;
grpc_millis timeout = 0;
for (grpc_json* field = json->child; field != NULL; field = field->next) {
if (field->key == NULL) continue;
for (grpc_json* field = json->child; field != nullptr; field = field->next) {
if (field->key == nullptr) continue;
if (strcmp(field->key, "waitForReady") == 0) {
if (wait_for_ready != WAIT_FOR_READY_UNSET) return NULL; // Duplicate.
if (!parse_wait_for_ready(field, &wait_for_ready)) return NULL;
if (wait_for_ready != WAIT_FOR_READY_UNSET) return nullptr; // Duplicate.
if (!parse_wait_for_ready(field, &wait_for_ready)) return nullptr;
} else if (strcmp(field->key, "timeout") == 0) {
if (timeout > 0) return NULL; // Duplicate.
if (!parse_timeout(field, &timeout)) return NULL;
if (timeout > 0) return nullptr; // Duplicate.
if (!parse_timeout(field, &timeout)) return nullptr;
}
}
method_parameters* value =
@ -233,7 +233,7 @@ static void set_channel_connectivity_state_locked(grpc_exec_ctx* exec_ctx,
* - Make it possible for policies to return GRPC_CHANNEL_TRANSIENT_FAILURE.
* - Hand over pending picks from old policies during the switch that happens
* when resolver provides an update. */
if (chand->lb_policy != NULL) {
if (chand->lb_policy != nullptr) {
if (state == GRPC_CHANNEL_TRANSIENT_FAILURE) {
/* cancel picks with wait_for_ready=false */
grpc_lb_policy_cancel_picks_locked(
@ -265,11 +265,11 @@ static void on_lb_policy_state_changed_locked(grpc_exec_ctx* exec_ctx,
gpr_log(GPR_DEBUG, "chand=%p: lb_policy=%p state changed to %s", w->chand,
w->lb_policy, grpc_connectivity_state_name(w->state));
}
if (publish_state == GRPC_CHANNEL_SHUTDOWN && w->chand->resolver != NULL) {
if (publish_state == GRPC_CHANNEL_SHUTDOWN && w->chand->resolver != nullptr) {
publish_state = GRPC_CHANNEL_TRANSIENT_FAILURE;
grpc_resolver_channel_saw_error_locked(exec_ctx, w->chand->resolver);
GRPC_LB_POLICY_UNREF(exec_ctx, w->chand->lb_policy, "channel");
w->chand->lb_policy = NULL;
w->chand->lb_policy = nullptr;
}
set_channel_connectivity_state_locked(exec_ctx, w->chand, publish_state,
GRPC_ERROR_REF(error), "lb_changed");
@ -317,13 +317,13 @@ static void parse_retry_throttle_params(const grpc_json* field, void* arg) {
service_config_parsing_state* parsing_state =
(service_config_parsing_state*)arg;
if (strcmp(field->key, "retryThrottling") == 0) {
if (parsing_state->retry_throttle_data != NULL) return; // Duplicate.
if (parsing_state->retry_throttle_data != nullptr) return; // Duplicate.
if (field->type != GRPC_JSON_OBJECT) return;
int max_milli_tokens = 0;
int milli_token_ratio = 0;
for (grpc_json* sub_field = field->child; sub_field != NULL;
for (grpc_json* sub_field = field->child; sub_field != nullptr;
sub_field = sub_field->next) {
if (sub_field->key == NULL) return;
if (sub_field->key == nullptr) return;
if (strcmp(sub_field->key, "maxTokens") == 0) {
if (max_milli_tokens != 0) return; // Duplicate.
if (sub_field->type != GRPC_JSON_NUMBER) return;
@ -338,7 +338,7 @@ static void parse_retry_throttle_params(const grpc_json* field, void* arg) {
uint32_t multiplier = 1;
uint32_t decimal_value = 0;
const char* decimal_point = strchr(sub_field->value, '.');
if (decimal_point != NULL) {
if (decimal_point != nullptr) {
whole_len = (size_t)(decimal_point - sub_field->value);
multiplier = 1000;
size_t decimal_len = strlen(decimal_point + 1);
@ -377,18 +377,18 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx* exec_ctx,
}
// Extract the following fields from the resolver result, if non-NULL.
bool lb_policy_updated = false;
char* lb_policy_name_dup = NULL;
char* lb_policy_name_dup = nullptr;
bool lb_policy_name_changed = false;
grpc_lb_policy* new_lb_policy = NULL;
char* service_config_json = NULL;
grpc_server_retry_throttle_data* retry_throttle_data = NULL;
grpc_slice_hash_table* method_params_table = NULL;
if (chand->resolver_result != NULL) {
grpc_lb_policy* new_lb_policy = nullptr;
char* service_config_json = nullptr;
grpc_server_retry_throttle_data* retry_throttle_data = nullptr;
grpc_slice_hash_table* method_params_table = nullptr;
if (chand->resolver_result != nullptr) {
// Find LB policy name.
const char* lb_policy_name = NULL;
const char* lb_policy_name = nullptr;
const grpc_arg* channel_arg =
grpc_channel_args_find(chand->resolver_result, GRPC_ARG_LB_POLICY_NAME);
if (channel_arg != NULL) {
if (channel_arg != nullptr) {
GPR_ASSERT(channel_arg->type == GRPC_ARG_STRING);
lb_policy_name = channel_arg->value.string;
}
@ -396,7 +396,7 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx* exec_ctx,
// the grpclb policy, regardless of what the resolver actually specified.
channel_arg =
grpc_channel_args_find(chand->resolver_result, GRPC_ARG_LB_ADDRESSES);
if (channel_arg != NULL && channel_arg->type == GRPC_ARG_POINTER) {
if (channel_arg != nullptr && channel_arg->type == GRPC_ARG_POINTER) {
grpc_lb_addresses* addresses =
(grpc_lb_addresses*)channel_arg->value.pointer.p;
bool found_balancer_address = false;
@ -407,7 +407,7 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx* exec_ctx,
}
}
if (found_balancer_address) {
if (lb_policy_name != NULL && strcmp(lb_policy_name, "grpclb") != 0) {
if (lb_policy_name != nullptr && strcmp(lb_policy_name, "grpclb") != 0) {
gpr_log(GPR_INFO,
"resolver requested LB policy %s but provided at least one "
"balancer address -- forcing use of grpclb LB policy",
@ -418,7 +418,7 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx* exec_ctx,
}
// Use pick_first if nothing was specified and we didn't select grpclb
// above.
if (lb_policy_name == NULL) lb_policy_name = "pick_first";
if (lb_policy_name == nullptr) lb_policy_name = "pick_first";
grpc_lb_policy_args lb_policy_args;
lb_policy_args.args = chand->resolver_result;
lb_policy_args.client_channel_factory = chand->client_channel_factory;
@ -429,9 +429,9 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx* exec_ctx,
// only thing that modifies its value, and it can only be invoked
// once at any given time.
lb_policy_name_changed =
chand->info_lb_policy_name == NULL ||
chand->info_lb_policy_name == nullptr ||
strcmp(chand->info_lb_policy_name, lb_policy_name) != 0;
if (chand->lb_policy != NULL && !lb_policy_name_changed) {
if (chand->lb_policy != nullptr && !lb_policy_name_changed) {
// Continue using the same LB policy. Update with new addresses.
lb_policy_updated = true;
grpc_lb_policy_update_locked(exec_ctx, chand->lb_policy, &lb_policy_args);
@ -439,22 +439,22 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx* exec_ctx,
// Instantiate new LB policy.
new_lb_policy =
grpc_lb_policy_create(exec_ctx, lb_policy_name, &lb_policy_args);
if (new_lb_policy == NULL) {
if (new_lb_policy == nullptr) {
gpr_log(GPR_ERROR, "could not create LB policy \"%s\"", lb_policy_name);
}
}
// Find service config.
channel_arg =
grpc_channel_args_find(chand->resolver_result, GRPC_ARG_SERVICE_CONFIG);
if (channel_arg != NULL) {
if (channel_arg != nullptr) {
GPR_ASSERT(channel_arg->type == GRPC_ARG_STRING);
service_config_json = gpr_strdup(channel_arg->value.string);
grpc_service_config* service_config =
grpc_service_config_create(service_config_json);
if (service_config != NULL) {
if (service_config != nullptr) {
channel_arg =
grpc_channel_args_find(chand->resolver_result, GRPC_ARG_SERVER_URI);
GPR_ASSERT(channel_arg != NULL);
GPR_ASSERT(channel_arg != nullptr);
GPR_ASSERT(channel_arg->type == GRPC_ARG_STRING);
grpc_uri* uri =
grpc_uri_parse(exec_ctx, channel_arg->value.string, true);
@ -478,7 +478,7 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx* exec_ctx,
// The copy will be saved in chand->lb_policy_name below.
lb_policy_name_dup = gpr_strdup(lb_policy_name);
grpc_channel_args_destroy(exec_ctx, chand->resolver_result);
chand->resolver_result = NULL;
chand->resolver_result = nullptr;
}
if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG,
@ -493,22 +493,22 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx* exec_ctx,
//
// First, swap out the data used by cc_get_channel_info().
gpr_mu_lock(&chand->info_mu);
if (lb_policy_name_dup != NULL) {
if (lb_policy_name_dup != nullptr) {
gpr_free(chand->info_lb_policy_name);
chand->info_lb_policy_name = lb_policy_name_dup;
}
if (service_config_json != NULL) {
if (service_config_json != nullptr) {
gpr_free(chand->info_service_config_json);
chand->info_service_config_json = service_config_json;
}
gpr_mu_unlock(&chand->info_mu);
// Swap out the retry throttle data.
if (chand->retry_throttle_data != NULL) {
if (chand->retry_throttle_data != nullptr) {
grpc_server_retry_throttle_data_unref(chand->retry_throttle_data);
}
chand->retry_throttle_data = retry_throttle_data;
// Swap out the method params table.
if (chand->method_params_table != NULL) {
if (chand->method_params_table != nullptr) {
grpc_slice_hash_table_unref(exec_ctx, chand->method_params_table);
}
chand->method_params_table = method_params_table;
@ -518,9 +518,9 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx* exec_ctx,
// Note that we do NOT do this if either (a) we updated the existing
// LB policy above or (b) we failed to create the new LB policy (in
// which case we want to continue using the most recent one we had).
if (new_lb_policy != NULL || error != GRPC_ERROR_NONE ||
chand->resolver == NULL) {
if (chand->lb_policy != NULL) {
if (new_lb_policy != nullptr || error != GRPC_ERROR_NONE ||
chand->resolver == nullptr) {
if (chand->lb_policy != nullptr) {
if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG, "chand=%p: unreffing lb_policy=%p", chand,
chand->lb_policy);
@ -534,17 +534,17 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx* exec_ctx,
}
// Now that we've swapped out the relevant fields of chand, check for
// error or shutdown.
if (error != GRPC_ERROR_NONE || chand->resolver == NULL) {
if (error != GRPC_ERROR_NONE || chand->resolver == nullptr) {
if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG, "chand=%p: shutting down", chand);
}
if (chand->resolver != NULL) {
if (chand->resolver != nullptr) {
if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG, "chand=%p: shutting down resolver", chand);
}
grpc_resolver_shutdown_locked(exec_ctx, chand->resolver);
GRPC_RESOLVER_UNREF(exec_ctx, chand->resolver, "channel");
chand->resolver = NULL;
chand->resolver = nullptr;
}
set_channel_connectivity_state_locked(
exec_ctx, chand, GRPC_CHANNEL_SHUTDOWN,
@ -561,7 +561,7 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx* exec_ctx,
grpc_connectivity_state state = GRPC_CHANNEL_TRANSIENT_FAILURE;
grpc_error* state_error =
GRPC_ERROR_CREATE_FROM_STATIC_STRING("No load balancing policy");
if (new_lb_policy != NULL) {
if (new_lb_policy != nullptr) {
if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG, "chand=%p: initializing new LB policy", chand);
}
@ -598,46 +598,46 @@ static void start_transport_op_locked(grpc_exec_ctx* exec_ctx, void* arg,
(grpc_channel_element*)op->handler_private.extra_arg;
channel_data* chand = (channel_data*)elem->channel_data;
if (op->on_connectivity_state_change != NULL) {
if (op->on_connectivity_state_change != nullptr) {
grpc_connectivity_state_notify_on_state_change(
exec_ctx, &chand->state_tracker, op->connectivity_state,
op->on_connectivity_state_change);
op->on_connectivity_state_change = NULL;
op->connectivity_state = NULL;
op->on_connectivity_state_change = nullptr;
op->connectivity_state = nullptr;
}
if (op->send_ping != NULL) {
if (chand->lb_policy == NULL) {
if (op->send_ping != nullptr) {
if (chand->lb_policy == nullptr) {
GRPC_CLOSURE_SCHED(
exec_ctx, op->send_ping,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Ping with no load balancing"));
} else {
grpc_lb_policy_ping_one_locked(exec_ctx, chand->lb_policy, op->send_ping);
op->bind_pollset = NULL;
op->bind_pollset = nullptr;
}
op->send_ping = NULL;
op->send_ping = nullptr;
}
if (op->disconnect_with_error != GRPC_ERROR_NONE) {
if (chand->resolver != NULL) {
if (chand->resolver != nullptr) {
set_channel_connectivity_state_locked(
exec_ctx, chand, GRPC_CHANNEL_SHUTDOWN,
GRPC_ERROR_REF(op->disconnect_with_error), "disconnect");
grpc_resolver_shutdown_locked(exec_ctx, chand->resolver);
GRPC_RESOLVER_UNREF(exec_ctx, chand->resolver, "channel");
chand->resolver = NULL;
chand->resolver = nullptr;
if (!chand->started_resolving) {
grpc_closure_list_fail_all(&chand->waiting_for_resolver_result_closures,
GRPC_ERROR_REF(op->disconnect_with_error));
GRPC_CLOSURE_LIST_SCHED(exec_ctx,
&chand->waiting_for_resolver_result_closures);
}
if (chand->lb_policy != NULL) {
if (chand->lb_policy != nullptr) {
grpc_pollset_set_del_pollset_set(exec_ctx,
chand->lb_policy->interested_parties,
chand->interested_parties);
GRPC_LB_POLICY_UNREF(exec_ctx, chand->lb_policy, "channel");
chand->lb_policy = NULL;
chand->lb_policy = nullptr;
}
}
GRPC_ERROR_UNREF(op->disconnect_with_error);
@ -653,7 +653,7 @@ static void cc_start_transport_op(grpc_exec_ctx* exec_ctx,
channel_data* chand = (channel_data*)elem->channel_data;
GPR_ASSERT(op->set_accept_stream == false);
if (op->bind_pollset != NULL) {
if (op->bind_pollset != nullptr) {
grpc_pollset_set_add_pollset(exec_ctx, chand->interested_parties,
op->bind_pollset);
}
@ -672,15 +672,15 @@ static void cc_get_channel_info(grpc_exec_ctx* exec_ctx,
const grpc_channel_info* info) {
channel_data* chand = (channel_data*)elem->channel_data;
gpr_mu_lock(&chand->info_mu);
if (info->lb_policy_name != NULL) {
*info->lb_policy_name = chand->info_lb_policy_name == NULL
? NULL
if (info->lb_policy_name != nullptr) {
*info->lb_policy_name = chand->info_lb_policy_name == nullptr
? nullptr
: gpr_strdup(chand->info_lb_policy_name);
}
if (info->service_config_json != NULL) {
if (info->service_config_json != nullptr) {
*info->service_config_json =
chand->info_service_config_json == NULL
? NULL
chand->info_service_config_json == nullptr
? nullptr
: gpr_strdup(chand->info_service_config_json);
}
gpr_mu_unlock(&chand->info_mu);
@ -699,7 +699,7 @@ static grpc_error* cc_init_channel_elem(grpc_exec_ctx* exec_ctx,
gpr_mu_init(&chand->external_connectivity_watcher_list_mu);
gpr_mu_lock(&chand->external_connectivity_watcher_list_mu);
chand->external_connectivity_watcher_list_head = NULL;
chand->external_connectivity_watcher_list_head = nullptr;
gpr_mu_unlock(&chand->external_connectivity_watcher_list_mu);
chand->owning_stack = args->channel_stack;
@ -713,7 +713,7 @@ static grpc_error* cc_init_channel_elem(grpc_exec_ctx* exec_ctx,
// Record client channel factory.
const grpc_arg* arg = grpc_channel_args_find(args->channel_args,
GRPC_ARG_CLIENT_CHANNEL_FACTORY);
if (arg == NULL) {
if (arg == nullptr) {
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Missing client channel factory in args for client channel filter");
}
@ -727,7 +727,7 @@ static grpc_error* cc_init_channel_elem(grpc_exec_ctx* exec_ctx,
(grpc_client_channel_factory*)arg->value.pointer.p;
// Get server name to resolve, using proxy mapper if needed.
arg = grpc_channel_args_find(args->channel_args, GRPC_ARG_SERVER_URI);
if (arg == NULL) {
if (arg == nullptr) {
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Missing server uri in args for client channel filter");
}
@ -735,18 +735,18 @@ static grpc_error* cc_init_channel_elem(grpc_exec_ctx* exec_ctx,
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"server uri arg must be a string");
}
char* proxy_name = NULL;
grpc_channel_args* new_args = NULL;
char* proxy_name = nullptr;
grpc_channel_args* new_args = nullptr;
grpc_proxy_mappers_map_name(exec_ctx, arg->value.string, args->channel_args,
&proxy_name, &new_args);
// Instantiate resolver.
chand->resolver = grpc_resolver_create(
exec_ctx, proxy_name != NULL ? proxy_name : arg->value.string,
new_args != NULL ? new_args : args->channel_args,
exec_ctx, proxy_name != nullptr ? proxy_name : arg->value.string,
new_args != nullptr ? new_args : args->channel_args,
chand->interested_parties, chand->combiner);
if (proxy_name != NULL) gpr_free(proxy_name);
if (new_args != NULL) grpc_channel_args_destroy(exec_ctx, new_args);
if (chand->resolver == NULL) {
if (proxy_name != nullptr) gpr_free(proxy_name);
if (new_args != nullptr) grpc_channel_args_destroy(exec_ctx, new_args);
if (chand->resolver == nullptr) {
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("resolver creation failed");
}
chand->deadline_checking_enabled =
@ -765,17 +765,17 @@ static void shutdown_resolver_locked(grpc_exec_ctx* exec_ctx, void* arg,
static void cc_destroy_channel_elem(grpc_exec_ctx* exec_ctx,
grpc_channel_element* elem) {
channel_data* chand = (channel_data*)elem->channel_data;
if (chand->resolver != NULL) {
if (chand->resolver != nullptr) {
GRPC_CLOSURE_SCHED(
exec_ctx,
GRPC_CLOSURE_CREATE(shutdown_resolver_locked, chand->resolver,
grpc_combiner_scheduler(chand->combiner)),
GRPC_ERROR_NONE);
}
if (chand->client_channel_factory != NULL) {
if (chand->client_channel_factory != nullptr) {
grpc_client_channel_factory_unref(exec_ctx, chand->client_channel_factory);
}
if (chand->lb_policy != NULL) {
if (chand->lb_policy != nullptr) {
grpc_pollset_set_del_pollset_set(exec_ctx,
chand->lb_policy->interested_parties,
chand->interested_parties);
@ -783,10 +783,10 @@ static void cc_destroy_channel_elem(grpc_exec_ctx* exec_ctx,
}
gpr_free(chand->info_lb_policy_name);
gpr_free(chand->info_service_config_json);
if (chand->retry_throttle_data != NULL) {
if (chand->retry_throttle_data != nullptr) {
grpc_server_retry_throttle_data_unref(chand->retry_throttle_data);
}
if (chand->method_params_table != NULL) {
if (chand->method_params_table != nullptr) {
grpc_slice_hash_table_unref(exec_ctx, chand->method_params_table);
}
grpc_client_channel_stop_backup_polling(exec_ctx, chand->interested_parties);
@ -869,7 +869,7 @@ grpc_subchannel_call* grpc_client_channel_get_subchannel_call(
static void waiting_for_pick_batches_add(
call_data* calld, grpc_transport_stream_op_batch* batch) {
if (batch->send_initial_metadata) {
GPR_ASSERT(calld->initial_metadata_batch == NULL);
GPR_ASSERT(calld->initial_metadata_batch == nullptr);
calld->initial_metadata_batch = batch;
} else {
GPR_ASSERT(calld->waiting_for_pick_batches_count < MAX_WAITING_BATCHES);
@ -911,7 +911,7 @@ static void waiting_for_pick_batches_fail(grpc_exec_ctx* exec_ctx,
GRPC_ERROR_REF(error),
"waiting_for_pick_batches_fail");
}
if (calld->initial_metadata_batch != NULL) {
if (calld->initial_metadata_batch != nullptr) {
grpc_transport_stream_op_batch_finish_with_failure(
exec_ctx, calld->initial_metadata_batch, GRPC_ERROR_REF(error),
calld->call_combiner);
@ -955,7 +955,7 @@ static void waiting_for_pick_batches_resume(grpc_exec_ctx* exec_ctx,
GRPC_ERROR_NONE,
"waiting_for_pick_batches_resume");
}
GPR_ASSERT(calld->initial_metadata_batch != NULL);
GPR_ASSERT(calld->initial_metadata_batch != nullptr);
grpc_subchannel_call_process_op(exec_ctx, calld->subchannel_call,
calld->initial_metadata_batch);
}
@ -970,14 +970,14 @@ static void apply_service_config_to_call_locked(grpc_exec_ctx* exec_ctx,
gpr_log(GPR_DEBUG, "chand=%p calld=%p: applying service config to call",
chand, calld);
}
if (chand->retry_throttle_data != NULL) {
if (chand->retry_throttle_data != nullptr) {
calld->retry_throttle_data =
grpc_server_retry_throttle_data_ref(chand->retry_throttle_data);
}
if (chand->method_params_table != NULL) {
if (chand->method_params_table != nullptr) {
calld->method_params = (method_parameters*)grpc_method_config_table_get(
exec_ctx, chand->method_params_table, calld->path);
if (calld->method_params != NULL) {
if (calld->method_params != nullptr) {
method_parameters_ref(calld->method_params);
// If the deadline from the service config is shorter than the one
// from the client API, reset the deadline timer.
@ -1030,7 +1030,7 @@ static void pick_done_locked(grpc_exec_ctx* exec_ctx, grpc_call_element* elem,
grpc_error* error) {
call_data* calld = (call_data*)elem->call_data;
channel_data* chand = (channel_data*)elem->channel_data;
if (calld->connected_subchannel == NULL) {
if (calld->connected_subchannel == nullptr) {
// Failed to create subchannel.
GRPC_ERROR_UNREF(calld->error);
calld->error = error == GRPC_ERROR_NONE
@ -1071,7 +1071,7 @@ static void pick_callback_cancel_locked(grpc_exec_ctx* exec_ctx, void* arg,
grpc_call_element* elem = (grpc_call_element*)arg;
channel_data* chand = (channel_data*)elem->channel_data;
call_data* calld = (call_data*)elem->call_data;
if (calld->lb_policy != NULL) {
if (calld->lb_policy != nullptr) {
if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG, "chand=%p calld=%p: cancelling pick from LB policy %p",
chand, calld, calld->lb_policy);
@ -1094,9 +1094,9 @@ static void pick_callback_done_locked(grpc_exec_ctx* exec_ctx, void* arg,
gpr_log(GPR_DEBUG, "chand=%p calld=%p: pick completed asynchronously",
chand, calld);
}
GPR_ASSERT(calld->lb_policy != NULL);
GPR_ASSERT(calld->lb_policy != nullptr);
GRPC_LB_POLICY_UNREF(exec_ctx, calld->lb_policy, "pick_subchannel");
calld->lb_policy = NULL;
calld->lb_policy = nullptr;
async_pick_done_locked(exec_ctx, elem, GRPC_ERROR_REF(error));
}
@ -1122,7 +1122,7 @@ static bool pick_callback_start_locked(grpc_exec_ctx* exec_ctx,
initial_metadata_flags &
GRPC_INITIAL_METADATA_WAIT_FOR_READY_EXPLICITLY_SET;
const bool wait_for_ready_set_from_service_config =
calld->method_params != NULL &&
calld->method_params != nullptr &&
calld->method_params->wait_for_ready != WAIT_FOR_READY_UNSET;
if (!wait_for_ready_set_from_api && wait_for_ready_set_from_service_config) {
if (calld->method_params->wait_for_ready == WAIT_FOR_READY_TRUE) {
@ -1142,7 +1142,7 @@ static bool pick_callback_start_locked(grpc_exec_ctx* exec_ctx,
grpc_combiner_scheduler(chand->combiner));
const bool pick_done = grpc_lb_policy_pick_locked(
exec_ctx, chand->lb_policy, &inputs, &calld->connected_subchannel,
calld->subchannel_call_context, NULL, &calld->lb_pick_closure);
calld->subchannel_call_context, nullptr, &calld->lb_pick_closure);
if (pick_done) {
/* synchronous grpc_lb_policy_pick call. Unref the LB policy. */
if (grpc_client_channel_trace.enabled()) {
@ -1150,7 +1150,7 @@ static bool pick_callback_start_locked(grpc_exec_ctx* exec_ctx,
chand, calld);
}
GRPC_LB_POLICY_UNREF(exec_ctx, calld->lb_policy, "pick_subchannel");
calld->lb_policy = NULL;
calld->lb_policy = nullptr;
} else {
GRPC_CALL_STACK_REF(calld->owning_call, "pick_callback_cancel");
grpc_call_combiner_set_notify_on_cancel(
@ -1230,7 +1230,7 @@ static void pick_after_resolver_result_done_locked(grpc_exec_ctx* exec_ctx,
chand, calld);
}
async_pick_done_locked(exec_ctx, elem, GRPC_ERROR_REF(error));
} else if (chand->lb_policy != NULL) {
} else if (chand->lb_policy != nullptr) {
if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG, "chand=%p calld=%p: resolver returned, doing pick",
chand, calld);
@ -1251,7 +1251,7 @@ static void pick_after_resolver_result_done_locked(grpc_exec_ctx* exec_ctx,
// removed in https://github.com/grpc/grpc/pull/12297. Need to figure
// out what is actually causing this to occur and then figure out the
// right way to deal with it.
else if (chand->resolver != NULL) {
else if (chand->resolver != nullptr) {
// No LB policy, so try again.
if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG,
@ -1298,8 +1298,8 @@ static void start_pick_locked(grpc_exec_ctx* exec_ctx, void* arg,
grpc_call_element* elem = (grpc_call_element*)arg;
call_data* calld = (call_data*)elem->call_data;
channel_data* chand = (channel_data*)elem->channel_data;
GPR_ASSERT(calld->connected_subchannel == NULL);
if (chand->lb_policy != NULL) {
GPR_ASSERT(calld->connected_subchannel == nullptr);
if (chand->lb_policy != nullptr) {
// We already have an LB policy, so ask it for a pick.
if (pick_callback_start_locked(exec_ctx, elem)) {
// Pick completed synchronously.
@ -1308,7 +1308,7 @@ static void start_pick_locked(grpc_exec_ctx* exec_ctx, void* arg,
}
} else {
// We do not yet have an LB policy, so wait for a resolver result.
if (chand->resolver == NULL) {
if (chand->resolver == nullptr) {
pick_done_locked(exec_ctx, elem,
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Disconnected"));
return;
@ -1330,7 +1330,7 @@ static void start_pick_locked(grpc_exec_ctx* exec_ctx, void* arg,
static void on_complete(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
grpc_call_element* elem = (grpc_call_element*)arg;
call_data* calld = (call_data*)elem->call_data;
if (calld->retry_throttle_data != NULL) {
if (calld->retry_throttle_data != nullptr) {
if (error == GRPC_ERROR_NONE) {
grpc_server_retry_throttle_data_record_success(
calld->retry_throttle_data);
@ -1381,7 +1381,7 @@ static void cc_start_transport_stream_op_batch(
}
// If we have a subchannel call, send the cancellation batch down.
// Otherwise, fail all pending batches.
if (calld->subchannel_call != NULL) {
if (calld->subchannel_call != nullptr) {
grpc_subchannel_call_process_op(exec_ctx, calld->subchannel_call, batch);
} else {
waiting_for_pick_batches_add(calld, batch);
@ -1393,7 +1393,7 @@ static void cc_start_transport_stream_op_batch(
// Intercept on_complete for recv_trailing_metadata so that we can
// check retry throttle status.
if (batch->recv_trailing_metadata) {
GPR_ASSERT(batch->on_complete != NULL);
GPR_ASSERT(batch->on_complete != nullptr);
calld->original_on_complete = batch->on_complete;
GRPC_CLOSURE_INIT(&calld->on_complete, on_complete, elem,
grpc_schedule_on_exec_ctx);
@ -1403,7 +1403,7 @@ static void cc_start_transport_stream_op_batch(
// Note that once we have completed the pick, we do not need to enter
// the channel combiner, which is more efficient (especially for
// streaming calls).
if (calld->subchannel_call != NULL) {
if (calld->subchannel_call != nullptr) {
if (grpc_client_channel_trace.enabled()) {
gpr_log(GPR_DEBUG,
"chand=%p calld=%p: sending batch to subchannel_call=%p", chand,
@ -1472,20 +1472,20 @@ static void cc_destroy_call_elem(grpc_exec_ctx* exec_ctx,
grpc_deadline_state_destroy(exec_ctx, elem);
}
grpc_slice_unref_internal(exec_ctx, calld->path);
if (calld->method_params != NULL) {
if (calld->method_params != nullptr) {
method_parameters_unref(calld->method_params);
}
GRPC_ERROR_UNREF(calld->error);
if (calld->subchannel_call != NULL) {
if (calld->subchannel_call != nullptr) {
grpc_subchannel_call_set_cleanup_closure(calld->subchannel_call,
then_schedule_closure);
then_schedule_closure = NULL;
then_schedule_closure = nullptr;
GRPC_SUBCHANNEL_CALL_UNREF(exec_ctx, calld->subchannel_call,
"client_channel_destroy_call");
}
GPR_ASSERT(calld->lb_policy == NULL);
GPR_ASSERT(calld->lb_policy == nullptr);
GPR_ASSERT(calld->waiting_for_pick_batches_count == 0);
if (calld->connected_subchannel != NULL) {
if (calld->connected_subchannel != nullptr) {
GRPC_CONNECTED_SUBCHANNEL_UNREF(exec_ctx, calld->connected_subchannel,
"picked");
}
@ -1526,11 +1526,11 @@ const grpc_channel_filter grpc_client_channel_filter = {
static void try_to_connect_locked(grpc_exec_ctx* exec_ctx, void* arg,
grpc_error* error_ignored) {
channel_data* chand = (channel_data*)arg;
if (chand->lb_policy != NULL) {
if (chand->lb_policy != nullptr) {
grpc_lb_policy_exit_idle_locked(exec_ctx, chand->lb_policy);
} else {
chand->exit_idle_when_lb_policy_arrives = true;
if (!chand->started_resolving && chand->resolver != NULL) {
if (!chand->started_resolving && chand->resolver != nullptr) {
start_resolving_locked(exec_ctx, chand);
}
}
@ -1568,7 +1568,7 @@ static external_connectivity_watcher* lookup_external_connectivity_watcher(
gpr_mu_lock(&chand->external_connectivity_watcher_list_mu);
external_connectivity_watcher* w =
chand->external_connectivity_watcher_list_head;
while (w != NULL && w->on_complete != on_complete) {
while (w != nullptr && w->on_complete != on_complete) {
w = w->next;
}
gpr_mu_unlock(&chand->external_connectivity_watcher_list_mu);
@ -1598,7 +1598,7 @@ static void external_connectivity_watcher_list_remove(
}
external_connectivity_watcher* w =
chand->external_connectivity_watcher_list_head;
while (w != NULL) {
while (w != nullptr) {
if (w->next == too_remove) {
w->next = w->next->next;
gpr_mu_unlock(&chand->external_connectivity_watcher_list_mu);
@ -1617,7 +1617,7 @@ int grpc_client_channel_num_external_connectivity_watchers(
gpr_mu_lock(&chand->external_connectivity_watcher_list_mu);
external_connectivity_watcher* w =
chand->external_connectivity_watcher_list_head;
while (w != NULL) {
while (w != nullptr) {
count++;
w = w->next;
}
@ -1642,8 +1642,8 @@ static void on_external_watch_complete_locked(grpc_exec_ctx* exec_ctx,
static void watch_connectivity_state_locked(grpc_exec_ctx* exec_ctx, void* arg,
grpc_error* error_ignored) {
external_connectivity_watcher* w = (external_connectivity_watcher*)arg;
external_connectivity_watcher* found = NULL;
if (w->state != NULL) {
external_connectivity_watcher* found = nullptr;
if (w->state != nullptr) {
external_connectivity_watcher_list_append(w->chand, w);
GRPC_CLOSURE_RUN(exec_ctx, w->watcher_timer_init, GRPC_ERROR_NONE);
GRPC_CLOSURE_INIT(&w->my_closure, on_external_watch_complete_locked, w,
@ -1651,12 +1651,12 @@ static void watch_connectivity_state_locked(grpc_exec_ctx* exec_ctx, void* arg,
grpc_connectivity_state_notify_on_state_change(
exec_ctx, &w->chand->state_tracker, w->state, &w->my_closure);
} else {
GPR_ASSERT(w->watcher_timer_init == NULL);
GPR_ASSERT(w->watcher_timer_init == nullptr);
found = lookup_external_connectivity_watcher(w->chand, w->on_complete);
if (found) {
GPR_ASSERT(found->on_complete == w->on_complete);
grpc_connectivity_state_notify_on_state_change(
exec_ctx, &found->chand->state_tracker, NULL, &found->my_closure);
exec_ctx, &found->chand->state_tracker, nullptr, &found->my_closure);
}
grpc_polling_entity_del_from_pollset_set(exec_ctx, &w->pollent,
w->chand->interested_parties);

@ -252,10 +252,10 @@ grpc_error* grpc_chttp2_perform_read(grpc_exec_ctx* exec_ctx,
t->incoming_frame_size -= (uint32_t)(end - cur);
return GRPC_ERROR_NONE;
}
GPR_UNREACHABLE_CODE(return 0);
GPR_UNREACHABLE_CODE(return nullptr);
}
GPR_UNREACHABLE_CODE(return 0);
GPR_UNREACHABLE_CODE(return nullptr);
}
static grpc_error* init_frame_parser(grpc_exec_ctx* exec_ctx,

@ -54,7 +54,7 @@ bool TraceFlag::Set(const char* name, bool enabled) {
LogAllTracers();
} else if (0 == strcmp(name, "refcount")) {
for (t = root_tracer_; t; t = t->next_tracer_) {
if (strstr(t->name_, "refcount") != NULL) {
if (strstr(t->name_, "refcount") != nullptr) {
t->set_enabled(enabled);
}
}
@ -93,7 +93,7 @@ static void add(const char* beg, const char* end, char*** ss, size_t* ns) {
static void split(const char* s, char*** ss, size_t* ns) {
const char* c = strchr(s, ',');
if (c == NULL) {
if (c == nullptr) {
add(s, s + strlen(s), ss, ns);
} else {
add(s, c, ss, ns);
@ -102,7 +102,7 @@ static void split(const char* s, char*** ss, size_t* ns) {
}
static void parse(const char* s) {
char** strings = NULL;
char** strings = nullptr;
size_t nstrings = 0;
size_t i;
split(s, &strings, &nstrings);
@ -123,7 +123,7 @@ static void parse(const char* s) {
void grpc_tracer_init(const char* env_var) {
char* e = gpr_getenv(env_var);
if (e != NULL) {
if (e != nullptr) {
parse(e);
gpr_free(e);
}

@ -58,7 +58,7 @@ static const char* installed_roots_path =
/* -- Overridden default roots. -- */
static grpc_ssl_roots_override_callback ssl_roots_override_cb = NULL;
static grpc_ssl_roots_override_callback ssl_roots_override_cb = nullptr;
void grpc_set_ssl_roots_override_callback(grpc_ssl_roots_override_callback cb) {
ssl_roots_override_cb = cb;
@ -72,11 +72,11 @@ void grpc_set_ssl_roots_override_callback(grpc_ssl_roots_override_callback cb) {
"ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384"
static gpr_once cipher_suites_once = GPR_ONCE_INIT;
static const char* cipher_suites = NULL;
static const char* cipher_suites = nullptr;
static void init_cipher_suites(void) {
char* overridden = gpr_getenv("GRPC_SSL_CIPHER_SUITES");
cipher_suites = overridden != NULL ? overridden : GRPC_SSL_CIPHER_SUITES;
cipher_suites = overridden != nullptr ? overridden : GRPC_SSL_CIPHER_SUITES;
}
static const char* ssl_cipher_suites(void) {
@ -90,7 +90,7 @@ static const char* ssl_cipher_suites(void) {
const tsi_peer_property* tsi_peer_get_property_by_name(const tsi_peer* peer,
const char* name) {
size_t i;
if (peer == NULL) return NULL;
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) {
@ -101,13 +101,13 @@ const tsi_peer_property* tsi_peer_get_property_by_name(const tsi_peer* peer,
return property;
}
}
return NULL;
return nullptr;
}
void grpc_channel_security_connector_add_handshakers(
grpc_exec_ctx* exec_ctx, grpc_channel_security_connector* connector,
grpc_handshake_manager* handshake_mgr) {
if (connector != NULL) {
if (connector != nullptr) {
connector->add_handshakers(exec_ctx, connector, handshake_mgr);
}
}
@ -115,7 +115,7 @@ void grpc_channel_security_connector_add_handshakers(
void grpc_server_security_connector_add_handshakers(
grpc_exec_ctx* exec_ctx, grpc_server_security_connector* connector,
grpc_handshake_manager* handshake_mgr) {
if (connector != NULL) {
if (connector != nullptr) {
connector->add_handshakers(exec_ctx, connector, handshake_mgr);
}
}
@ -125,7 +125,7 @@ void grpc_security_connector_check_peer(grpc_exec_ctx* exec_ctx,
tsi_peer peer,
grpc_auth_context** auth_context,
grpc_closure* on_peer_checked) {
if (sc == NULL) {
if (sc == nullptr) {
GRPC_CLOSURE_SCHED(exec_ctx, on_peer_checked,
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"cannot check peer -- no security connector"));
@ -137,7 +137,7 @@ void grpc_security_connector_check_peer(grpc_exec_ctx* exec_ctx,
int grpc_security_connector_cmp(grpc_security_connector* sc,
grpc_security_connector* other) {
if (sc == NULL || other == NULL) return GPR_ICMP(sc, other);
if (sc == nullptr || other == nullptr) return GPR_ICMP(sc, other);
int c = GPR_ICMP(sc->vtable, other->vtable);
if (c != 0) return c;
return sc->vtable->cmp(sc, other);
@ -145,8 +145,8 @@ int grpc_security_connector_cmp(grpc_security_connector* sc,
int grpc_channel_security_connector_cmp(grpc_channel_security_connector* sc1,
grpc_channel_security_connector* sc2) {
GPR_ASSERT(sc1->channel_creds != NULL);
GPR_ASSERT(sc2->channel_creds != NULL);
GPR_ASSERT(sc1->channel_creds != nullptr);
GPR_ASSERT(sc2->channel_creds != nullptr);
int c = GPR_ICMP(sc1->channel_creds, sc2->channel_creds);
if (c != 0) return c;
c = GPR_ICMP(sc1->request_metadata_creds, sc2->request_metadata_creds);
@ -161,8 +161,8 @@ int grpc_channel_security_connector_cmp(grpc_channel_security_connector* sc1,
int grpc_server_security_connector_cmp(grpc_server_security_connector* sc1,
grpc_server_security_connector* sc2) {
GPR_ASSERT(sc1->server_creds != NULL);
GPR_ASSERT(sc2->server_creds != NULL);
GPR_ASSERT(sc1->server_creds != nullptr);
GPR_ASSERT(sc2->server_creds != nullptr);
int c = GPR_ICMP(sc1->server_creds, sc2->server_creds);
if (c != 0) return c;
return GPR_ICMP((void*)sc1->add_handshakers, (void*)sc2->add_handshakers);
@ -172,7 +172,7 @@ bool grpc_channel_security_connector_check_call_host(
grpc_exec_ctx* exec_ctx, grpc_channel_security_connector* sc,
const char* host, grpc_auth_context* auth_context,
grpc_closure* on_call_host_checked, grpc_error** error) {
if (sc == NULL || sc->check_call_host == NULL) {
if (sc == nullptr || sc->check_call_host == nullptr) {
*error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"cannot check call host -- no security connector");
return true;
@ -184,7 +184,7 @@ bool grpc_channel_security_connector_check_call_host(
void grpc_channel_security_connector_cancel_check_call_host(
grpc_exec_ctx* exec_ctx, grpc_channel_security_connector* sc,
grpc_closure* on_call_host_checked, grpc_error* error) {
if (sc == NULL || sc->cancel_check_call_host == NULL) {
if (sc == nullptr || sc->cancel_check_call_host == nullptr) {
GRPC_ERROR_UNREF(error);
return;
}
@ -195,7 +195,7 @@ void grpc_channel_security_connector_cancel_check_call_host(
grpc_security_connector* grpc_security_connector_ref(
grpc_security_connector* sc, const char* file, int line,
const char* reason) {
if (sc == NULL) return NULL;
if (sc == nullptr) return nullptr;
if (grpc_trace_security_connector_refcount.enabled()) {
gpr_atm val = gpr_atm_no_barrier_load(&sc->refcount.count);
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
@ -216,7 +216,7 @@ void grpc_security_connector_unref(grpc_exec_ctx* exec_ctx,
grpc_security_connector* sc,
const char* file, int line,
const char* reason) {
if (sc == NULL) return;
if (sc == nullptr) return;
if (grpc_trace_security_connector_refcount.enabled()) {
gpr_atm val = gpr_atm_no_barrier_load(&sc->refcount.count);
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
@ -255,11 +255,11 @@ grpc_arg grpc_security_connector_to_arg(grpc_security_connector* sc) {
}
grpc_security_connector* grpc_security_connector_from_arg(const grpc_arg* arg) {
if (strcmp(arg->key, GRPC_ARG_SECURITY_CONNECTOR)) return NULL;
if (strcmp(arg->key, GRPC_ARG_SECURITY_CONNECTOR)) return nullptr;
if (arg->type != GRPC_ARG_POINTER) {
gpr_log(GPR_ERROR, "Invalid type %d for arg %s", arg->type,
GRPC_ARG_SECURITY_CONNECTOR);
return NULL;
return nullptr;
}
return (grpc_security_connector*)arg->value.pointer.p;
}
@ -267,13 +267,13 @@ grpc_security_connector* grpc_security_connector_from_arg(const grpc_arg* arg) {
grpc_security_connector* grpc_security_connector_find_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_security_connector* sc =
grpc_security_connector_from_arg(&args->args[i]);
if (sc != NULL) return sc;
}
return NULL;
return nullptr;
}
static tsi_client_certificate_request_type
@ -326,9 +326,9 @@ static void fake_server_destroy(grpc_exec_ctx* exec_ctx,
static bool fake_check_target(const char* target_type, const char* target,
const char* set_str) {
GPR_ASSERT(target_type != NULL);
GPR_ASSERT(target != NULL);
char** set = NULL;
GPR_ASSERT(target_type != nullptr);
GPR_ASSERT(target != nullptr);
char** set = nullptr;
size_t set_size = 0;
gpr_string_split(set_str, ",", &set, &set_size);
bool found = false;
@ -345,8 +345,8 @@ static bool fake_check_target(const char* target_type, const char* target,
static void fake_secure_name_check(const char* target,
const char* expected_targets,
bool is_lb_channel) {
if (expected_targets == NULL) return;
char** lbs_and_backends = NULL;
if (expected_targets == nullptr) return;
char** lbs_and_backends = nullptr;
size_t lbs_and_backends_size = 0;
bool success = false;
gpr_string_split(expected_targets, ";", &lbs_and_backends,
@ -392,18 +392,18 @@ static void fake_check_peer(grpc_exec_ctx* exec_ctx,
grpc_closure* on_peer_checked) {
const char* prop_name;
grpc_error* error = GRPC_ERROR_NONE;
*auth_context = NULL;
*auth_context = nullptr;
if (peer.property_count != 1) {
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Fake peers should only have 1 property.");
goto end;
}
prop_name = peer.properties[0].name;
if (prop_name == NULL ||
if (prop_name == nullptr ||
strcmp(prop_name, TSI_CERTIFICATE_TYPE_PEER_PROPERTY)) {
char* msg;
gpr_asprintf(&msg, "Unexpected property in fake peer: %s.",
prop_name == NULL ? "<EMPTY>" : prop_name);
prop_name == nullptr ? "<EMPTY>" : prop_name);
error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg);
goto end;
@ -414,7 +414,7 @@ static void fake_check_peer(grpc_exec_ctx* exec_ctx,
"Invalid value for cert type property.");
goto end;
}
*auth_context = grpc_auth_context_create(NULL);
*auth_context = grpc_auth_context_create(nullptr);
grpc_auth_context_add_cstring_property(
*auth_context, GRPC_TRANSPORT_SECURITY_TYPE_PROPERTY_NAME,
GRPC_FAKE_TRANSPORT_SECURITY_TYPE);
@ -450,7 +450,7 @@ static int fake_channel_cmp(grpc_security_connector* sc1,
if (c != 0) return c;
c = strcmp(c1->target, c2->target);
if (c != 0) return c;
if (c1->expected_targets == NULL || c2->expected_targets == NULL) {
if (c1->expected_targets == nullptr || c2->expected_targets == nullptr) {
c = GPR_ICMP(c1->expected_targets, c2->expected_targets);
} else {
c = strcmp(c1->expected_targets, c2->expected_targets);
@ -525,7 +525,7 @@ grpc_channel_security_connector* grpc_fake_channel_security_connector_create(
c->target = gpr_strdup(target);
const char* expected_targets = grpc_fake_transport_get_expected_targets(args);
c->expected_targets = gpr_strdup(expected_targets);
c->is_lb_channel = (grpc_lb_targets_info_find_in_args(args) != NULL);
c->is_lb_channel = (grpc_lb_targets_info_find_in_args(args) != nullptr);
return &c->base;
}
@ -558,11 +558,11 @@ typedef struct {
static bool server_connector_has_cert_config_fetcher(
grpc_ssl_server_security_connector* c) {
GPR_ASSERT(c != NULL);
GPR_ASSERT(c != nullptr);
grpc_ssl_server_credentials* server_creds =
(grpc_ssl_server_credentials*)c->base.server_creds;
GPR_ASSERT(server_creds != NULL);
return server_creds->certificate_config_fetcher.cb != NULL;
GPR_ASSERT(server_creds != nullptr);
return server_creds->certificate_config_fetcher.cb != nullptr;
}
static void ssl_channel_destroy(grpc_exec_ctx* exec_ctx,
@ -572,9 +572,9 @@ static void ssl_channel_destroy(grpc_exec_ctx* exec_ctx,
grpc_channel_credentials_unref(exec_ctx, c->base.channel_creds);
grpc_call_credentials_unref(exec_ctx, c->base.request_metadata_creds);
tsi_ssl_client_handshaker_factory_unref(c->client_handshaker_factory);
c->client_handshaker_factory = NULL;
if (c->target_name != NULL) gpr_free(c->target_name);
if (c->overridden_target_name != NULL) gpr_free(c->overridden_target_name);
c->client_handshaker_factory = nullptr;
if (c->target_name != nullptr) gpr_free(c->target_name);
if (c->overridden_target_name != nullptr) gpr_free(c->overridden_target_name);
gpr_free(sc);
}
@ -584,7 +584,7 @@ static void ssl_server_destroy(grpc_exec_ctx* exec_ctx,
(grpc_ssl_server_security_connector*)sc;
grpc_server_credentials_unref(exec_ctx, c->base.server_creds);
tsi_ssl_server_handshaker_factory_unref(c->server_handshaker_factory);
c->server_handshaker_factory = NULL;
c->server_handshaker_factory = nullptr;
gpr_free(sc);
}
@ -594,10 +594,10 @@ static void ssl_channel_add_handshakers(grpc_exec_ctx* exec_ctx,
grpc_ssl_channel_security_connector* c =
(grpc_ssl_channel_security_connector*)sc;
// Instantiate TSI handshaker.
tsi_handshaker* tsi_hs = NULL;
tsi_handshaker* tsi_hs = nullptr;
tsi_result result = tsi_ssl_client_handshaker_factory_create_handshaker(
c->client_handshaker_factory,
c->overridden_target_name != NULL ? c->overridden_target_name
c->overridden_target_name != nullptr ? c->overridden_target_name
: c->target_name,
&tsi_hs);
if (result != TSI_OK) {
@ -630,7 +630,7 @@ static const char** fill_alpn_protocol_strings(size_t* num_alpn_protocols) {
static bool try_replace_server_handshaker_factory(
grpc_ssl_server_security_connector* sc,
const grpc_ssl_server_certificate_config* config) {
if (config == NULL) {
if (config == nullptr) {
gpr_log(GPR_ERROR,
"Server certificate config callback returned invalid (NULL) "
"config.");
@ -643,7 +643,7 @@ static bool try_replace_server_handshaker_factory(
fill_alpn_protocol_strings(&num_alpn_protocols);
tsi_ssl_pem_key_cert_pair* cert_pairs = grpc_convert_grpc_to_tsi_cert_pairs(
config->pem_key_cert_pairs, config->num_key_cert_pairs);
tsi_ssl_server_handshaker_factory* new_handshaker_factory = NULL;
tsi_ssl_server_handshaker_factory* new_handshaker_factory = nullptr;
grpc_ssl_server_credentials* server_creds =
(grpc_ssl_server_credentials*)sc->base.server_creds;
tsi_result result = tsi_create_ssl_server_handshaker_factory_ex(
@ -670,10 +670,10 @@ static bool try_replace_server_handshaker_factory(
* an error. Returns true if new credentials were sucessfully loaded. */
static bool try_fetch_ssl_server_credentials(
grpc_ssl_server_security_connector* sc) {
grpc_ssl_server_certificate_config* certificate_config = NULL;
grpc_ssl_server_certificate_config* certificate_config = nullptr;
bool status;
GPR_ASSERT(sc != NULL);
GPR_ASSERT(sc != nullptr);
if (!server_connector_has_cert_config_fetcher(sc)) return false;
grpc_ssl_server_credentials* server_creds =
@ -695,7 +695,7 @@ static bool try_fetch_ssl_server_credentials(
status = false;
}
if (certificate_config != NULL) {
if (certificate_config != nullptr) {
grpc_ssl_server_certificate_config_destroy(certificate_config);
}
return status;
@ -708,7 +708,7 @@ static void ssl_server_add_handshakers(grpc_exec_ctx* exec_ctx,
(grpc_ssl_server_security_connector*)sc;
// Instantiate TSI handshaker.
try_fetch_ssl_server_credentials(c);
tsi_handshaker* tsi_hs = NULL;
tsi_handshaker* tsi_hs = nullptr;
tsi_result result = tsi_ssl_server_handshaker_factory_create_handshaker(
c->server_handshaker_factory, &tsi_hs);
if (result != TSI_OK) {
@ -724,10 +724,10 @@ static void ssl_server_add_handshakers(grpc_exec_ctx* exec_ctx,
}
static int ssl_host_matches_name(const tsi_peer* peer, const char* peer_name) {
char* allocated_name = NULL;
char* allocated_name = nullptr;
int r;
if (strchr(peer_name, ':') != NULL) {
if (strchr(peer_name, ':') != nullptr) {
char* ignored_port;
gpr_split_host_port(peer_name, &allocated_name, &ignored_port);
gpr_free(ignored_port);
@ -741,12 +741,12 @@ static int ssl_host_matches_name(const tsi_peer* peer, const char* peer_name) {
grpc_auth_context* tsi_ssl_peer_to_auth_context(const tsi_peer* peer) {
size_t i;
grpc_auth_context* ctx = NULL;
const char* peer_identity_property_name = NULL;
grpc_auth_context* ctx = nullptr;
const char* peer_identity_property_name = nullptr;
/* The caller has checked the certificate type property. */
GPR_ASSERT(peer->property_count >= 1);
ctx = grpc_auth_context_create(NULL);
ctx = grpc_auth_context_create(nullptr);
grpc_auth_context_add_cstring_property(
ctx, GRPC_TRANSPORT_SECURITY_TYPE_PROPERTY_NAME,
GRPC_SSL_TRANSPORT_SECURITY_TYPE);
@ -770,7 +770,7 @@ grpc_auth_context* tsi_ssl_peer_to_auth_context(const tsi_peer* peer) {
prop->value.data, prop->value.length);
}
}
if (peer_identity_property_name != NULL) {
if (peer_identity_property_name != nullptr) {
GPR_ASSERT(grpc_auth_context_set_peer_identity_property_name(
ctx, peer_identity_property_name) == 1);
}
@ -783,7 +783,7 @@ static grpc_error* ssl_check_peer(grpc_security_connector* sc,
/* Check the ALPN. */
const tsi_peer_property* p =
tsi_peer_get_property_by_name(peer, TSI_SSL_ALPN_SELECTED_PROTOCOL);
if (p == NULL) {
if (p == nullptr) {
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Cannot check peer: missing selected ALPN property.");
}
@ -793,7 +793,7 @@ static grpc_error* ssl_check_peer(grpc_security_connector* sc,
}
/* Check the peer name if specified. */
if (peer_name != NULL && !ssl_host_matches_name(peer, peer_name)) {
if (peer_name != nullptr && !ssl_host_matches_name(peer, peer_name)) {
char* msg;
gpr_asprintf(&msg, "Peer name %s is not in peer certificate", peer_name);
grpc_error* error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
@ -811,7 +811,7 @@ static void ssl_channel_check_peer(grpc_exec_ctx* exec_ctx,
grpc_ssl_channel_security_connector* c =
(grpc_ssl_channel_security_connector*)sc;
grpc_error* error = ssl_check_peer(sc,
c->overridden_target_name != NULL
c->overridden_target_name != nullptr
? c->overridden_target_name
: c->target_name,
&peer, auth_context);
@ -823,7 +823,7 @@ static void ssl_server_check_peer(grpc_exec_ctx* exec_ctx,
grpc_security_connector* sc, tsi_peer peer,
grpc_auth_context** auth_context,
grpc_closure* on_peer_checked) {
grpc_error* error = ssl_check_peer(sc, NULL, &peer, auth_context);
grpc_error* error = ssl_check_peer(sc, nullptr, &peer, auth_context);
tsi_peer_destruct(&peer);
GRPC_CLOSURE_SCHED(exec_ctx, on_peer_checked, error);
}
@ -838,8 +838,8 @@ static int ssl_channel_cmp(grpc_security_connector* sc1,
if (c != 0) return c;
c = strcmp(c1->target_name, c2->target_name);
if (c != 0) return c;
return (c1->overridden_target_name == NULL ||
c2->overridden_target_name == NULL)
return (c1->overridden_target_name == nullptr ||
c2->overridden_target_name == nullptr)
? GPR_ICMP(c1->overridden_target_name, c2->overridden_target_name)
: strcmp(c1->overridden_target_name, c2->overridden_target_name);
}
@ -875,7 +875,7 @@ tsi_peer tsi_shallow_peer_from_ssl_auth_context(
peer.properties = (tsi_peer_property*)gpr_malloc(max_num_props *
sizeof(tsi_peer_property));
it = grpc_auth_context_property_iterator(auth_context);
while ((prop = grpc_auth_property_iterator_next(&it)) != NULL) {
while ((prop = grpc_auth_property_iterator_next(&it)) != nullptr) {
if (strcmp(prop->name, GRPC_X509_SAN_PROPERTY_NAME) == 0) {
add_shallow_auth_property_to_peer(
&peer, prop, TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY);
@ -892,7 +892,7 @@ tsi_peer tsi_shallow_peer_from_ssl_auth_context(
}
void tsi_shallow_peer_destruct(tsi_peer* peer) {
if (peer->properties != NULL) gpr_free(peer->properties);
if (peer->properties != nullptr) gpr_free(peer->properties);
}
static bool ssl_channel_check_call_host(grpc_exec_ctx* exec_ctx,
@ -909,7 +909,7 @@ static bool ssl_channel_check_call_host(grpc_exec_ctx* exec_ctx,
/* If the target name was overridden, then the original target_name was
'checked' transitively during the previous peer check at the end of the
handshake. */
if (c->overridden_target_name != NULL && strcmp(host, c->target_name) == 0) {
if (c->overridden_target_name != nullptr && strcmp(host, c->target_name) == 0) {
status = GRPC_SECURITY_OK;
}
if (status != GRPC_SECURITY_OK) {
@ -939,7 +939,7 @@ static grpc_slice compute_default_pem_root_certs_once(void) {
/* First try to load the roots from the environment. */
char* default_root_certs_path =
gpr_getenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR);
if (default_root_certs_path != NULL) {
if (default_root_certs_path != nullptr) {
GRPC_LOG_IF_ERROR("load_file",
grpc_load_file(default_root_certs_path, 1, &result));
gpr_free(default_root_certs_path);
@ -948,10 +948,10 @@ 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) {
char* pem_root_certs = NULL;
char* pem_root_certs = nullptr;
ovrd_res = ssl_roots_override_cb(&pem_root_certs);
if (ovrd_res == GRPC_SSL_ROOTS_OVERRIDE_OK) {
GPR_ASSERT(pem_root_certs != NULL);
GPR_ASSERT(pem_root_certs != nullptr);
result = grpc_slice_from_copied_buffer(
pem_root_certs,
strlen(pem_root_certs) + 1); // NULL terminator.
@ -1002,13 +1002,13 @@ grpc_security_status grpc_ssl_channel_security_connector_create(
char* port;
bool has_key_cert_pair;
if (config == NULL || target_name == NULL) {
if (config == nullptr || target_name == nullptr) {
gpr_log(GPR_ERROR, "An ssl channel needs a config and a target name.");
goto error;
}
if (config->pem_root_certs == NULL) {
if (config->pem_root_certs == nullptr) {
pem_root_certs = grpc_get_default_ssl_roots();
if (pem_root_certs == NULL) {
if (pem_root_certs == nullptr) {
gpr_log(GPR_ERROR, "Could not get default pem root certs.");
goto error;
}
@ -1030,13 +1030,13 @@ grpc_security_status grpc_ssl_channel_security_connector_create(
c->base.add_handshakers = ssl_channel_add_handshakers;
gpr_split_host_port(target_name, &c->target_name, &port);
gpr_free(port);
if (overridden_target_name != NULL) {
if (overridden_target_name != nullptr) {
c->overridden_target_name = gpr_strdup(overridden_target_name);
}
has_key_cert_pair = config->pem_key_cert_pair != NULL &&
config->pem_key_cert_pair->private_key != NULL &&
config->pem_key_cert_pair->cert_chain != NULL;
has_key_cert_pair = config->pem_key_cert_pair != nullptr &&
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,
ssl_cipher_suites(), alpn_protocol_strings, (uint16_t)num_alpn_protocols,
@ -1045,7 +1045,7 @@ grpc_security_status grpc_ssl_channel_security_connector_create(
gpr_log(GPR_ERROR, "Handshaker factory creation failed with %s.",
tsi_result_to_string(result));
ssl_channel_destroy(exec_ctx, &c->base.base);
*sc = NULL;
*sc = nullptr;
goto error;
}
*sc = &c->base;
@ -1079,8 +1079,8 @@ grpc_security_status grpc_ssl_server_security_connector_create(
(grpc_ssl_server_credentials*)gsc;
grpc_security_status retval = GRPC_SECURITY_OK;
GPR_ASSERT(server_credentials != NULL);
GPR_ASSERT(sc != NULL);
GPR_ASSERT(server_credentials != nullptr);
GPR_ASSERT(sc != nullptr);
grpc_ssl_server_security_connector* c =
grpc_ssl_server_security_connector_initialize(gsc);
@ -1113,8 +1113,8 @@ grpc_security_status grpc_ssl_server_security_connector_create(
if (retval == GRPC_SECURITY_OK) {
*sc = &c->base;
} else {
if (c != NULL) ssl_server_destroy(exec_ctx, &c->base.base);
if (sc != NULL) *sc = NULL;
if (c != nullptr) ssl_server_destroy(exec_ctx, &c->base.base);
if (sc != nullptr) *sc = nullptr;
}
return retval;
}

@ -306,7 +306,7 @@ void* grpc_call_arena_alloc(grpc_call* call, size_t size) {
static parent_call* get_or_create_parent_call(grpc_call* call) {
parent_call* p = (parent_call*)gpr_atm_acq_load(&call->parent_call_atm);
if (p == NULL) {
if (p == nullptr) {
p = (parent_call*)gpr_arena_alloc(call->arena, sizeof(*p));
gpr_mu_init(&p->child_list_mu);
if (!gpr_atm_rel_cas(&call->parent_call_atm, (gpr_atm)NULL, (gpr_atm)p)) {
@ -344,7 +344,7 @@ grpc_error* grpc_call_create(grpc_exec_ctx* exec_ctx,
call->start_time = gpr_now(GPR_CLOCK_MONOTONIC);
/* Always support no compression */
GPR_BITSET(&call->encodings_accepted_by_peer, GRPC_COMPRESS_NONE);
call->is_client = args->server_transport_data == NULL;
call->is_client = args->server_transport_data == nullptr;
if (call->is_client) {
GRPC_STATS_INC_CLIENT_CALLS_CREATED(exec_ctx);
} else {
@ -377,7 +377,7 @@ grpc_error* grpc_call_create(grpc_exec_ctx* exec_ctx,
bool immediately_cancel = false;
if (args->parent != NULL) {
if (args->parent != nullptr) {
child_call* cc = call->child =
(child_call*)gpr_arena_alloc(arena, sizeof(child_call));
call->child->parent = args->parent;
@ -405,7 +405,7 @@ grpc_error* grpc_call_create(grpc_exec_ctx* exec_ctx,
}
grpc_call_context_set(call, GRPC_CONTEXT_TRACING,
args->parent->context[GRPC_CONTEXT_TRACING].value,
NULL);
nullptr);
} else if (args->propagation_mask & GRPC_PROPAGATE_CENSUS_STATS_CONTEXT) {
add_init_error(&error, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Census context propagation requested "
@ -418,7 +418,7 @@ grpc_error* grpc_call_create(grpc_exec_ctx* exec_ctx,
}
}
if (pc->first_child == NULL) {
if (pc->first_child == nullptr) {
pc->first_child = call;
cc->sibling_next = cc->sibling_prev = call;
} else {
@ -453,15 +453,15 @@ grpc_error* grpc_call_create(grpc_exec_ctx* exec_ctx,
cancel_with_error(exec_ctx, call, STATUS_FROM_API_OVERRIDE,
GRPC_ERROR_CANCELLED);
}
if (args->cq != NULL) {
if (args->cq != nullptr) {
GPR_ASSERT(
args->pollset_set_alternative == NULL &&
args->pollset_set_alternative == nullptr &&
"Only one of 'cq' and 'pollset_set_alternative' should be non-NULL.");
GRPC_CQ_INTERNAL_REF(args->cq, "bind");
call->pollent =
grpc_polling_entity_create_from_pollset(grpc_cq_pollset(args->cq));
}
if (args->pollset_set_alternative != NULL) {
if (args->pollset_set_alternative != nullptr) {
call->pollent = grpc_polling_entity_create_from_pollset_set(
args->pollset_set_alternative);
}
@ -480,7 +480,7 @@ void grpc_call_set_completion_queue(grpc_exec_ctx* exec_ctx, grpc_call* call,
grpc_completion_queue* cq) {
GPR_ASSERT(cq);
if (grpc_polling_entity_pollset_set(&call->pollent) != NULL) {
if (grpc_polling_entity_pollset_set(&call->pollent) != nullptr) {
gpr_log(GPR_ERROR, "A pollset_set is already registered for this call.");
abort();
}
@ -526,11 +526,11 @@ static void destroy_call(grpc_exec_ctx* exec_ctx, void* call,
grpc_metadata_batch_destroy(
exec_ctx, &c->metadata_batch[1 /* is_receiving */][i /* is_initial */]);
}
if (c->receiving_stream != NULL) {
if (c->receiving_stream != nullptr) {
grpc_byte_stream_destroy(exec_ctx, c->receiving_stream);
}
parent_call* pc = get_parent_call(c);
if (pc != NULL) {
if (pc != nullptr) {
gpr_mu_destroy(&pc->child_list_mu);
}
for (ii = 0; ii < c->send_extra_metadata_count; ii++) {
@ -546,7 +546,7 @@ static void destroy_call(grpc_exec_ctx* exec_ctx, void* call,
}
get_final_status(exec_ctx, c, set_status_value_directly,
&c->final_info.final_status, NULL);
&c->final_info.final_status, nullptr);
c->final_info.stats.latency =
gpr_time_sub(gpr_now(GPR_CLOCK_MONOTONIC), c->start_time);
@ -578,7 +578,7 @@ void grpc_call_unref(grpc_call* c) {
if (c == pc->first_child) {
pc->first_child = cc->sibling_next;
if (c == pc->first_child) {
pc->first_child = NULL;
pc->first_child = nullptr;
}
}
cc->sibling_prev->child->sibling_next = cc->sibling_next;
@ -599,7 +599,7 @@ void grpc_call_unref(grpc_call* c) {
// effect of scheduling the previously set cancellation closure, if
// any, so that it can release any internal references it may be
// holding to the call stack.
grpc_call_combiner_set_notify_on_cancel(&exec_ctx, &c->call_combiner, NULL);
grpc_call_combiner_set_notify_on_cancel(&exec_ctx, &c->call_combiner, nullptr);
}
GRPC_CALL_INTERNAL_UNREF(&exec_ctx, c, "destroy");
grpc_exec_ctx_finish(&exec_ctx);
@ -643,9 +643,9 @@ static void execute_batch(grpc_exec_ctx* exec_ctx, grpc_call* call,
char* grpc_call_get_peer(grpc_call* call) {
char* peer_string = (char*)gpr_atm_acq_load(&call->peer_string);
if (peer_string != NULL) return gpr_strdup(peer_string);
if (peer_string != nullptr) return gpr_strdup(peer_string);
peer_string = grpc_channel_get_target(call->channel);
if (peer_string != NULL) return peer_string;
if (peer_string != nullptr) return peer_string;
return gpr_strdup("unknown");
}
@ -666,7 +666,7 @@ grpc_call_error grpc_call_cancel_with_status(grpc_call* c,
"grpc_call_cancel_with_status("
"c=%p, status=%d, description=%s, reserved=%p)",
4, (c, (int)status, description, reserved));
GPR_ASSERT(reserved == NULL);
GPR_ASSERT(reserved == nullptr);
cancel_with_status(&exec_ctx, c, STATUS_FROM_API_OVERRIDE, status,
description);
grpc_exec_ctx_finish(&exec_ctx);
@ -741,13 +741,13 @@ static bool get_final_status_from(grpc_exec_ctx* exec_ctx, grpc_call* call,
grpc_status_code code;
grpc_slice slice = grpc_empty_slice();
grpc_error_get_status(exec_ctx, error, call->send_deadline, &code, &slice,
NULL);
nullptr);
if (code == GRPC_STATUS_OK && !allow_ok_status) {
return false;
}
set_value(code, set_value_user_data);
if (details != NULL) {
if (details != nullptr) {
*details = grpc_slice_ref_internal(slice);
}
return true;
@ -867,7 +867,7 @@ static void set_encodings_accepted_by_peer(grpc_exec_ctx* exec_ctx,
accepted_user_data =
grpc_mdelem_get_user_data(mdel, destroy_encodings_accepted_by_peer);
if (accepted_user_data != NULL) {
if (accepted_user_data != nullptr) {
call->encodings_accepted_by_peer =
(uint32_t)(((uintptr_t)accepted_user_data) - 1);
return;
@ -914,7 +914,7 @@ static void set_stream_encodings_accepted_by_peer(grpc_exec_ctx* exec_ctx,
accepted_user_data =
grpc_mdelem_get_user_data(mdel, destroy_encodings_accepted_by_peer);
if (accepted_user_data != NULL) {
if (accepted_user_data != nullptr) {
call->stream_encodings_accepted_by_peer =
(uint32_t)(((uintptr_t)accepted_user_data) - 1);
return;
@ -1051,7 +1051,7 @@ static uint32_t decode_status(grpc_mdelem md) {
if (grpc_mdelem_eq(md, GRPC_MDELEM_GRPC_STATUS_1)) return 1;
if (grpc_mdelem_eq(md, GRPC_MDELEM_GRPC_STATUS_2)) return 2;
user_data = grpc_mdelem_get_user_data(md, destroy_status);
if (user_data != NULL) {
if (user_data != nullptr) {
status = ((uint32_t)(intptr_t)user_data) - STATUS_OFFSET;
} else {
if (!grpc_parse_slice_to_uint32(GRPC_MDVALUE(md), &status)) {
@ -1107,7 +1107,7 @@ static void publish_app_metadata(grpc_call* call, grpc_metadata_batch* b,
dest->metadata = (grpc_metadata*)gpr_realloc(
dest->metadata, sizeof(grpc_metadata) * dest->capacity);
}
for (grpc_linked_mdelem* l = b->list.head; l != NULL; l = l->next) {
for (grpc_linked_mdelem* l = b->list.head; l != nullptr; l = l->next) {
mdusr = &dest->metadata[dest->count++];
/* we pass back borrowed slices that are valid whilst the call is valid */
mdusr->key = GRPC_MDKEY(l->md);
@ -1118,8 +1118,8 @@ static void publish_app_metadata(grpc_call* call, grpc_metadata_batch* b,
static void recv_initial_filter(grpc_exec_ctx* exec_ctx, grpc_call* call,
grpc_metadata_batch* b) {
if (b->idx.named.content_encoding != NULL) {
if (b->idx.named.grpc_encoding != NULL) {
if (b->idx.named.content_encoding != nullptr) {
if (b->idx.named.grpc_encoding != nullptr) {
gpr_log(GPR_ERROR,
"Received both content-encoding and grpc-encoding header. "
"Ignoring grpc-encoding.");
@ -1130,21 +1130,21 @@ static void recv_initial_filter(grpc_exec_ctx* exec_ctx, grpc_call* call,
call, decode_stream_compression(b->idx.named.content_encoding->md));
GPR_TIMER_END("incoming_stream_compression_algorithm", 0);
grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.content_encoding);
} else if (b->idx.named.grpc_encoding != NULL) {
} else if (b->idx.named.grpc_encoding != nullptr) {
GPR_TIMER_BEGIN("incoming_compression_algorithm", 0);
set_incoming_compression_algorithm(
call, decode_compression(b->idx.named.grpc_encoding->md));
GPR_TIMER_END("incoming_compression_algorithm", 0);
grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.grpc_encoding);
}
if (b->idx.named.grpc_accept_encoding != NULL) {
if (b->idx.named.grpc_accept_encoding != nullptr) {
GPR_TIMER_BEGIN("encodings_accepted_by_peer", 0);
set_encodings_accepted_by_peer(exec_ctx, call,
b->idx.named.grpc_accept_encoding->md);
grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.grpc_accept_encoding);
GPR_TIMER_END("encodings_accepted_by_peer", 0);
}
if (b->idx.named.accept_encoding != NULL) {
if (b->idx.named.accept_encoding != nullptr) {
GPR_TIMER_BEGIN("stream_encodings_accepted_by_peer", 0);
set_stream_encodings_accepted_by_peer(exec_ctx, call,
b->idx.named.accept_encoding->md);
@ -1157,7 +1157,7 @@ static void recv_initial_filter(grpc_exec_ctx* exec_ctx, grpc_call* call,
static void recv_trailing_filter(grpc_exec_ctx* exec_ctx, void* args,
grpc_metadata_batch* b) {
grpc_call* call = (grpc_call*)args;
if (b->idx.named.grpc_status != NULL) {
if (b->idx.named.grpc_status != nullptr) {
uint32_t status_code = decode_status(b->idx.named.grpc_status->md);
grpc_error* error =
status_code == GRPC_STATUS_OK
@ -1166,7 +1166,7 @@ static void recv_trailing_filter(grpc_exec_ctx* exec_ctx, void* args,
"Error received from peer"),
GRPC_ERROR_INT_GRPC_STATUS,
(intptr_t)status_code);
if (b->idx.named.grpc_message != NULL) {
if (b->idx.named.grpc_message != nullptr) {
error = grpc_error_set_str(
error, GRPC_ERROR_STR_GRPC_MESSAGE,
grpc_slice_ref_internal(GRPC_MDVALUE(b->idx.named.grpc_message->md)));
@ -1239,13 +1239,13 @@ static batch_control* allocate_batch_control(grpc_call* call,
size_t num_ops) {
int slot = batch_slot_for_op(ops[0].op);
batch_control** pslot = &call->active_batches[slot];
if (*pslot == NULL) {
if (*pslot == nullptr) {
*pslot =
(batch_control*)gpr_arena_alloc(call->arena, sizeof(batch_control));
}
batch_control* bctl = *pslot;
if (bctl->call != NULL) {
return NULL;
if (bctl->call != nullptr) {
return nullptr;
}
memset(bctl, 0, sizeof(*bctl));
bctl->call = call;
@ -1257,7 +1257,7 @@ static void finish_batch_completion(grpc_exec_ctx* exec_ctx, void* user_data,
grpc_cq_completion* storage) {
batch_control* bctl = (batch_control*)user_data;
grpc_call* call = bctl->call;
bctl->call = NULL;
bctl->call = nullptr;
GRPC_CALL_INTERNAL_UNREF(exec_ctx, call, "completion");
}
@ -1269,7 +1269,7 @@ static grpc_error* consolidate_batch_errors(batch_control* bctl) {
/* Skip creating a composite error in the case that only one error was
logged */
grpc_error* e = bctl->errors[0];
bctl->errors[0] = NULL;
bctl->errors[0] = nullptr;
return e;
} else {
grpc_error* error = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
@ -1309,11 +1309,11 @@ static void post_batch_completion(grpc_exec_ctx* exec_ctx,
/* propagate cancellation to any interested children */
gpr_atm_rel_store(&call->received_final_op_atm, 1);
parent_call* pc = get_parent_call(call);
if (pc != NULL) {
if (pc != nullptr) {
grpc_call* child;
gpr_mu_lock(&pc->child_list_mu);
child = pc->first_child;
if (child != NULL) {
if (child != nullptr) {
do {
next_child_call = child->child->sibling_next;
if (child->cancellation_is_inherited) {
@ -1334,21 +1334,21 @@ static void post_batch_completion(grpc_exec_ctx* exec_ctx,
call->final_op.client.status_details);
} else {
get_final_status(exec_ctx, call, set_cancelled_value,
call->final_op.server.cancelled, NULL);
call->final_op.server.cancelled, nullptr);
}
GRPC_ERROR_UNREF(error);
error = GRPC_ERROR_NONE;
}
if (error != GRPC_ERROR_NONE && bctl->op.recv_message &&
*call->receiving_buffer != NULL) {
*call->receiving_buffer != nullptr) {
grpc_byte_buffer_destroy(*call->receiving_buffer);
*call->receiving_buffer = NULL;
*call->receiving_buffer = nullptr;
}
if (bctl->completion_data.notify_tag.is_closure) {
/* unrefs bctl->error */
bctl->call = NULL;
bctl->call = nullptr;
GRPC_CLOSURE_RUN(
exec_ctx, (grpc_closure*)bctl->completion_data.notify_tag.tag, error);
GRPC_CALL_INTERNAL_UNREF(exec_ctx, call, "completion");
@ -1376,7 +1376,7 @@ static void continue_receiving_slices(grpc_exec_ctx* exec_ctx,
if (remaining == 0) {
call->receiving_message = 0;
grpc_byte_stream_destroy(exec_ctx, call->receiving_stream);
call->receiving_stream = NULL;
call->receiving_stream = nullptr;
finish_batch_step(exec_ctx, bctl);
return;
}
@ -1389,9 +1389,9 @@ static void continue_receiving_slices(grpc_exec_ctx* exec_ctx,
call->receiving_slice);
} else {
grpc_byte_stream_destroy(exec_ctx, call->receiving_stream);
call->receiving_stream = NULL;
call->receiving_stream = nullptr;
grpc_byte_buffer_destroy(*call->receiving_buffer);
*call->receiving_buffer = NULL;
*call->receiving_buffer = nullptr;
call->receiving_message = 0;
finish_batch_step(exec_ctx, bctl);
return;
@ -1428,9 +1428,9 @@ static void receiving_slice_ready(grpc_exec_ctx* exec_ctx, void* bctlp,
GRPC_LOG_IF_ERROR("receiving_slice_ready", GRPC_ERROR_REF(error));
}
grpc_byte_stream_destroy(exec_ctx, call->receiving_stream);
call->receiving_stream = NULL;
call->receiving_stream = nullptr;
grpc_byte_buffer_destroy(*call->receiving_buffer);
*call->receiving_buffer = NULL;
*call->receiving_buffer = nullptr;
call->receiving_message = 0;
finish_batch_step(exec_ctx, bctl);
if (release_error) {
@ -1442,8 +1442,8 @@ static void receiving_slice_ready(grpc_exec_ctx* exec_ctx, void* bctlp,
static void process_data_after_md(grpc_exec_ctx* exec_ctx,
batch_control* bctl) {
grpc_call* call = bctl->call;
if (call->receiving_stream == NULL) {
*call->receiving_buffer = NULL;
if (call->receiving_stream == nullptr) {
*call->receiving_buffer = nullptr;
call->receiving_message = 0;
finish_batch_step(exec_ctx, bctl);
} else {
@ -1466,9 +1466,9 @@ static void receiving_stream_ready(grpc_exec_ctx* exec_ctx, void* bctlp,
batch_control* bctl = (batch_control*)bctlp;
grpc_call* call = bctl->call;
if (error != GRPC_ERROR_NONE) {
if (call->receiving_stream != NULL) {
if (call->receiving_stream != nullptr) {
grpc_byte_stream_destroy(exec_ctx, call->receiving_stream);
call->receiving_stream = NULL;
call->receiving_stream = nullptr;
}
add_batch_error(exec_ctx, bctl, GRPC_ERROR_REF(error), true);
cancel_with_error(exec_ctx, call, STATUS_FROM_SURFACE,
@ -1477,7 +1477,7 @@ static void receiving_stream_ready(grpc_exec_ctx* exec_ctx, void* bctlp,
/* If recv_state is RECV_NONE, we will save the batch_control
* object with rel_cas, and will not use it after the cas. Its corresponding
* acq_load is in receiving_initial_metadata_ready() */
if (error != GRPC_ERROR_NONE || call->receiving_stream == NULL ||
if (error != GRPC_ERROR_NONE || call->receiving_stream == nullptr ||
!gpr_atm_rel_cas(&call->recv_state, RECV_NONE, (gpr_atm)bctlp)) {
process_data_after_md(exec_ctx, bctl);
}
@ -1503,7 +1503,7 @@ static void validate_filtered_metadata(grpc_exec_ctx* exec_ctx,
GRPC_STREAM_COMPRESS_NONE) {
const grpc_stream_compression_algorithm algo =
call->incoming_stream_compression_algorithm;
char* error_msg = NULL;
char* error_msg = nullptr;
const grpc_compression_options compression_options =
grpc_channel_compression_options(call->channel);
if (algo >= GRPC_STREAM_COMPRESS_ALGORITHMS_COUNT) {
@ -1515,7 +1515,7 @@ static void validate_filtered_metadata(grpc_exec_ctx* exec_ctx,
} else if (grpc_compression_options_is_stream_compression_algorithm_enabled(
&compression_options, algo) == 0) {
/* check if algorithm is supported by current channel config */
const char* algo_name = NULL;
const char* algo_name = nullptr;
grpc_stream_compression_algorithm_name(algo, &algo_name);
gpr_asprintf(&error_msg, "Stream compression algorithm '%s' is disabled.",
algo_name);
@ -1529,7 +1529,7 @@ static void validate_filtered_metadata(grpc_exec_ctx* exec_ctx,
if (!GPR_BITGET(call->stream_encodings_accepted_by_peer,
call->incoming_stream_compression_algorithm)) {
if (grpc_compression_trace.enabled()) {
const char* algo_name = NULL;
const char* algo_name = nullptr;
grpc_stream_compression_algorithm_name(
call->incoming_stream_compression_algorithm, &algo_name);
gpr_log(
@ -1543,7 +1543,7 @@ static void validate_filtered_metadata(grpc_exec_ctx* exec_ctx,
} else if (call->incoming_compression_algorithm != GRPC_COMPRESS_NONE) {
const grpc_compression_algorithm algo =
call->incoming_compression_algorithm;
char* error_msg = NULL;
char* error_msg = nullptr;
const grpc_compression_options compression_options =
grpc_channel_compression_options(call->channel);
/* check if algorithm is known */
@ -1556,7 +1556,7 @@ static void validate_filtered_metadata(grpc_exec_ctx* exec_ctx,
} else if (grpc_compression_options_is_algorithm_enabled(
&compression_options, algo) == 0) {
/* check if algorithm is supported by current channel config */
const char* algo_name = NULL;
const char* algo_name = nullptr;
grpc_compression_algorithm_name(algo, &algo_name);
gpr_asprintf(&error_msg, "Compression algorithm '%s' is disabled.",
algo_name);
@ -1572,7 +1572,7 @@ static void validate_filtered_metadata(grpc_exec_ctx* exec_ctx,
if (!GPR_BITGET(call->encodings_accepted_by_peer,
call->incoming_compression_algorithm)) {
if (grpc_compression_trace.enabled()) {
const char* algo_name = NULL;
const char* algo_name = nullptr;
grpc_compression_algorithm_name(call->incoming_compression_algorithm,
&algo_name);
gpr_log(GPR_ERROR,
@ -1620,7 +1620,7 @@ static void receiving_initial_metadata_ready(grpc_exec_ctx* exec_ctx,
}
}
grpc_closure* saved_rsr_closure = NULL;
grpc_closure* saved_rsr_closure = nullptr;
while (true) {
gpr_atm rsr_bctlp = gpr_atm_acq_load(&call->recv_state);
/* Should only receive initial metadata once */
@ -1644,7 +1644,7 @@ static void receiving_initial_metadata_ready(grpc_exec_ctx* exec_ctx,
break;
}
}
if (saved_rsr_closure != NULL) {
if (saved_rsr_closure != nullptr) {
GRPC_CLOSURE_RUN(exec_ctx, saved_rsr_closure, GRPC_ERROR_REF(error));
}
@ -1695,7 +1695,7 @@ static grpc_call_error call_start_batch(grpc_exec_ctx* exec_ctx,
}
bctl = allocate_batch_control(call, ops, nops);
if (bctl == NULL) {
if (bctl == nullptr) {
return GRPC_CALL_ERROR_TOO_MANY_OPERATIONS;
}
bctl->completion_data.notify_tag.tag = notify_tag;
@ -2080,7 +2080,7 @@ grpc_call_error grpc_call_start_batch(grpc_call* call, const grpc_op* ops,
"reserved=%p)",
5, (call, ops, (unsigned long)nops, tag, reserved));
if (reserved != NULL) {
if (reserved != nullptr) {
err = GRPC_CALL_ERROR;
} else {
err = call_start_batch(&exec_ctx, call, ops, nops, tag, 0);

Loading…
Cancel
Save