aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/surface/call.cc
diff options
context:
space:
mode:
authorGravatar Noah Eisen <ncteisen@google.com>2018-02-09 09:16:55 -0800
committerGravatar Noah Eisen <ncteisen@google.com>2018-02-09 09:16:55 -0800
commitbe82e64b3debcdb1d9ec6a149fc85af0d46bfb7e (patch)
treecc5e1234073eb250a2c319b5a4db2919fce060ea /src/core/lib/surface/call.cc
parent194436342137924b4fb7429bede037a4b5ec7edb (diff)
Autofix c casts to c++ casts
Diffstat (limited to 'src/core/lib/surface/call.cc')
-rw-r--r--src/core/lib/surface/call.cc78
1 files changed, 39 insertions, 39 deletions
diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc
index a7b932b46d..d6949103c7 100644
--- a/src/core/lib/surface/call.cc
+++ b/src/core/lib/surface/call.cc
@@ -97,7 +97,7 @@ static received_status unpack_received_status(gpr_atm atm) {
if ((atm & 1) == 0) {
return {false, GRPC_ERROR_NONE};
} else {
- return {true, (grpc_error*)(atm & ~(gpr_atm)1)};
+ return {true, (grpc_error*)(atm & ~static_cast<gpr_atm>(1))};
}
}
@@ -304,7 +304,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 == nullptr) {
- p = (parent_call*)gpr_arena_alloc(call->arena, sizeof(*p));
+ p = static_cast<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) nullptr,
(gpr_atm)p)) {
@@ -330,8 +330,8 @@ grpc_error* grpc_call_create(const grpc_call_create_args* args,
size_t initial_size = grpc_channel_get_call_size_estimate(args->channel);
GRPC_STATS_INC_CALL_INITIAL_SIZE(initial_size);
gpr_arena* arena = gpr_arena_create(initial_size);
- call = (grpc_call*)gpr_arena_alloc(
- arena, sizeof(grpc_call) + channel_stack->call_stack_size);
+ call = static_cast<grpc_call*>(gpr_arena_alloc(
+ arena, sizeof(grpc_call) + channel_stack->call_stack_size));
gpr_ref_init(&call->ext_ref, 1);
call->arena = arena;
grpc_call_combiner_init(&call->call_combiner);
@@ -360,7 +360,7 @@ grpc_error* grpc_call_create(const grpc_call_create_args* args,
GRPC_MDVALUE(args->add_initial_metadata[i]));
}
}
- call->send_extra_metadata_count = (int)args->add_initial_metadata_count;
+ call->send_extra_metadata_count = static_cast<int>(args->add_initial_metadata_count);
} else {
GPR_ASSERT(args->add_initial_metadata_count == 0);
call->send_extra_metadata_count = 0;
@@ -376,7 +376,7 @@ grpc_error* grpc_call_create(const grpc_call_create_args* args,
if (args->parent != nullptr) {
child_call* cc = call->child =
- (child_call*)gpr_arena_alloc(arena, sizeof(child_call));
+ static_cast<child_call*>(gpr_arena_alloc(arena, sizeof(child_call)));
call->child->parent = args->parent;
GRPC_CALL_INTERNAL_REF(args->parent, "child");
@@ -500,7 +500,7 @@ void grpc_call_internal_unref(grpc_call* c REF_ARG) {
}
static void release_call(void* call, grpc_error* error) {
- grpc_call* c = (grpc_call*)call;
+ grpc_call* c = static_cast<grpc_call*>(call);
grpc_channel* channel = c->channel;
grpc_call_combiner_destroy(&c->call_combiner);
gpr_free((char*)c->peer_string);
@@ -513,7 +513,7 @@ static void destroy_call(void* call, grpc_error* error) {
GPR_TIMER_SCOPE("destroy_call", 0);
size_t i;
int ii;
- grpc_call* c = (grpc_call*)call;
+ grpc_call* c = static_cast<grpc_call*>(call);
for (i = 0; i < 2; i++) {
grpc_metadata_batch_destroy(
&c->metadata_batch[1 /* is_receiving */][i /* is_initial */]);
@@ -608,8 +608,8 @@ grpc_call_error grpc_call_cancel(grpc_call* call, void* reserved) {
// the filter stack.
static void execute_batch_in_call_combiner(void* arg, grpc_error* ignored) {
GPR_TIMER_SCOPE("execute_batch", 0);
- grpc_transport_stream_op_batch* batch = (grpc_transport_stream_op_batch*)arg;
- grpc_call* call = (grpc_call*)batch->handler_private.extra_arg;
+ grpc_transport_stream_op_batch* batch = static_cast<grpc_transport_stream_op_batch*>(arg);
+ grpc_call* call = static_cast<grpc_call*>(batch->handler_private.extra_arg);
grpc_call_element* elem = CALL_ELEM_FROM_CALL(call, 0);
GRPC_CALL_LOG_OP(GPR_INFO, elem, batch);
elem->filter->start_transport_stream_op_batch(elem, batch);
@@ -667,7 +667,7 @@ typedef struct {
// The on_complete callback used when sending a cancel_stream batch down
// the filter stack. Yields the call combiner when the batch is done.
static void done_termination(void* arg, grpc_error* error) {
- cancel_state* state = (cancel_state*)arg;
+ cancel_state* state = static_cast<cancel_state*>(arg);
GRPC_CALL_COMBINER_STOP(&state->call->call_combiner,
"on_complete for cancel_stream op");
GRPC_CALL_INTERNAL_UNREF(state->call, "termination");
@@ -683,7 +683,7 @@ static void cancel_with_error(grpc_call* c, status_source source,
// down the filter stack in a timely manner.
grpc_call_combiner_cancel(&c->call_combiner, GRPC_ERROR_REF(error));
set_status_from_error(c, source, GRPC_ERROR_REF(error));
- cancel_state* state = (cancel_state*)gpr_malloc(sizeof(*state));
+ cancel_state* state = static_cast<cancel_state*>(gpr_malloc(sizeof(*state)));
state->call = c;
GRPC_CLOSURE_INIT(&state->finish_batch, done_termination, state,
grpc_schedule_on_exec_ctx);
@@ -845,7 +845,7 @@ static void set_encodings_accepted_by_peer(grpc_call* call, grpc_mdelem mdel,
grpc_mdelem_get_user_data(mdel, destroy_encodings_accepted_by_peer);
if (accepted_user_data != nullptr) {
*encodings_accepted_by_peer =
- (uint32_t)(((uintptr_t)accepted_user_data) - 1);
+ static_cast<uint32_t>(((uintptr_t)accepted_user_data) - 1);
return;
}
@@ -863,11 +863,11 @@ static void set_encodings_accepted_by_peer(grpc_call* call, grpc_mdelem mdel,
if (!stream_encoding) {
r = grpc_message_compression_algorithm_parse(
accept_encoding_entry_slice,
- (grpc_message_compression_algorithm*)&algorithm);
+ reinterpret_cast<grpc_message_compression_algorithm*>(&algorithm));
} else {
r = grpc_stream_compression_algorithm_parse(
accept_encoding_entry_slice,
- (grpc_stream_compression_algorithm*)&algorithm);
+ reinterpret_cast<grpc_stream_compression_algorithm*>(&algorithm));
}
if (r) {
GPR_BITSET(encodings_accepted_by_peer, algorithm);
@@ -885,7 +885,7 @@ static void set_encodings_accepted_by_peer(grpc_call* call, grpc_mdelem mdel,
grpc_mdelem_set_user_data(
mdel, destroy_encodings_accepted_by_peer,
- (void*)(((uintptr_t)(*encodings_accepted_by_peer)) + 1));
+ (void*)((static_cast<uintptr_t>(*encodings_accepted_by_peer)) + 1));
}
uint32_t grpc_call_test_only_get_encodings_accepted_by_peer(grpc_call* call) {
@@ -936,7 +936,7 @@ static int prepare_application_metadata(grpc_call* call, int count,
grpc_validate_header_nonbin_value_is_legal(md->value))) {
break;
}
- l->md = grpc_mdelem_from_grpc_metadata((grpc_metadata*)md);
+ l->md = grpc_mdelem_from_grpc_metadata(const_cast<grpc_metadata*>(md));
}
if (i != total_count) {
for (int j = 0; j < i; j++) {
@@ -986,13 +986,13 @@ static uint32_t decode_status(grpc_mdelem md) {
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 != nullptr) {
- status = ((uint32_t)(intptr_t)user_data) - STATUS_OFFSET;
+ status = (static_cast<uint32_t>((intptr_t)user_data)) - STATUS_OFFSET;
} else {
if (!grpc_parse_slice_to_uint32(GRPC_MDVALUE(md), &status)) {
status = GRPC_STATUS_UNKNOWN; /* could not parse status code */
}
grpc_mdelem_set_user_data(md, destroy_status,
- (void*)(intptr_t)(status + STATUS_OFFSET));
+ (void*)static_cast<intptr_t>(status + STATUS_OFFSET));
}
return status;
}
@@ -1040,8 +1040,8 @@ static void publish_app_metadata(grpc_call* call, grpc_metadata_batch* b,
if (dest->count + b->list.count > dest->capacity) {
dest->capacity =
GPR_MAX(dest->capacity + b->list.count, dest->capacity * 3 / 2);
- dest->metadata = (grpc_metadata*)gpr_realloc(
- dest->metadata, sizeof(grpc_metadata) * dest->capacity);
+ dest->metadata = static_cast<grpc_metadata*>(gpr_realloc(
+ dest->metadata, sizeof(grpc_metadata) * dest->capacity));
}
for (grpc_linked_mdelem* l = b->list.head; l != nullptr; l = l->next) {
mdusr = &dest->metadata[dest->count++];
@@ -1086,7 +1086,7 @@ static void recv_initial_filter(grpc_call* call, grpc_metadata_batch* b) {
}
static void recv_trailing_filter(void* args, grpc_metadata_batch* b) {
- grpc_call* call = (grpc_call*)args;
+ grpc_call* call = static_cast<grpc_call*>(args);
if (b->idx.named.grpc_status != nullptr) {
uint32_t status_code = decode_status(b->idx.named.grpc_status->md);
grpc_error* error =
@@ -1095,7 +1095,7 @@ static void recv_trailing_filter(void* args, grpc_metadata_batch* b) {
: grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Error received from peer"),
GRPC_ERROR_INT_GRPC_STATUS,
- (intptr_t)status_code);
+ static_cast<intptr_t>(status_code));
if (b->idx.named.grpc_message != nullptr) {
error = grpc_error_set_str(
error, GRPC_ERROR_STR_GRPC_MESSAGE,
@@ -1120,11 +1120,11 @@ grpc_call_stack* grpc_call_get_call_stack(grpc_call* call) {
*/
static void set_status_value_directly(grpc_status_code status, void* dest) {
- *(grpc_status_code*)dest = status;
+ *static_cast<grpc_status_code*>(dest) = status;
}
static void set_cancelled_value(grpc_status_code status, void* dest) {
- *(int*)dest = (status != GRPC_STATUS_OK);
+ *static_cast<int*>(dest) = (status != GRPC_STATUS_OK);
}
static bool are_write_flags_valid(uint32_t flags) {
@@ -1171,7 +1171,7 @@ static batch_control* allocate_batch_control(grpc_call* call,
batch_control** pslot = &call->active_batches[slot];
if (*pslot == nullptr) {
*pslot =
- (batch_control*)gpr_arena_alloc(call->arena, sizeof(batch_control));
+ static_cast<batch_control*>(gpr_arena_alloc(call->arena, sizeof(batch_control)));
}
batch_control* bctl = *pslot;
if (bctl->call != nullptr) {
@@ -1185,14 +1185,14 @@ static batch_control* allocate_batch_control(grpc_call* call,
static void finish_batch_completion(void* user_data,
grpc_cq_completion* storage) {
- batch_control* bctl = (batch_control*)user_data;
+ batch_control* bctl = static_cast<batch_control*>(user_data);
grpc_call* call = bctl->call;
bctl->call = nullptr;
GRPC_CALL_INTERNAL_UNREF(call, "completion");
}
static grpc_error* consolidate_batch_errors(batch_control* bctl) {
- size_t n = (size_t)gpr_atm_acq_load(&bctl->num_errors);
+ size_t n = static_cast<size_t>gpr_atm_acq_load(&bctl->num_errors);
if (n == 0) {
return GRPC_ERROR_NONE;
} else if (n == 1) {
@@ -1332,7 +1332,7 @@ static void continue_receiving_slices(batch_control* bctl) {
}
static void receiving_slice_ready(void* bctlp, grpc_error* error) {
- batch_control* bctl = (batch_control*)bctlp;
+ batch_control* bctl = static_cast<batch_control*>(bctlp);
grpc_call* call = bctl->call;
grpc_byte_stream* bs = call->receiving_stream;
bool release_error = false;
@@ -1395,7 +1395,7 @@ static void process_data_after_md(batch_control* bctl) {
}
static void receiving_stream_ready(void* bctlp, grpc_error* error) {
- batch_control* bctl = (batch_control*)bctlp;
+ batch_control* bctl = static_cast<batch_control*>(bctlp);
grpc_call* call = bctl->call;
if (error != GRPC_ERROR_NONE) {
if (call->receiving_stream != nullptr) {
@@ -1419,7 +1419,7 @@ static void receiving_stream_ready(void* bctlp, grpc_error* error) {
// before processing the received message.
static void receiving_stream_ready_in_call_combiner(void* bctlp,
grpc_error* error) {
- batch_control* bctl = (batch_control*)bctlp;
+ batch_control* bctl = static_cast<batch_control*>(bctlp);
grpc_call* call = bctl->call;
GRPC_CALL_COMBINER_STOP(&call->call_combiner, "recv_message_ready");
receiving_stream_ready(bctlp, error);
@@ -1495,7 +1495,7 @@ static void validate_filtered_metadata(batch_control* bctl) {
static void add_batch_error(batch_control* bctl, grpc_error* error,
bool has_cancelled) {
if (error == GRPC_ERROR_NONE) return;
- int idx = (int)gpr_atm_full_fetch_add(&bctl->num_errors, 1);
+ int idx = static_cast<int>(gpr_atm_full_fetch_add(&bctl->num_errors, 1));
if (idx == 0 && !has_cancelled) {
cancel_with_error(bctl->call, STATUS_FROM_CORE, GRPC_ERROR_REF(error));
}
@@ -1503,7 +1503,7 @@ static void add_batch_error(batch_control* bctl, grpc_error* error,
}
static void receiving_initial_metadata_ready(void* bctlp, grpc_error* error) {
- batch_control* bctl = (batch_control*)bctlp;
+ batch_control* bctl = static_cast<batch_control*>(bctlp);
grpc_call* call = bctl->call;
GRPC_CALL_COMBINER_STOP(&call->call_combiner, "recv_initial_metadata_ready");
@@ -1555,7 +1555,7 @@ static void receiving_initial_metadata_ready(void* bctlp, grpc_error* error) {
}
static void finish_batch(void* bctlp, grpc_error* error) {
- batch_control* bctl = (batch_control*)bctlp;
+ batch_control* bctl = static_cast<batch_control*>(bctlp);
grpc_call* call = bctl->call;
GRPC_CALL_COMBINER_STOP(&call->call_combiner, "on_complete");
add_batch_error(bctl, GRPC_ERROR_REF(error), false);
@@ -1586,7 +1586,7 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
GPR_ASSERT(grpc_cq_begin_op(call->cq, notify_tag));
grpc_cq_end_op(
call->cq, notify_tag, GRPC_ERROR_NONE, free_no_op_completion, nullptr,
- (grpc_cq_completion*)gpr_malloc(sizeof(grpc_cq_completion)));
+ static_cast<grpc_cq_completion*>(gpr_malloc(sizeof(grpc_cq_completion))));
} else {
GRPC_CLOSURE_SCHED((grpc_closure*)notify_tag, GRPC_ERROR_NONE);
}
@@ -1600,7 +1600,7 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
}
bctl->completion_data.notify_tag.tag = notify_tag;
bctl->completion_data.notify_tag.is_closure =
- (uint8_t)(is_notify_tag_closure != 0);
+ static_cast<uint8_t>(is_notify_tag_closure != 0);
stream_op = &bctl->op;
stream_op_payload = &call->stream_op_payload;
@@ -1660,9 +1660,9 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
stream_op->send_initial_metadata = true;
call->sent_initial_metadata = true;
if (!prepare_application_metadata(
- call, (int)op->data.send_initial_metadata.count,
+ call, static_cast<int>(op->data.send_initial_metadata.count),
op->data.send_initial_metadata.metadata, 0, call->is_client,
- &call->compression_md, (int)additional_metadata_count)) {
+ &call->compression_md, static_cast<int>(additional_metadata_count))) {
error = GRPC_CALL_ERROR_INVALID_METADATA;
goto done_with_error;
}
@@ -1779,7 +1779,7 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops,
}
if (!prepare_application_metadata(
call,
- (int)op->data.send_status_from_server.trailing_metadata_count,
+ static_cast<int>(op->data.send_status_from_server.trailing_metadata_count),
op->data.send_status_from_server.trailing_metadata, 1, 1,
nullptr, 0)) {
for (int n = 0; n < call->send_extra_metadata_count; n++) {