diff options
author | 2017-11-13 17:08:48 -0800 | |
---|---|---|
committer | 2017-11-13 17:08:48 -0800 | |
commit | 6870e6f1fdfe150cb5d3b391cf9a6f667e14c50c (patch) | |
tree | 413246709c0d53e0284dcf79e3c99b9a8d0088f5 /src/core/lib/surface/call.cc | |
parent | 68bb1bf7480e87005220003985da19ea0a0929d0 (diff) |
clang tidy
Diffstat (limited to 'src/core/lib/surface/call.cc')
-rw-r--r-- | src/core/lib/surface/call.cc | 122 |
1 files changed, 61 insertions, 61 deletions
diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index 173f6985f7..4e3290ac4d 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -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); |