Autofix c casts to c++ casts
This commit is contained in:
parent
1944363421
commit
be82e64b3d
|
|
@ -31,5 +31,5 @@ void grpc_census_call_set_context(grpc_call* call, census_context* context) {
|
|||
|
||||
census_context* grpc_census_call_get_context(grpc_call* call) {
|
||||
GRPC_API_TRACE("grpc_census_call_get_context(call=%p)", 1, (call));
|
||||
return (census_context*)grpc_call_context_get(call, GRPC_CONTEXT_TRACING);
|
||||
return static_cast<census_context*>(grpc_call_context_get(call, GRPC_CONTEXT_TRACING));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ static void backup_poller_shutdown_unref(backup_poller* p) {
|
|||
}
|
||||
|
||||
static void done_poller(void* arg, grpc_error* error) {
|
||||
backup_poller_shutdown_unref((backup_poller*)arg);
|
||||
backup_poller_shutdown_unref(static_cast<backup_poller*>(arg));
|
||||
}
|
||||
|
||||
static void g_poller_unref() {
|
||||
|
|
@ -102,7 +102,7 @@ static void g_poller_unref() {
|
|||
}
|
||||
|
||||
static void run_poller(void* arg, grpc_error* error) {
|
||||
backup_poller* p = (backup_poller*)arg;
|
||||
backup_poller* p = static_cast<backup_poller*>(arg);
|
||||
if (error != GRPC_ERROR_NONE) {
|
||||
if (error != GRPC_ERROR_CANCELLED) {
|
||||
GRPC_LOG_IF_ERROR("run_poller", GRPC_ERROR_REF(error));
|
||||
|
|
@ -133,8 +133,8 @@ void grpc_client_channel_start_backup_polling(
|
|||
}
|
||||
gpr_mu_lock(&g_poller_mu);
|
||||
if (g_poller == nullptr) {
|
||||
g_poller = (backup_poller*)gpr_zalloc(sizeof(backup_poller));
|
||||
g_poller->pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size());
|
||||
g_poller = static_cast<backup_poller*>(gpr_zalloc(sizeof(backup_poller)));
|
||||
g_poller->pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
|
||||
g_poller->shutting_down = false;
|
||||
grpc_pollset_init(g_poller->pollset, &g_poller->pollset_mu);
|
||||
gpr_ref_init(&g_poller->refs, 0);
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ static void delete_state_watcher(state_watcher* w) {
|
|||
|
||||
static void finished_completion(void* pw, grpc_cq_completion* ignored) {
|
||||
bool should_delete = false;
|
||||
state_watcher* w = (state_watcher*)pw;
|
||||
state_watcher* w = static_cast<state_watcher*>(pw);
|
||||
gpr_mu_lock(&w->mu);
|
||||
switch (w->phase) {
|
||||
case WAITING:
|
||||
|
|
@ -162,11 +162,11 @@ static void partly_done(state_watcher* w, bool due_to_completion,
|
|||
}
|
||||
|
||||
static void watch_complete(void* pw, grpc_error* error) {
|
||||
partly_done((state_watcher*)pw, true, GRPC_ERROR_REF(error));
|
||||
partly_done(static_cast<state_watcher*>(pw), true, GRPC_ERROR_REF(error));
|
||||
}
|
||||
|
||||
static void timeout_complete(void* pw, grpc_error* error) {
|
||||
partly_done((state_watcher*)pw, false, GRPC_ERROR_REF(error));
|
||||
partly_done(static_cast<state_watcher*>(pw), false, GRPC_ERROR_REF(error));
|
||||
}
|
||||
|
||||
int grpc_channel_num_external_connectivity_watchers(grpc_channel* channel) {
|
||||
|
|
@ -182,7 +182,7 @@ typedef struct watcher_timer_init_arg {
|
|||
} watcher_timer_init_arg;
|
||||
|
||||
static void watcher_timer_init(void* arg, grpc_error* error_ignored) {
|
||||
watcher_timer_init_arg* wa = (watcher_timer_init_arg*)arg;
|
||||
watcher_timer_init_arg* wa = static_cast<watcher_timer_init_arg*>(arg);
|
||||
|
||||
grpc_timer_init(&wa->w->alarm, grpc_timespec_to_millis_round_up(wa->deadline),
|
||||
&wa->w->on_timeout);
|
||||
|
|
@ -201,7 +201,7 @@ void grpc_channel_watch_connectivity_state(
|
|||
grpc_channel_element* client_channel_elem =
|
||||
grpc_channel_stack_last_element(grpc_channel_get_channel_stack(channel));
|
||||
grpc_core::ExecCtx exec_ctx;
|
||||
state_watcher* w = (state_watcher*)gpr_malloc(sizeof(*w));
|
||||
state_watcher* w = static_cast<state_watcher*>(gpr_malloc(sizeof(*w)));
|
||||
|
||||
GRPC_API_TRACE(
|
||||
"grpc_channel_watch_connectivity_state("
|
||||
|
|
@ -228,7 +228,7 @@ void grpc_channel_watch_connectivity_state(
|
|||
w->error = nullptr;
|
||||
|
||||
watcher_timer_init_arg* wa =
|
||||
(watcher_timer_init_arg*)gpr_malloc(sizeof(watcher_timer_init_arg));
|
||||
static_cast<watcher_timer_init_arg*>(gpr_malloc(sizeof(watcher_timer_init_arg)));
|
||||
wa->w = w;
|
||||
wa->deadline = deadline;
|
||||
GRPC_CLOSURE_INIT(&w->watcher_timer_init, watcher_timer_init, wa,
|
||||
|
|
|
|||
|
|
@ -88,10 +88,10 @@ static void method_parameters_unref(method_parameters* method_params) {
|
|||
|
||||
// Wrappers to pass to grpc_service_config_create_method_config_table().
|
||||
static void* method_parameters_ref_wrapper(void* value) {
|
||||
return method_parameters_ref((method_parameters*)value);
|
||||
return method_parameters_ref(static_cast<method_parameters*>(value));
|
||||
}
|
||||
static void method_parameters_unref_wrapper(void* value) {
|
||||
method_parameters_unref((method_parameters*)value);
|
||||
method_parameters_unref(static_cast<method_parameters*>(value));
|
||||
}
|
||||
|
||||
static bool parse_wait_for_ready(grpc_json* field,
|
||||
|
|
@ -119,7 +119,7 @@ static bool parse_timeout(grpc_json* field, grpc_millis* timeout) {
|
|||
gpr_free(buf);
|
||||
return false;
|
||||
}
|
||||
int num_digits = (int)strlen(decimal_point + 1);
|
||||
int num_digits = static_cast<int>(strlen(decimal_point + 1));
|
||||
if (num_digits > 9) { // We don't accept greater precision than nanos.
|
||||
gpr_free(buf);
|
||||
return false;
|
||||
|
|
@ -149,7 +149,7 @@ static void* method_parameters_create_from_json(const grpc_json* json) {
|
|||
}
|
||||
}
|
||||
method_parameters* value =
|
||||
(method_parameters*)gpr_malloc(sizeof(method_parameters));
|
||||
static_cast<method_parameters*>(gpr_malloc(sizeof(method_parameters)));
|
||||
gpr_ref_init(&value->refs, 1);
|
||||
value->timeout = timeout;
|
||||
value->wait_for_ready = wait_for_ready;
|
||||
|
|
@ -260,7 +260,7 @@ static void set_channel_connectivity_state_locked(channel_data* chand,
|
|||
}
|
||||
|
||||
static void on_lb_policy_state_changed_locked(void* arg, grpc_error* error) {
|
||||
lb_policy_connectivity_watcher* w = (lb_policy_connectivity_watcher*)arg;
|
||||
lb_policy_connectivity_watcher* w = static_cast<lb_policy_connectivity_watcher*>(arg);
|
||||
/* check if the notification is for the latest policy */
|
||||
if (w->lb_policy == w->chand->lb_policy) {
|
||||
if (grpc_client_channel_trace.enabled()) {
|
||||
|
|
@ -281,7 +281,7 @@ static void watch_lb_policy_locked(channel_data* chand,
|
|||
grpc_lb_policy* lb_policy,
|
||||
grpc_connectivity_state current_state) {
|
||||
lb_policy_connectivity_watcher* w =
|
||||
(lb_policy_connectivity_watcher*)gpr_malloc(sizeof(*w));
|
||||
static_cast<lb_policy_connectivity_watcher*>(gpr_malloc(sizeof(*w)));
|
||||
GRPC_CHANNEL_STACK_REF(chand->owning_stack, "watch_lb_policy");
|
||||
w->chand = chand;
|
||||
GRPC_CLOSURE_INIT(&w->on_changed, on_lb_policy_state_changed_locked, w,
|
||||
|
|
@ -310,7 +310,7 @@ typedef struct {
|
|||
|
||||
static void parse_retry_throttle_params(const grpc_json* field, void* arg) {
|
||||
service_config_parsing_state* parsing_state =
|
||||
(service_config_parsing_state*)arg;
|
||||
static_cast<service_config_parsing_state*>(arg);
|
||||
if (strcmp(field->key, "retryThrottling") == 0) {
|
||||
if (parsing_state->retry_throttle_data != nullptr) return; // Duplicate.
|
||||
if (field->type != GRPC_JSON_OBJECT) return;
|
||||
|
|
@ -334,7 +334,7 @@ static void parse_retry_throttle_params(const grpc_json* field, void* arg) {
|
|||
uint32_t decimal_value = 0;
|
||||
const char* decimal_point = strchr(sub_field->value, '.');
|
||||
if (decimal_point != nullptr) {
|
||||
whole_len = (size_t)(decimal_point - sub_field->value);
|
||||
whole_len = static_cast<size_t>(decimal_point - sub_field->value);
|
||||
multiplier = 1000;
|
||||
size_t decimal_len = strlen(decimal_point + 1);
|
||||
if (decimal_len > 3) decimal_len = 3;
|
||||
|
|
@ -353,7 +353,7 @@ static void parse_retry_throttle_params(const grpc_json* field, void* arg) {
|
|||
&whole_value)) {
|
||||
return;
|
||||
}
|
||||
milli_token_ratio = (int)((whole_value * multiplier) + decimal_value);
|
||||
milli_token_ratio = static_cast<int>((whole_value * multiplier) + decimal_value);
|
||||
if (milli_token_ratio <= 0) return;
|
||||
}
|
||||
}
|
||||
|
|
@ -364,7 +364,7 @@ static void parse_retry_throttle_params(const grpc_json* field, void* arg) {
|
|||
}
|
||||
|
||||
static void request_reresolution_locked(void* arg, grpc_error* error) {
|
||||
reresolution_request_args* args = (reresolution_request_args*)arg;
|
||||
reresolution_request_args* args = static_cast<reresolution_request_args*>(arg);
|
||||
channel_data* chand = args->chand;
|
||||
// If this invocation is for a stale LB policy, treat it as an LB shutdown
|
||||
// signal.
|
||||
|
|
@ -383,7 +383,7 @@ static void request_reresolution_locked(void* arg, grpc_error* error) {
|
|||
}
|
||||
|
||||
static void on_resolver_result_changed_locked(void* arg, grpc_error* error) {
|
||||
channel_data* chand = (channel_data*)arg;
|
||||
channel_data* chand = static_cast<channel_data*>(arg);
|
||||
if (grpc_client_channel_trace.enabled()) {
|
||||
gpr_log(GPR_DEBUG, "chand=%p: got resolver result: error=%s", chand,
|
||||
grpc_error_string(error));
|
||||
|
|
@ -412,7 +412,7 @@ static void on_resolver_result_changed_locked(void* arg, grpc_error* error) {
|
|||
grpc_channel_args_find(chand->resolver_result, GRPC_ARG_LB_ADDRESSES);
|
||||
if (channel_arg != nullptr && channel_arg->type == GRPC_ARG_POINTER) {
|
||||
grpc_lb_addresses* addresses =
|
||||
(grpc_lb_addresses*)channel_arg->value.pointer.p;
|
||||
static_cast<grpc_lb_addresses*>(channel_arg->value.pointer.p);
|
||||
bool found_balancer_address = false;
|
||||
for (size_t i = 0; i < addresses->num_addresses; ++i) {
|
||||
if (addresses->addresses[i].is_balancer) {
|
||||
|
|
@ -458,7 +458,7 @@ static void on_resolver_result_changed_locked(void* arg, grpc_error* error) {
|
|||
lb_policy_name);
|
||||
} else {
|
||||
reresolution_request_args* args =
|
||||
(reresolution_request_args*)gpr_zalloc(sizeof(*args));
|
||||
static_cast<reresolution_request_args*>(gpr_zalloc(sizeof(*args)));
|
||||
args->chand = chand;
|
||||
args->lb_policy = new_lb_policy;
|
||||
GRPC_CLOSURE_INIT(&args->closure, request_reresolution_locked, args,
|
||||
|
|
@ -610,10 +610,10 @@ static void on_resolver_result_changed_locked(void* arg, grpc_error* error) {
|
|||
}
|
||||
|
||||
static void start_transport_op_locked(void* arg, grpc_error* error_ignored) {
|
||||
grpc_transport_op* op = (grpc_transport_op*)arg;
|
||||
grpc_transport_op* op = static_cast<grpc_transport_op*>(arg);
|
||||
grpc_channel_element* elem =
|
||||
(grpc_channel_element*)op->handler_private.extra_arg;
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
static_cast<grpc_channel_element*>(op->handler_private.extra_arg);
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
|
||||
if (op->on_connectivity_state_change != nullptr) {
|
||||
grpc_connectivity_state_notify_on_state_change(
|
||||
|
|
@ -668,7 +668,7 @@ static void start_transport_op_locked(void* arg, grpc_error* error_ignored) {
|
|||
|
||||
static void cc_start_transport_op(grpc_channel_element* elem,
|
||||
grpc_transport_op* op) {
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
|
||||
GPR_ASSERT(op->set_accept_stream == false);
|
||||
if (op->bind_pollset != nullptr) {
|
||||
|
|
@ -685,7 +685,7 @@ static void cc_start_transport_op(grpc_channel_element* elem,
|
|||
|
||||
static void cc_get_channel_info(grpc_channel_element* elem,
|
||||
const grpc_channel_info* info) {
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
gpr_mu_lock(&chand->info_mu);
|
||||
if (info->lb_policy_name != nullptr) {
|
||||
*info->lb_policy_name = chand->info_lb_policy_name == nullptr
|
||||
|
|
@ -704,7 +704,7 @@ static void cc_get_channel_info(grpc_channel_element* elem,
|
|||
/* Constructor for channel_data */
|
||||
static grpc_error* cc_init_channel_elem(grpc_channel_element* elem,
|
||||
grpc_channel_element_args* args) {
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
GPR_ASSERT(args->is_last);
|
||||
GPR_ASSERT(elem->filter == &grpc_client_channel_filter);
|
||||
// Initialize data members.
|
||||
|
|
@ -736,9 +736,9 @@ static grpc_error* cc_init_channel_elem(grpc_channel_element* elem,
|
|||
"client channel factory arg must be a pointer");
|
||||
}
|
||||
grpc_client_channel_factory_ref(
|
||||
(grpc_client_channel_factory*)arg->value.pointer.p);
|
||||
static_cast<grpc_client_channel_factory*>(arg->value.pointer.p));
|
||||
chand->client_channel_factory =
|
||||
(grpc_client_channel_factory*)arg->value.pointer.p;
|
||||
static_cast<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 == nullptr) {
|
||||
|
|
@ -775,7 +775,7 @@ static void shutdown_resolver_locked(void* arg, grpc_error* error) {
|
|||
|
||||
/* Destructor for channel_data */
|
||||
static void cc_destroy_channel_elem(grpc_channel_element* elem) {
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
if (chand->resolver != nullptr) {
|
||||
GRPC_CLOSURE_SCHED(
|
||||
GRPC_CLOSURE_CREATE(shutdown_resolver_locked, chand->resolver.release(),
|
||||
|
|
@ -867,7 +867,7 @@ typedef struct client_channel_call_data {
|
|||
|
||||
grpc_subchannel_call* grpc_client_channel_get_subchannel_call(
|
||||
grpc_call_element* elem) {
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
return calld->subchannel_call;
|
||||
}
|
||||
|
||||
|
|
@ -886,7 +886,7 @@ static void waiting_for_pick_batches_add(
|
|||
|
||||
// This is called via the call combiner, so access to calld is synchronized.
|
||||
static void fail_pending_batch_in_call_combiner(void* arg, grpc_error* error) {
|
||||
call_data* calld = (call_data*)arg;
|
||||
call_data* calld = static_cast<call_data*>(arg);
|
||||
if (calld->waiting_for_pick_batches_count > 0) {
|
||||
--calld->waiting_for_pick_batches_count;
|
||||
grpc_transport_stream_op_batch_finish_with_failure(
|
||||
|
|
@ -898,7 +898,7 @@ static void fail_pending_batch_in_call_combiner(void* arg, grpc_error* error) {
|
|||
// This is called via the call combiner, so access to calld is synchronized.
|
||||
static void waiting_for_pick_batches_fail(grpc_call_element* elem,
|
||||
grpc_error* error) {
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
if (grpc_client_channel_trace.enabled()) {
|
||||
gpr_log(GPR_DEBUG,
|
||||
"chand=%p calld=%p: failing %" PRIuPTR " pending batches: %s",
|
||||
|
|
@ -926,7 +926,7 @@ static void waiting_for_pick_batches_fail(grpc_call_element* elem,
|
|||
|
||||
// This is called via the call combiner, so access to calld is synchronized.
|
||||
static void run_pending_batch_in_call_combiner(void* arg, grpc_error* ignored) {
|
||||
call_data* calld = (call_data*)arg;
|
||||
call_data* calld = static_cast<call_data*>(arg);
|
||||
if (calld->waiting_for_pick_batches_count > 0) {
|
||||
--calld->waiting_for_pick_batches_count;
|
||||
grpc_subchannel_call_process_op(
|
||||
|
|
@ -937,8 +937,8 @@ static void run_pending_batch_in_call_combiner(void* arg, grpc_error* ignored) {
|
|||
|
||||
// This is called via the call combiner, so access to calld is synchronized.
|
||||
static void waiting_for_pick_batches_resume(grpc_call_element* elem) {
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
if (grpc_client_channel_trace.enabled()) {
|
||||
gpr_log(GPR_DEBUG,
|
||||
"chand=%p calld=%p: sending %" PRIuPTR
|
||||
|
|
@ -962,8 +962,8 @@ static void waiting_for_pick_batches_resume(grpc_call_element* elem) {
|
|||
// Applies service config to the call. Must be invoked once we know
|
||||
// that the resolver has returned results to the channel.
|
||||
static void apply_service_config_to_call_locked(grpc_call_element* elem) {
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
if (grpc_client_channel_trace.enabled()) {
|
||||
gpr_log(GPR_DEBUG, "chand=%p calld=%p: applying service config to call",
|
||||
chand, calld);
|
||||
|
|
@ -973,8 +973,8 @@ static void apply_service_config_to_call_locked(grpc_call_element* elem) {
|
|||
grpc_server_retry_throttle_data_ref(chand->retry_throttle_data);
|
||||
}
|
||||
if (chand->method_params_table != nullptr) {
|
||||
calld->method_params = (method_parameters*)grpc_method_config_table_get(
|
||||
chand->method_params_table, calld->path);
|
||||
calld->method_params = static_cast<method_parameters*>(grpc_method_config_table_get(
|
||||
chand->method_params_table, calld->path));
|
||||
if (calld->method_params != nullptr) {
|
||||
method_parameters_ref(calld->method_params);
|
||||
// If the deadline from the service config is shorter than the one
|
||||
|
|
@ -995,8 +995,8 @@ static void apply_service_config_to_call_locked(grpc_call_element* elem) {
|
|||
|
||||
static void create_subchannel_call_locked(grpc_call_element* elem,
|
||||
grpc_error* error) {
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
const grpc_core::ConnectedSubchannel::CallArgs call_args = {
|
||||
calld->pollent, // pollent
|
||||
calld->path, // path
|
||||
|
|
@ -1023,8 +1023,8 @@ static void create_subchannel_call_locked(grpc_call_element* elem,
|
|||
|
||||
// Invoked when a pick is completed, on both success or failure.
|
||||
static void pick_done_locked(grpc_call_element* elem, grpc_error* error) {
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
if (calld->pick.connected_subchannel == nullptr) {
|
||||
// Failed to create subchannel.
|
||||
GRPC_ERROR_UNREF(calld->error);
|
||||
|
|
@ -1051,8 +1051,8 @@ static void pick_done_locked(grpc_call_element* elem, grpc_error* error) {
|
|||
// pick was done asynchronously. Removes the call's polling entity from
|
||||
// chand->interested_parties before invoking pick_done_locked().
|
||||
static void async_pick_done_locked(grpc_call_element* elem, grpc_error* error) {
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
grpc_polling_entity_del_from_pollset_set(calld->pollent,
|
||||
chand->interested_parties);
|
||||
pick_done_locked(elem, error);
|
||||
|
|
@ -1061,9 +1061,9 @@ static void async_pick_done_locked(grpc_call_element* elem, grpc_error* error) {
|
|||
// Note: This runs under the client_channel combiner, but will NOT be
|
||||
// holding the call combiner.
|
||||
static void pick_callback_cancel_locked(void* arg, grpc_error* error) {
|
||||
grpc_call_element* elem = (grpc_call_element*)arg;
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
grpc_call_element* elem = static_cast<grpc_call_element*>(arg);
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
// Note: chand->lb_policy may have changed since we started our pick,
|
||||
// in which case we will be cancelling the pick on a policy other than
|
||||
// the one we started it on. However, this will just be a no-op.
|
||||
|
|
@ -1081,9 +1081,9 @@ static void pick_callback_cancel_locked(void* arg, grpc_error* error) {
|
|||
// Callback invoked by grpc_lb_policy_pick_locked() for async picks.
|
||||
// Unrefs the LB policy and invokes async_pick_done_locked().
|
||||
static void pick_callback_done_locked(void* arg, grpc_error* error) {
|
||||
grpc_call_element* elem = (grpc_call_element*)arg;
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
grpc_call_element* elem = static_cast<grpc_call_element*>(arg);
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
if (grpc_client_channel_trace.enabled()) {
|
||||
gpr_log(GPR_DEBUG, "chand=%p calld=%p: pick completed asynchronously",
|
||||
chand, calld);
|
||||
|
|
@ -1096,8 +1096,8 @@ static void pick_callback_done_locked(void* arg, grpc_error* error) {
|
|||
// If the pick was completed synchronously, unrefs the LB policy and
|
||||
// returns true.
|
||||
static bool pick_callback_start_locked(grpc_call_element* elem) {
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
if (grpc_client_channel_trace.enabled()) {
|
||||
gpr_log(GPR_DEBUG, "chand=%p calld=%p: starting pick on lb_policy=%p",
|
||||
chand, calld, chand->lb_policy);
|
||||
|
|
@ -1161,7 +1161,7 @@ typedef struct {
|
|||
// holding the call combiner.
|
||||
static void pick_after_resolver_result_cancel_locked(void* arg,
|
||||
grpc_error* error) {
|
||||
pick_after_resolver_result_args* args = (pick_after_resolver_result_args*)arg;
|
||||
pick_after_resolver_result_args* args = static_cast<pick_after_resolver_result_args*>(arg);
|
||||
if (args->finished) {
|
||||
gpr_free(args);
|
||||
return;
|
||||
|
|
@ -1175,8 +1175,8 @@ static void pick_after_resolver_result_cancel_locked(void* arg,
|
|||
// async_pick_done_locked() to propagate the error back to the caller.
|
||||
args->finished = true;
|
||||
grpc_call_element* elem = args->elem;
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
if (grpc_client_channel_trace.enabled()) {
|
||||
gpr_log(GPR_DEBUG,
|
||||
"chand=%p calld=%p: cancelling pick waiting for resolver result",
|
||||
|
|
@ -1195,7 +1195,7 @@ static void pick_after_resolver_result_start_locked(grpc_call_element* elem);
|
|||
|
||||
static void pick_after_resolver_result_done_locked(void* arg,
|
||||
grpc_error* error) {
|
||||
pick_after_resolver_result_args* args = (pick_after_resolver_result_args*)arg;
|
||||
pick_after_resolver_result_args* args = static_cast<pick_after_resolver_result_args*>(arg);
|
||||
if (args->finished) {
|
||||
/* cancelled, do nothing */
|
||||
if (grpc_client_channel_trace.enabled()) {
|
||||
|
|
@ -1206,8 +1206,8 @@ static void pick_after_resolver_result_done_locked(void* arg,
|
|||
}
|
||||
args->finished = true;
|
||||
grpc_call_element* elem = args->elem;
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
if (error != GRPC_ERROR_NONE) {
|
||||
if (grpc_client_channel_trace.enabled()) {
|
||||
gpr_log(GPR_DEBUG, "chand=%p calld=%p: resolver failed to return data",
|
||||
|
|
@ -1255,15 +1255,15 @@ static void pick_after_resolver_result_done_locked(void* arg,
|
|||
}
|
||||
|
||||
static void pick_after_resolver_result_start_locked(grpc_call_element* elem) {
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
if (grpc_client_channel_trace.enabled()) {
|
||||
gpr_log(GPR_DEBUG,
|
||||
"chand=%p calld=%p: deferring pick pending resolver result", chand,
|
||||
calld);
|
||||
}
|
||||
pick_after_resolver_result_args* args =
|
||||
(pick_after_resolver_result_args*)gpr_zalloc(sizeof(*args));
|
||||
static_cast<pick_after_resolver_result_args*>(gpr_zalloc(sizeof(*args)));
|
||||
args->elem = elem;
|
||||
GRPC_CLOSURE_INIT(&args->closure, pick_after_resolver_result_done_locked,
|
||||
args, grpc_combiner_scheduler(chand->combiner));
|
||||
|
|
@ -1277,9 +1277,9 @@ static void pick_after_resolver_result_start_locked(grpc_call_element* elem) {
|
|||
}
|
||||
|
||||
static void start_pick_locked(void* arg, grpc_error* ignored) {
|
||||
grpc_call_element* elem = (grpc_call_element*)arg;
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
grpc_call_element* elem = static_cast<grpc_call_element*>(arg);
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
GPR_ASSERT(calld->pick.connected_subchannel == nullptr);
|
||||
if (chand->lb_policy != nullptr) {
|
||||
// We already have an LB policy, so ask it for a pick.
|
||||
|
|
@ -1310,8 +1310,8 @@ static void start_pick_locked(void* arg, grpc_error* ignored) {
|
|||
}
|
||||
|
||||
static void on_complete(void* arg, grpc_error* error) {
|
||||
grpc_call_element* elem = (grpc_call_element*)arg;
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
grpc_call_element* elem = static_cast<grpc_call_element*>(arg);
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
if (calld->retry_throttle_data != nullptr) {
|
||||
if (error == GRPC_ERROR_NONE) {
|
||||
grpc_server_retry_throttle_data_record_success(
|
||||
|
|
@ -1331,8 +1331,8 @@ static void on_complete(void* arg, grpc_error* error) {
|
|||
static void cc_start_transport_stream_op_batch(
|
||||
grpc_call_element* elem, grpc_transport_stream_op_batch* batch) {
|
||||
GPR_TIMER_SCOPE("cc_start_transport_stream_op_batch", 0);
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
if (chand->deadline_checking_enabled) {
|
||||
grpc_deadline_state_client_start_transport_stream_op_batch(elem, batch);
|
||||
}
|
||||
|
|
@ -1419,8 +1419,8 @@ static void cc_start_transport_stream_op_batch(
|
|||
/* Constructor for call_data */
|
||||
static grpc_error* cc_init_call_elem(grpc_call_element* elem,
|
||||
const grpc_call_element_args* args) {
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
// Initialize data members.
|
||||
calld->path = grpc_slice_ref_internal(args->path);
|
||||
calld->call_start_time = args->start_time;
|
||||
|
|
@ -1439,8 +1439,8 @@ static grpc_error* cc_init_call_elem(grpc_call_element* elem,
|
|||
static void cc_destroy_call_elem(grpc_call_element* elem,
|
||||
const grpc_call_final_info* final_info,
|
||||
grpc_closure* then_schedule_closure) {
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
if (chand->deadline_checking_enabled) {
|
||||
grpc_deadline_state_destroy(elem);
|
||||
}
|
||||
|
|
@ -1471,7 +1471,7 @@ static void cc_destroy_call_elem(grpc_call_element* elem,
|
|||
|
||||
static void cc_set_pollset_or_pollset_set(grpc_call_element* elem,
|
||||
grpc_polling_entity* pollent) {
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
calld->pollent = pollent;
|
||||
}
|
||||
|
||||
|
|
@ -1494,7 +1494,7 @@ const grpc_channel_filter grpc_client_channel_filter = {
|
|||
};
|
||||
|
||||
static void try_to_connect_locked(void* arg, grpc_error* error_ignored) {
|
||||
channel_data* chand = (channel_data*)arg;
|
||||
channel_data* chand = static_cast<channel_data*>(arg);
|
||||
if (chand->lb_policy != nullptr) {
|
||||
grpc_lb_policy_exit_idle_locked(chand->lb_policy);
|
||||
} else {
|
||||
|
|
@ -1508,7 +1508,7 @@ static void try_to_connect_locked(void* arg, grpc_error* error_ignored) {
|
|||
|
||||
grpc_connectivity_state grpc_client_channel_check_connectivity_state(
|
||||
grpc_channel_element* elem, int try_to_connect) {
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
grpc_connectivity_state out =
|
||||
grpc_connectivity_state_check(&chand->state_tracker);
|
||||
if (out == GRPC_CHANNEL_IDLE && try_to_connect) {
|
||||
|
|
@ -1579,7 +1579,7 @@ static void external_connectivity_watcher_list_remove(
|
|||
|
||||
int grpc_client_channel_num_external_connectivity_watchers(
|
||||
grpc_channel_element* elem) {
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
int count = 0;
|
||||
|
||||
gpr_mu_lock(&chand->external_connectivity_watcher_list_mu);
|
||||
|
|
@ -1595,7 +1595,7 @@ int grpc_client_channel_num_external_connectivity_watchers(
|
|||
}
|
||||
|
||||
static void on_external_watch_complete_locked(void* arg, grpc_error* error) {
|
||||
external_connectivity_watcher* w = (external_connectivity_watcher*)arg;
|
||||
external_connectivity_watcher* w = static_cast<external_connectivity_watcher*>(arg);
|
||||
grpc_closure* follow_up = w->on_complete;
|
||||
grpc_polling_entity_del_from_pollset_set(&w->pollent,
|
||||
w->chand->interested_parties);
|
||||
|
|
@ -1608,7 +1608,7 @@ static void on_external_watch_complete_locked(void* arg, grpc_error* error) {
|
|||
|
||||
static void watch_connectivity_state_locked(void* arg,
|
||||
grpc_error* error_ignored) {
|
||||
external_connectivity_watcher* w = (external_connectivity_watcher*)arg;
|
||||
external_connectivity_watcher* w = static_cast<external_connectivity_watcher*>(arg);
|
||||
external_connectivity_watcher* found = nullptr;
|
||||
if (w->state != nullptr) {
|
||||
external_connectivity_watcher_list_append(w->chand, w);
|
||||
|
|
@ -1637,9 +1637,9 @@ void grpc_client_channel_watch_connectivity_state(
|
|||
grpc_channel_element* elem, grpc_polling_entity pollent,
|
||||
grpc_connectivity_state* state, grpc_closure* closure,
|
||||
grpc_closure* watcher_timer_init) {
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
external_connectivity_watcher* w =
|
||||
(external_connectivity_watcher*)gpr_zalloc(sizeof(*w));
|
||||
static_cast<external_connectivity_watcher*>(gpr_zalloc(sizeof(*w)));
|
||||
w->chand = chand;
|
||||
w->pollent = pollent;
|
||||
w->on_complete = closure;
|
||||
|
|
|
|||
|
|
@ -39,12 +39,12 @@ grpc_channel* grpc_client_channel_factory_create_channel(
|
|||
}
|
||||
|
||||
static void* factory_arg_copy(void* factory) {
|
||||
grpc_client_channel_factory_ref((grpc_client_channel_factory*)factory);
|
||||
grpc_client_channel_factory_ref(static_cast<grpc_client_channel_factory*>(factory));
|
||||
return factory;
|
||||
}
|
||||
|
||||
static void factory_arg_destroy(void* factory) {
|
||||
grpc_client_channel_factory_unref((grpc_client_channel_factory*)factory);
|
||||
grpc_client_channel_factory_unref(static_cast<grpc_client_channel_factory*>(factory));
|
||||
}
|
||||
|
||||
static int factory_arg_cmp(void* factory1, void* factory2) {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
static bool append_filter(grpc_channel_stack_builder* builder, void* arg) {
|
||||
return grpc_channel_stack_builder_append_filter(
|
||||
builder, (const grpc_channel_filter*)arg, nullptr, nullptr);
|
||||
builder, static_cast<const grpc_channel_filter*>(arg), nullptr, nullptr);
|
||||
}
|
||||
|
||||
static bool set_default_host_if_unset(grpc_channel_stack_builder* builder,
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ static void handshake_failed_locked(http_connect_handshaker* handshaker,
|
|||
|
||||
// Callback invoked when finished writing HTTP CONNECT request.
|
||||
static void on_write_done(void* arg, grpc_error* error) {
|
||||
http_connect_handshaker* handshaker = (http_connect_handshaker*)arg;
|
||||
http_connect_handshaker* handshaker = static_cast<http_connect_handshaker*>(arg);
|
||||
gpr_mu_lock(&handshaker->mu);
|
||||
if (error != GRPC_ERROR_NONE || handshaker->shutdown) {
|
||||
// If the write failed or we're shutting down, clean up and invoke the
|
||||
|
|
@ -139,7 +139,7 @@ static void on_write_done(void* arg, grpc_error* error) {
|
|||
|
||||
// Callback invoked for reading HTTP CONNECT response.
|
||||
static void on_read_done(void* arg, grpc_error* error) {
|
||||
http_connect_handshaker* handshaker = (http_connect_handshaker*)arg;
|
||||
http_connect_handshaker* handshaker = static_cast<http_connect_handshaker*>(arg);
|
||||
gpr_mu_lock(&handshaker->mu);
|
||||
if (error != GRPC_ERROR_NONE || handshaker->shutdown) {
|
||||
// If the read failed or we're shutting down, clean up and invoke the
|
||||
|
|
@ -224,13 +224,13 @@ done:
|
|||
//
|
||||
|
||||
static void http_connect_handshaker_destroy(grpc_handshaker* handshaker_in) {
|
||||
http_connect_handshaker* handshaker = (http_connect_handshaker*)handshaker_in;
|
||||
http_connect_handshaker* handshaker = reinterpret_cast<http_connect_handshaker*>(handshaker_in);
|
||||
http_connect_handshaker_unref(handshaker);
|
||||
}
|
||||
|
||||
static void http_connect_handshaker_shutdown(grpc_handshaker* handshaker_in,
|
||||
grpc_error* why) {
|
||||
http_connect_handshaker* handshaker = (http_connect_handshaker*)handshaker_in;
|
||||
http_connect_handshaker* handshaker = reinterpret_cast<http_connect_handshaker*>(handshaker_in);
|
||||
gpr_mu_lock(&handshaker->mu);
|
||||
if (!handshaker->shutdown) {
|
||||
handshaker->shutdown = true;
|
||||
|
|
@ -244,7 +244,7 @@ static void http_connect_handshaker_shutdown(grpc_handshaker* handshaker_in,
|
|||
static void http_connect_handshaker_do_handshake(
|
||||
grpc_handshaker* handshaker_in, grpc_tcp_server_acceptor* acceptor,
|
||||
grpc_closure* on_handshake_done, grpc_handshaker_args* args) {
|
||||
http_connect_handshaker* handshaker = (http_connect_handshaker*)handshaker_in;
|
||||
http_connect_handshaker* handshaker = reinterpret_cast<http_connect_handshaker*>(handshaker_in);
|
||||
// Check for HTTP CONNECT channel arg.
|
||||
// If not found, invoke on_handshake_done without doing anything.
|
||||
const grpc_arg* arg =
|
||||
|
|
@ -270,8 +270,8 @@ static void http_connect_handshaker_do_handshake(
|
|||
GPR_ASSERT(arg->type == GRPC_ARG_STRING);
|
||||
gpr_string_split(arg->value.string, "\n", &header_strings,
|
||||
&num_header_strings);
|
||||
headers = (grpc_http_header*)gpr_malloc(sizeof(grpc_http_header) *
|
||||
num_header_strings);
|
||||
headers = static_cast<grpc_http_header*>(gpr_malloc(sizeof(grpc_http_header) *
|
||||
num_header_strings));
|
||||
for (size_t i = 0; i < num_header_strings; ++i) {
|
||||
char* sep = strchr(header_strings[i], ':');
|
||||
if (sep == nullptr) {
|
||||
|
|
@ -324,7 +324,7 @@ static const grpc_handshaker_vtable http_connect_handshaker_vtable = {
|
|||
|
||||
static grpc_handshaker* grpc_http_connect_handshaker_create() {
|
||||
http_connect_handshaker* handshaker =
|
||||
(http_connect_handshaker*)gpr_malloc(sizeof(*handshaker));
|
||||
static_cast<http_connect_handshaker*>(gpr_malloc(sizeof(*handshaker)));
|
||||
memset(handshaker, 0, sizeof(*handshaker));
|
||||
grpc_handshaker_init(&http_connect_handshaker_vtable, &handshaker->base);
|
||||
gpr_mu_init(&handshaker->mu);
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ struct call_data {
|
|||
} // namespace
|
||||
|
||||
static void on_complete_for_send(void* arg, grpc_error* error) {
|
||||
call_data* calld = (call_data*)arg;
|
||||
call_data* calld = static_cast<call_data*>(arg);
|
||||
if (error == GRPC_ERROR_NONE) {
|
||||
calld->send_initial_metadata_succeeded = true;
|
||||
}
|
||||
|
|
@ -56,7 +56,7 @@ static void on_complete_for_send(void* arg, grpc_error* error) {
|
|||
}
|
||||
|
||||
static void recv_initial_metadata_ready(void* arg, grpc_error* error) {
|
||||
call_data* calld = (call_data*)arg;
|
||||
call_data* calld = static_cast<call_data*>(arg);
|
||||
if (error == GRPC_ERROR_NONE) {
|
||||
calld->recv_initial_metadata_succeeded = true;
|
||||
}
|
||||
|
|
@ -66,13 +66,13 @@ static void recv_initial_metadata_ready(void* arg, grpc_error* error) {
|
|||
|
||||
static grpc_error* init_call_elem(grpc_call_element* elem,
|
||||
const grpc_call_element_args* args) {
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
// Get stats object from context and take a ref.
|
||||
GPR_ASSERT(args->context != nullptr);
|
||||
if (args->context[GRPC_GRPCLB_CLIENT_STATS].value != nullptr) {
|
||||
calld->client_stats = grpc_grpclb_client_stats_ref(
|
||||
(grpc_grpclb_client_stats*)args->context[GRPC_GRPCLB_CLIENT_STATS]
|
||||
.value);
|
||||
static_cast<grpc_grpclb_client_stats*>(args->context[GRPC_GRPCLB_CLIENT_STATS]
|
||||
.value));
|
||||
// Record call started.
|
||||
grpc_grpclb_client_stats_add_call_started(calld->client_stats);
|
||||
}
|
||||
|
|
@ -82,7 +82,7 @@ static grpc_error* init_call_elem(grpc_call_element* elem,
|
|||
static void destroy_call_elem(grpc_call_element* elem,
|
||||
const grpc_call_final_info* final_info,
|
||||
grpc_closure* ignored) {
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
if (calld->client_stats != nullptr) {
|
||||
// Record call finished, optionally setting client_failed_to_send and
|
||||
// received.
|
||||
|
|
@ -97,7 +97,7 @@ static void destroy_call_elem(grpc_call_element* elem,
|
|||
|
||||
static void start_transport_stream_op_batch(
|
||||
grpc_call_element* elem, grpc_transport_stream_op_batch* batch) {
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
GPR_TIMER_SCOPE("clr_start_transport_stream_op_batch", 0);
|
||||
if (calld->client_stats != nullptr) {
|
||||
// Intercept send_initial_metadata.
|
||||
|
|
|
|||
|
|
@ -320,7 +320,7 @@ static void glb_lb_call_data_ref(glb_lb_call_data* lb_calld,
|
|||
const gpr_atm count = gpr_atm_acq_load(&lb_calld->refs.count);
|
||||
gpr_log(GPR_DEBUG, "[%s %p] lb_calld %p REF %lu->%lu (%s)",
|
||||
grpc_lb_glb_trace.name(), lb_calld->glb_policy, lb_calld,
|
||||
(unsigned long)(count - 1), (unsigned long)count, reason);
|
||||
static_cast<unsigned long>(count - 1), static_cast<unsigned long>(count), reason);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -331,7 +331,7 @@ static void glb_lb_call_data_unref(glb_lb_call_data* lb_calld,
|
|||
const gpr_atm count = gpr_atm_acq_load(&lb_calld->refs.count);
|
||||
gpr_log(GPR_DEBUG, "[%s %p] lb_calld %p UNREF %lu->%lu (%s)",
|
||||
grpc_lb_glb_trace.name(), lb_calld->glb_policy, lb_calld,
|
||||
(unsigned long)(count + 1), (unsigned long)count, reason);
|
||||
static_cast<unsigned long>(count + 1), static_cast<unsigned long>(count), reason);
|
||||
}
|
||||
if (done) {
|
||||
GPR_ASSERT(lb_calld->lb_call != nullptr);
|
||||
|
|
@ -372,7 +372,7 @@ static grpc_error* initial_metadata_add_lb_token(
|
|||
}
|
||||
|
||||
static void destroy_client_stats(void* arg) {
|
||||
grpc_grpclb_client_stats_unref((grpc_grpclb_client_stats*)arg);
|
||||
grpc_grpclb_client_stats_unref(static_cast<grpc_grpclb_client_stats*>(arg));
|
||||
}
|
||||
|
||||
static void pending_pick_set_metadata_and_context(pending_pick* pp) {
|
||||
|
|
@ -408,7 +408,7 @@ static void pending_pick_set_metadata_and_context(pending_pick* pp) {
|
|||
* reference to its associated round robin instance. We wrap this closure in
|
||||
* order to unref the round robin instance upon its invocation */
|
||||
static void pending_pick_complete(void* arg, grpc_error* error) {
|
||||
pending_pick* pp = (pending_pick*)arg;
|
||||
pending_pick* pp = static_cast<pending_pick*>(arg);
|
||||
pending_pick_set_metadata_and_context(pp);
|
||||
GRPC_CLOSURE_SCHED(pp->original_on_complete, GRPC_ERROR_REF(error));
|
||||
gpr_free(pp);
|
||||
|
|
@ -416,7 +416,7 @@ static void pending_pick_complete(void* arg, grpc_error* error) {
|
|||
|
||||
static pending_pick* pending_pick_create(glb_lb_policy* glb_policy,
|
||||
grpc_lb_policy_pick_state* pick) {
|
||||
pending_pick* pp = (pending_pick*)gpr_zalloc(sizeof(*pp));
|
||||
pending_pick* pp = static_cast<pending_pick*>(gpr_zalloc(sizeof(*pp)));
|
||||
pp->pick = pick;
|
||||
pp->glb_policy = glb_policy;
|
||||
GRPC_CLOSURE_INIT(&pp->on_complete, pending_pick_complete, pp,
|
||||
|
|
@ -433,7 +433,7 @@ static void pending_pick_add(pending_pick** root, pending_pick* new_pp) {
|
|||
|
||||
static void pending_ping_add(pending_ping** root, grpc_closure* on_initiate,
|
||||
grpc_closure* on_ack) {
|
||||
pending_ping* pping = (pending_ping*)gpr_zalloc(sizeof(*pping));
|
||||
pending_ping* pping = static_cast<pending_ping*>(gpr_zalloc(sizeof(*pping)));
|
||||
pping->on_initiate = on_initiate;
|
||||
pping->on_ack = on_ack;
|
||||
pping->next = *root;
|
||||
|
|
@ -448,7 +448,7 @@ static bool is_server_valid(const grpc_grpclb_server* server, size_t idx,
|
|||
if (log) {
|
||||
gpr_log(GPR_ERROR,
|
||||
"Invalid port '%d' at index %lu of serverlist. Ignoring.",
|
||||
server->port, (unsigned long)idx);
|
||||
server->port, static_cast<unsigned long>(idx));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -457,7 +457,7 @@ static bool is_server_valid(const grpc_grpclb_server* server, size_t idx,
|
|||
gpr_log(GPR_ERROR,
|
||||
"Expected IP to be 4 or 16 bytes, got %d at index %lu of "
|
||||
"serverlist. Ignoring",
|
||||
ip->size, (unsigned long)idx);
|
||||
ip->size, static_cast<unsigned long>(idx));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -487,19 +487,19 @@ static void parse_server(const grpc_grpclb_server* server,
|
|||
grpc_resolved_address* addr) {
|
||||
memset(addr, 0, sizeof(*addr));
|
||||
if (server->drop) return;
|
||||
const uint16_t netorder_port = htons((uint16_t)server->port);
|
||||
const uint16_t netorder_port = htons(static_cast<uint16_t>(server->port));
|
||||
/* the addresses are given in binary format (a in(6)_addr struct) in
|
||||
* server->ip_address.bytes. */
|
||||
const grpc_grpclb_ip_address* ip = &server->ip_address;
|
||||
if (ip->size == 4) {
|
||||
addr->len = sizeof(struct sockaddr_in);
|
||||
struct sockaddr_in* addr4 = (struct sockaddr_in*)&addr->addr;
|
||||
struct sockaddr_in* addr4 = reinterpret_cast<struct sockaddr_in*>(&addr->addr);
|
||||
addr4->sin_family = AF_INET;
|
||||
memcpy(&addr4->sin_addr, ip->bytes, ip->size);
|
||||
addr4->sin_port = netorder_port;
|
||||
} else if (ip->size == 16) {
|
||||
addr->len = sizeof(struct sockaddr_in6);
|
||||
struct sockaddr_in6* addr6 = (struct sockaddr_in6*)&addr->addr;
|
||||
struct sockaddr_in6* addr6 = reinterpret_cast<struct sockaddr_in6*>(&addr->addr);
|
||||
addr6->sin6_family = AF_INET6;
|
||||
memcpy(&addr6->sin6_addr, ip->bytes, ip->size);
|
||||
addr6->sin6_port = netorder_port;
|
||||
|
|
@ -684,7 +684,7 @@ static bool pick_from_internal_rr_locked(glb_lb_policy* glb_policy,
|
|||
grpc_grpclb_client_stats_ref(glb_policy->lb_calld->client_stats);
|
||||
}
|
||||
GPR_ASSERT(pp->pick->user_data == nullptr);
|
||||
pp->pick->user_data = (void**)&pp->lb_token;
|
||||
pp->pick->user_data = reinterpret_cast<void**>(&pp->lb_token);
|
||||
// Pick via the RR policy.
|
||||
bool pick_done = grpc_lb_policy_pick_locked(glb_policy->rr_policy, pp->pick);
|
||||
if (pick_done) {
|
||||
|
|
@ -716,7 +716,7 @@ static grpc_lb_policy_args* lb_policy_args_create(glb_lb_policy* glb_policy) {
|
|||
addresses = grpc_lb_addresses_copy(glb_policy->fallback_backend_addresses);
|
||||
}
|
||||
GPR_ASSERT(addresses != nullptr);
|
||||
grpc_lb_policy_args* args = (grpc_lb_policy_args*)gpr_zalloc(sizeof(*args));
|
||||
grpc_lb_policy_args* args = static_cast<grpc_lb_policy_args*>(gpr_zalloc(sizeof(*args)));
|
||||
args->client_channel_factory = glb_policy->cc_factory;
|
||||
args->combiner = glb_policy->base.combiner;
|
||||
// Replace the LB addresses in the channel args that we pass down to
|
||||
|
|
@ -823,7 +823,7 @@ static void rr_handover_locked(glb_lb_policy* glb_policy) {
|
|||
}
|
||||
|
||||
static void on_rr_connectivity_changed_locked(void* arg, grpc_error* error) {
|
||||
glb_lb_policy* glb_policy = (glb_lb_policy*)arg;
|
||||
glb_lb_policy* glb_policy = static_cast<glb_lb_policy*>(arg);
|
||||
if (glb_policy->shutting_down) {
|
||||
GRPC_LB_POLICY_UNREF(&glb_policy->base, "glb_rr_connectivity_cb");
|
||||
return;
|
||||
|
|
@ -859,8 +859,8 @@ static grpc_slice_hash_table_entry targets_info_entry_create(
|
|||
}
|
||||
|
||||
static int balancer_name_cmp_fn(void* a, void* b) {
|
||||
const char* a_str = (const char*)a;
|
||||
const char* b_str = (const char*)b;
|
||||
const char* a_str = static_cast<const char*>(a);
|
||||
const char* b_str = static_cast<const char*>(b);
|
||||
return strcmp(a_str, b_str);
|
||||
}
|
||||
|
||||
|
|
@ -887,8 +887,8 @@ static grpc_channel_args* build_lb_channel_args(
|
|||
grpc_lb_addresses* lb_addresses =
|
||||
grpc_lb_addresses_create(num_grpclb_addrs, nullptr);
|
||||
grpc_slice_hash_table_entry* targets_info_entries =
|
||||
(grpc_slice_hash_table_entry*)gpr_zalloc(sizeof(*targets_info_entries) *
|
||||
num_grpclb_addrs);
|
||||
static_cast<grpc_slice_hash_table_entry*>(gpr_zalloc(sizeof(*targets_info_entries) *
|
||||
num_grpclb_addrs));
|
||||
|
||||
size_t lb_addresses_idx = 0;
|
||||
for (size_t i = 0; i < addresses->num_addresses; ++i) {
|
||||
|
|
@ -931,7 +931,7 @@ static grpc_channel_args* build_lb_channel_args(
|
|||
}
|
||||
|
||||
static void glb_destroy(grpc_lb_policy* pol) {
|
||||
glb_lb_policy* glb_policy = (glb_lb_policy*)pol;
|
||||
glb_lb_policy* glb_policy = reinterpret_cast<glb_lb_policy*>(pol);
|
||||
GPR_ASSERT(glb_policy->pending_picks == nullptr);
|
||||
GPR_ASSERT(glb_policy->pending_pings == nullptr);
|
||||
gpr_free((void*)glb_policy->server_name);
|
||||
|
|
@ -951,7 +951,7 @@ static void glb_destroy(grpc_lb_policy* pol) {
|
|||
|
||||
static void glb_shutdown_locked(grpc_lb_policy* pol,
|
||||
grpc_lb_policy* new_policy) {
|
||||
glb_lb_policy* glb_policy = (glb_lb_policy*)pol;
|
||||
glb_lb_policy* glb_policy = reinterpret_cast<glb_lb_policy*>(pol);
|
||||
grpc_error* error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Channel shutdown");
|
||||
glb_policy->shutting_down = true;
|
||||
if (glb_policy->lb_calld != nullptr) {
|
||||
|
|
@ -1027,7 +1027,7 @@ static void glb_shutdown_locked(grpc_lb_policy* pol,
|
|||
static void glb_cancel_pick_locked(grpc_lb_policy* pol,
|
||||
grpc_lb_policy_pick_state* pick,
|
||||
grpc_error* error) {
|
||||
glb_lb_policy* glb_policy = (glb_lb_policy*)pol;
|
||||
glb_lb_policy* glb_policy = reinterpret_cast<glb_lb_policy*>(pol);
|
||||
pending_pick* pp = glb_policy->pending_picks;
|
||||
glb_policy->pending_picks = nullptr;
|
||||
while (pp != nullptr) {
|
||||
|
|
@ -1064,7 +1064,7 @@ static void glb_cancel_picks_locked(grpc_lb_policy* pol,
|
|||
uint32_t initial_metadata_flags_mask,
|
||||
uint32_t initial_metadata_flags_eq,
|
||||
grpc_error* error) {
|
||||
glb_lb_policy* glb_policy = (glb_lb_policy*)pol;
|
||||
glb_lb_policy* glb_policy = reinterpret_cast<glb_lb_policy*>(pol);
|
||||
pending_pick* pp = glb_policy->pending_picks;
|
||||
glb_policy->pending_picks = nullptr;
|
||||
while (pp != nullptr) {
|
||||
|
|
@ -1111,7 +1111,7 @@ static void start_picking_locked(glb_lb_policy* glb_policy) {
|
|||
}
|
||||
|
||||
static void glb_exit_idle_locked(grpc_lb_policy* pol) {
|
||||
glb_lb_policy* glb_policy = (glb_lb_policy*)pol;
|
||||
glb_lb_policy* glb_policy = reinterpret_cast<glb_lb_policy*>(pol);
|
||||
if (!glb_policy->started_picking) {
|
||||
start_picking_locked(glb_policy);
|
||||
}
|
||||
|
|
@ -1119,7 +1119,7 @@ static void glb_exit_idle_locked(grpc_lb_policy* pol) {
|
|||
|
||||
static int glb_pick_locked(grpc_lb_policy* pol,
|
||||
grpc_lb_policy_pick_state* pick) {
|
||||
glb_lb_policy* glb_policy = (glb_lb_policy*)pol;
|
||||
glb_lb_policy* glb_policy = reinterpret_cast<glb_lb_policy*>(pol);
|
||||
pending_pick* pp = pending_pick_create(glb_policy, pick);
|
||||
bool pick_done = false;
|
||||
if (glb_policy->rr_policy != nullptr) {
|
||||
|
|
@ -1165,14 +1165,14 @@ static int glb_pick_locked(grpc_lb_policy* pol,
|
|||
|
||||
static grpc_connectivity_state glb_check_connectivity_locked(
|
||||
grpc_lb_policy* pol, grpc_error** connectivity_error) {
|
||||
glb_lb_policy* glb_policy = (glb_lb_policy*)pol;
|
||||
glb_lb_policy* glb_policy = reinterpret_cast<glb_lb_policy*>(pol);
|
||||
return grpc_connectivity_state_get(&glb_policy->state_tracker,
|
||||
connectivity_error);
|
||||
}
|
||||
|
||||
static void glb_ping_one_locked(grpc_lb_policy* pol, grpc_closure* on_initiate,
|
||||
grpc_closure* on_ack) {
|
||||
glb_lb_policy* glb_policy = (glb_lb_policy*)pol;
|
||||
glb_lb_policy* glb_policy = reinterpret_cast<glb_lb_policy*>(pol);
|
||||
if (glb_policy->rr_policy) {
|
||||
grpc_lb_policy_ping_one_locked(glb_policy->rr_policy, on_initiate, on_ack);
|
||||
} else {
|
||||
|
|
@ -1186,13 +1186,13 @@ static void glb_ping_one_locked(grpc_lb_policy* pol, grpc_closure* on_initiate,
|
|||
static void glb_notify_on_state_change_locked(grpc_lb_policy* pol,
|
||||
grpc_connectivity_state* current,
|
||||
grpc_closure* notify) {
|
||||
glb_lb_policy* glb_policy = (glb_lb_policy*)pol;
|
||||
glb_lb_policy* glb_policy = reinterpret_cast<glb_lb_policy*>(pol);
|
||||
grpc_connectivity_state_notify_on_state_change(&glb_policy->state_tracker,
|
||||
current, notify);
|
||||
}
|
||||
|
||||
static void lb_call_on_retry_timer_locked(void* arg, grpc_error* error) {
|
||||
glb_lb_policy* glb_policy = (glb_lb_policy*)arg;
|
||||
glb_lb_policy* glb_policy = static_cast<glb_lb_policy*>(arg);
|
||||
glb_policy->retry_timer_callback_pending = false;
|
||||
if (!glb_policy->shutting_down && error == GRPC_ERROR_NONE &&
|
||||
glb_policy->lb_calld == nullptr) {
|
||||
|
|
@ -1244,7 +1244,7 @@ static void schedule_next_client_load_report(glb_lb_call_data* lb_calld) {
|
|||
}
|
||||
|
||||
static void client_load_report_done_locked(void* arg, grpc_error* error) {
|
||||
glb_lb_call_data* lb_calld = (glb_lb_call_data*)arg;
|
||||
glb_lb_call_data* lb_calld = static_cast<glb_lb_call_data*>(arg);
|
||||
glb_lb_policy* glb_policy = lb_calld->glb_policy;
|
||||
grpc_byte_buffer_destroy(lb_calld->send_message_payload);
|
||||
lb_calld->send_message_payload = nullptr;
|
||||
|
|
@ -1257,8 +1257,7 @@ static void client_load_report_done_locked(void* arg, grpc_error* error) {
|
|||
|
||||
static bool load_report_counters_are_zero(grpc_grpclb_request* request) {
|
||||
grpc_grpclb_dropped_call_counts* drop_entries =
|
||||
(grpc_grpclb_dropped_call_counts*)
|
||||
request->client_stats.calls_finished_with_drop.arg;
|
||||
static_cast<grpc_grpclb_dropped_call_counts*>(request->client_stats.calls_finished_with_drop.arg);
|
||||
return request->client_stats.num_calls_started == 0 &&
|
||||
request->client_stats.num_calls_finished == 0 &&
|
||||
request->client_stats.num_calls_finished_with_client_failed_to_send ==
|
||||
|
|
@ -1307,7 +1306,7 @@ static void send_client_load_report_locked(glb_lb_call_data* lb_calld) {
|
|||
}
|
||||
|
||||
static void maybe_send_client_load_report_locked(void* arg, grpc_error* error) {
|
||||
glb_lb_call_data* lb_calld = (glb_lb_call_data*)arg;
|
||||
glb_lb_call_data* lb_calld = static_cast<glb_lb_call_data*>(arg);
|
||||
glb_lb_policy* glb_policy = lb_calld->glb_policy;
|
||||
lb_calld->client_load_report_timer_callback_pending = false;
|
||||
if (error != GRPC_ERROR_NONE || lb_calld != glb_policy->lb_calld) {
|
||||
|
|
@ -1339,7 +1338,7 @@ static glb_lb_call_data* lb_call_data_create_locked(glb_lb_policy* glb_policy) {
|
|||
glb_policy->lb_call_timeout_ms == 0
|
||||
? GRPC_MILLIS_INF_FUTURE
|
||||
: grpc_core::ExecCtx::Get()->Now() + glb_policy->lb_call_timeout_ms;
|
||||
glb_lb_call_data* lb_calld = (glb_lb_call_data*)gpr_zalloc(sizeof(*lb_calld));
|
||||
glb_lb_call_data* lb_calld = static_cast<glb_lb_call_data*>(gpr_zalloc(sizeof(*lb_calld)));
|
||||
lb_calld->lb_call = grpc_channel_create_pollset_set_call(
|
||||
glb_policy->lb_channel, nullptr, GRPC_PROPAGATE_DEFAULTS,
|
||||
glb_policy->base.interested_parties,
|
||||
|
|
@ -1413,7 +1412,7 @@ static void query_for_backends_locked(glb_lb_policy* glb_policy) {
|
|||
glb_lb_call_data_ref(glb_policy->lb_calld,
|
||||
"lb_on_sent_initial_request_locked");
|
||||
call_error = grpc_call_start_batch_and_execute(
|
||||
glb_policy->lb_calld->lb_call, ops, (size_t)(op - ops),
|
||||
glb_policy->lb_calld->lb_call, ops, static_cast<size_t>(op - ops),
|
||||
&glb_policy->lb_calld->lb_on_sent_initial_request);
|
||||
GPR_ASSERT(GRPC_CALL_OK == call_error);
|
||||
// Op: recv initial metadata.
|
||||
|
|
@ -1433,7 +1432,7 @@ static void query_for_backends_locked(glb_lb_policy* glb_policy) {
|
|||
op++;
|
||||
glb_lb_call_data_ref(glb_policy->lb_calld, "lb_on_response_received_locked");
|
||||
call_error = grpc_call_start_batch_and_execute(
|
||||
glb_policy->lb_calld->lb_call, ops, (size_t)(op - ops),
|
||||
glb_policy->lb_calld->lb_call, ops, static_cast<size_t>(op - ops),
|
||||
&glb_policy->lb_calld->lb_on_response_received);
|
||||
GPR_ASSERT(GRPC_CALL_OK == call_error);
|
||||
// Op: recv server status.
|
||||
|
|
@ -1451,13 +1450,13 @@ static void query_for_backends_locked(glb_lb_policy* glb_policy) {
|
|||
// ref instead of a new ref. When it's invoked, it's the initial ref that is
|
||||
// unreffed.
|
||||
call_error = grpc_call_start_batch_and_execute(
|
||||
glb_policy->lb_calld->lb_call, ops, (size_t)(op - ops),
|
||||
glb_policy->lb_calld->lb_call, ops, static_cast<size_t>(op - ops),
|
||||
&glb_policy->lb_calld->lb_on_server_status_received);
|
||||
GPR_ASSERT(GRPC_CALL_OK == call_error);
|
||||
}
|
||||
|
||||
static void lb_on_sent_initial_request_locked(void* arg, grpc_error* error) {
|
||||
glb_lb_call_data* lb_calld = (glb_lb_call_data*)arg;
|
||||
glb_lb_call_data* lb_calld = static_cast<glb_lb_call_data*>(arg);
|
||||
grpc_byte_buffer_destroy(lb_calld->send_message_payload);
|
||||
lb_calld->send_message_payload = nullptr;
|
||||
// If we attempted to send a client load report before the initial request was
|
||||
|
|
@ -1471,7 +1470,7 @@ static void lb_on_sent_initial_request_locked(void* arg, grpc_error* error) {
|
|||
}
|
||||
|
||||
static void lb_on_response_received_locked(void* arg, grpc_error* error) {
|
||||
glb_lb_call_data* lb_calld = (glb_lb_call_data*)arg;
|
||||
glb_lb_call_data* lb_calld = static_cast<glb_lb_call_data*>(arg);
|
||||
glb_lb_policy* glb_policy = lb_calld->glb_policy;
|
||||
// Empty payload means the LB call was cancelled.
|
||||
if (lb_calld != glb_policy->lb_calld ||
|
||||
|
|
@ -1594,7 +1593,7 @@ static void lb_on_response_received_locked(void* arg, grpc_error* error) {
|
|||
// Reuse the "lb_on_response_received_locked" ref taken in
|
||||
// query_for_backends_locked().
|
||||
const grpc_call_error call_error = grpc_call_start_batch_and_execute(
|
||||
lb_calld->lb_call, ops, (size_t)(op - ops),
|
||||
lb_calld->lb_call, ops, static_cast<size_t>(op - ops),
|
||||
&lb_calld->lb_on_response_received);
|
||||
GPR_ASSERT(GRPC_CALL_OK == call_error);
|
||||
} else {
|
||||
|
|
@ -1604,7 +1603,7 @@ static void lb_on_response_received_locked(void* arg, grpc_error* error) {
|
|||
}
|
||||
|
||||
static void lb_on_server_status_received_locked(void* arg, grpc_error* error) {
|
||||
glb_lb_call_data* lb_calld = (glb_lb_call_data*)arg;
|
||||
glb_lb_call_data* lb_calld = static_cast<glb_lb_call_data*>(arg);
|
||||
glb_lb_policy* glb_policy = lb_calld->glb_policy;
|
||||
GPR_ASSERT(lb_calld->lb_call != nullptr);
|
||||
if (grpc_lb_glb_trace.enabled()) {
|
||||
|
|
@ -1641,7 +1640,7 @@ static void lb_on_server_status_received_locked(void* arg, grpc_error* error) {
|
|||
}
|
||||
|
||||
static void lb_on_fallback_timer_locked(void* arg, grpc_error* error) {
|
||||
glb_lb_policy* glb_policy = (glb_lb_policy*)arg;
|
||||
glb_lb_policy* glb_policy = static_cast<glb_lb_policy*>(arg);
|
||||
glb_policy->fallback_timer_callback_pending = false;
|
||||
/* If we receive a serverlist after the timer fires but before this callback
|
||||
* actually runs, don't fall back. */
|
||||
|
|
@ -1673,7 +1672,7 @@ static void fallback_update_locked(glb_lb_policy* glb_policy,
|
|||
|
||||
static void glb_update_locked(grpc_lb_policy* policy,
|
||||
const grpc_lb_policy_args* args) {
|
||||
glb_lb_policy* glb_policy = (glb_lb_policy*)policy;
|
||||
glb_lb_policy* glb_policy = reinterpret_cast<glb_lb_policy*>(policy);
|
||||
const grpc_arg* arg =
|
||||
grpc_channel_args_find(args->args, GRPC_ARG_LB_ADDRESSES);
|
||||
if (arg == nullptr || arg->type != GRPC_ARG_POINTER) {
|
||||
|
|
@ -1694,7 +1693,7 @@ static void glb_update_locked(grpc_lb_policy* policy,
|
|||
return;
|
||||
}
|
||||
const grpc_lb_addresses* addresses =
|
||||
(const grpc_lb_addresses*)arg->value.pointer.p;
|
||||
static_cast<const grpc_lb_addresses*>(arg->value.pointer.p);
|
||||
// If a non-empty serverlist hasn't been received from the balancer,
|
||||
// propagate the update to fallback_backend_addresses.
|
||||
if (glb_policy->serverlist == nullptr) {
|
||||
|
|
@ -1731,7 +1730,7 @@ static void glb_update_locked(grpc_lb_policy* policy,
|
|||
// stayed READY throughout the update (for example if the update is identical).
|
||||
static void glb_lb_channel_on_connectivity_changed_cb(void* arg,
|
||||
grpc_error* error) {
|
||||
glb_lb_policy* glb_policy = (glb_lb_policy*)arg;
|
||||
glb_lb_policy* glb_policy = static_cast<glb_lb_policy*>(arg);
|
||||
if (glb_policy->shutting_down) goto done;
|
||||
// Re-initialize the lb_call. This should also take care of updating the
|
||||
// embedded RR policy. Note that the current RR policy, if any, will stay in
|
||||
|
|
@ -1777,7 +1776,7 @@ static void glb_lb_channel_on_connectivity_changed_cb(void* arg,
|
|||
|
||||
static void glb_set_reresolve_closure_locked(
|
||||
grpc_lb_policy* policy, grpc_closure* request_reresolution) {
|
||||
glb_lb_policy* glb_policy = (glb_lb_policy*)policy;
|
||||
glb_lb_policy* glb_policy = reinterpret_cast<glb_lb_policy*>(policy);
|
||||
GPR_ASSERT(!glb_policy->shutting_down);
|
||||
GPR_ASSERT(glb_policy->base.request_reresolution == nullptr);
|
||||
if (glb_policy->rr_policy != nullptr) {
|
||||
|
|
@ -1810,14 +1809,14 @@ static grpc_lb_policy* glb_create(grpc_lb_policy_factory* factory,
|
|||
if (arg == nullptr || arg->type != GRPC_ARG_POINTER) {
|
||||
return nullptr;
|
||||
}
|
||||
grpc_lb_addresses* addresses = (grpc_lb_addresses*)arg->value.pointer.p;
|
||||
grpc_lb_addresses* addresses = static_cast<grpc_lb_addresses*>(arg->value.pointer.p);
|
||||
size_t num_grpclb_addrs = 0;
|
||||
for (size_t i = 0; i < addresses->num_addresses; ++i) {
|
||||
if (addresses->addresses[i].is_balancer) ++num_grpclb_addrs;
|
||||
}
|
||||
if (num_grpclb_addrs == 0) return nullptr;
|
||||
|
||||
glb_lb_policy* glb_policy = (glb_lb_policy*)gpr_zalloc(sizeof(*glb_policy));
|
||||
glb_lb_policy* glb_policy = static_cast<glb_lb_policy*>(gpr_zalloc(sizeof(*glb_policy)));
|
||||
|
||||
/* Get server name. */
|
||||
arg = grpc_channel_args_find(args->args, GRPC_ARG_SERVER_URI);
|
||||
|
|
@ -1921,7 +1920,7 @@ static bool maybe_add_client_load_reporting_filter(
|
|||
if (channel_arg != nullptr && channel_arg->type == GRPC_ARG_STRING &&
|
||||
strcmp(channel_arg->value.string, "grpclb") == 0) {
|
||||
return grpc_channel_stack_builder_append_filter(
|
||||
builder, (const grpc_channel_filter*)arg, nullptr, nullptr);
|
||||
builder, static_cast<const grpc_channel_filter*>(arg), nullptr, nullptr);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ struct grpc_grpclb_client_stats {
|
|||
|
||||
grpc_grpclb_client_stats* grpc_grpclb_client_stats_create() {
|
||||
grpc_grpclb_client_stats* client_stats =
|
||||
(grpc_grpclb_client_stats*)gpr_zalloc(sizeof(*client_stats));
|
||||
static_cast<grpc_grpclb_client_stats*>(gpr_zalloc(sizeof(*client_stats)));
|
||||
gpr_ref_init(&client_stats->refs, 1);
|
||||
return client_stats;
|
||||
}
|
||||
|
|
@ -88,8 +88,8 @@ void grpc_grpclb_client_stats_add_call_dropped_locked(
|
|||
// Record the drop.
|
||||
if (client_stats->drop_token_counts == nullptr) {
|
||||
client_stats->drop_token_counts =
|
||||
(grpc_grpclb_dropped_call_counts*)gpr_zalloc(
|
||||
sizeof(grpc_grpclb_dropped_call_counts));
|
||||
static_cast<grpc_grpclb_dropped_call_counts*>(gpr_zalloc(
|
||||
sizeof(grpc_grpclb_dropped_call_counts)));
|
||||
}
|
||||
grpc_grpclb_dropped_call_counts* drop_token_counts =
|
||||
client_stats->drop_token_counts;
|
||||
|
|
@ -104,9 +104,9 @@ void grpc_grpclb_client_stats_add_call_dropped_locked(
|
|||
while (new_num_entries < drop_token_counts->num_entries + 1) {
|
||||
new_num_entries *= 2;
|
||||
}
|
||||
drop_token_counts->token_counts = (grpc_grpclb_drop_token_count*)gpr_realloc(
|
||||
drop_token_counts->token_counts = static_cast<grpc_grpclb_drop_token_count*>(gpr_realloc(
|
||||
drop_token_counts->token_counts,
|
||||
new_num_entries * sizeof(grpc_grpclb_drop_token_count));
|
||||
new_num_entries * sizeof(grpc_grpclb_drop_token_count)));
|
||||
grpc_grpclb_drop_token_count* new_entry =
|
||||
&drop_token_counts->token_counts[drop_token_counts->num_entries++];
|
||||
new_entry->token = gpr_strdup(token);
|
||||
|
|
@ -114,7 +114,7 @@ void grpc_grpclb_client_stats_add_call_dropped_locked(
|
|||
}
|
||||
|
||||
static void atomic_get_and_reset_counter(int64_t* value, gpr_atm* counter) {
|
||||
*value = (int64_t)gpr_atm_acq_load(counter);
|
||||
*value = static_cast<int64_t>gpr_atm_acq_load(counter);
|
||||
gpr_atm_full_fetch_add(counter, (gpr_atm)(-*value));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
/* invoked once for every Server in ServerList */
|
||||
static bool count_serverlist(pb_istream_t* stream, const pb_field_t* field,
|
||||
void** arg) {
|
||||
grpc_grpclb_serverlist* sl = (grpc_grpclb_serverlist*)*arg;
|
||||
grpc_grpclb_serverlist* sl = static_cast<grpc_grpclb_serverlist*>(*arg);
|
||||
grpc_grpclb_server server;
|
||||
if (!pb_decode(stream, grpc_lb_v1_Server_fields, &server)) {
|
||||
gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(stream));
|
||||
|
|
@ -46,10 +46,10 @@ typedef struct decode_serverlist_arg {
|
|||
/* invoked once for every Server in ServerList */
|
||||
static bool decode_serverlist(pb_istream_t* stream, const pb_field_t* field,
|
||||
void** arg) {
|
||||
decode_serverlist_arg* dec_arg = (decode_serverlist_arg*)*arg;
|
||||
decode_serverlist_arg* dec_arg = static_cast<decode_serverlist_arg*>(*arg);
|
||||
GPR_ASSERT(dec_arg->serverlist->num_servers >= dec_arg->decoding_idx);
|
||||
grpc_grpclb_server* server =
|
||||
(grpc_grpclb_server*)gpr_zalloc(sizeof(grpc_grpclb_server));
|
||||
static_cast<grpc_grpclb_server*>(gpr_zalloc(sizeof(grpc_grpclb_server)));
|
||||
if (!pb_decode(stream, grpc_lb_v1_Server_fields, server)) {
|
||||
gpr_free(server);
|
||||
gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(stream));
|
||||
|
|
@ -61,7 +61,7 @@ static bool decode_serverlist(pb_istream_t* stream, const pb_field_t* field,
|
|||
|
||||
grpc_grpclb_request* grpc_grpclb_request_create(const char* lb_service_name) {
|
||||
grpc_grpclb_request* req =
|
||||
(grpc_grpclb_request*)gpr_malloc(sizeof(grpc_grpclb_request));
|
||||
static_cast<grpc_grpclb_request*>(gpr_malloc(sizeof(grpc_grpclb_request)));
|
||||
req->has_client_stats = false;
|
||||
req->has_initial_request = true;
|
||||
req->initial_request.has_name = true;
|
||||
|
|
@ -80,15 +80,15 @@ static void populate_timestamp(gpr_timespec timestamp,
|
|||
|
||||
static bool encode_string(pb_ostream_t* stream, const pb_field_t* field,
|
||||
void* const* arg) {
|
||||
char* str = (char*)*arg;
|
||||
char* str = static_cast<char*>(*arg);
|
||||
if (!pb_encode_tag_for_field(stream, field)) return false;
|
||||
return pb_encode_string(stream, (uint8_t*)str, strlen(str));
|
||||
return pb_encode_string(stream, reinterpret_cast<uint8_t*>(str), strlen(str));
|
||||
}
|
||||
|
||||
static bool encode_drops(pb_ostream_t* stream, const pb_field_t* field,
|
||||
void* const* arg) {
|
||||
grpc_grpclb_dropped_call_counts* drop_entries =
|
||||
(grpc_grpclb_dropped_call_counts*)*arg;
|
||||
static_cast<grpc_grpclb_dropped_call_counts*>(*arg);
|
||||
if (drop_entries == nullptr) return true;
|
||||
for (size_t i = 0; i < drop_entries->num_entries; ++i) {
|
||||
if (!pb_encode_tag_for_field(stream, field)) return false;
|
||||
|
|
@ -108,7 +108,7 @@ static bool encode_drops(pb_ostream_t* stream, const pb_field_t* field,
|
|||
grpc_grpclb_request* grpc_grpclb_load_report_request_create_locked(
|
||||
grpc_grpclb_client_stats* client_stats) {
|
||||
grpc_grpclb_request* req =
|
||||
(grpc_grpclb_request*)gpr_zalloc(sizeof(grpc_grpclb_request));
|
||||
static_cast<grpc_grpclb_request*>(gpr_zalloc(sizeof(grpc_grpclb_request)));
|
||||
req->has_client_stats = true;
|
||||
req->client_stats.has_timestamp = true;
|
||||
populate_timestamp(gpr_now(GPR_CLOCK_REALTIME), &req->client_stats.timestamp);
|
||||
|
|
@ -123,8 +123,8 @@ grpc_grpclb_request* grpc_grpclb_load_report_request_create_locked(
|
|||
&req->client_stats.num_calls_finished,
|
||||
&req->client_stats.num_calls_finished_with_client_failed_to_send,
|
||||
&req->client_stats.num_calls_finished_known_received,
|
||||
(grpc_grpclb_dropped_call_counts**)&req->client_stats
|
||||
.calls_finished_with_drop.arg);
|
||||
reinterpret_cast<grpc_grpclb_dropped_call_counts**>(&req->client_stats
|
||||
.calls_finished_with_drop.arg));
|
||||
return req;
|
||||
}
|
||||
|
||||
|
|
@ -148,8 +148,7 @@ grpc_slice grpc_grpclb_request_encode(const grpc_grpclb_request* request) {
|
|||
void grpc_grpclb_request_destroy(grpc_grpclb_request* request) {
|
||||
if (request->has_client_stats) {
|
||||
grpc_grpclb_dropped_call_counts* drop_entries =
|
||||
(grpc_grpclb_dropped_call_counts*)
|
||||
request->client_stats.calls_finished_with_drop.arg;
|
||||
static_cast<grpc_grpclb_dropped_call_counts*>(request->client_stats.calls_finished_with_drop.arg);
|
||||
grpc_grpclb_dropped_call_counts_destroy(drop_entries);
|
||||
}
|
||||
gpr_free(request);
|
||||
|
|
@ -171,8 +170,8 @@ grpc_grpclb_initial_response* grpc_grpclb_initial_response_parse(
|
|||
if (!res.has_initial_response) return nullptr;
|
||||
|
||||
grpc_grpclb_initial_response* initial_res =
|
||||
(grpc_grpclb_initial_response*)gpr_malloc(
|
||||
sizeof(grpc_grpclb_initial_response));
|
||||
static_cast<grpc_grpclb_initial_response*>(gpr_malloc(
|
||||
sizeof(grpc_grpclb_initial_response)));
|
||||
memcpy(initial_res, &res.initial_response,
|
||||
sizeof(grpc_grpclb_initial_response));
|
||||
|
||||
|
|
@ -186,7 +185,7 @@ grpc_grpclb_serverlist* grpc_grpclb_response_parse_serverlist(
|
|||
GRPC_SLICE_LENGTH(encoded_grpc_grpclb_response));
|
||||
pb_istream_t stream_at_start = stream;
|
||||
grpc_grpclb_serverlist* sl =
|
||||
(grpc_grpclb_serverlist*)gpr_zalloc(sizeof(grpc_grpclb_serverlist));
|
||||
static_cast<grpc_grpclb_serverlist*>(gpr_zalloc(sizeof(grpc_grpclb_serverlist)));
|
||||
grpc_grpclb_response res;
|
||||
memset(&res, 0, sizeof(grpc_grpclb_response));
|
||||
// First pass: count number of servers.
|
||||
|
|
@ -200,8 +199,8 @@ grpc_grpclb_serverlist* grpc_grpclb_response_parse_serverlist(
|
|||
}
|
||||
// Second pass: populate servers.
|
||||
if (sl->num_servers > 0) {
|
||||
sl->servers = (grpc_grpclb_server**)gpr_zalloc(sizeof(grpc_grpclb_server*) *
|
||||
sl->num_servers);
|
||||
sl->servers = static_cast<grpc_grpclb_server**>(gpr_zalloc(sizeof(grpc_grpclb_server*) *
|
||||
sl->num_servers));
|
||||
decode_serverlist_arg decode_arg;
|
||||
memset(&decode_arg, 0, sizeof(decode_arg));
|
||||
decode_arg.serverlist = sl;
|
||||
|
|
@ -232,13 +231,13 @@ void grpc_grpclb_destroy_serverlist(grpc_grpclb_serverlist* serverlist) {
|
|||
grpc_grpclb_serverlist* grpc_grpclb_serverlist_copy(
|
||||
const grpc_grpclb_serverlist* sl) {
|
||||
grpc_grpclb_serverlist* copy =
|
||||
(grpc_grpclb_serverlist*)gpr_zalloc(sizeof(grpc_grpclb_serverlist));
|
||||
static_cast<grpc_grpclb_serverlist*>(gpr_zalloc(sizeof(grpc_grpclb_serverlist)));
|
||||
copy->num_servers = sl->num_servers;
|
||||
copy->servers = (grpc_grpclb_server**)gpr_malloc(sizeof(grpc_grpclb_server*) *
|
||||
sl->num_servers);
|
||||
copy->servers = static_cast<grpc_grpclb_server**>(gpr_malloc(sizeof(grpc_grpclb_server*) *
|
||||
sl->num_servers));
|
||||
for (size_t i = 0; i < sl->num_servers; i++) {
|
||||
copy->servers[i] =
|
||||
(grpc_grpclb_server*)gpr_malloc(sizeof(grpc_grpclb_server));
|
||||
static_cast<grpc_grpclb_server*>(gpr_malloc(sizeof(grpc_grpclb_server)));
|
||||
memcpy(copy->servers[i], sl->servers[i], sizeof(grpc_grpclb_server));
|
||||
}
|
||||
return copy;
|
||||
|
|
@ -291,7 +290,7 @@ int grpc_grpclb_duration_compare(const grpc_grpclb_duration* lhs,
|
|||
}
|
||||
|
||||
grpc_millis grpc_grpclb_duration_to_millis(grpc_grpclb_duration* duration_pb) {
|
||||
return (grpc_millis)(
|
||||
return static_cast<grpc_millis>(
|
||||
(duration_pb->has_seconds ? duration_pb->seconds : 0) * GPR_MS_PER_SEC +
|
||||
(duration_pb->has_nanos ? duration_pb->nanos : 0) / GPR_NS_PER_MS);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ typedef struct {
|
|||
} pick_first_lb_policy;
|
||||
|
||||
static void pf_destroy(grpc_lb_policy* pol) {
|
||||
pick_first_lb_policy* p = (pick_first_lb_policy*)pol;
|
||||
pick_first_lb_policy* p = reinterpret_cast<pick_first_lb_policy*>(pol);
|
||||
GPR_ASSERT(p->subchannel_list == nullptr);
|
||||
GPR_ASSERT(p->latest_pending_subchannel_list == nullptr);
|
||||
GPR_ASSERT(p->pending_picks == nullptr);
|
||||
|
|
@ -65,7 +65,7 @@ static void pf_destroy(grpc_lb_policy* pol) {
|
|||
|
||||
static void pf_shutdown_locked(grpc_lb_policy* pol,
|
||||
grpc_lb_policy* new_policy) {
|
||||
pick_first_lb_policy* p = (pick_first_lb_policy*)pol;
|
||||
pick_first_lb_policy* p = reinterpret_cast<pick_first_lb_policy*>(pol);
|
||||
grpc_error* error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Channel shutdown");
|
||||
if (grpc_lb_pick_first_trace.enabled()) {
|
||||
gpr_log(GPR_DEBUG, "Pick First %p Shutting down", p);
|
||||
|
|
@ -105,7 +105,7 @@ static void pf_shutdown_locked(grpc_lb_policy* pol,
|
|||
static void pf_cancel_pick_locked(grpc_lb_policy* pol,
|
||||
grpc_lb_policy_pick_state* pick,
|
||||
grpc_error* error) {
|
||||
pick_first_lb_policy* p = (pick_first_lb_policy*)pol;
|
||||
pick_first_lb_policy* p = reinterpret_cast<pick_first_lb_policy*>(pol);
|
||||
grpc_lb_policy_pick_state* pp = p->pending_picks;
|
||||
p->pending_picks = nullptr;
|
||||
while (pp != nullptr) {
|
||||
|
|
@ -128,7 +128,7 @@ static void pf_cancel_picks_locked(grpc_lb_policy* pol,
|
|||
uint32_t initial_metadata_flags_mask,
|
||||
uint32_t initial_metadata_flags_eq,
|
||||
grpc_error* error) {
|
||||
pick_first_lb_policy* p = (pick_first_lb_policy*)pol;
|
||||
pick_first_lb_policy* p = reinterpret_cast<pick_first_lb_policy*>(pol);
|
||||
grpc_lb_policy_pick_state* pick = p->pending_picks;
|
||||
p->pending_picks = nullptr;
|
||||
while (pick != nullptr) {
|
||||
|
|
@ -165,7 +165,7 @@ static void start_picking_locked(pick_first_lb_policy* p) {
|
|||
}
|
||||
|
||||
static void pf_exit_idle_locked(grpc_lb_policy* pol) {
|
||||
pick_first_lb_policy* p = (pick_first_lb_policy*)pol;
|
||||
pick_first_lb_policy* p = reinterpret_cast<pick_first_lb_policy*>(pol);
|
||||
if (!p->started_picking) {
|
||||
start_picking_locked(p);
|
||||
}
|
||||
|
|
@ -173,7 +173,7 @@ static void pf_exit_idle_locked(grpc_lb_policy* pol) {
|
|||
|
||||
static int pf_pick_locked(grpc_lb_policy* pol,
|
||||
grpc_lb_policy_pick_state* pick) {
|
||||
pick_first_lb_policy* p = (pick_first_lb_policy*)pol;
|
||||
pick_first_lb_policy* p = reinterpret_cast<pick_first_lb_policy*>(pol);
|
||||
// If we have a selected subchannel already, return synchronously.
|
||||
if (p->selected != nullptr) {
|
||||
pick->connected_subchannel = p->selected->connected_subchannel;
|
||||
|
|
@ -200,21 +200,21 @@ static void destroy_unselected_subchannels_locked(pick_first_lb_policy* p) {
|
|||
|
||||
static grpc_connectivity_state pf_check_connectivity_locked(
|
||||
grpc_lb_policy* pol, grpc_error** error) {
|
||||
pick_first_lb_policy* p = (pick_first_lb_policy*)pol;
|
||||
pick_first_lb_policy* p = reinterpret_cast<pick_first_lb_policy*>(pol);
|
||||
return grpc_connectivity_state_get(&p->state_tracker, error);
|
||||
}
|
||||
|
||||
static void pf_notify_on_state_change_locked(grpc_lb_policy* pol,
|
||||
grpc_connectivity_state* current,
|
||||
grpc_closure* notify) {
|
||||
pick_first_lb_policy* p = (pick_first_lb_policy*)pol;
|
||||
pick_first_lb_policy* p = reinterpret_cast<pick_first_lb_policy*>(pol);
|
||||
grpc_connectivity_state_notify_on_state_change(&p->state_tracker, current,
|
||||
notify);
|
||||
}
|
||||
|
||||
static void pf_ping_one_locked(grpc_lb_policy* pol, grpc_closure* on_initiate,
|
||||
grpc_closure* on_ack) {
|
||||
pick_first_lb_policy* p = (pick_first_lb_policy*)pol;
|
||||
pick_first_lb_policy* p = reinterpret_cast<pick_first_lb_policy*>(pol);
|
||||
if (p->selected) {
|
||||
p->selected->connected_subchannel->Ping(on_initiate, on_ack);
|
||||
} else {
|
||||
|
|
@ -229,7 +229,7 @@ static void pf_connectivity_changed_locked(void* arg, grpc_error* error);
|
|||
|
||||
static void pf_update_locked(grpc_lb_policy* policy,
|
||||
const grpc_lb_policy_args* args) {
|
||||
pick_first_lb_policy* p = (pick_first_lb_policy*)policy;
|
||||
pick_first_lb_policy* p = reinterpret_cast<pick_first_lb_policy*>(policy);
|
||||
const grpc_arg* arg =
|
||||
grpc_channel_args_find(args->args, GRPC_ARG_LB_ADDRESSES);
|
||||
if (arg == nullptr || arg->type != GRPC_ARG_POINTER) {
|
||||
|
|
@ -249,10 +249,10 @@ static void pf_update_locked(grpc_lb_policy* policy,
|
|||
return;
|
||||
}
|
||||
const grpc_lb_addresses* addresses =
|
||||
(const grpc_lb_addresses*)arg->value.pointer.p;
|
||||
static_cast<const grpc_lb_addresses*>(arg->value.pointer.p);
|
||||
if (grpc_lb_pick_first_trace.enabled()) {
|
||||
gpr_log(GPR_INFO, "Pick First %p received update with %lu addresses",
|
||||
(void*)p, (unsigned long)addresses->num_addresses);
|
||||
(void*)p, static_cast<unsigned long>(addresses->num_addresses));
|
||||
}
|
||||
grpc_lb_subchannel_list* subchannel_list = grpc_lb_subchannel_list_create(
|
||||
&p->base, &grpc_lb_pick_first_trace, addresses, args,
|
||||
|
|
@ -347,8 +347,8 @@ static void pf_update_locked(grpc_lb_policy* policy,
|
|||
}
|
||||
|
||||
static void pf_connectivity_changed_locked(void* arg, grpc_error* error) {
|
||||
grpc_lb_subchannel_data* sd = (grpc_lb_subchannel_data*)arg;
|
||||
pick_first_lb_policy* p = (pick_first_lb_policy*)sd->subchannel_list->policy;
|
||||
grpc_lb_subchannel_data* sd = static_cast<grpc_lb_subchannel_data*>(arg);
|
||||
pick_first_lb_policy* p = reinterpret_cast<pick_first_lb_policy*>(sd->subchannel_list->policy);
|
||||
if (grpc_lb_pick_first_trace.enabled()) {
|
||||
gpr_log(GPR_DEBUG,
|
||||
"Pick First %p connectivity changed for subchannel %p (%" PRIuPTR
|
||||
|
|
@ -521,7 +521,7 @@ static void pf_connectivity_changed_locked(void* arg, grpc_error* error) {
|
|||
|
||||
static void pf_set_reresolve_closure_locked(
|
||||
grpc_lb_policy* policy, grpc_closure* request_reresolution) {
|
||||
pick_first_lb_policy* p = (pick_first_lb_policy*)policy;
|
||||
pick_first_lb_policy* p = reinterpret_cast<pick_first_lb_policy*>(policy);
|
||||
GPR_ASSERT(!p->shutdown);
|
||||
GPR_ASSERT(policy->request_reresolution == nullptr);
|
||||
policy->request_reresolution = request_reresolution;
|
||||
|
|
@ -547,7 +547,7 @@ static void pick_first_factory_unref(grpc_lb_policy_factory* factory) {}
|
|||
static grpc_lb_policy* create_pick_first(grpc_lb_policy_factory* factory,
|
||||
grpc_lb_policy_args* args) {
|
||||
GPR_ASSERT(args->client_channel_factory != nullptr);
|
||||
pick_first_lb_policy* p = (pick_first_lb_policy*)gpr_zalloc(sizeof(*p));
|
||||
pick_first_lb_policy* p = static_cast<pick_first_lb_policy*>(gpr_zalloc(sizeof(*p)));
|
||||
if (grpc_lb_pick_first_trace.enabled()) {
|
||||
gpr_log(GPR_DEBUG, "Pick First %p created.", (void*)p);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,8 +82,8 @@ static size_t get_next_ready_subchannel_index_locked(
|
|||
gpr_log(GPR_INFO,
|
||||
"[RR %p] getting next ready subchannel (out of %lu), "
|
||||
"last_ready_subchannel_index=%lu",
|
||||
(void*)p, (unsigned long)p->subchannel_list->num_subchannels,
|
||||
(unsigned long)p->last_ready_subchannel_index);
|
||||
(void*)p, static_cast<unsigned long>(p->subchannel_list->num_subchannels),
|
||||
static_cast<unsigned long>(p->last_ready_subchannel_index));
|
||||
}
|
||||
for (size_t i = 0; i < p->subchannel_list->num_subchannels; ++i) {
|
||||
const size_t index = (i + p->last_ready_subchannel_index + 1) %
|
||||
|
|
@ -94,7 +94,7 @@ static size_t get_next_ready_subchannel_index_locked(
|
|||
"[RR %p] checking subchannel %p, subchannel_list %p, index %lu: "
|
||||
"state=%s",
|
||||
(void*)p, (void*)p->subchannel_list->subchannels[index].subchannel,
|
||||
(void*)p->subchannel_list, (unsigned long)index,
|
||||
(void*)p->subchannel_list, static_cast<unsigned long>(index),
|
||||
grpc_connectivity_state_name(
|
||||
p->subchannel_list->subchannels[index].curr_connectivity_state));
|
||||
}
|
||||
|
|
@ -106,7 +106,7 @@ static size_t get_next_ready_subchannel_index_locked(
|
|||
"subchannel_list %p",
|
||||
(void*)p,
|
||||
(void*)p->subchannel_list->subchannels[index].subchannel,
|
||||
(unsigned long)index, (void*)p->subchannel_list);
|
||||
static_cast<unsigned long>(index), (void*)p->subchannel_list);
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
|
@ -125,7 +125,7 @@ static void update_last_ready_subchannel_index_locked(round_robin_lb_policy* p,
|
|||
if (grpc_lb_round_robin_trace.enabled()) {
|
||||
gpr_log(GPR_DEBUG,
|
||||
"[RR %p] setting last_ready_subchannel_index=%lu (SC %p, CSC %p)",
|
||||
(void*)p, (unsigned long)last_ready_index,
|
||||
(void*)p, static_cast<unsigned long>(last_ready_index),
|
||||
(void*)p->subchannel_list->subchannels[last_ready_index].subchannel,
|
||||
(void*)p->subchannel_list->subchannels[last_ready_index]
|
||||
.connected_subchannel.get());
|
||||
|
|
@ -133,7 +133,7 @@ static void update_last_ready_subchannel_index_locked(round_robin_lb_policy* p,
|
|||
}
|
||||
|
||||
static void rr_destroy(grpc_lb_policy* pol) {
|
||||
round_robin_lb_policy* p = (round_robin_lb_policy*)pol;
|
||||
round_robin_lb_policy* p = reinterpret_cast<round_robin_lb_policy*>(pol);
|
||||
if (grpc_lb_round_robin_trace.enabled()) {
|
||||
gpr_log(GPR_DEBUG, "[RR %p] Destroying Round Robin policy at %p",
|
||||
(void*)pol, (void*)pol);
|
||||
|
|
@ -147,7 +147,7 @@ static void rr_destroy(grpc_lb_policy* pol) {
|
|||
|
||||
static void rr_shutdown_locked(grpc_lb_policy* pol,
|
||||
grpc_lb_policy* new_policy) {
|
||||
round_robin_lb_policy* p = (round_robin_lb_policy*)pol;
|
||||
round_robin_lb_policy* p = reinterpret_cast<round_robin_lb_policy*>(pol);
|
||||
grpc_error* error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Channel shutdown");
|
||||
if (grpc_lb_round_robin_trace.enabled()) {
|
||||
gpr_log(GPR_DEBUG, "[RR %p] Shutting down", p);
|
||||
|
|
@ -187,7 +187,7 @@ static void rr_shutdown_locked(grpc_lb_policy* pol,
|
|||
static void rr_cancel_pick_locked(grpc_lb_policy* pol,
|
||||
grpc_lb_policy_pick_state* pick,
|
||||
grpc_error* error) {
|
||||
round_robin_lb_policy* p = (round_robin_lb_policy*)pol;
|
||||
round_robin_lb_policy* p = reinterpret_cast<round_robin_lb_policy*>(pol);
|
||||
grpc_lb_policy_pick_state* pp = p->pending_picks;
|
||||
p->pending_picks = nullptr;
|
||||
while (pp != nullptr) {
|
||||
|
|
@ -210,7 +210,7 @@ static void rr_cancel_picks_locked(grpc_lb_policy* pol,
|
|||
uint32_t initial_metadata_flags_mask,
|
||||
uint32_t initial_metadata_flags_eq,
|
||||
grpc_error* error) {
|
||||
round_robin_lb_policy* p = (round_robin_lb_policy*)pol;
|
||||
round_robin_lb_policy* p = reinterpret_cast<round_robin_lb_policy*>(pol);
|
||||
grpc_lb_policy_pick_state* pick = p->pending_picks;
|
||||
p->pending_picks = nullptr;
|
||||
while (pick != nullptr) {
|
||||
|
|
@ -243,7 +243,7 @@ static void start_picking_locked(round_robin_lb_policy* p) {
|
|||
}
|
||||
|
||||
static void rr_exit_idle_locked(grpc_lb_policy* pol) {
|
||||
round_robin_lb_policy* p = (round_robin_lb_policy*)pol;
|
||||
round_robin_lb_policy* p = reinterpret_cast<round_robin_lb_policy*>(pol);
|
||||
if (!p->started_picking) {
|
||||
start_picking_locked(p);
|
||||
}
|
||||
|
|
@ -251,7 +251,7 @@ static void rr_exit_idle_locked(grpc_lb_policy* pol) {
|
|||
|
||||
static int rr_pick_locked(grpc_lb_policy* pol,
|
||||
grpc_lb_policy_pick_state* pick) {
|
||||
round_robin_lb_policy* p = (round_robin_lb_policy*)pol;
|
||||
round_robin_lb_policy* p = reinterpret_cast<round_robin_lb_policy*>(pol);
|
||||
if (grpc_lb_round_robin_trace.enabled()) {
|
||||
gpr_log(GPR_INFO, "[RR %p] Trying to pick (shutdown: %d)", pol,
|
||||
p->shutdown);
|
||||
|
|
@ -334,7 +334,7 @@ static void update_lb_connectivity_status_locked(grpc_lb_subchannel_data* sd,
|
|||
* subchannel_list->num_subchannels.
|
||||
*/
|
||||
grpc_lb_subchannel_list* subchannel_list = sd->subchannel_list;
|
||||
round_robin_lb_policy* p = (round_robin_lb_policy*)subchannel_list->policy;
|
||||
round_robin_lb_policy* p = reinterpret_cast<round_robin_lb_policy*>(subchannel_list->policy);
|
||||
GPR_ASSERT(sd->curr_connectivity_state != GRPC_CHANNEL_IDLE);
|
||||
if (subchannel_list->num_ready > 0) {
|
||||
/* 1) READY */
|
||||
|
|
@ -355,9 +355,9 @@ static void update_lb_connectivity_status_locked(grpc_lb_subchannel_data* sd,
|
|||
}
|
||||
|
||||
static void rr_connectivity_changed_locked(void* arg, grpc_error* error) {
|
||||
grpc_lb_subchannel_data* sd = (grpc_lb_subchannel_data*)arg;
|
||||
grpc_lb_subchannel_data* sd = static_cast<grpc_lb_subchannel_data*>(arg);
|
||||
round_robin_lb_policy* p =
|
||||
(round_robin_lb_policy*)sd->subchannel_list->policy;
|
||||
reinterpret_cast<round_robin_lb_policy*>(sd->subchannel_list->policy);
|
||||
if (grpc_lb_round_robin_trace.enabled()) {
|
||||
gpr_log(
|
||||
GPR_DEBUG,
|
||||
|
|
@ -426,7 +426,7 @@ static void rr_connectivity_changed_locked(void* arg, grpc_error* error) {
|
|||
if (grpc_lb_round_robin_trace.enabled()) {
|
||||
const unsigned long num_subchannels =
|
||||
p->subchannel_list != nullptr
|
||||
? (unsigned long)p->subchannel_list->num_subchannels
|
||||
? static_cast<unsigned long>(p->subchannel_list->num_subchannels)
|
||||
: 0;
|
||||
gpr_log(GPR_DEBUG,
|
||||
"[RR %p] phasing out subchannel list %p (size %lu) in favor "
|
||||
|
|
@ -467,7 +467,7 @@ static void rr_connectivity_changed_locked(void* arg, grpc_error* error) {
|
|||
"[RR %p] Fulfilling pending pick. Target <-- subchannel %p "
|
||||
"(subchannel_list %p, index %lu)",
|
||||
(void*)p, (void*)selected->subchannel,
|
||||
(void*)p->subchannel_list, (unsigned long)next_ready_index);
|
||||
(void*)p->subchannel_list, static_cast<unsigned long>(next_ready_index));
|
||||
}
|
||||
GRPC_CLOSURE_SCHED(pick->on_complete, GRPC_ERROR_NONE);
|
||||
}
|
||||
|
|
@ -490,21 +490,21 @@ static void rr_connectivity_changed_locked(void* arg, grpc_error* error) {
|
|||
|
||||
static grpc_connectivity_state rr_check_connectivity_locked(
|
||||
grpc_lb_policy* pol, grpc_error** error) {
|
||||
round_robin_lb_policy* p = (round_robin_lb_policy*)pol;
|
||||
round_robin_lb_policy* p = reinterpret_cast<round_robin_lb_policy*>(pol);
|
||||
return grpc_connectivity_state_get(&p->state_tracker, error);
|
||||
}
|
||||
|
||||
static void rr_notify_on_state_change_locked(grpc_lb_policy* pol,
|
||||
grpc_connectivity_state* current,
|
||||
grpc_closure* notify) {
|
||||
round_robin_lb_policy* p = (round_robin_lb_policy*)pol;
|
||||
round_robin_lb_policy* p = reinterpret_cast<round_robin_lb_policy*>(pol);
|
||||
grpc_connectivity_state_notify_on_state_change(&p->state_tracker, current,
|
||||
notify);
|
||||
}
|
||||
|
||||
static void rr_ping_one_locked(grpc_lb_policy* pol, grpc_closure* on_initiate,
|
||||
grpc_closure* on_ack) {
|
||||
round_robin_lb_policy* p = (round_robin_lb_policy*)pol;
|
||||
round_robin_lb_policy* p = reinterpret_cast<round_robin_lb_policy*>(pol);
|
||||
const size_t next_ready_index = get_next_ready_subchannel_index_locked(p);
|
||||
if (next_ready_index < p->subchannel_list->num_subchannels) {
|
||||
grpc_lb_subchannel_data* selected =
|
||||
|
|
@ -522,7 +522,7 @@ static void rr_ping_one_locked(grpc_lb_policy* pol, grpc_closure* on_initiate,
|
|||
|
||||
static void rr_update_locked(grpc_lb_policy* policy,
|
||||
const grpc_lb_policy_args* args) {
|
||||
round_robin_lb_policy* p = (round_robin_lb_policy*)policy;
|
||||
round_robin_lb_policy* p = reinterpret_cast<round_robin_lb_policy*>(policy);
|
||||
const grpc_arg* arg =
|
||||
grpc_channel_args_find(args->args, GRPC_ARG_LB_ADDRESSES);
|
||||
if (arg == nullptr || arg->type != GRPC_ARG_POINTER) {
|
||||
|
|
@ -537,7 +537,7 @@ static void rr_update_locked(grpc_lb_policy* policy,
|
|||
}
|
||||
return;
|
||||
}
|
||||
grpc_lb_addresses* addresses = (grpc_lb_addresses*)arg->value.pointer.p;
|
||||
grpc_lb_addresses* addresses = static_cast<grpc_lb_addresses*>(arg->value.pointer.p);
|
||||
if (grpc_lb_round_robin_trace.enabled()) {
|
||||
gpr_log(GPR_DEBUG, "[RR %p] received update with %" PRIuPTR " addresses", p,
|
||||
addresses->num_addresses);
|
||||
|
|
@ -617,7 +617,7 @@ static void rr_update_locked(grpc_lb_policy* policy,
|
|||
|
||||
static void rr_set_reresolve_closure_locked(
|
||||
grpc_lb_policy* policy, grpc_closure* request_reresolution) {
|
||||
round_robin_lb_policy* p = (round_robin_lb_policy*)policy;
|
||||
round_robin_lb_policy* p = reinterpret_cast<round_robin_lb_policy*>(policy);
|
||||
GPR_ASSERT(!p->shutdown);
|
||||
GPR_ASSERT(policy->request_reresolution == nullptr);
|
||||
policy->request_reresolution = request_reresolution;
|
||||
|
|
@ -643,7 +643,7 @@ static void round_robin_factory_unref(grpc_lb_policy_factory* factory) {}
|
|||
static grpc_lb_policy* round_robin_create(grpc_lb_policy_factory* factory,
|
||||
grpc_lb_policy_args* args) {
|
||||
GPR_ASSERT(args->client_channel_factory != nullptr);
|
||||
round_robin_lb_policy* p = (round_robin_lb_policy*)gpr_zalloc(sizeof(*p));
|
||||
round_robin_lb_policy* p = static_cast<round_robin_lb_policy*>(gpr_zalloc(sizeof(*p)));
|
||||
grpc_lb_policy_init(&p->base, &round_robin_lb_policy_vtable, args->combiner);
|
||||
grpc_subchannel_index_ref();
|
||||
grpc_connectivity_state_init(&p->state_tracker, GRPC_CHANNEL_IDLE,
|
||||
|
|
@ -651,7 +651,7 @@ static grpc_lb_policy* round_robin_create(grpc_lb_policy_factory* factory,
|
|||
rr_update_locked(&p->base, args);
|
||||
if (grpc_lb_round_robin_trace.enabled()) {
|
||||
gpr_log(GPR_DEBUG, "[RR %p] Created with %lu subchannels", (void*)p,
|
||||
(unsigned long)p->subchannel_list->num_subchannels);
|
||||
static_cast<unsigned long>(p->subchannel_list->num_subchannels));
|
||||
}
|
||||
return &p->base;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ void grpc_lb_subchannel_data_unref_subchannel(grpc_lb_subchannel_data* sd,
|
|||
" (subchannel %p): unreffing subchannel",
|
||||
sd->subchannel_list->tracer->name(), sd->subchannel_list->policy,
|
||||
sd->subchannel_list,
|
||||
(size_t)(sd - sd->subchannel_list->subchannels),
|
||||
static_cast<size_t>(sd - sd->subchannel_list->subchannels),
|
||||
sd->subchannel_list->num_subchannels, sd->subchannel);
|
||||
}
|
||||
GRPC_SUBCHANNEL_UNREF(sd->subchannel, reason);
|
||||
|
|
@ -60,7 +60,7 @@ void grpc_lb_subchannel_data_start_connectivity_watch(
|
|||
" (subchannel %p): requesting connectivity change "
|
||||
"notification (from %s)",
|
||||
sd->subchannel_list->tracer->name(), sd->subchannel_list->policy,
|
||||
sd->subchannel_list, (size_t)(sd - sd->subchannel_list->subchannels),
|
||||
sd->subchannel_list, static_cast<size_t>(sd - sd->subchannel_list->subchannels),
|
||||
sd->subchannel_list->num_subchannels, sd->subchannel,
|
||||
grpc_connectivity_state_name(sd->pending_connectivity_state_unsafe));
|
||||
}
|
||||
|
|
@ -79,7 +79,7 @@ void grpc_lb_subchannel_data_stop_connectivity_watch(
|
|||
" (subchannel %p): stopping connectivity watch",
|
||||
sd->subchannel_list->tracer->name(), sd->subchannel_list->policy,
|
||||
sd->subchannel_list,
|
||||
(size_t)(sd - sd->subchannel_list->subchannels),
|
||||
static_cast<size_t>(sd - sd->subchannel_list->subchannels),
|
||||
sd->subchannel_list->num_subchannels, sd->subchannel);
|
||||
}
|
||||
GPR_ASSERT(sd->connectivity_notification_pending);
|
||||
|
|
@ -91,7 +91,7 @@ grpc_lb_subchannel_list* grpc_lb_subchannel_list_create(
|
|||
const grpc_lb_addresses* addresses, const grpc_lb_policy_args* args,
|
||||
grpc_iomgr_cb_func connectivity_changed_cb) {
|
||||
grpc_lb_subchannel_list* subchannel_list =
|
||||
(grpc_lb_subchannel_list*)gpr_zalloc(sizeof(*subchannel_list));
|
||||
static_cast<grpc_lb_subchannel_list*>(gpr_zalloc(sizeof(*subchannel_list)));
|
||||
if (tracer->enabled()) {
|
||||
gpr_log(GPR_DEBUG,
|
||||
"[%s %p] Creating subchannel list %p for %" PRIuPTR " subchannels",
|
||||
|
|
@ -100,8 +100,8 @@ grpc_lb_subchannel_list* grpc_lb_subchannel_list_create(
|
|||
subchannel_list->policy = p;
|
||||
subchannel_list->tracer = tracer;
|
||||
gpr_ref_init(&subchannel_list->refcount, 1);
|
||||
subchannel_list->subchannels = (grpc_lb_subchannel_data*)gpr_zalloc(
|
||||
sizeof(grpc_lb_subchannel_data) * addresses->num_addresses);
|
||||
subchannel_list->subchannels = static_cast<grpc_lb_subchannel_data*>(gpr_zalloc(
|
||||
sizeof(grpc_lb_subchannel_data) * addresses->num_addresses));
|
||||
// We need to remove the LB addresses in order to be able to compare the
|
||||
// subchannel keys of subchannels from a different batch of addresses.
|
||||
static const char* keys_to_remove[] = {GRPC_ARG_SUBCHANNEL_ADDRESS,
|
||||
|
|
@ -190,7 +190,7 @@ void grpc_lb_subchannel_list_ref(grpc_lb_subchannel_list* subchannel_list,
|
|||
const gpr_atm count = gpr_atm_acq_load(&subchannel_list->refcount.count);
|
||||
gpr_log(GPR_DEBUG, "[%s %p] subchannel_list %p REF %lu->%lu (%s)",
|
||||
subchannel_list->tracer->name(), subchannel_list->policy,
|
||||
subchannel_list, (unsigned long)(count - 1), (unsigned long)count,
|
||||
subchannel_list, static_cast<unsigned long>(count - 1), static_cast<unsigned long>(count),
|
||||
reason);
|
||||
}
|
||||
}
|
||||
|
|
@ -202,7 +202,7 @@ void grpc_lb_subchannel_list_unref(grpc_lb_subchannel_list* subchannel_list,
|
|||
const gpr_atm count = gpr_atm_acq_load(&subchannel_list->refcount.count);
|
||||
gpr_log(GPR_DEBUG, "[%s %p] subchannel_list %p UNREF %lu->%lu (%s)",
|
||||
subchannel_list->tracer->name(), subchannel_list->policy,
|
||||
subchannel_list, (unsigned long)(count + 1), (unsigned long)count,
|
||||
subchannel_list, static_cast<unsigned long>(count + 1), static_cast<unsigned long>(count),
|
||||
reason);
|
||||
}
|
||||
if (done) {
|
||||
|
|
@ -230,7 +230,7 @@ static void subchannel_data_cancel_connectivity_watch(
|
|||
" (subchannel %p): canceling connectivity watch (%s)",
|
||||
sd->subchannel_list->tracer->name(), sd->subchannel_list->policy,
|
||||
sd->subchannel_list,
|
||||
(size_t)(sd - sd->subchannel_list->subchannels),
|
||||
static_cast<size_t>(sd - sd->subchannel_list->subchannels),
|
||||
sd->subchannel_list->num_subchannels, sd->subchannel, reason);
|
||||
}
|
||||
grpc_subchannel_notify_on_state_change(sd->subchannel, nullptr, nullptr,
|
||||
|
|
|
|||
|
|
@ -29,11 +29,11 @@
|
|||
grpc_lb_addresses* grpc_lb_addresses_create(
|
||||
size_t num_addresses, const grpc_lb_user_data_vtable* user_data_vtable) {
|
||||
grpc_lb_addresses* addresses =
|
||||
(grpc_lb_addresses*)gpr_zalloc(sizeof(grpc_lb_addresses));
|
||||
static_cast<grpc_lb_addresses*>(gpr_zalloc(sizeof(grpc_lb_addresses)));
|
||||
addresses->num_addresses = num_addresses;
|
||||
addresses->user_data_vtable = user_data_vtable;
|
||||
const size_t addresses_size = sizeof(grpc_lb_address) * num_addresses;
|
||||
addresses->addresses = (grpc_lb_address*)gpr_zalloc(addresses_size);
|
||||
addresses->addresses = static_cast<grpc_lb_address*>(gpr_zalloc(addresses_size));
|
||||
return addresses;
|
||||
}
|
||||
|
||||
|
|
@ -124,14 +124,14 @@ void grpc_lb_addresses_destroy(grpc_lb_addresses* addresses) {
|
|||
}
|
||||
|
||||
static void* lb_addresses_copy(void* addresses) {
|
||||
return grpc_lb_addresses_copy((grpc_lb_addresses*)addresses);
|
||||
return grpc_lb_addresses_copy(static_cast<grpc_lb_addresses*>(addresses));
|
||||
}
|
||||
static void lb_addresses_destroy(void* addresses) {
|
||||
grpc_lb_addresses_destroy((grpc_lb_addresses*)addresses);
|
||||
grpc_lb_addresses_destroy(static_cast<grpc_lb_addresses*>(addresses));
|
||||
}
|
||||
static int lb_addresses_cmp(void* addresses1, void* addresses2) {
|
||||
return grpc_lb_addresses_cmp((grpc_lb_addresses*)addresses1,
|
||||
(grpc_lb_addresses*)addresses2);
|
||||
return grpc_lb_addresses_cmp(static_cast<grpc_lb_addresses*>(addresses1),
|
||||
static_cast<grpc_lb_addresses*>(addresses2));
|
||||
}
|
||||
static const grpc_arg_pointer_vtable lb_addresses_arg_vtable = {
|
||||
lb_addresses_copy, lb_addresses_destroy, lb_addresses_cmp};
|
||||
|
|
@ -148,7 +148,7 @@ grpc_lb_addresses* grpc_lb_addresses_find_channel_arg(
|
|||
grpc_channel_args_find(channel_args, GRPC_ARG_LB_ADDRESSES);
|
||||
if (lb_addresses_arg == nullptr || lb_addresses_arg->type != GRPC_ARG_POINTER)
|
||||
return nullptr;
|
||||
return (grpc_lb_addresses*)lb_addresses_arg->value.pointer.p;
|
||||
return static_cast<grpc_lb_addresses*>(lb_addresses_arg->value.pointer.p);
|
||||
}
|
||||
|
||||
void grpc_lb_policy_factory_ref(grpc_lb_policy_factory* factory) {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ bool grpc_parse_unix(const grpc_uri* uri,
|
|||
gpr_log(GPR_ERROR, "Expected 'unix' scheme, got '%s'", uri->scheme);
|
||||
return false;
|
||||
}
|
||||
struct sockaddr_un* un = (struct sockaddr_un*)resolved_addr->addr;
|
||||
struct sockaddr_un* un = reinterpret_cast<struct sockaddr_un*>(resolved_addr->addr);
|
||||
const size_t maxlen = sizeof(un->sun_path);
|
||||
const size_t path_len = strnlen(uri->path, maxlen);
|
||||
if (path_len == maxlen) return false;
|
||||
|
|
@ -69,7 +69,7 @@ bool grpc_parse_ipv4_hostport(const char* hostport, grpc_resolved_address* addr,
|
|||
// Parse IP address.
|
||||
memset(addr, 0, sizeof(*addr));
|
||||
addr->len = sizeof(struct sockaddr_in);
|
||||
struct sockaddr_in* in = (struct sockaddr_in*)addr->addr;
|
||||
struct sockaddr_in* in = reinterpret_cast<struct sockaddr_in*>(addr->addr);
|
||||
in->sin_family = AF_INET;
|
||||
if (inet_pton(AF_INET, host, &in->sin_addr) == 0) {
|
||||
if (log_errors) gpr_log(GPR_ERROR, "invalid ipv4 address: '%s'", host);
|
||||
|
|
@ -85,7 +85,7 @@ bool grpc_parse_ipv4_hostport(const char* hostport, grpc_resolved_address* addr,
|
|||
if (log_errors) gpr_log(GPR_ERROR, "invalid ipv4 port: '%s'", port);
|
||||
goto done;
|
||||
}
|
||||
in->sin_port = htons((uint16_t)port_num);
|
||||
in->sin_port = htons(static_cast<uint16_t>(port_num));
|
||||
success = true;
|
||||
done:
|
||||
gpr_free(host);
|
||||
|
|
@ -115,14 +115,14 @@ bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr,
|
|||
// Parse IP address.
|
||||
memset(addr, 0, sizeof(*addr));
|
||||
addr->len = sizeof(struct sockaddr_in6);
|
||||
struct sockaddr_in6* in6 = (struct sockaddr_in6*)addr->addr;
|
||||
struct sockaddr_in6* in6 = reinterpret_cast<struct sockaddr_in6*>(addr->addr);
|
||||
in6->sin6_family = AF_INET6;
|
||||
// Handle the RFC6874 syntax for IPv6 zone identifiers.
|
||||
char* host_end = (char*)gpr_memrchr(host, '%', strlen(host));
|
||||
char* host_end = static_cast<char*>(gpr_memrchr(host, '%', strlen(host)));
|
||||
if (host_end != nullptr) {
|
||||
GPR_ASSERT(host_end >= host);
|
||||
char host_without_scope[INET6_ADDRSTRLEN];
|
||||
size_t host_without_scope_len = (size_t)(host_end - host);
|
||||
size_t host_without_scope_len = static_cast<size_t>(host_end - host);
|
||||
uint32_t sin6_scope_id = 0;
|
||||
strncpy(host_without_scope, host, host_without_scope_len);
|
||||
host_without_scope[host_without_scope_len] = '\0';
|
||||
|
|
@ -154,7 +154,7 @@ bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr,
|
|||
if (log_errors) gpr_log(GPR_ERROR, "invalid ipv6 port: '%s'", port);
|
||||
goto done;
|
||||
}
|
||||
in6->sin6_port = htons((uint16_t)port_num);
|
||||
in6->sin6_port = htons(static_cast<uint16_t>(port_num));
|
||||
success = true;
|
||||
done:
|
||||
gpr_free(host);
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@ typedef struct {
|
|||
static void grpc_proxy_mapper_list_register(grpc_proxy_mapper_list* list,
|
||||
bool at_start,
|
||||
grpc_proxy_mapper* mapper) {
|
||||
list->list = (grpc_proxy_mapper**)gpr_realloc(
|
||||
list->list, (list->num_mappers + 1) * sizeof(grpc_proxy_mapper*));
|
||||
list->list = static_cast<grpc_proxy_mapper**>(gpr_realloc(
|
||||
list->list, (list->num_mappers + 1) * sizeof(grpc_proxy_mapper*)));
|
||||
if (at_start) {
|
||||
memmove(list->list + 1, list->list,
|
||||
sizeof(grpc_proxy_mapper*) * list->num_mappers);
|
||||
|
|
|
|||
|
|
@ -312,7 +312,7 @@ void AresDnsResolver::OnResolvedLocked(void* arg, grpc_error* error) {
|
|||
if (lb_policy_name != nullptr) {
|
||||
args_to_remove[num_args_to_remove++] = GRPC_ARG_LB_POLICY_NAME;
|
||||
new_args[num_args_to_add++] = grpc_channel_arg_string_create(
|
||||
(char*)GRPC_ARG_LB_POLICY_NAME, (char*)lb_policy_name);
|
||||
(char*)GRPC_ARG_LB_POLICY_NAME, const_cast<char*>(lb_policy_name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ static void fd_node_shutdown(fd_node* fdn) {
|
|||
|
||||
grpc_error* grpc_ares_ev_driver_create(grpc_ares_ev_driver** ev_driver,
|
||||
grpc_pollset_set* pollset_set) {
|
||||
*ev_driver = (grpc_ares_ev_driver*)gpr_malloc(sizeof(grpc_ares_ev_driver));
|
||||
*ev_driver = static_cast<grpc_ares_ev_driver*>(gpr_malloc(sizeof(grpc_ares_ev_driver)));
|
||||
int status = ares_init(&(*ev_driver)->channel);
|
||||
gpr_log(GPR_DEBUG, "grpc_ares_ev_driver_create");
|
||||
if (status != ARES_SUCCESS) {
|
||||
|
|
@ -195,7 +195,7 @@ static bool grpc_ares_is_fd_still_readable(grpc_ares_ev_driver* ev_driver,
|
|||
}
|
||||
|
||||
static void on_readable_cb(void* arg, grpc_error* error) {
|
||||
fd_node* fdn = (fd_node*)arg;
|
||||
fd_node* fdn = static_cast<fd_node*>(arg);
|
||||
grpc_ares_ev_driver* ev_driver = fdn->ev_driver;
|
||||
gpr_mu_lock(&fdn->mu);
|
||||
const int fd = grpc_fd_wrapped_fd(fdn->fd);
|
||||
|
|
@ -229,7 +229,7 @@ static void on_readable_cb(void* arg, grpc_error* error) {
|
|||
}
|
||||
|
||||
static void on_writable_cb(void* arg, grpc_error* error) {
|
||||
fd_node* fdn = (fd_node*)arg;
|
||||
fd_node* fdn = static_cast<fd_node*>(arg);
|
||||
grpc_ares_ev_driver* ev_driver = fdn->ev_driver;
|
||||
gpr_mu_lock(&fdn->mu);
|
||||
const int fd = grpc_fd_wrapped_fd(fdn->fd);
|
||||
|
|
@ -280,7 +280,7 @@ static void grpc_ares_notify_on_event_locked(grpc_ares_ev_driver* ev_driver) {
|
|||
if (fdn == nullptr) {
|
||||
char* fd_name;
|
||||
gpr_asprintf(&fd_name, "ares_ev_driver-%" PRIuPTR, i);
|
||||
fdn = (fd_node*)gpr_malloc(sizeof(fd_node));
|
||||
fdn = static_cast<fd_node*>(gpr_malloc(sizeof(fd_node)));
|
||||
gpr_log(GPR_DEBUG, "new fd: %d", socks[i]);
|
||||
fdn->fd = grpc_fd_create(socks[i], fd_name);
|
||||
fdn->ev_driver = ev_driver;
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ static uint16_t strhtons(const char* port) {
|
|||
} else if (strcmp(port, "https") == 0) {
|
||||
return htons(443);
|
||||
}
|
||||
return htons((unsigned short)atoi(port));
|
||||
return htons(static_cast<unsigned short>(atoi(port)));
|
||||
}
|
||||
|
||||
static void grpc_ares_request_ref(grpc_ares_request* r) {
|
||||
|
|
@ -110,8 +110,8 @@ static void grpc_ares_request_unref(grpc_ares_request* r) {
|
|||
static grpc_ares_hostbyname_request* create_hostbyname_request(
|
||||
grpc_ares_request* parent_request, char* host, uint16_t port,
|
||||
bool is_balancer) {
|
||||
grpc_ares_hostbyname_request* hr = (grpc_ares_hostbyname_request*)gpr_zalloc(
|
||||
sizeof(grpc_ares_hostbyname_request));
|
||||
grpc_ares_hostbyname_request* hr = static_cast<grpc_ares_hostbyname_request*>(gpr_zalloc(
|
||||
sizeof(grpc_ares_hostbyname_request)));
|
||||
hr->parent_request = parent_request;
|
||||
hr->host = gpr_strdup(host);
|
||||
hr->port = port;
|
||||
|
|
@ -128,7 +128,7 @@ static void destroy_hostbyname_request(grpc_ares_hostbyname_request* hr) {
|
|||
|
||||
static void on_hostbyname_done_cb(void* arg, int status, int timeouts,
|
||||
struct hostent* hostent) {
|
||||
grpc_ares_hostbyname_request* hr = (grpc_ares_hostbyname_request*)arg;
|
||||
grpc_ares_hostbyname_request* hr = static_cast<grpc_ares_hostbyname_request*>(arg);
|
||||
grpc_ares_request* r = hr->parent_request;
|
||||
gpr_mu_lock(&r->mu);
|
||||
if (status == ARES_SUCCESS) {
|
||||
|
|
@ -144,9 +144,9 @@ static void on_hostbyname_done_cb(void* arg, int status, int timeouts,
|
|||
for (i = 0; hostent->h_addr_list[i] != nullptr; i++) {
|
||||
}
|
||||
(*lb_addresses)->num_addresses += i;
|
||||
(*lb_addresses)->addresses = (grpc_lb_address*)gpr_realloc(
|
||||
(*lb_addresses)->addresses = static_cast<grpc_lb_address*>(gpr_realloc(
|
||||
(*lb_addresses)->addresses,
|
||||
sizeof(grpc_lb_address) * (*lb_addresses)->num_addresses);
|
||||
sizeof(grpc_lb_address) * (*lb_addresses)->num_addresses));
|
||||
for (i = prev_naddr; i < (*lb_addresses)->num_addresses; i++) {
|
||||
switch (hostent->h_addrtype) {
|
||||
case AF_INET6: {
|
||||
|
|
@ -155,7 +155,7 @@ static void on_hostbyname_done_cb(void* arg, int status, int timeouts,
|
|||
memset(&addr, 0, addr_len);
|
||||
memcpy(&addr.sin6_addr, hostent->h_addr_list[i - prev_naddr],
|
||||
sizeof(struct in6_addr));
|
||||
addr.sin6_family = (sa_family_t)hostent->h_addrtype;
|
||||
addr.sin6_family = static_cast<sa_family_t>(hostent->h_addrtype);
|
||||
addr.sin6_port = hr->port;
|
||||
grpc_lb_addresses_set_address(
|
||||
*lb_addresses, i, &addr, addr_len,
|
||||
|
|
@ -176,7 +176,7 @@ static void on_hostbyname_done_cb(void* arg, int status, int timeouts,
|
|||
memset(&addr, 0, addr_len);
|
||||
memcpy(&addr.sin_addr, hostent->h_addr_list[i - prev_naddr],
|
||||
sizeof(struct in_addr));
|
||||
addr.sin_family = (sa_family_t)hostent->h_addrtype;
|
||||
addr.sin_family = static_cast<sa_family_t>(hostent->h_addrtype);
|
||||
addr.sin_port = hr->port;
|
||||
grpc_lb_addresses_set_address(
|
||||
*lb_addresses, i, &addr, addr_len,
|
||||
|
|
@ -211,7 +211,7 @@ static void on_hostbyname_done_cb(void* arg, int status, int timeouts,
|
|||
|
||||
static void on_srv_query_done_cb(void* arg, int status, int timeouts,
|
||||
unsigned char* abuf, int alen) {
|
||||
grpc_ares_request* r = (grpc_ares_request*)arg;
|
||||
grpc_ares_request* r = static_cast<grpc_ares_request*>(arg);
|
||||
grpc_core::ExecCtx exec_ctx;
|
||||
gpr_log(GPR_DEBUG, "on_query_srv_done_cb");
|
||||
if (status == ARES_SUCCESS) {
|
||||
|
|
@ -259,7 +259,7 @@ static void on_txt_done_cb(void* arg, int status, int timeouts,
|
|||
unsigned char* buf, int len) {
|
||||
gpr_log(GPR_DEBUG, "on_txt_done_cb");
|
||||
char* error_msg;
|
||||
grpc_ares_request* r = (grpc_ares_request*)arg;
|
||||
grpc_ares_request* r = static_cast<grpc_ares_request*>(arg);
|
||||
const size_t prefix_len = sizeof(g_service_config_attribute_prefix) - 1;
|
||||
struct ares_txt_ext* result = nullptr;
|
||||
struct ares_txt_ext* reply = nullptr;
|
||||
|
|
@ -279,13 +279,13 @@ static void on_txt_done_cb(void* arg, int status, int timeouts,
|
|||
// Found a service config record.
|
||||
if (result != nullptr) {
|
||||
size_t service_config_len = result->length - prefix_len;
|
||||
*r->service_config_json_out = (char*)gpr_malloc(service_config_len + 1);
|
||||
*r->service_config_json_out = static_cast<char*>(gpr_malloc(service_config_len + 1));
|
||||
memcpy(*r->service_config_json_out, result->txt + prefix_len,
|
||||
service_config_len);
|
||||
for (result = result->next; result != nullptr && !result->record_start;
|
||||
result = result->next) {
|
||||
*r->service_config_json_out = (char*)gpr_realloc(
|
||||
*r->service_config_json_out, service_config_len + result->length + 1);
|
||||
*r->service_config_json_out = static_cast<char*>(gpr_realloc(
|
||||
*r->service_config_json_out, service_config_len + result->length + 1));
|
||||
memcpy(*r->service_config_json_out + service_config_len, result->txt,
|
||||
result->length);
|
||||
service_config_len += result->length;
|
||||
|
|
@ -348,7 +348,7 @@ static grpc_ares_request* grpc_dns_lookup_ares_impl(
|
|||
error = grpc_ares_ev_driver_create(&ev_driver, interested_parties);
|
||||
if (error != GRPC_ERROR_NONE) goto error_cleanup;
|
||||
|
||||
r = (grpc_ares_request*)gpr_zalloc(sizeof(grpc_ares_request));
|
||||
r = static_cast<grpc_ares_request*>(gpr_zalloc(sizeof(grpc_ares_request)));
|
||||
gpr_mu_init(&r->mu);
|
||||
r->ev_driver = ev_driver;
|
||||
r->on_done = on_done;
|
||||
|
|
@ -364,7 +364,7 @@ static grpc_ares_request* grpc_dns_lookup_ares_impl(
|
|||
grpc_resolved_address addr;
|
||||
if (grpc_parse_ipv4_hostport(dns_server, &addr, false /* log_errors */)) {
|
||||
r->dns_server_addr.family = AF_INET;
|
||||
struct sockaddr_in* in = (struct sockaddr_in*)addr.addr;
|
||||
struct sockaddr_in* in = reinterpret_cast<struct sockaddr_in*>(addr.addr);
|
||||
memcpy(&r->dns_server_addr.addr.addr4, &in->sin_addr,
|
||||
sizeof(struct in_addr));
|
||||
r->dns_server_addr.tcp_port = grpc_sockaddr_get_port(&addr);
|
||||
|
|
@ -372,7 +372,7 @@ static grpc_ares_request* grpc_dns_lookup_ares_impl(
|
|||
} else if (grpc_parse_ipv6_hostport(dns_server, &addr,
|
||||
false /* log_errors */)) {
|
||||
r->dns_server_addr.family = AF_INET6;
|
||||
struct sockaddr_in6* in6 = (struct sockaddr_in6*)addr.addr;
|
||||
struct sockaddr_in6* in6 = reinterpret_cast<struct sockaddr_in6*>(addr.addr);
|
||||
memcpy(&r->dns_server_addr.addr.addr6, &in6->sin6_addr,
|
||||
sizeof(struct in6_addr));
|
||||
r->dns_server_addr.tcp_port = grpc_sockaddr_get_port(&addr);
|
||||
|
|
@ -487,16 +487,16 @@ typedef struct grpc_resolve_address_ares_request {
|
|||
|
||||
static void on_dns_lookup_done_cb(void* arg, grpc_error* error) {
|
||||
grpc_resolve_address_ares_request* r =
|
||||
(grpc_resolve_address_ares_request*)arg;
|
||||
static_cast<grpc_resolve_address_ares_request*>(arg);
|
||||
grpc_resolved_addresses** resolved_addresses = r->addrs_out;
|
||||
if (r->lb_addrs == nullptr || r->lb_addrs->num_addresses == 0) {
|
||||
*resolved_addresses = nullptr;
|
||||
} else {
|
||||
*resolved_addresses =
|
||||
(grpc_resolved_addresses*)gpr_zalloc(sizeof(grpc_resolved_addresses));
|
||||
static_cast<grpc_resolved_addresses*>(gpr_zalloc(sizeof(grpc_resolved_addresses)));
|
||||
(*resolved_addresses)->naddrs = r->lb_addrs->num_addresses;
|
||||
(*resolved_addresses)->addrs = (grpc_resolved_address*)gpr_zalloc(
|
||||
sizeof(grpc_resolved_address) * (*resolved_addresses)->naddrs);
|
||||
(*resolved_addresses)->addrs = static_cast<grpc_resolved_address*>(gpr_zalloc(
|
||||
sizeof(grpc_resolved_address) * (*resolved_addresses)->naddrs));
|
||||
for (size_t i = 0; i < (*resolved_addresses)->naddrs; i++) {
|
||||
GPR_ASSERT(!r->lb_addrs->addresses[i].is_balancer);
|
||||
memcpy(&(*resolved_addresses)->addrs[i],
|
||||
|
|
@ -514,8 +514,8 @@ static void grpc_resolve_address_ares_impl(const char* name,
|
|||
grpc_closure* on_done,
|
||||
grpc_resolved_addresses** addrs) {
|
||||
grpc_resolve_address_ares_request* r =
|
||||
(grpc_resolve_address_ares_request*)gpr_zalloc(
|
||||
sizeof(grpc_resolve_address_ares_request));
|
||||
static_cast<grpc_resolve_address_ares_request*>(gpr_zalloc(
|
||||
sizeof(grpc_resolve_address_ares_request)));
|
||||
r->addrs_out = addrs;
|
||||
r->on_resolve_address_done = on_done;
|
||||
GRPC_CLOSURE_INIT(&r->on_dns_lookup_done, on_dns_lookup_done_cb, r,
|
||||
|
|
|
|||
|
|
@ -59,9 +59,9 @@ bool grpc_server_retry_throttle_data_record_failure(
|
|||
// First, check if we are stale and need to be replaced.
|
||||
get_replacement_throttle_data_if_needed(&throttle_data);
|
||||
// We decrement milli_tokens by 1000 (1 token) for each failure.
|
||||
const int new_value = (int)gpr_atm_no_barrier_clamped_add(
|
||||
&throttle_data->milli_tokens, (gpr_atm)-1000, (gpr_atm)0,
|
||||
(gpr_atm)throttle_data->max_milli_tokens);
|
||||
const int new_value = static_cast<int>(gpr_atm_no_barrier_clamped_add(
|
||||
&throttle_data->milli_tokens, static_cast<gpr_atm>(-1000), static_cast<gpr_atm>(0),
|
||||
static_cast<gpr_atm>(throttle_data->max_milli_tokens)));
|
||||
// Retries are allowed as long as the new value is above the threshold
|
||||
// (max_milli_tokens / 2).
|
||||
return new_value > throttle_data->max_milli_tokens / 2;
|
||||
|
|
@ -73,8 +73,8 @@ void grpc_server_retry_throttle_data_record_success(
|
|||
get_replacement_throttle_data_if_needed(&throttle_data);
|
||||
// We increment milli_tokens by milli_token_ratio for each success.
|
||||
gpr_atm_no_barrier_clamped_add(
|
||||
&throttle_data->milli_tokens, (gpr_atm)throttle_data->milli_token_ratio,
|
||||
(gpr_atm)0, (gpr_atm)throttle_data->max_milli_tokens);
|
||||
&throttle_data->milli_tokens, static_cast<gpr_atm>(throttle_data->milli_token_ratio),
|
||||
static_cast<gpr_atm>(0), static_cast<gpr_atm>(throttle_data->max_milli_tokens));
|
||||
}
|
||||
|
||||
grpc_server_retry_throttle_data* grpc_server_retry_throttle_data_ref(
|
||||
|
|
@ -100,7 +100,7 @@ static grpc_server_retry_throttle_data* grpc_server_retry_throttle_data_create(
|
|||
int max_milli_tokens, int milli_token_ratio,
|
||||
grpc_server_retry_throttle_data* old_throttle_data) {
|
||||
grpc_server_retry_throttle_data* throttle_data =
|
||||
(grpc_server_retry_throttle_data*)gpr_malloc(sizeof(*throttle_data));
|
||||
static_cast<grpc_server_retry_throttle_data*>(gpr_malloc(sizeof(*throttle_data)));
|
||||
memset(throttle_data, 0, sizeof(*throttle_data));
|
||||
gpr_ref_init(&throttle_data->refs, 1);
|
||||
throttle_data->max_milli_tokens = max_milli_tokens;
|
||||
|
|
@ -112,9 +112,9 @@ static grpc_server_retry_throttle_data* grpc_server_retry_throttle_data_create(
|
|||
// we will start out doing the same thing on the new one.
|
||||
if (old_throttle_data != nullptr) {
|
||||
double token_fraction =
|
||||
(int)gpr_atm_acq_load(&old_throttle_data->milli_tokens) /
|
||||
(double)old_throttle_data->max_milli_tokens;
|
||||
initial_milli_tokens = (int)(token_fraction * max_milli_tokens);
|
||||
static_cast<int>gpr_atm_acq_load(&old_throttle_data->milli_tokens) /
|
||||
static_cast<double>(old_throttle_data->max_milli_tokens);
|
||||
initial_milli_tokens = static_cast<int>(token_fraction * max_milli_tokens);
|
||||
}
|
||||
gpr_atm_rel_store(&throttle_data->milli_tokens,
|
||||
(gpr_atm)initial_milli_tokens);
|
||||
|
|
@ -132,22 +132,22 @@ static grpc_server_retry_throttle_data* grpc_server_retry_throttle_data_create(
|
|||
//
|
||||
|
||||
static void* copy_server_name(void* key, void* unused) {
|
||||
return gpr_strdup((const char*)key);
|
||||
return gpr_strdup(static_cast<const char*>(key));
|
||||
}
|
||||
|
||||
static long compare_server_name(void* key1, void* key2, void* unused) {
|
||||
return strcmp((const char*)key1, (const char*)key2);
|
||||
return strcmp(static_cast<const char*>(key1), static_cast<const char*>(key2));
|
||||
}
|
||||
|
||||
static void destroy_server_retry_throttle_data(void* value, void* unused) {
|
||||
grpc_server_retry_throttle_data* throttle_data =
|
||||
(grpc_server_retry_throttle_data*)value;
|
||||
static_cast<grpc_server_retry_throttle_data*>(value);
|
||||
grpc_server_retry_throttle_data_unref(throttle_data);
|
||||
}
|
||||
|
||||
static void* copy_server_retry_throttle_data(void* value, void* unused) {
|
||||
grpc_server_retry_throttle_data* throttle_data =
|
||||
(grpc_server_retry_throttle_data*)value;
|
||||
static_cast<grpc_server_retry_throttle_data*>(value);
|
||||
return grpc_server_retry_throttle_data_ref(throttle_data);
|
||||
}
|
||||
|
||||
|
|
@ -178,13 +178,13 @@ grpc_server_retry_throttle_data* grpc_retry_throttle_map_get_data_for_server(
|
|||
const char* server_name, int max_milli_tokens, int milli_token_ratio) {
|
||||
gpr_mu_lock(&g_mu);
|
||||
grpc_server_retry_throttle_data* throttle_data =
|
||||
(grpc_server_retry_throttle_data*)grpc_avl_get(g_avl, (char*)server_name,
|
||||
nullptr);
|
||||
static_cast<grpc_server_retry_throttle_data*>(grpc_avl_get(g_avl, const_cast<char*>(server_name),
|
||||
nullptr));
|
||||
if (throttle_data == nullptr) {
|
||||
// Entry not found. Create a new one.
|
||||
throttle_data = grpc_server_retry_throttle_data_create(
|
||||
max_milli_tokens, milli_token_ratio, nullptr);
|
||||
g_avl = grpc_avl_add(g_avl, (char*)server_name, throttle_data, nullptr);
|
||||
g_avl = grpc_avl_add(g_avl, const_cast<char*>(server_name), throttle_data, nullptr);
|
||||
} else {
|
||||
if (throttle_data->max_milli_tokens != max_milli_tokens ||
|
||||
throttle_data->milli_token_ratio != milli_token_ratio) {
|
||||
|
|
@ -192,7 +192,7 @@ grpc_server_retry_throttle_data* grpc_retry_throttle_map_get_data_for_server(
|
|||
// the original one.
|
||||
throttle_data = grpc_server_retry_throttle_data_create(
|
||||
max_milli_tokens, milli_token_ratio, throttle_data);
|
||||
g_avl = grpc_avl_add(g_avl, (char*)server_name, throttle_data, nullptr);
|
||||
g_avl = grpc_avl_add(g_avl, const_cast<char*>(server_name), throttle_data, nullptr);
|
||||
} else {
|
||||
// Entry found. Increase refcount.
|
||||
grpc_server_retry_throttle_data_ref(throttle_data);
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ static void on_subchannel_connected(void* subchannel, grpc_error* error);
|
|||
*/
|
||||
|
||||
static void connection_destroy(void* arg, grpc_error* error) {
|
||||
grpc_channel_stack* stk = (grpc_channel_stack*)arg;
|
||||
grpc_channel_stack* stk = static_cast<grpc_channel_stack*>(arg);
|
||||
grpc_channel_stack_destroy(stk);
|
||||
gpr_free(stk);
|
||||
}
|
||||
|
|
@ -169,7 +169,7 @@ static void connection_destroy(void* arg, grpc_error* error) {
|
|||
*/
|
||||
|
||||
static void subchannel_destroy(void* arg, grpc_error* error) {
|
||||
grpc_subchannel* c = (grpc_subchannel*)arg;
|
||||
grpc_subchannel* c = static_cast<grpc_subchannel*>(arg);
|
||||
gpr_free((void*)c->filters);
|
||||
grpc_channel_args_destroy(c->args);
|
||||
grpc_connectivity_state_destroy(&c->state_tracker);
|
||||
|
|
@ -241,7 +241,7 @@ static void disconnect(grpc_subchannel* c) {
|
|||
void grpc_subchannel_unref(grpc_subchannel* c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
|
||||
gpr_atm old_refs;
|
||||
// add a weak ref and subtract a strong ref (atomically)
|
||||
old_refs = ref_mutate(c, (gpr_atm)1 - (gpr_atm)(1 << INTERNAL_REF_BITS),
|
||||
old_refs = ref_mutate(c, static_cast<gpr_atm>(1) - static_cast<gpr_atm>(1 << INTERNAL_REF_BITS),
|
||||
1 REF_MUTATE_PURPOSE("STRONG_UNREF"));
|
||||
if ((old_refs & STRONG_REF_MASK) == (1 << INTERNAL_REF_BITS)) {
|
||||
disconnect(c);
|
||||
|
|
@ -252,7 +252,7 @@ void grpc_subchannel_unref(grpc_subchannel* c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
|
|||
void grpc_subchannel_weak_unref(
|
||||
grpc_subchannel* c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
|
||||
gpr_atm old_refs;
|
||||
old_refs = ref_mutate(c, -(gpr_atm)1, 1 REF_MUTATE_PURPOSE("WEAK_UNREF"));
|
||||
old_refs = ref_mutate(c, -static_cast<gpr_atm>(1), 1 REF_MUTATE_PURPOSE("WEAK_UNREF"));
|
||||
if (old_refs == 1) {
|
||||
GRPC_CLOSURE_SCHED(
|
||||
GRPC_CLOSURE_CREATE(subchannel_destroy, c, grpc_schedule_on_exec_ctx),
|
||||
|
|
@ -318,15 +318,15 @@ grpc_subchannel* grpc_subchannel_create(grpc_connector* connector,
|
|||
}
|
||||
|
||||
GRPC_STATS_INC_CLIENT_SUBCHANNELS_CREATED();
|
||||
c = (grpc_subchannel*)gpr_zalloc(sizeof(*c));
|
||||
c = static_cast<grpc_subchannel*>(gpr_zalloc(sizeof(*c)));
|
||||
c->key = key;
|
||||
gpr_atm_no_barrier_store(&c->ref_pair, 1 << INTERNAL_REF_BITS);
|
||||
c->connector = connector;
|
||||
grpc_connector_ref(c->connector);
|
||||
c->num_filters = args->filter_count;
|
||||
if (c->num_filters > 0) {
|
||||
c->filters = (const grpc_channel_filter**)gpr_malloc(
|
||||
sizeof(grpc_channel_filter*) * c->num_filters);
|
||||
c->filters = static_cast<const grpc_channel_filter**>(gpr_malloc(
|
||||
sizeof(grpc_channel_filter*) * c->num_filters));
|
||||
memcpy((void*)c->filters, args->filters,
|
||||
sizeof(grpc_channel_filter*) * c->num_filters);
|
||||
} else {
|
||||
|
|
@ -334,7 +334,7 @@ grpc_subchannel* grpc_subchannel_create(grpc_connector* connector,
|
|||
}
|
||||
c->pollset_set = grpc_pollset_set_create();
|
||||
grpc_resolved_address* addr =
|
||||
(grpc_resolved_address*)gpr_malloc(sizeof(*addr));
|
||||
static_cast<grpc_resolved_address*>(gpr_malloc(sizeof(*addr)));
|
||||
grpc_get_subchannel_address_arg(args->args, addr);
|
||||
grpc_resolved_address* new_address = nullptr;
|
||||
grpc_channel_args* new_args = nullptr;
|
||||
|
|
@ -391,7 +391,7 @@ grpc_connectivity_state grpc_subchannel_check_connectivity(grpc_subchannel* c,
|
|||
}
|
||||
|
||||
static void on_external_state_watcher_done(void* arg, grpc_error* error) {
|
||||
external_state_watcher* w = (external_state_watcher*)arg;
|
||||
external_state_watcher* w = static_cast<external_state_watcher*>(arg);
|
||||
grpc_closure* follow_up = w->notify;
|
||||
if (w->pollset_set != nullptr) {
|
||||
grpc_pollset_set_del_pollset_set(w->subchannel->pollset_set,
|
||||
|
|
@ -407,7 +407,7 @@ static void on_external_state_watcher_done(void* arg, grpc_error* error) {
|
|||
}
|
||||
|
||||
static void on_alarm(void* arg, grpc_error* error) {
|
||||
grpc_subchannel* c = (grpc_subchannel*)arg;
|
||||
grpc_subchannel* c = static_cast<grpc_subchannel*>(arg);
|
||||
gpr_mu_lock(&c->mu);
|
||||
c->have_alarm = false;
|
||||
if (c->disconnected) {
|
||||
|
|
@ -486,7 +486,7 @@ void grpc_subchannel_notify_on_state_change(
|
|||
}
|
||||
gpr_mu_unlock(&c->mu);
|
||||
} else {
|
||||
w = (external_state_watcher*)gpr_malloc(sizeof(*w));
|
||||
w = static_cast<external_state_watcher*>(gpr_malloc(sizeof(*w)));
|
||||
w->subchannel = c;
|
||||
w->pollset_set = interested_parties;
|
||||
w->notify = notify;
|
||||
|
|
@ -509,7 +509,7 @@ void grpc_subchannel_notify_on_state_change(
|
|||
|
||||
static void on_connected_subchannel_connectivity_changed(void* p,
|
||||
grpc_error* error) {
|
||||
state_watcher* connected_subchannel_watcher = (state_watcher*)p;
|
||||
state_watcher* connected_subchannel_watcher = static_cast<state_watcher*>(p);
|
||||
grpc_subchannel* c = connected_subchannel_watcher->subchannel;
|
||||
gpr_mu* mu = &c->mu;
|
||||
|
||||
|
|
@ -570,7 +570,7 @@ static bool publish_transport_locked(grpc_subchannel* c) {
|
|||
}
|
||||
grpc_channel_stack* stk;
|
||||
grpc_error* error = grpc_channel_stack_builder_finish(
|
||||
builder, 0, 1, connection_destroy, nullptr, (void**)&stk);
|
||||
builder, 0, 1, connection_destroy, nullptr, reinterpret_cast<void**>(&stk));
|
||||
if (error != GRPC_ERROR_NONE) {
|
||||
grpc_transport_destroy(c->connecting_result.transport);
|
||||
gpr_log(GPR_ERROR, "error initializing subchannel stack: %s",
|
||||
|
|
@ -582,7 +582,7 @@ static bool publish_transport_locked(grpc_subchannel* c) {
|
|||
|
||||
/* initialize state watcher */
|
||||
state_watcher* connected_subchannel_watcher =
|
||||
(state_watcher*)gpr_zalloc(sizeof(*connected_subchannel_watcher));
|
||||
static_cast<state_watcher*>(gpr_zalloc(sizeof(*connected_subchannel_watcher)));
|
||||
connected_subchannel_watcher->subchannel = c;
|
||||
connected_subchannel_watcher->connectivity_state = GRPC_CHANNEL_READY;
|
||||
GRPC_CLOSURE_INIT(&connected_subchannel_watcher->closure,
|
||||
|
|
@ -617,7 +617,7 @@ static bool publish_transport_locked(grpc_subchannel* c) {
|
|||
}
|
||||
|
||||
static void on_subchannel_connected(void* arg, grpc_error* error) {
|
||||
grpc_subchannel* c = (grpc_subchannel*)arg;
|
||||
grpc_subchannel* c = static_cast<grpc_subchannel*>(arg);
|
||||
grpc_channel_args* delete_channel_args = c->connecting_result.channel_args;
|
||||
|
||||
GRPC_SUBCHANNEL_WEAK_REF(c, "on_subchannel_connected");
|
||||
|
|
@ -653,7 +653,7 @@ static void on_subchannel_connected(void* arg, grpc_error* error) {
|
|||
|
||||
static void subchannel_call_destroy(void* call, grpc_error* error) {
|
||||
GPR_TIMER_SCOPE("grpc_subchannel_call_unref.destroy", 0);
|
||||
grpc_subchannel_call* c = (grpc_subchannel_call*)call;
|
||||
grpc_subchannel_call* c = static_cast<grpc_subchannel_call*>(call);
|
||||
GPR_ASSERT(c->schedule_closure_after_destroy != nullptr);
|
||||
grpc_core::ConnectedSubchannel* connection = c->connection;
|
||||
grpc_call_stack_destroy(SUBCHANNEL_CALL_TO_CALL_STACK(c), nullptr,
|
||||
|
|
@ -770,9 +770,9 @@ void ConnectedSubchannel::Ping(grpc_closure* on_initiate,
|
|||
|
||||
grpc_error* ConnectedSubchannel::CreateCall(const CallArgs& args,
|
||||
grpc_subchannel_call** call) {
|
||||
*call = (grpc_subchannel_call*)gpr_arena_alloc(
|
||||
*call = static_cast<grpc_subchannel_call*>(gpr_arena_alloc(
|
||||
args.arena,
|
||||
sizeof(grpc_subchannel_call) + channel_stack_->call_stack_size);
|
||||
sizeof(grpc_subchannel_call) + channel_stack_->call_stack_size));
|
||||
grpc_call_stack* callstk = SUBCHANNEL_CALL_TO_CALL_STACK(*call);
|
||||
RefCountedPtr<ConnectedSubchannel> connection =
|
||||
Ref(DEBUG_LOCATION, "subchannel_call");
|
||||
|
|
|
|||
|
|
@ -45,12 +45,12 @@ static bool g_force_creation = false;
|
|||
static grpc_subchannel_key* create_key(
|
||||
const grpc_subchannel_args* args,
|
||||
grpc_channel_args* (*copy_channel_args)(const grpc_channel_args* args)) {
|
||||
grpc_subchannel_key* k = (grpc_subchannel_key*)gpr_malloc(sizeof(*k));
|
||||
grpc_subchannel_key* k = static_cast<grpc_subchannel_key*>(gpr_malloc(sizeof(*k)));
|
||||
k->args.filter_count = args->filter_count;
|
||||
if (k->args.filter_count > 0) {
|
||||
k->args.filters = (const grpc_channel_filter**)gpr_malloc(
|
||||
sizeof(*k->args.filters) * k->args.filter_count);
|
||||
memcpy((grpc_channel_filter*)k->args.filters, args->filters,
|
||||
k->args.filters = static_cast<const grpc_channel_filter**>(gpr_malloc(
|
||||
sizeof(*k->args.filters) * k->args.filter_count));
|
||||
memcpy(reinterpret_cast<grpc_channel_filter*>(k->args.filters), args->filters,
|
||||
sizeof(*k->args.filters) * k->args.filter_count);
|
||||
} else {
|
||||
k->args.filters = nullptr;
|
||||
|
|
@ -82,22 +82,22 @@ int grpc_subchannel_key_compare(const grpc_subchannel_key* a,
|
|||
}
|
||||
|
||||
void grpc_subchannel_key_destroy(grpc_subchannel_key* k) {
|
||||
gpr_free((grpc_channel_args*)k->args.filters);
|
||||
grpc_channel_args_destroy((grpc_channel_args*)k->args.args);
|
||||
gpr_free(reinterpret_cast<grpc_channel_args*>(k->args.filters));
|
||||
grpc_channel_args_destroy(const_cast<grpc_channel_args*>(k->args.args));
|
||||
gpr_free(k);
|
||||
}
|
||||
|
||||
static void sck_avl_destroy(void* p, void* user_data) {
|
||||
grpc_subchannel_key_destroy((grpc_subchannel_key*)p);
|
||||
grpc_subchannel_key_destroy(static_cast<grpc_subchannel_key*>(p));
|
||||
}
|
||||
|
||||
static void* sck_avl_copy(void* p, void* unused) {
|
||||
return subchannel_key_copy((grpc_subchannel_key*)p);
|
||||
return subchannel_key_copy(static_cast<grpc_subchannel_key*>(p));
|
||||
}
|
||||
|
||||
static long sck_avl_compare(void* a, void* b, void* unused) {
|
||||
return grpc_subchannel_key_compare((grpc_subchannel_key*)a,
|
||||
(grpc_subchannel_key*)b);
|
||||
return grpc_subchannel_key_compare(static_cast<grpc_subchannel_key*>(a),
|
||||
static_cast<grpc_subchannel_key*>(b));
|
||||
}
|
||||
|
||||
static void scv_avl_destroy(void* p, void* user_data) {
|
||||
|
|
@ -170,7 +170,7 @@ grpc_subchannel* grpc_subchannel_index_register(grpc_subchannel_key* key,
|
|||
gpr_mu_unlock(&g_mu);
|
||||
|
||||
// - Check to see if a subchannel already exists
|
||||
c = (grpc_subchannel*)grpc_avl_get(index, key, grpc_core::ExecCtx::Get());
|
||||
c = static_cast<grpc_subchannel*>(grpc_avl_get(index, key, grpc_core::ExecCtx::Get()));
|
||||
if (c != nullptr) {
|
||||
c = GRPC_SUBCHANNEL_REF_FROM_WEAK_REF(c, "index_register");
|
||||
}
|
||||
|
|
@ -221,7 +221,7 @@ void grpc_subchannel_index_unregister(grpc_subchannel_key* key,
|
|||
// Check to see if this key still refers to the previously
|
||||
// registered subchannel
|
||||
grpc_subchannel* c =
|
||||
(grpc_subchannel*)grpc_avl_get(index, key, grpc_core::ExecCtx::Get());
|
||||
static_cast<grpc_subchannel*>(grpc_avl_get(index, key, grpc_core::ExecCtx::Get()));
|
||||
if (c != constructed) {
|
||||
grpc_avl_unref(index, grpc_core::ExecCtx::Get());
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ static grpc_uri* bad_uri(const char* uri_text, size_t pos, const char* section,
|
|||
gpr_log(GPR_ERROR, "%s%s'", line_prefix, uri_text);
|
||||
gpr_free(line_prefix);
|
||||
|
||||
line_prefix = (char*)gpr_malloc(pfx_len + 1);
|
||||
line_prefix = static_cast<char*>(gpr_malloc(pfx_len + 1));
|
||||
memset(line_prefix, ' ', pfx_len);
|
||||
line_prefix[pfx_len] = 0;
|
||||
gpr_log(GPR_ERROR, "%s^ here", line_prefix);
|
||||
|
|
@ -159,7 +159,7 @@ static void parse_query_parts(grpc_uri* uri) {
|
|||
gpr_string_split(uri->query, QUERY_PARTS_SEPARATOR, &uri->query_parts,
|
||||
&uri->num_query_parts);
|
||||
uri->query_parts_values =
|
||||
(char**)gpr_malloc(uri->num_query_parts * sizeof(char**));
|
||||
static_cast<char**>(gpr_malloc(uri->num_query_parts * sizeof(char**)));
|
||||
for (size_t i = 0; i < uri->num_query_parts; i++) {
|
||||
char** query_param_parts;
|
||||
size_t num_query_param_parts;
|
||||
|
|
@ -271,7 +271,7 @@ grpc_uri* grpc_uri_parse(const char* uri_text, bool suppress_errors) {
|
|||
fragment_end = i;
|
||||
}
|
||||
|
||||
uri = (grpc_uri*)gpr_zalloc(sizeof(*uri));
|
||||
uri = static_cast<grpc_uri*>(gpr_zalloc(sizeof(*uri)));
|
||||
uri->scheme = decode_and_copy_component(uri_text, scheme_begin, scheme_end);
|
||||
uri->authority =
|
||||
decode_and_copy_component(uri_text, authority_begin, authority_end);
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
// The on_complete callback used when sending a cancel_error batch down the
|
||||
// filter stack. Yields the call combiner when the batch returns.
|
||||
static void yield_call_combiner(void* arg, grpc_error* ignored) {
|
||||
grpc_deadline_state* deadline_state = (grpc_deadline_state*)arg;
|
||||
grpc_deadline_state* deadline_state = static_cast<grpc_deadline_state*>(arg);
|
||||
GRPC_CALL_COMBINER_STOP(deadline_state->call_combiner,
|
||||
"got on_complete from cancel_stream batch");
|
||||
GRPC_CALL_STACK_UNREF(deadline_state->call_stack, "deadline_timer");
|
||||
|
|
@ -46,8 +46,8 @@ static void yield_call_combiner(void* arg, grpc_error* ignored) {
|
|||
// This is called via the call combiner, so access to deadline_state is
|
||||
// synchronized.
|
||||
static void send_cancel_op_in_call_combiner(void* arg, grpc_error* error) {
|
||||
grpc_call_element* elem = (grpc_call_element*)arg;
|
||||
grpc_deadline_state* deadline_state = (grpc_deadline_state*)elem->call_data;
|
||||
grpc_call_element* elem = static_cast<grpc_call_element*>(arg);
|
||||
grpc_deadline_state* deadline_state = static_cast<grpc_deadline_state*>(elem->call_data);
|
||||
grpc_transport_stream_op_batch* batch = grpc_make_transport_stream_op(
|
||||
GRPC_CLOSURE_INIT(&deadline_state->timer_callback, yield_call_combiner,
|
||||
deadline_state, grpc_schedule_on_exec_ctx));
|
||||
|
|
@ -58,8 +58,8 @@ static void send_cancel_op_in_call_combiner(void* arg, grpc_error* error) {
|
|||
|
||||
// Timer callback.
|
||||
static void timer_callback(void* arg, grpc_error* error) {
|
||||
grpc_call_element* elem = (grpc_call_element*)arg;
|
||||
grpc_deadline_state* deadline_state = (grpc_deadline_state*)elem->call_data;
|
||||
grpc_call_element* elem = static_cast<grpc_call_element*>(arg);
|
||||
grpc_deadline_state* deadline_state = static_cast<grpc_deadline_state*>(elem->call_data);
|
||||
if (error != GRPC_ERROR_CANCELLED) {
|
||||
error = grpc_error_set_int(
|
||||
GRPC_ERROR_CREATE_FROM_STATIC_STRING("Deadline Exceeded"),
|
||||
|
|
@ -85,7 +85,7 @@ static void start_timer_if_needed(grpc_call_element* elem,
|
|||
if (deadline == GRPC_MILLIS_INF_FUTURE) {
|
||||
return;
|
||||
}
|
||||
grpc_deadline_state* deadline_state = (grpc_deadline_state*)elem->call_data;
|
||||
grpc_deadline_state* deadline_state = static_cast<grpc_deadline_state*>(elem->call_data);
|
||||
grpc_closure* closure = nullptr;
|
||||
switch (deadline_state->timer_state) {
|
||||
case GRPC_DEADLINE_STATE_PENDING:
|
||||
|
|
@ -126,7 +126,7 @@ static void cancel_timer_if_needed(grpc_deadline_state* deadline_state) {
|
|||
|
||||
// Callback run when the call is complete.
|
||||
static void on_complete(void* arg, grpc_error* error) {
|
||||
grpc_deadline_state* deadline_state = (grpc_deadline_state*)arg;
|
||||
grpc_deadline_state* deadline_state = static_cast<grpc_deadline_state*>(arg);
|
||||
cancel_timer_if_needed(deadline_state);
|
||||
// Invoke the next callback.
|
||||
GRPC_CLOSURE_RUN(deadline_state->next_on_complete, GRPC_ERROR_REF(error));
|
||||
|
|
@ -151,9 +151,9 @@ struct start_timer_after_init_state {
|
|||
};
|
||||
static void start_timer_after_init(void* arg, grpc_error* error) {
|
||||
struct start_timer_after_init_state* state =
|
||||
(struct start_timer_after_init_state*)arg;
|
||||
static_cast<struct start_timer_after_init_state*>(arg);
|
||||
grpc_deadline_state* deadline_state =
|
||||
(grpc_deadline_state*)state->elem->call_data;
|
||||
static_cast<grpc_deadline_state*>(state->elem->call_data);
|
||||
if (!state->in_call_combiner) {
|
||||
// We are initially called without holding the call combiner, so we
|
||||
// need to bounce ourselves into it.
|
||||
|
|
@ -173,7 +173,7 @@ void grpc_deadline_state_init(grpc_call_element* elem,
|
|||
grpc_call_stack* call_stack,
|
||||
grpc_call_combiner* call_combiner,
|
||||
grpc_millis deadline) {
|
||||
grpc_deadline_state* deadline_state = (grpc_deadline_state*)elem->call_data;
|
||||
grpc_deadline_state* deadline_state = static_cast<grpc_deadline_state*>(elem->call_data);
|
||||
deadline_state->call_stack = call_stack;
|
||||
deadline_state->call_combiner = call_combiner;
|
||||
// Deadline will always be infinite on servers, so the timer will only be
|
||||
|
|
@ -187,7 +187,7 @@ void grpc_deadline_state_init(grpc_call_element* elem,
|
|||
// create a closure to start the timer, and we schedule that closure
|
||||
// to be run after call stack initialization is done.
|
||||
struct start_timer_after_init_state* state =
|
||||
(struct start_timer_after_init_state*)gpr_zalloc(sizeof(*state));
|
||||
static_cast<struct start_timer_after_init_state*>(gpr_zalloc(sizeof(*state)));
|
||||
state->elem = elem;
|
||||
state->deadline = deadline;
|
||||
GRPC_CLOSURE_INIT(&state->closure, start_timer_after_init, state,
|
||||
|
|
@ -197,20 +197,20 @@ void grpc_deadline_state_init(grpc_call_element* elem,
|
|||
}
|
||||
|
||||
void grpc_deadline_state_destroy(grpc_call_element* elem) {
|
||||
grpc_deadline_state* deadline_state = (grpc_deadline_state*)elem->call_data;
|
||||
grpc_deadline_state* deadline_state = static_cast<grpc_deadline_state*>(elem->call_data);
|
||||
cancel_timer_if_needed(deadline_state);
|
||||
}
|
||||
|
||||
void grpc_deadline_state_reset(grpc_call_element* elem,
|
||||
grpc_millis new_deadline) {
|
||||
grpc_deadline_state* deadline_state = (grpc_deadline_state*)elem->call_data;
|
||||
grpc_deadline_state* deadline_state = static_cast<grpc_deadline_state*>(elem->call_data);
|
||||
cancel_timer_if_needed(deadline_state);
|
||||
start_timer_if_needed(elem, new_deadline);
|
||||
}
|
||||
|
||||
void grpc_deadline_state_client_start_transport_stream_op_batch(
|
||||
grpc_call_element* elem, grpc_transport_stream_op_batch* op) {
|
||||
grpc_deadline_state* deadline_state = (grpc_deadline_state*)elem->call_data;
|
||||
grpc_deadline_state* deadline_state = static_cast<grpc_deadline_state*>(elem->call_data);
|
||||
if (op->cancel_stream) {
|
||||
cancel_timer_if_needed(deadline_state);
|
||||
} else {
|
||||
|
|
@ -278,8 +278,8 @@ static void client_start_transport_stream_op_batch(
|
|||
|
||||
// Callback for receiving initial metadata on the server.
|
||||
static void recv_initial_metadata_ready(void* arg, grpc_error* error) {
|
||||
grpc_call_element* elem = (grpc_call_element*)arg;
|
||||
server_call_data* calld = (server_call_data*)elem->call_data;
|
||||
grpc_call_element* elem = static_cast<grpc_call_element*>(arg);
|
||||
server_call_data* calld = static_cast<server_call_data*>(elem->call_data);
|
||||
// Get deadline from metadata and start the timer if needed.
|
||||
start_timer_if_needed(elem, calld->recv_initial_metadata->deadline);
|
||||
// Invoke the next callback.
|
||||
|
|
@ -290,7 +290,7 @@ static void recv_initial_metadata_ready(void* arg, grpc_error* error) {
|
|||
// Method for starting a call op for server filter.
|
||||
static void server_start_transport_stream_op_batch(
|
||||
grpc_call_element* elem, grpc_transport_stream_op_batch* op) {
|
||||
server_call_data* calld = (server_call_data*)elem->call_data;
|
||||
server_call_data* calld = static_cast<server_call_data*>(elem->call_data);
|
||||
if (op->cancel_stream) {
|
||||
cancel_timer_if_needed(&calld->base.deadline_state);
|
||||
} else {
|
||||
|
|
@ -360,7 +360,7 @@ static bool maybe_add_deadline_filter(grpc_channel_stack_builder* builder,
|
|||
return grpc_deadline_checking_enabled(
|
||||
grpc_channel_stack_builder_get_channel_arguments(builder))
|
||||
? grpc_channel_stack_builder_prepend_filter(
|
||||
builder, (const grpc_channel_filter*)arg, nullptr, nullptr)
|
||||
builder, static_cast<const grpc_channel_filter*>(arg), nullptr, nullptr)
|
||||
: true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -138,8 +138,8 @@ static grpc_error* client_filter_incoming_metadata(grpc_call_element* elem,
|
|||
}
|
||||
|
||||
static void recv_initial_metadata_ready(void* user_data, grpc_error* error) {
|
||||
grpc_call_element* elem = (grpc_call_element*)user_data;
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
grpc_call_element* elem = static_cast<grpc_call_element*>(user_data);
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
if (error == GRPC_ERROR_NONE) {
|
||||
error = client_filter_incoming_metadata(elem, calld->recv_initial_metadata);
|
||||
} else {
|
||||
|
|
@ -150,8 +150,8 @@ static void recv_initial_metadata_ready(void* user_data, grpc_error* error) {
|
|||
|
||||
static void recv_trailing_metadata_on_complete(void* user_data,
|
||||
grpc_error* error) {
|
||||
grpc_call_element* elem = (grpc_call_element*)user_data;
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
grpc_call_element* elem = static_cast<grpc_call_element*>(user_data);
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
if (error == GRPC_ERROR_NONE) {
|
||||
error =
|
||||
client_filter_incoming_metadata(elem, calld->recv_trailing_metadata);
|
||||
|
|
@ -162,8 +162,8 @@ static void recv_trailing_metadata_on_complete(void* user_data,
|
|||
}
|
||||
|
||||
static void send_message_on_complete(void* arg, grpc_error* error) {
|
||||
grpc_call_element* elem = (grpc_call_element*)arg;
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
grpc_call_element* elem = static_cast<grpc_call_element*>(arg);
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
grpc_byte_stream_cache_destroy(&calld->send_message_cache);
|
||||
GRPC_CLOSURE_RUN(calld->original_send_message_on_complete,
|
||||
GRPC_ERROR_REF(error));
|
||||
|
|
@ -189,7 +189,7 @@ static grpc_error* pull_slice_from_send_message(call_data* calld) {
|
|||
// and on_send_message_next_done() will be invoked when it is complete.
|
||||
static grpc_error* read_all_available_send_message_data(call_data* calld) {
|
||||
while (grpc_byte_stream_next(&calld->send_message_caching_stream.base,
|
||||
~(size_t)0, &calld->on_send_message_next_done)) {
|
||||
~static_cast<size_t>(0), &calld->on_send_message_next_done)) {
|
||||
grpc_error* error = pull_slice_from_send_message(calld);
|
||||
if (error != GRPC_ERROR_NONE) return error;
|
||||
if (calld->send_message_bytes_read ==
|
||||
|
|
@ -202,8 +202,8 @@ static grpc_error* read_all_available_send_message_data(call_data* calld) {
|
|||
|
||||
// Async callback for grpc_byte_stream_next().
|
||||
static void on_send_message_next_done(void* arg, grpc_error* error) {
|
||||
grpc_call_element* elem = (grpc_call_element*)arg;
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
grpc_call_element* elem = static_cast<grpc_call_element*>(arg);
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
if (error != GRPC_ERROR_NONE) {
|
||||
grpc_transport_stream_op_batch_finish_with_failure(
|
||||
calld->send_message_batch, error, calld->call_combiner);
|
||||
|
|
@ -224,7 +224,7 @@ static void on_send_message_next_done(void* arg, grpc_error* error) {
|
|||
}
|
||||
|
||||
static char* slice_buffer_to_string(grpc_slice_buffer* slice_buffer) {
|
||||
char* payload_bytes = (char*)gpr_malloc(slice_buffer->length + 1);
|
||||
char* payload_bytes = static_cast<char*>(gpr_malloc(slice_buffer->length + 1));
|
||||
size_t offset = 0;
|
||||
for (size_t i = 0; i < slice_buffer->count; ++i) {
|
||||
memcpy(payload_bytes + offset,
|
||||
|
|
@ -240,7 +240,7 @@ static char* slice_buffer_to_string(grpc_slice_buffer* slice_buffer) {
|
|||
// append the base64-encoded query for a GET request.
|
||||
static grpc_error* update_path_for_get(grpc_call_element* elem,
|
||||
grpc_transport_stream_op_batch* batch) {
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
grpc_slice path_slice =
|
||||
GRPC_MDVALUE(batch->payload->send_initial_metadata.send_initial_metadata
|
||||
->idx.named.path->md);
|
||||
|
|
@ -253,19 +253,19 @@ static grpc_error* update_path_for_get(grpc_call_element* elem,
|
|||
false /* multi_line */);
|
||||
grpc_slice path_with_query_slice = GRPC_SLICE_MALLOC(estimated_len);
|
||||
/* memcopy individual pieces into this slice */
|
||||
char* write_ptr = (char*)GRPC_SLICE_START_PTR(path_with_query_slice);
|
||||
char* original_path = (char*)GRPC_SLICE_START_PTR(path_slice);
|
||||
char* write_ptr = reinterpret_cast<char*>GRPC_SLICE_START_PTR(path_with_query_slice);
|
||||
char* original_path = reinterpret_cast<char*>GRPC_SLICE_START_PTR(path_slice);
|
||||
memcpy(write_ptr, original_path, GRPC_SLICE_LENGTH(path_slice));
|
||||
write_ptr += GRPC_SLICE_LENGTH(path_slice);
|
||||
*write_ptr++ = '?';
|
||||
char* payload_bytes =
|
||||
slice_buffer_to_string(&calld->send_message_cache.cache_buffer);
|
||||
grpc_base64_encode_core((char*)write_ptr, payload_bytes,
|
||||
grpc_base64_encode_core(write_ptr, payload_bytes,
|
||||
batch->payload->send_message.send_message->length,
|
||||
true /* url_safe */, false /* multi_line */);
|
||||
gpr_free(payload_bytes);
|
||||
/* remove trailing unused memory and add trailing 0 to terminate string */
|
||||
char* t = (char*)GRPC_SLICE_START_PTR(path_with_query_slice);
|
||||
char* t = reinterpret_cast<char*>GRPC_SLICE_START_PTR(path_with_query_slice);
|
||||
/* safe to use strlen since base64_encode will always add '\0' */
|
||||
path_with_query_slice =
|
||||
grpc_slice_sub_no_ref(path_with_query_slice, 0, strlen(t));
|
||||
|
|
@ -287,8 +287,8 @@ static void remove_if_present(grpc_metadata_batch* batch,
|
|||
|
||||
static void hc_start_transport_stream_op_batch(
|
||||
grpc_call_element* elem, grpc_transport_stream_op_batch* batch) {
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
channel_data* channeld = (channel_data*)elem->channel_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
channel_data* channeld = static_cast<channel_data*>(elem->channel_data);
|
||||
GPR_TIMER_SCOPE("hc_start_transport_stream_op_batch", 0);
|
||||
|
||||
if (batch->recv_initial_metadata) {
|
||||
|
|
@ -409,7 +409,7 @@ done:
|
|||
/* Constructor for call_data */
|
||||
static grpc_error* init_call_elem(grpc_call_element* elem,
|
||||
const grpc_call_element_args* args) {
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
calld->call_combiner = args->call_combiner;
|
||||
GRPC_CLOSURE_INIT(&calld->recv_initial_metadata_ready,
|
||||
recv_initial_metadata_ready, elem,
|
||||
|
|
@ -458,7 +458,7 @@ static size_t max_payload_size_from_args(const grpc_channel_args* args) {
|
|||
gpr_log(GPR_ERROR, "%s: must be an integer",
|
||||
GRPC_ARG_MAX_PAYLOAD_SIZE_FOR_GET);
|
||||
} else {
|
||||
return (size_t)args->args[i].value.integer;
|
||||
return static_cast<size_t>(args->args[i].value.integer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -519,7 +519,7 @@ static grpc_slice user_agent_from_args(const grpc_channel_args* args,
|
|||
/* Constructor for channel_data */
|
||||
static grpc_error* init_channel_elem(grpc_channel_element* elem,
|
||||
grpc_channel_element_args* args) {
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
GPR_ASSERT(!args->is_last);
|
||||
GPR_ASSERT(args->optional_transport != nullptr);
|
||||
chand->static_scheme = scheme_from_args(args->channel_args);
|
||||
|
|
@ -534,7 +534,7 @@ static grpc_error* init_channel_elem(grpc_channel_element* elem,
|
|||
|
||||
/* Destructor for channel data */
|
||||
static void destroy_channel_elem(grpc_channel_element* elem) {
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
GRPC_MDELEM_UNREF(chand->user_agent);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ static bool is_building_http_like_transport(
|
|||
static bool maybe_add_optional_filter(grpc_channel_stack_builder* builder,
|
||||
void* arg) {
|
||||
if (!is_building_http_like_transport(builder)) return true;
|
||||
optional_filter* filtarg = (optional_filter*)arg;
|
||||
optional_filter* filtarg = static_cast<optional_filter*>(arg);
|
||||
const grpc_channel_args* channel_args =
|
||||
grpc_channel_stack_builder_get_channel_arguments(builder);
|
||||
bool enable = grpc_channel_arg_get_bool(
|
||||
|
|
@ -58,7 +58,7 @@ static bool maybe_add_required_filter(grpc_channel_stack_builder* builder,
|
|||
void* arg) {
|
||||
return is_building_http_like_transport(builder)
|
||||
? grpc_channel_stack_builder_prepend_filter(
|
||||
builder, (const grpc_channel_filter*)arg, nullptr, nullptr)
|
||||
builder, static_cast<const grpc_channel_filter*>(arg), nullptr, nullptr)
|
||||
: true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -80,8 +80,8 @@ struct channel_data {
|
|||
|
||||
static bool skip_compression(grpc_call_element* elem, uint32_t flags,
|
||||
bool has_compression_algorithm) {
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
channel_data* channeld = (channel_data*)elem->channel_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
channel_data* channeld = static_cast<channel_data*>(elem->channel_data);
|
||||
|
||||
if (flags & (GRPC_WRITE_NO_COMPRESS | GRPC_WRITE_INTERNAL_COMPRESS)) {
|
||||
return true;
|
||||
|
|
@ -103,8 +103,8 @@ static grpc_error* process_send_initial_metadata(
|
|||
static grpc_error* process_send_initial_metadata(
|
||||
grpc_call_element* elem, grpc_metadata_batch* initial_metadata,
|
||||
bool* has_compression_algorithm) {
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
channel_data* channeld = (channel_data*)elem->channel_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
channel_data* channeld = static_cast<channel_data*>(elem->channel_data);
|
||||
*has_compression_algorithm = false;
|
||||
grpc_compression_algorithm compression_algorithm;
|
||||
grpc_stream_compression_algorithm stream_compression_algorithm =
|
||||
|
|
@ -194,15 +194,15 @@ static grpc_error* process_send_initial_metadata(
|
|||
}
|
||||
|
||||
static void send_message_on_complete(void* arg, grpc_error* error) {
|
||||
grpc_call_element* elem = (grpc_call_element*)arg;
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
grpc_call_element* elem = static_cast<grpc_call_element*>(arg);
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
grpc_slice_buffer_reset_and_unref_internal(&calld->slices);
|
||||
GRPC_CLOSURE_RUN(calld->original_send_message_on_complete,
|
||||
GRPC_ERROR_REF(error));
|
||||
}
|
||||
|
||||
static void send_message_batch_continue(grpc_call_element* elem) {
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
// Note: The call to grpc_call_next_op() results in yielding the
|
||||
// call combiner, so we need to clear calld->send_message_batch
|
||||
// before we do that.
|
||||
|
|
@ -213,7 +213,7 @@ static void send_message_batch_continue(grpc_call_element* elem) {
|
|||
}
|
||||
|
||||
static void finish_send_message(grpc_call_element* elem) {
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
// Compress the data if appropriate.
|
||||
grpc_slice_buffer tmp;
|
||||
grpc_slice_buffer_init(&tmp);
|
||||
|
|
@ -226,7 +226,7 @@ static void finish_send_message(grpc_call_element* elem) {
|
|||
const char* algo_name;
|
||||
const size_t before_size = calld->slices.length;
|
||||
const size_t after_size = tmp.length;
|
||||
const float savings_ratio = 1.0f - (float)after_size / (float)before_size;
|
||||
const float savings_ratio = 1.0f - static_cast<float>(after_size) / static_cast<float>(before_size);
|
||||
GPR_ASSERT(grpc_message_compression_algorithm_name(
|
||||
calld->message_compression_algorithm, &algo_name));
|
||||
gpr_log(GPR_DEBUG,
|
||||
|
|
@ -264,7 +264,7 @@ static void finish_send_message(grpc_call_element* elem) {
|
|||
|
||||
static void fail_send_message_batch_in_call_combiner(void* arg,
|
||||
grpc_error* error) {
|
||||
call_data* calld = (call_data*)arg;
|
||||
call_data* calld = static_cast<call_data*>(arg);
|
||||
if (calld->send_message_batch != nullptr) {
|
||||
grpc_transport_stream_op_batch_finish_with_failure(
|
||||
calld->send_message_batch, GRPC_ERROR_REF(error), calld->call_combiner);
|
||||
|
|
@ -289,9 +289,9 @@ static grpc_error* pull_slice_from_send_message(call_data* calld) {
|
|||
// an async call to grpc_byte_stream_next() has been started, which will
|
||||
// eventually result in calling on_send_message_next_done().
|
||||
static void continue_reading_send_message(grpc_call_element* elem) {
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
while (grpc_byte_stream_next(
|
||||
calld->send_message_batch->payload->send_message.send_message, ~(size_t)0,
|
||||
calld->send_message_batch->payload->send_message.send_message, ~static_cast<size_t>(0),
|
||||
&calld->on_send_message_next_done)) {
|
||||
grpc_error* error = pull_slice_from_send_message(calld);
|
||||
if (error != GRPC_ERROR_NONE) {
|
||||
|
|
@ -310,8 +310,8 @@ static void continue_reading_send_message(grpc_call_element* elem) {
|
|||
|
||||
// Async callback for grpc_byte_stream_next().
|
||||
static void on_send_message_next_done(void* arg, grpc_error* error) {
|
||||
grpc_call_element* elem = (grpc_call_element*)arg;
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
grpc_call_element* elem = static_cast<grpc_call_element*>(arg);
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
if (error != GRPC_ERROR_NONE) {
|
||||
// Closure callback; does not take ownership of error.
|
||||
fail_send_message_batch_in_call_combiner(calld, error);
|
||||
|
|
@ -333,8 +333,8 @@ static void on_send_message_next_done(void* arg, grpc_error* error) {
|
|||
}
|
||||
|
||||
static void start_send_message_batch(void* arg, grpc_error* unused) {
|
||||
grpc_call_element* elem = (grpc_call_element*)arg;
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
grpc_call_element* elem = static_cast<grpc_call_element*>(arg);
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
if (skip_compression(
|
||||
elem,
|
||||
calld->send_message_batch->payload->send_message.send_message->flags,
|
||||
|
|
@ -348,7 +348,7 @@ static void start_send_message_batch(void* arg, grpc_error* unused) {
|
|||
static void compress_start_transport_stream_op_batch(
|
||||
grpc_call_element* elem, grpc_transport_stream_op_batch* batch) {
|
||||
GPR_TIMER_SCOPE("compress_start_transport_stream_op_batch", 0);
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
// Handle cancel_stream.
|
||||
if (batch->cancel_stream) {
|
||||
GRPC_ERROR_UNREF(calld->cancel_error);
|
||||
|
|
@ -424,7 +424,7 @@ static void compress_start_transport_stream_op_batch(
|
|||
/* Constructor for call_data */
|
||||
static grpc_error* init_call_elem(grpc_call_element* elem,
|
||||
const grpc_call_element_args* args) {
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
calld->call_combiner = args->call_combiner;
|
||||
calld->cancel_error = GRPC_ERROR_NONE;
|
||||
grpc_slice_buffer_init(&calld->slices);
|
||||
|
|
@ -441,7 +441,7 @@ static grpc_error* init_call_elem(grpc_call_element* elem,
|
|||
static void destroy_call_elem(grpc_call_element* elem,
|
||||
const grpc_call_final_info* final_info,
|
||||
grpc_closure* ignored) {
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
grpc_slice_buffer_destroy_internal(&calld->slices);
|
||||
GRPC_ERROR_UNREF(calld->cancel_error);
|
||||
}
|
||||
|
|
@ -449,7 +449,7 @@ static void destroy_call_elem(grpc_call_element* elem,
|
|||
/* Constructor for channel_data */
|
||||
static grpc_error* init_channel_elem(grpc_channel_element* elem,
|
||||
grpc_channel_element_args* args) {
|
||||
channel_data* channeld = (channel_data*)elem->channel_data;
|
||||
channel_data* channeld = static_cast<channel_data*>(elem->channel_data);
|
||||
|
||||
channeld->enabled_algorithms_bitset =
|
||||
grpc_channel_args_compression_algorithm_get_states(args->channel_args);
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ static void add_error(const char* error_name, grpc_error** cumulative,
|
|||
|
||||
static grpc_error* server_filter_incoming_metadata(grpc_call_element* elem,
|
||||
grpc_metadata_batch* b) {
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
grpc_error* error = GRPC_ERROR_NONE;
|
||||
static const char* error_name = "Failed processing incoming headers";
|
||||
|
||||
|
|
@ -204,7 +204,7 @@ static grpc_error* server_filter_incoming_metadata(grpc_call_element* elem,
|
|||
* query parameter which is base64 encoded request payload. */
|
||||
const char k_query_separator = '?';
|
||||
grpc_slice path_slice = GRPC_MDVALUE(b->idx.named.path->md);
|
||||
uint8_t* path_ptr = (uint8_t*)GRPC_SLICE_START_PTR(path_slice);
|
||||
uint8_t* path_ptr = GRPC_SLICE_START_PTR(path_slice);
|
||||
size_t path_length = GRPC_SLICE_LENGTH(path_slice);
|
||||
/* offset of the character '?' */
|
||||
size_t offset = 0;
|
||||
|
|
@ -226,7 +226,7 @@ static grpc_error* server_filter_incoming_metadata(grpc_call_element* elem,
|
|||
const int k_url_safe = 1;
|
||||
grpc_slice_buffer_add(&calld->read_slice_buffer,
|
||||
grpc_base64_decode_with_len(
|
||||
(const char*)GRPC_SLICE_START_PTR(query_slice),
|
||||
reinterpret_cast<const char*>GRPC_SLICE_START_PTR(query_slice),
|
||||
GRPC_SLICE_LENGTH(query_slice), k_url_safe));
|
||||
grpc_slice_buffer_stream_init(&calld->read_stream,
|
||||
&calld->read_slice_buffer, 0);
|
||||
|
|
@ -262,8 +262,8 @@ static grpc_error* server_filter_incoming_metadata(grpc_call_element* elem,
|
|||
}
|
||||
|
||||
static void hs_on_recv(void* user_data, grpc_error* err) {
|
||||
grpc_call_element* elem = (grpc_call_element*)user_data;
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
grpc_call_element* elem = static_cast<grpc_call_element*>(user_data);
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
if (err == GRPC_ERROR_NONE) {
|
||||
err = server_filter_incoming_metadata(elem, calld->recv_initial_metadata);
|
||||
} else {
|
||||
|
|
@ -273,13 +273,13 @@ static void hs_on_recv(void* user_data, grpc_error* err) {
|
|||
}
|
||||
|
||||
static void hs_on_complete(void* user_data, grpc_error* err) {
|
||||
grpc_call_element* elem = (grpc_call_element*)user_data;
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
grpc_call_element* elem = static_cast<grpc_call_element*>(user_data);
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
/* Call recv_message_ready if we got the payload via the path field */
|
||||
if (calld->seen_path_with_query && calld->recv_message_ready != nullptr) {
|
||||
*calld->pp_recv_message = calld->payload_bin_delivered
|
||||
? nullptr
|
||||
: (grpc_byte_stream*)&calld->read_stream;
|
||||
: reinterpret_cast<grpc_byte_stream*>(&calld->read_stream);
|
||||
// Re-enter call combiner for recv_message_ready, since the surface
|
||||
// code will release the call combiner for each callback it receives.
|
||||
GRPC_CALL_COMBINER_START(calld->call_combiner, calld->recv_message_ready,
|
||||
|
|
@ -292,8 +292,8 @@ static void hs_on_complete(void* user_data, grpc_error* err) {
|
|||
}
|
||||
|
||||
static void hs_recv_message_ready(void* user_data, grpc_error* err) {
|
||||
grpc_call_element* elem = (grpc_call_element*)user_data;
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
grpc_call_element* elem = static_cast<grpc_call_element*>(user_data);
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
if (calld->seen_path_with_query) {
|
||||
// Do nothing. This is probably a GET request, and payload will be
|
||||
// returned in hs_on_complete callback.
|
||||
|
|
@ -309,7 +309,7 @@ static void hs_recv_message_ready(void* user_data, grpc_error* err) {
|
|||
static grpc_error* hs_mutate_op(grpc_call_element* elem,
|
||||
grpc_transport_stream_op_batch* op) {
|
||||
/* grab pointers to our data from the call element */
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
|
||||
if (op->send_initial_metadata) {
|
||||
grpc_error* error = GRPC_ERROR_NONE;
|
||||
|
|
@ -368,7 +368,7 @@ static grpc_error* hs_mutate_op(grpc_call_element* elem,
|
|||
static void hs_start_transport_stream_op_batch(
|
||||
grpc_call_element* elem, grpc_transport_stream_op_batch* op) {
|
||||
GPR_TIMER_SCOPE("hs_start_transport_stream_op_batch", 0);
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
grpc_error* error = hs_mutate_op(elem, op);
|
||||
if (error != GRPC_ERROR_NONE) {
|
||||
grpc_transport_stream_op_batch_finish_with_failure(op, error,
|
||||
|
|
@ -382,7 +382,7 @@ static void hs_start_transport_stream_op_batch(
|
|||
static grpc_error* init_call_elem(grpc_call_element* elem,
|
||||
const grpc_call_element_args* args) {
|
||||
/* grab pointers to our data from the call element */
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
/* initialize members */
|
||||
calld->call_combiner = args->call_combiner;
|
||||
GRPC_CLOSURE_INIT(&calld->hs_on_recv, hs_on_recv, elem,
|
||||
|
|
@ -399,7 +399,7 @@ static grpc_error* init_call_elem(grpc_call_element* elem,
|
|||
static void destroy_call_elem(grpc_call_element* elem,
|
||||
const grpc_call_final_info* final_info,
|
||||
grpc_closure* ignored) {
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
grpc_slice_buffer_destroy_internal(&calld->read_slice_buffer);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,8 +57,8 @@ struct channel_data {
|
|||
} // namespace
|
||||
|
||||
static void on_initial_md_ready(void* user_data, grpc_error* err) {
|
||||
grpc_call_element* elem = (grpc_call_element*)user_data;
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
grpc_call_element* elem = static_cast<grpc_call_element*>(user_data);
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
|
||||
if (err == GRPC_ERROR_NONE) {
|
||||
if (calld->recv_initial_metadata->idx.named.path != nullptr) {
|
||||
|
|
@ -88,7 +88,7 @@ static void on_initial_md_ready(void* user_data, grpc_error* err) {
|
|||
/* Constructor for call_data */
|
||||
static grpc_error* init_call_elem(grpc_call_element* elem,
|
||||
const grpc_call_element_args* args) {
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
calld->id = (intptr_t)args->call_stack;
|
||||
GRPC_CLOSURE_INIT(&calld->on_initial_md_ready, on_initial_md_ready, elem,
|
||||
grpc_schedule_on_exec_ctx);
|
||||
|
|
@ -111,7 +111,7 @@ static grpc_error* init_call_elem(grpc_call_element* elem,
|
|||
static void destroy_call_elem(grpc_call_element* elem,
|
||||
const grpc_call_final_info* final_info,
|
||||
grpc_closure* ignored) {
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
|
||||
/* TODO(dgq): do something with the data
|
||||
channel_data *chand = elem->channel_data;
|
||||
|
|
@ -140,7 +140,7 @@ static grpc_error* init_channel_elem(grpc_channel_element* elem,
|
|||
grpc_channel_element_args* args) {
|
||||
GPR_ASSERT(!args->is_last);
|
||||
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
chand->id = (intptr_t)args->channel_stack;
|
||||
|
||||
/* TODO(dgq): do something with the data
|
||||
|
|
@ -173,8 +173,8 @@ static void destroy_channel_elem(grpc_channel_element* elem) {
|
|||
|
||||
static grpc_filtered_mdelem lr_trailing_md_filter(void* user_data,
|
||||
grpc_mdelem md) {
|
||||
grpc_call_element* elem = (grpc_call_element*)user_data;
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
grpc_call_element* elem = static_cast<grpc_call_element*>(user_data);
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_LB_COST_BIN)) {
|
||||
calld->trailing_md_string = GRPC_MDVALUE(md);
|
||||
return GRPC_FILTERED_REMOVE();
|
||||
|
|
@ -185,7 +185,7 @@ static grpc_filtered_mdelem lr_trailing_md_filter(void* user_data,
|
|||
static void lr_start_transport_stream_op_batch(
|
||||
grpc_call_element* elem, grpc_transport_stream_op_batch* op) {
|
||||
GPR_TIMER_SCOPE("lr_start_transport_stream_op_batch", 0);
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
|
||||
if (op->recv_initial_metadata) {
|
||||
/* substitute our callback for the higher callback */
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ static bool maybe_add_server_load_reporting_filter(
|
|||
grpc_channel_stack_builder* builder, void* arg) {
|
||||
const grpc_channel_args* args =
|
||||
grpc_channel_stack_builder_get_channel_arguments(builder);
|
||||
const grpc_channel_filter* filter = (const grpc_channel_filter*)arg;
|
||||
const grpc_channel_filter* filter = static_cast<const grpc_channel_filter*>(arg);
|
||||
grpc_channel_stack_builder_iterator* it =
|
||||
grpc_channel_stack_builder_iterator_find(builder, filter->name);
|
||||
const bool already_has_load_reporting_filter =
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ static void decrease_call_count(channel_data* chand) {
|
|||
}
|
||||
|
||||
static void start_max_idle_timer_after_init(void* arg, grpc_error* error) {
|
||||
channel_data* chand = (channel_data*)arg;
|
||||
channel_data* chand = static_cast<channel_data*>(arg);
|
||||
/* Decrease call_count. If there are no active calls at this time,
|
||||
max_idle_timer will start here. If the number of active calls is not 0,
|
||||
max_idle_timer will start after all the active calls end. */
|
||||
|
|
@ -216,7 +216,7 @@ static void start_max_idle_timer_after_init(void* arg, grpc_error* error) {
|
|||
}
|
||||
|
||||
static void start_max_age_timer_after_init(void* arg, grpc_error* error) {
|
||||
channel_data* chand = (channel_data*)arg;
|
||||
channel_data* chand = static_cast<channel_data*>(arg);
|
||||
gpr_mu_lock(&chand->max_age_timer_mu);
|
||||
chand->max_age_timer_pending = true;
|
||||
GRPC_CHANNEL_STACK_REF(chand->channel_stack, "max_age max_age_timer");
|
||||
|
|
@ -234,7 +234,7 @@ static void start_max_age_timer_after_init(void* arg, grpc_error* error) {
|
|||
|
||||
static void start_max_age_grace_timer_after_goaway_op(void* arg,
|
||||
grpc_error* error) {
|
||||
channel_data* chand = (channel_data*)arg;
|
||||
channel_data* chand = static_cast<channel_data*>(arg);
|
||||
gpr_mu_lock(&chand->max_age_timer_mu);
|
||||
chand->max_age_grace_timer_pending = true;
|
||||
GRPC_CHANNEL_STACK_REF(chand->channel_stack, "max_age max_age_grace_timer");
|
||||
|
|
@ -262,7 +262,7 @@ static void close_max_idle_channel(channel_data* chand) {
|
|||
}
|
||||
|
||||
static void max_idle_timer_cb(void* arg, grpc_error* error) {
|
||||
channel_data* chand = (channel_data*)arg;
|
||||
channel_data* chand = static_cast<channel_data*>(arg);
|
||||
if (error == GRPC_ERROR_NONE) {
|
||||
bool try_again = true;
|
||||
while (try_again) {
|
||||
|
|
@ -285,7 +285,7 @@ static void max_idle_timer_cb(void* arg, grpc_error* error) {
|
|||
GRPC_CHANNEL_STACK_REF(chand->channel_stack,
|
||||
"max_age max_idle_timer");
|
||||
grpc_timer_init(&chand->max_idle_timer,
|
||||
(grpc_millis)gpr_atm_no_barrier_load(
|
||||
static_cast<grpc_millis>gpr_atm_no_barrier_load(
|
||||
&chand->last_enter_idle_time_millis) +
|
||||
chand->max_connection_idle,
|
||||
&chand->max_idle_timer_cb);
|
||||
|
|
@ -306,7 +306,7 @@ static void max_idle_timer_cb(void* arg, grpc_error* error) {
|
|||
}
|
||||
|
||||
static void close_max_age_channel(void* arg, grpc_error* error) {
|
||||
channel_data* chand = (channel_data*)arg;
|
||||
channel_data* chand = static_cast<channel_data*>(arg);
|
||||
gpr_mu_lock(&chand->max_age_timer_mu);
|
||||
chand->max_age_timer_pending = false;
|
||||
gpr_mu_unlock(&chand->max_age_timer_mu);
|
||||
|
|
@ -328,7 +328,7 @@ static void close_max_age_channel(void* arg, grpc_error* error) {
|
|||
}
|
||||
|
||||
static void force_close_max_age_channel(void* arg, grpc_error* error) {
|
||||
channel_data* chand = (channel_data*)arg;
|
||||
channel_data* chand = static_cast<channel_data*>(arg);
|
||||
gpr_mu_lock(&chand->max_age_timer_mu);
|
||||
chand->max_age_grace_timer_pending = false;
|
||||
gpr_mu_unlock(&chand->max_age_timer_mu);
|
||||
|
|
@ -346,7 +346,7 @@ static void force_close_max_age_channel(void* arg, grpc_error* error) {
|
|||
}
|
||||
|
||||
static void channel_connectivity_changed(void* arg, grpc_error* error) {
|
||||
channel_data* chand = (channel_data*)arg;
|
||||
channel_data* chand = static_cast<channel_data*>(arg);
|
||||
if (chand->connectivity_state != GRPC_CHANNEL_SHUTDOWN) {
|
||||
grpc_transport_op* op = grpc_make_transport_op(nullptr);
|
||||
op->on_connectivity_state_change = &chand->channel_connectivity_changed;
|
||||
|
|
@ -384,15 +384,15 @@ add_random_max_connection_age_jitter_and_convert_to_grpc_millis(int value) {
|
|||
double result = multiplier * value;
|
||||
/* INT_MAX - 0.5 converts the value to float, so that result will not be
|
||||
cast to int implicitly before the comparison. */
|
||||
return result > ((double)GRPC_MILLIS_INF_FUTURE) - 0.5
|
||||
return result > (static_cast<double>GRPC_MILLIS_INF_FUTURE) - 0.5
|
||||
? GRPC_MILLIS_INF_FUTURE
|
||||
: (grpc_millis)result;
|
||||
: static_cast<grpc_millis>(result);
|
||||
}
|
||||
|
||||
/* Constructor for call_data. */
|
||||
static grpc_error* init_call_elem(grpc_call_element* elem,
|
||||
const grpc_call_element_args* args) {
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
increase_call_count(chand);
|
||||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
|
|
@ -401,14 +401,14 @@ static grpc_error* init_call_elem(grpc_call_element* elem,
|
|||
static void destroy_call_elem(grpc_call_element* elem,
|
||||
const grpc_call_final_info* final_info,
|
||||
grpc_closure* ignored) {
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
decrease_call_count(chand);
|
||||
}
|
||||
|
||||
/* Constructor for channel_data. */
|
||||
static grpc_error* init_channel_elem(grpc_channel_element* elem,
|
||||
grpc_channel_element_args* args) {
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
gpr_mu_init(&chand->max_age_timer_mu);
|
||||
chand->max_age_timer_pending = false;
|
||||
chand->max_age_grace_timer_pending = false;
|
||||
|
|
|
|||
|
|
@ -42,14 +42,14 @@ typedef struct {
|
|||
|
||||
static void* refcounted_message_size_limits_ref(void* value) {
|
||||
refcounted_message_size_limits* limits =
|
||||
(refcounted_message_size_limits*)value;
|
||||
static_cast<refcounted_message_size_limits*>(value);
|
||||
gpr_ref(&limits->refs);
|
||||
return value;
|
||||
}
|
||||
|
||||
static void refcounted_message_size_limits_unref(void* value) {
|
||||
refcounted_message_size_limits* limits =
|
||||
(refcounted_message_size_limits*)value;
|
||||
static_cast<refcounted_message_size_limits*>(value);
|
||||
if (gpr_unref(&limits->refs)) {
|
||||
gpr_free(value);
|
||||
}
|
||||
|
|
@ -78,8 +78,8 @@ static void* refcounted_message_size_limits_create_from_json(
|
|||
}
|
||||
}
|
||||
refcounted_message_size_limits* value =
|
||||
(refcounted_message_size_limits*)gpr_malloc(
|
||||
sizeof(refcounted_message_size_limits));
|
||||
static_cast<refcounted_message_size_limits*>(gpr_malloc(
|
||||
sizeof(refcounted_message_size_limits)));
|
||||
gpr_ref_init(&value->refs, 1);
|
||||
value->limits.max_send_size = max_request_message_bytes;
|
||||
value->limits.max_recv_size = max_response_message_bytes;
|
||||
|
|
@ -110,10 +110,10 @@ struct channel_data {
|
|||
// Callback invoked when we receive a message. Here we check the max
|
||||
// receive message size.
|
||||
static void recv_message_ready(void* user_data, grpc_error* error) {
|
||||
grpc_call_element* elem = (grpc_call_element*)user_data;
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
grpc_call_element* elem = static_cast<grpc_call_element*>(user_data);
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
if (*calld->recv_message != nullptr && calld->limits.max_recv_size >= 0 &&
|
||||
(*calld->recv_message)->length > (size_t)calld->limits.max_recv_size) {
|
||||
(*calld->recv_message)->length > static_cast<size_t>(calld->limits.max_recv_size)) {
|
||||
char* message_string;
|
||||
gpr_asprintf(&message_string,
|
||||
"Received message larger than max (%u vs. %d)",
|
||||
|
|
@ -138,11 +138,11 @@ static void recv_message_ready(void* user_data, grpc_error* error) {
|
|||
// Start transport stream op.
|
||||
static void start_transport_stream_op_batch(
|
||||
grpc_call_element* elem, grpc_transport_stream_op_batch* op) {
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
// Check max send message size.
|
||||
if (op->send_message && calld->limits.max_send_size >= 0 &&
|
||||
op->payload->send_message.send_message->length >
|
||||
(size_t)calld->limits.max_send_size) {
|
||||
static_cast<size_t>(calld->limits.max_send_size)) {
|
||||
char* message_string;
|
||||
gpr_asprintf(&message_string, "Sent message larger than max (%u vs. %d)",
|
||||
op->payload->send_message.send_message->length,
|
||||
|
|
@ -170,8 +170,8 @@ static void start_transport_stream_op_batch(
|
|||
// Constructor for call_data.
|
||||
static grpc_error* init_call_elem(grpc_call_element* elem,
|
||||
const grpc_call_element_args* args) {
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
calld->call_combiner = args->call_combiner;
|
||||
calld->next_recv_message_ready = nullptr;
|
||||
GRPC_CLOSURE_INIT(&calld->recv_message_ready, recv_message_ready, elem,
|
||||
|
|
@ -183,8 +183,8 @@ static grpc_error* init_call_elem(grpc_call_element* elem,
|
|||
calld->limits = chand->limits;
|
||||
if (chand->method_limit_table != nullptr) {
|
||||
refcounted_message_size_limits* limits =
|
||||
(refcounted_message_size_limits*)grpc_method_config_table_get(
|
||||
chand->method_limit_table, args->path);
|
||||
static_cast<refcounted_message_size_limits*>(grpc_method_config_table_get(
|
||||
chand->method_limit_table, args->path));
|
||||
if (limits != nullptr) {
|
||||
if (limits->limits.max_send_size >= 0 &&
|
||||
(limits->limits.max_send_size < calld->limits.max_send_size ||
|
||||
|
|
@ -242,7 +242,7 @@ message_size_limits get_message_size_limits(
|
|||
static grpc_error* init_channel_elem(grpc_channel_element* elem,
|
||||
grpc_channel_element_args* args) {
|
||||
GPR_ASSERT(!args->is_last);
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
chand->limits = get_message_size_limits(args->channel_args);
|
||||
// Get method config table from channel args.
|
||||
const grpc_arg* channel_arg =
|
||||
|
|
@ -265,7 +265,7 @@ static grpc_error* init_channel_elem(grpc_channel_element* elem,
|
|||
|
||||
// Destructor for channel_data.
|
||||
static void destroy_channel_elem(grpc_channel_element* elem) {
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
grpc_slice_hash_table_unref(chand->method_limit_table);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,8 +53,8 @@ static bool get_user_agent_mdelem(const grpc_metadata_batch* batch,
|
|||
|
||||
// Callback invoked when we receive an initial metadata.
|
||||
static void recv_initial_metadata_ready(void* user_data, grpc_error* error) {
|
||||
grpc_call_element* elem = (grpc_call_element*)user_data;
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
grpc_call_element* elem = static_cast<grpc_call_element*>(user_data);
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
|
||||
if (GRPC_ERROR_NONE == error) {
|
||||
grpc_mdelem md;
|
||||
|
|
@ -75,7 +75,7 @@ static void recv_initial_metadata_ready(void* user_data, grpc_error* error) {
|
|||
// Start transport stream op.
|
||||
static void start_transport_stream_op_batch(
|
||||
grpc_call_element* elem, grpc_transport_stream_op_batch* op) {
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
|
||||
// Inject callback for receiving initial metadata
|
||||
if (op->recv_initial_metadata) {
|
||||
|
|
@ -102,7 +102,7 @@ static void start_transport_stream_op_batch(
|
|||
// Constructor for call_data.
|
||||
static grpc_error* init_call_elem(grpc_call_element* elem,
|
||||
const grpc_call_element_args* args) {
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
calld->next_recv_initial_metadata_ready = nullptr;
|
||||
calld->workaround_active = false;
|
||||
GRPC_CLOSURE_INIT(&calld->recv_initial_metadata_ready,
|
||||
|
|
|
|||
|
|
@ -27,14 +27,14 @@ static void destroy_user_agent_md(void* user_agent_md) {
|
|||
|
||||
grpc_workaround_user_agent_md* grpc_parse_user_agent(grpc_mdelem md) {
|
||||
grpc_workaround_user_agent_md* user_agent_md =
|
||||
(grpc_workaround_user_agent_md*)grpc_mdelem_get_user_data(
|
||||
md, destroy_user_agent_md);
|
||||
static_cast<grpc_workaround_user_agent_md*>(grpc_mdelem_get_user_data(
|
||||
md, destroy_user_agent_md));
|
||||
|
||||
if (nullptr != user_agent_md) {
|
||||
return user_agent_md;
|
||||
}
|
||||
user_agent_md = (grpc_workaround_user_agent_md*)gpr_malloc(
|
||||
sizeof(grpc_workaround_user_agent_md));
|
||||
user_agent_md = static_cast<grpc_workaround_user_agent_md*>(gpr_malloc(
|
||||
sizeof(grpc_workaround_user_agent_md)));
|
||||
for (int i = 0; i < GRPC_MAX_WORKAROUND_ID; i++) {
|
||||
if (ua_parser[i]) {
|
||||
user_agent_md->workaround_active[i] = ua_parser[i](md);
|
||||
|
|
|
|||
|
|
@ -57,12 +57,12 @@ typedef struct {
|
|||
} chttp2_connector;
|
||||
|
||||
static void chttp2_connector_ref(grpc_connector* con) {
|
||||
chttp2_connector* c = (chttp2_connector*)con;
|
||||
chttp2_connector* c = reinterpret_cast<chttp2_connector*>(con);
|
||||
gpr_ref(&c->refs);
|
||||
}
|
||||
|
||||
static void chttp2_connector_unref(grpc_connector* con) {
|
||||
chttp2_connector* c = (chttp2_connector*)con;
|
||||
chttp2_connector* c = reinterpret_cast<chttp2_connector*>(con);
|
||||
if (gpr_unref(&c->refs)) {
|
||||
gpr_mu_destroy(&c->mu);
|
||||
// If handshaking is not yet in progress, destroy the endpoint.
|
||||
|
|
@ -73,7 +73,7 @@ static void chttp2_connector_unref(grpc_connector* con) {
|
|||
}
|
||||
|
||||
static void chttp2_connector_shutdown(grpc_connector* con, grpc_error* why) {
|
||||
chttp2_connector* c = (chttp2_connector*)con;
|
||||
chttp2_connector* c = reinterpret_cast<chttp2_connector*>(con);
|
||||
gpr_mu_lock(&c->mu);
|
||||
c->shutdown = true;
|
||||
if (c->handshake_mgr != nullptr) {
|
||||
|
|
@ -89,8 +89,8 @@ static void chttp2_connector_shutdown(grpc_connector* con, grpc_error* why) {
|
|||
}
|
||||
|
||||
static void on_handshake_done(void* arg, grpc_error* error) {
|
||||
grpc_handshaker_args* args = (grpc_handshaker_args*)arg;
|
||||
chttp2_connector* c = (chttp2_connector*)args->user_data;
|
||||
grpc_handshaker_args* args = static_cast<grpc_handshaker_args*>(arg);
|
||||
chttp2_connector* c = static_cast<chttp2_connector*>(args->user_data);
|
||||
gpr_mu_lock(&c->mu);
|
||||
if (error != GRPC_ERROR_NONE || c->shutdown) {
|
||||
if (error == GRPC_ERROR_NONE) {
|
||||
|
|
@ -150,7 +150,7 @@ static void on_handshake_done(void* arg, grpc_error* error) {
|
|||
grpc_handshake_manager_destroy(c->handshake_mgr);
|
||||
c->handshake_mgr = nullptr;
|
||||
gpr_mu_unlock(&c->mu);
|
||||
chttp2_connector_unref((grpc_connector*)c);
|
||||
chttp2_connector_unref(reinterpret_cast<grpc_connector*>(c));
|
||||
}
|
||||
|
||||
static void start_handshake_locked(chttp2_connector* c) {
|
||||
|
|
@ -166,7 +166,7 @@ static void start_handshake_locked(chttp2_connector* c) {
|
|||
}
|
||||
|
||||
static void connected(void* arg, grpc_error* error) {
|
||||
chttp2_connector* c = (chttp2_connector*)arg;
|
||||
chttp2_connector* c = static_cast<chttp2_connector*>(arg);
|
||||
gpr_mu_lock(&c->mu);
|
||||
GPR_ASSERT(c->connecting);
|
||||
c->connecting = false;
|
||||
|
|
@ -184,7 +184,7 @@ static void connected(void* arg, grpc_error* error) {
|
|||
grpc_endpoint_shutdown(c->endpoint, GRPC_ERROR_REF(error));
|
||||
}
|
||||
gpr_mu_unlock(&c->mu);
|
||||
chttp2_connector_unref((grpc_connector*)arg);
|
||||
chttp2_connector_unref(static_cast<grpc_connector*>(arg));
|
||||
} else {
|
||||
GPR_ASSERT(c->endpoint != nullptr);
|
||||
start_handshake_locked(c);
|
||||
|
|
@ -196,7 +196,7 @@ static void chttp2_connector_connect(grpc_connector* con,
|
|||
const grpc_connect_in_args* args,
|
||||
grpc_connect_out_args* result,
|
||||
grpc_closure* notify) {
|
||||
chttp2_connector* c = (chttp2_connector*)con;
|
||||
chttp2_connector* c = reinterpret_cast<chttp2_connector*>(con);
|
||||
grpc_resolved_address addr;
|
||||
grpc_get_subchannel_address_arg(args->channel_args, &addr);
|
||||
gpr_mu_lock(&c->mu);
|
||||
|
|
@ -219,7 +219,7 @@ static const grpc_connector_vtable chttp2_connector_vtable = {
|
|||
chttp2_connector_connect};
|
||||
|
||||
grpc_connector* grpc_chttp2_connector_create() {
|
||||
chttp2_connector* c = (chttp2_connector*)gpr_zalloc(sizeof(*c));
|
||||
chttp2_connector* c = static_cast<chttp2_connector*>(gpr_zalloc(sizeof(*c)));
|
||||
c->base.vtable = &chttp2_connector_vtable;
|
||||
gpr_mu_init(&c->mu);
|
||||
gpr_ref_init(&c->refs, 1);
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ static grpc_subchannel_args* get_secure_naming_subchannel_args(
|
|||
const grpc_slice key = grpc_slice_from_static_string(
|
||||
target_uri->path[0] == '/' ? target_uri->path + 1 : target_uri->path);
|
||||
const char* value =
|
||||
(const char*)grpc_slice_hash_table_get(targets_info, key);
|
||||
static_cast<const char*>(grpc_slice_hash_table_get(targets_info, key));
|
||||
if (value != nullptr) target_name_to_check = gpr_strdup(value);
|
||||
grpc_slice_unref_internal(key);
|
||||
}
|
||||
|
|
@ -129,7 +129,7 @@ static grpc_subchannel_args* get_secure_naming_subchannel_args(
|
|||
grpc_channel_args_destroy(new_args_from_connector);
|
||||
}
|
||||
grpc_subchannel_args* final_sc_args =
|
||||
(grpc_subchannel_args*)gpr_malloc(sizeof(*final_sc_args));
|
||||
static_cast<grpc_subchannel_args*>(gpr_malloc(sizeof(*final_sc_args)));
|
||||
memcpy(final_sc_args, args, sizeof(*args));
|
||||
final_sc_args->args = new_args;
|
||||
return final_sc_args;
|
||||
|
|
@ -148,7 +148,7 @@ static grpc_subchannel* client_channel_factory_create_subchannel(
|
|||
grpc_connector* connector = grpc_chttp2_connector_create();
|
||||
grpc_subchannel* s = grpc_subchannel_create(connector, subchannel_args);
|
||||
grpc_connector_unref(connector);
|
||||
grpc_channel_args_destroy((grpc_channel_args*)subchannel_args->args);
|
||||
grpc_channel_args_destroy(const_cast<grpc_channel_args*>(subchannel_args->args));
|
||||
gpr_free(subchannel_args);
|
||||
return s;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ static void server_connection_state_unref(
|
|||
}
|
||||
|
||||
static void on_timeout(void* arg, grpc_error* error) {
|
||||
server_connection_state* connection_state = (server_connection_state*)arg;
|
||||
server_connection_state* connection_state = static_cast<server_connection_state*>(arg);
|
||||
// Note that we may be called with GRPC_ERROR_NONE when the timer fires
|
||||
// or with an error indicating that the timer system is being shut down.
|
||||
if (error != GRPC_ERROR_CANCELLED) {
|
||||
|
|
@ -92,7 +92,7 @@ static void on_timeout(void* arg, grpc_error* error) {
|
|||
}
|
||||
|
||||
static void on_receive_settings(void* arg, grpc_error* error) {
|
||||
server_connection_state* connection_state = (server_connection_state*)arg;
|
||||
server_connection_state* connection_state = static_cast<server_connection_state*>(arg);
|
||||
if (error == GRPC_ERROR_NONE) {
|
||||
grpc_timer_cancel(&connection_state->timer);
|
||||
}
|
||||
|
|
@ -100,9 +100,9 @@ static void on_receive_settings(void* arg, grpc_error* error) {
|
|||
}
|
||||
|
||||
static void on_handshake_done(void* arg, grpc_error* error) {
|
||||
grpc_handshaker_args* args = (grpc_handshaker_args*)arg;
|
||||
grpc_handshaker_args* args = static_cast<grpc_handshaker_args*>(arg);
|
||||
server_connection_state* connection_state =
|
||||
(server_connection_state*)args->user_data;
|
||||
static_cast<server_connection_state*>(args->user_data);
|
||||
gpr_mu_lock(&connection_state->svr_state->mu);
|
||||
if (error != GRPC_ERROR_NONE || connection_state->svr_state->shutdown) {
|
||||
const char* error_str = grpc_error_string(error);
|
||||
|
|
@ -132,7 +132,7 @@ static void on_handshake_done(void* arg, grpc_error* error) {
|
|||
connection_state->accepting_pollset, args->args);
|
||||
// Use notify_on_receive_settings callback to enforce the
|
||||
// handshake deadline.
|
||||
connection_state->transport = (grpc_chttp2_transport*)transport;
|
||||
connection_state->transport = reinterpret_cast<grpc_chttp2_transport*>(transport);
|
||||
gpr_ref(&connection_state->refs);
|
||||
GRPC_CLOSURE_INIT(&connection_state->on_receive_settings,
|
||||
on_receive_settings, connection_state,
|
||||
|
|
@ -162,7 +162,7 @@ static void on_handshake_done(void* arg, grpc_error* error) {
|
|||
static void on_accept(void* arg, grpc_endpoint* tcp,
|
||||
grpc_pollset* accepting_pollset,
|
||||
grpc_tcp_server_acceptor* acceptor) {
|
||||
server_state* state = (server_state*)arg;
|
||||
server_state* state = static_cast<server_state*>(arg);
|
||||
gpr_mu_lock(&state->mu);
|
||||
if (state->shutdown) {
|
||||
gpr_mu_unlock(&state->mu);
|
||||
|
|
@ -177,7 +177,7 @@ static void on_accept(void* arg, grpc_endpoint* tcp,
|
|||
gpr_mu_unlock(&state->mu);
|
||||
grpc_tcp_server_ref(state->tcp_server);
|
||||
server_connection_state* connection_state =
|
||||
(server_connection_state*)gpr_zalloc(sizeof(*connection_state));
|
||||
static_cast<server_connection_state*>(gpr_zalloc(sizeof(*connection_state)));
|
||||
gpr_ref_init(&connection_state->refs, 1);
|
||||
connection_state->svr_state = state;
|
||||
connection_state->accepting_pollset = accepting_pollset;
|
||||
|
|
@ -201,7 +201,7 @@ static void on_accept(void* arg, grpc_endpoint* tcp,
|
|||
static void server_start_listener(grpc_server* server, void* arg,
|
||||
grpc_pollset** pollsets,
|
||||
size_t pollset_count) {
|
||||
server_state* state = (server_state*)arg;
|
||||
server_state* state = static_cast<server_state*>(arg);
|
||||
gpr_mu_lock(&state->mu);
|
||||
state->shutdown = false;
|
||||
gpr_mu_unlock(&state->mu);
|
||||
|
|
@ -210,7 +210,7 @@ static void server_start_listener(grpc_server* server, void* arg,
|
|||
}
|
||||
|
||||
static void tcp_server_shutdown_complete(void* arg, grpc_error* error) {
|
||||
server_state* state = (server_state*)arg;
|
||||
server_state* state = static_cast<server_state*>(arg);
|
||||
/* ensure all threads have unlocked */
|
||||
gpr_mu_lock(&state->mu);
|
||||
grpc_closure* destroy_done = state->server_destroy_listener_done;
|
||||
|
|
@ -234,7 +234,7 @@ static void tcp_server_shutdown_complete(void* arg, grpc_error* error) {
|
|||
callbacks) */
|
||||
static void server_destroy_listener(grpc_server* server, void* arg,
|
||||
grpc_closure* destroy_done) {
|
||||
server_state* state = (server_state*)arg;
|
||||
server_state* state = static_cast<server_state*>(arg);
|
||||
gpr_mu_lock(&state->mu);
|
||||
state->shutdown = true;
|
||||
state->server_destroy_listener_done = destroy_done;
|
||||
|
|
@ -264,7 +264,7 @@ grpc_error* grpc_chttp2_server_add_port(grpc_server* server, const char* addr,
|
|||
if (err != GRPC_ERROR_NONE) {
|
||||
goto error;
|
||||
}
|
||||
state = (server_state*)gpr_zalloc(sizeof(*state));
|
||||
state = static_cast<server_state*>(gpr_zalloc(sizeof(*state)));
|
||||
GRPC_CLOSURE_INIT(&state->tcp_server_shutdown_complete,
|
||||
tcp_server_shutdown_complete, state,
|
||||
grpc_schedule_on_exec_ctx);
|
||||
|
|
@ -281,7 +281,7 @@ grpc_error* grpc_chttp2_server_add_port(grpc_server* server, const char* addr,
|
|||
gpr_mu_init(&state->mu);
|
||||
|
||||
naddrs = resolved->naddrs;
|
||||
errors = (grpc_error**)gpr_malloc(sizeof(*errors) * naddrs);
|
||||
errors = static_cast<grpc_error**>(gpr_malloc(sizeof(*errors) * naddrs));
|
||||
for (i = 0; i < naddrs; i++) {
|
||||
errors[i] =
|
||||
grpc_tcp_server_add_port(tcp_server, &resolved->addrs[i], &port_temp);
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ static bool input_is_valid(uint8_t* input_ptr, size_t length) {
|
|||
gpr_log(GPR_ERROR,
|
||||
"Base64 decoding failed, invalid character '%c' in base64 "
|
||||
"input.\n",
|
||||
(char)(*input_ptr));
|
||||
static_cast<char>(*input_ptr));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -94,7 +94,7 @@ bool grpc_base64_decode_partial(struct grpc_base64_decode_context* ctx) {
|
|||
}
|
||||
|
||||
// Process the tail of input data
|
||||
input_tail = (size_t)(ctx->input_end - ctx->input_cur);
|
||||
input_tail = static_cast<size_t>(ctx->input_end - ctx->input_cur);
|
||||
if (input_tail == 4) {
|
||||
// Process the input data with pad chars
|
||||
if (ctx->input_cur[3] == '=') {
|
||||
|
|
@ -141,7 +141,7 @@ grpc_slice grpc_chttp2_base64_decode(grpc_slice input) {
|
|||
"Base64 decoding failed, input of "
|
||||
"grpc_chttp2_base64_decode has a length of %d, which is not a "
|
||||
"multiple of 4.\n",
|
||||
(int)input_length);
|
||||
static_cast<int>(input_length));
|
||||
return grpc_empty_slice();
|
||||
}
|
||||
|
||||
|
|
@ -186,7 +186,7 @@ grpc_slice grpc_chttp2_base64_decode_with_length(grpc_slice input,
|
|||
"Base64 decoding failed, input of "
|
||||
"grpc_chttp2_base64_decode_with_length has a length of %d, which "
|
||||
"has a tail of 1 byte.\n",
|
||||
(int)input_length);
|
||||
static_cast<int>(input_length));
|
||||
grpc_slice_unref_internal(output);
|
||||
return grpc_empty_slice();
|
||||
}
|
||||
|
|
@ -195,8 +195,8 @@ grpc_slice grpc_chttp2_base64_decode_with_length(grpc_slice input,
|
|||
gpr_log(GPR_ERROR,
|
||||
"Base64 decoding failed, output_length %d is longer "
|
||||
"than the max possible output length %d.\n",
|
||||
(int)output_length,
|
||||
(int)(input_length / 4 * 3 + tail_xtra[input_length % 4]));
|
||||
static_cast<int>(output_length),
|
||||
static_cast<int>(input_length / 4 * 3 + tail_xtra[input_length % 4]));
|
||||
grpc_slice_unref_internal(output);
|
||||
return grpc_empty_slice();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ grpc_slice grpc_chttp2_base64_encode(grpc_slice input) {
|
|||
size_t output_length = input_triplets * 4 + tail_xtra[tail_case];
|
||||
grpc_slice output = GRPC_SLICE_MALLOC(output_length);
|
||||
uint8_t* in = GRPC_SLICE_START_PTR(input);
|
||||
char* out = (char*)GRPC_SLICE_START_PTR(output);
|
||||
char* out = reinterpret_cast<char*>GRPC_SLICE_START_PTR(output);
|
||||
size_t i;
|
||||
|
||||
/* encode full triplets */
|
||||
|
|
@ -115,7 +115,7 @@ grpc_slice grpc_chttp2_huffman_compress(grpc_slice input) {
|
|||
|
||||
while (temp_length > 8) {
|
||||
temp_length -= 8;
|
||||
*out++ = (uint8_t)(temp >> temp_length);
|
||||
*out++ = static_cast<uint8_t>(temp >> temp_length);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -124,8 +124,8 @@ grpc_slice grpc_chttp2_huffman_compress(grpc_slice input) {
|
|||
* expanded form due to the "integral promotion" performed (see section
|
||||
* 3.2.1.1 of the C89 draft standard). A cast to the smaller container type
|
||||
* is then required to avoid the compiler warning */
|
||||
*out++ = (uint8_t)((uint8_t)(temp << (8u - temp_length)) |
|
||||
(uint8_t)(0xffu >> temp_length));
|
||||
*out++ = static_cast<uint8_t>(static_cast<uint8_t>(temp << (8u - temp_length)) |
|
||||
static_cast<uint8_t>(0xffu >> temp_length));
|
||||
}
|
||||
|
||||
GPR_ASSERT(out == GRPC_SLICE_END_PTR(output));
|
||||
|
|
@ -142,7 +142,7 @@ typedef struct {
|
|||
static void enc_flush_some(huff_out* out) {
|
||||
while (out->temp_length > 8) {
|
||||
out->temp_length -= 8;
|
||||
*out->out++ = (uint8_t)(out->temp >> out->temp_length);
|
||||
*out->out++ = static_cast<uint8_t>(out->temp >> out->temp_length);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -150,8 +150,8 @@ static void enc_add2(huff_out* out, uint8_t a, uint8_t b) {
|
|||
b64_huff_sym sa = huff_alphabet[a];
|
||||
b64_huff_sym sb = huff_alphabet[b];
|
||||
out->temp = (out->temp << (sa.length + sb.length)) |
|
||||
((uint32_t)sa.bits << sb.length) | sb.bits;
|
||||
out->temp_length += (uint32_t)sa.length + (uint32_t)sb.length;
|
||||
(static_cast<uint32_t>(sa.bits) << sb.length) | sb.bits;
|
||||
out->temp_length += static_cast<uint32_t>(sa.length) + static_cast<uint32_t>(sb.length);
|
||||
enc_flush_some(out);
|
||||
}
|
||||
|
||||
|
|
@ -181,11 +181,11 @@ grpc_slice grpc_chttp2_base64_encode_and_huffman_compress(grpc_slice input) {
|
|||
|
||||
/* encode full triplets */
|
||||
for (i = 0; i < input_triplets; i++) {
|
||||
const uint8_t low_to_high = (uint8_t)((in[0] & 0x3) << 4);
|
||||
const uint8_t low_to_high = static_cast<uint8_t>((in[0] & 0x3) << 4);
|
||||
const uint8_t high_to_low = in[1] >> 4;
|
||||
enc_add2(&out, in[0] >> 2, low_to_high | high_to_low);
|
||||
|
||||
const uint8_t a = (uint8_t)((in[1] & 0xf) << 2);
|
||||
const uint8_t a = static_cast<uint8_t>((in[1] & 0xf) << 2);
|
||||
const uint8_t b = (in[2] >> 6);
|
||||
enc_add2(&out, a | b, in[2] & 0x3f);
|
||||
in += 3;
|
||||
|
|
@ -196,14 +196,14 @@ grpc_slice grpc_chttp2_base64_encode_and_huffman_compress(grpc_slice input) {
|
|||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
enc_add2(&out, in[0] >> 2, (uint8_t)((in[0] & 0x3) << 4));
|
||||
enc_add2(&out, in[0] >> 2, static_cast<uint8_t>((in[0] & 0x3) << 4));
|
||||
in += 1;
|
||||
break;
|
||||
case 2: {
|
||||
const uint8_t low_to_high = (uint8_t)((in[0] & 0x3) << 4);
|
||||
const uint8_t low_to_high = static_cast<uint8_t>((in[0] & 0x3) << 4);
|
||||
const uint8_t high_to_low = in[1] >> 4;
|
||||
enc_add2(&out, in[0] >> 2, low_to_high | high_to_low);
|
||||
enc_add1(&out, (uint8_t)((in[1] & 0xf) << 2));
|
||||
enc_add1(&out, static_cast<uint8_t>((in[1] & 0xf) << 2));
|
||||
in += 2;
|
||||
break;
|
||||
}
|
||||
|
|
@ -214,8 +214,8 @@ grpc_slice grpc_chttp2_base64_encode_and_huffman_compress(grpc_slice input) {
|
|||
* expanded form due to the "integral promotion" performed (see section
|
||||
* 3.2.1.1 of the C89 draft standard). A cast to the smaller container type
|
||||
* is then required to avoid the compiler warning */
|
||||
*out.out++ = (uint8_t)((uint8_t)(out.temp << (8u - out.temp_length)) |
|
||||
(uint8_t)(0xffu >> out.temp_length));
|
||||
*out.out++ = static_cast<uint8_t>(static_cast<uint8_t>(out.temp << (8u - out.temp_length)) |
|
||||
static_cast<uint8_t>(0xffu >> out.temp_length));
|
||||
}
|
||||
|
||||
GPR_ASSERT(out.out <= GRPC_SLICE_END_PTR(output));
|
||||
|
|
|
|||
|
|
@ -378,7 +378,7 @@ static void init_transport(grpc_chttp2_transport* t,
|
|||
GRPC_ARG_HTTP2_INITIAL_SEQUENCE_NUMBER,
|
||||
t->next_stream_id & 1, is_client ? "client" : "server");
|
||||
} else {
|
||||
t->next_stream_id = (uint32_t)value;
|
||||
t->next_stream_id = static_cast<uint32_t>(value);
|
||||
}
|
||||
}
|
||||
} else if (0 == strcmp(channel_args->args[i].key,
|
||||
|
|
@ -388,7 +388,7 @@ static void init_transport(grpc_chttp2_transport* t,
|
|||
grpc_channel_arg_get_integer(&channel_args->args[i], options);
|
||||
if (value >= 0) {
|
||||
grpc_chttp2_hpack_compressor_set_max_usable_size(&t->hpack_compressor,
|
||||
(uint32_t)value);
|
||||
static_cast<uint32_t>(value));
|
||||
}
|
||||
} else if (0 == strcmp(channel_args->args[i].key,
|
||||
GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA)) {
|
||||
|
|
@ -421,8 +421,8 @@ static void init_transport(grpc_chttp2_transport* t,
|
|||
INT_MAX});
|
||||
} else if (0 == strcmp(channel_args->args[i].key,
|
||||
GRPC_ARG_HTTP2_WRITE_BUFFER_SIZE)) {
|
||||
t->write_buffer_size = (uint32_t)grpc_channel_arg_get_integer(
|
||||
&channel_args->args[i], {0, 0, MAX_WRITE_BUFFER_SIZE});
|
||||
t->write_buffer_size = static_cast<uint32_t>(grpc_channel_arg_get_integer(
|
||||
&channel_args->args[i], {0, 0, MAX_WRITE_BUFFER_SIZE}));
|
||||
} else if (0 ==
|
||||
strcmp(channel_args->args[i].key, GRPC_ARG_HTTP2_BDP_PROBE)) {
|
||||
enable_bdp = grpc_channel_arg_get_bool(&channel_args->args[i], true);
|
||||
|
|
@ -448,8 +448,8 @@ static void init_transport(grpc_chttp2_transport* t,
|
|||
} else if (0 == strcmp(channel_args->args[i].key,
|
||||
GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS)) {
|
||||
t->keepalive_permit_without_calls =
|
||||
(uint32_t)grpc_channel_arg_get_integer(&channel_args->args[i],
|
||||
{0, 0, 1});
|
||||
static_cast<uint32_t>(grpc_channel_arg_get_integer(&channel_args->args[i],
|
||||
{0, 0, 1}));
|
||||
} else if (0 == strcmp(channel_args->args[i].key,
|
||||
GRPC_ARG_OPTIMIZATION_TARGET)) {
|
||||
if (channel_args->args[i].type != GRPC_ARG_STRING) {
|
||||
|
|
@ -498,7 +498,7 @@ static void init_transport(grpc_chttp2_transport* t,
|
|||
GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE,
|
||||
{-1, 5, INT32_MAX},
|
||||
{true, true}}};
|
||||
for (j = 0; j < (int)GPR_ARRAY_SIZE(settings_map); j++) {
|
||||
for (j = 0; j < static_cast<int>GPR_ARRAY_SIZE(settings_map); j++) {
|
||||
if (0 == strcmp(channel_args->args[i].key,
|
||||
settings_map[j].channel_arg_name)) {
|
||||
if (!settings_map[j].availability[is_client]) {
|
||||
|
|
@ -510,7 +510,7 @@ static void init_transport(grpc_chttp2_transport* t,
|
|||
&channel_args->args[i], settings_map[j].integer_options);
|
||||
if (value >= 0) {
|
||||
queue_setting_update(t, settings_map[j].setting_id,
|
||||
(uint32_t)value);
|
||||
static_cast<uint32_t>(value));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -562,7 +562,7 @@ static void init_transport(grpc_chttp2_transport* t,
|
|||
}
|
||||
|
||||
static void destroy_transport_locked(void* tp, grpc_error* error) {
|
||||
grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
|
||||
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(tp);
|
||||
t->destroying = 1;
|
||||
close_transport_locked(
|
||||
t, grpc_error_set_int(
|
||||
|
|
@ -572,7 +572,7 @@ static void destroy_transport_locked(void* tp, grpc_error* error) {
|
|||
}
|
||||
|
||||
static void destroy_transport(grpc_transport* gt) {
|
||||
grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
|
||||
grpc_chttp2_transport* t = reinterpret_cast<grpc_chttp2_transport*>(gt);
|
||||
GRPC_CLOSURE_SCHED(GRPC_CLOSURE_CREATE(destroy_transport_locked, t,
|
||||
grpc_combiner_scheduler(t->combiner)),
|
||||
GRPC_ERROR_NONE);
|
||||
|
|
@ -656,8 +656,8 @@ static int init_stream(grpc_transport* gt, grpc_stream* gs,
|
|||
grpc_stream_refcount* refcount, const void* server_data,
|
||||
gpr_arena* arena) {
|
||||
GPR_TIMER_SCOPE("init_stream", 0);
|
||||
grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
|
||||
grpc_chttp2_stream* s = (grpc_chttp2_stream*)gs;
|
||||
grpc_chttp2_transport* t = reinterpret_cast<grpc_chttp2_transport*>(gt);
|
||||
grpc_chttp2_stream* s = reinterpret_cast<grpc_chttp2_stream*>(gs);
|
||||
|
||||
s->t = t;
|
||||
s->refcount = refcount;
|
||||
|
|
@ -685,7 +685,7 @@ static int init_stream(grpc_transport* gt, grpc_stream* gs,
|
|||
GRPC_CHTTP2_REF_TRANSPORT(t, "stream");
|
||||
|
||||
if (server_data) {
|
||||
s->id = (uint32_t)(uintptr_t)server_data;
|
||||
s->id = static_cast<uint32_t>((uintptr_t)server_data);
|
||||
*t->accepting_stream = s;
|
||||
grpc_chttp2_stream_map_add(&t->stream_map, s->id, s);
|
||||
post_destructive_reclaimer(t);
|
||||
|
|
@ -705,7 +705,7 @@ static int init_stream(grpc_transport* gt, grpc_stream* gs,
|
|||
|
||||
static void destroy_stream_locked(void* sp, grpc_error* error) {
|
||||
GPR_TIMER_SCOPE("destroy_stream", 0);
|
||||
grpc_chttp2_stream* s = (grpc_chttp2_stream*)sp;
|
||||
grpc_chttp2_stream* s = static_cast<grpc_chttp2_stream*>(sp);
|
||||
grpc_chttp2_transport* t = s->t;
|
||||
|
||||
GPR_ASSERT((s->write_closed && s->read_closed) || s->id == 0);
|
||||
|
|
@ -753,8 +753,8 @@ static void destroy_stream_locked(void* sp, grpc_error* error) {
|
|||
static void destroy_stream(grpc_transport* gt, grpc_stream* gs,
|
||||
grpc_closure* then_schedule_closure) {
|
||||
GPR_TIMER_SCOPE("destroy_stream", 0);
|
||||
grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
|
||||
grpc_chttp2_stream* s = (grpc_chttp2_stream*)gs;
|
||||
grpc_chttp2_transport* t = reinterpret_cast<grpc_chttp2_transport*>(gt);
|
||||
grpc_chttp2_stream* s = reinterpret_cast<grpc_chttp2_stream*>(gs);
|
||||
|
||||
if (s->stream_compression_ctx != nullptr) {
|
||||
grpc_stream_compression_context_destroy(s->stream_compression_ctx);
|
||||
|
|
@ -774,7 +774,7 @@ static void destroy_stream(grpc_transport* gt, grpc_stream* gs,
|
|||
|
||||
grpc_chttp2_stream* grpc_chttp2_parsing_lookup_stream(grpc_chttp2_transport* t,
|
||||
uint32_t id) {
|
||||
return (grpc_chttp2_stream*)grpc_chttp2_stream_map_find(&t->stream_map, id);
|
||||
return static_cast<grpc_chttp2_stream*>(grpc_chttp2_stream_map_find(&t->stream_map, id));
|
||||
}
|
||||
|
||||
grpc_chttp2_stream* grpc_chttp2_parsing_accept_stream(grpc_chttp2_transport* t,
|
||||
|
|
@ -786,7 +786,7 @@ grpc_chttp2_stream* grpc_chttp2_parsing_accept_stream(grpc_chttp2_transport* t,
|
|||
GPR_ASSERT(t->accepting_stream == nullptr);
|
||||
t->accepting_stream = &accepting;
|
||||
t->channel_callback.accept_stream(t->channel_callback.accept_stream_user_data,
|
||||
&t->base, (void*)(uintptr_t)id);
|
||||
&t->base, (void*)static_cast<uintptr_t>(id));
|
||||
t->accepting_stream = nullptr;
|
||||
return accepting;
|
||||
}
|
||||
|
|
@ -968,7 +968,7 @@ static const char* begin_writing_desc(bool partial, bool inlined) {
|
|||
|
||||
static void write_action_begin_locked(void* gt, grpc_error* error_ignored) {
|
||||
GPR_TIMER_SCOPE("write_action_begin_locked", 0);
|
||||
grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
|
||||
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(gt);
|
||||
GPR_ASSERT(t->write_state != GRPC_CHTTP2_WRITE_STATE_IDLE);
|
||||
grpc_chttp2_begin_write_result r;
|
||||
if (t->closed_with_error != GRPC_ERROR_NONE) {
|
||||
|
|
@ -1005,7 +1005,7 @@ static void write_action_begin_locked(void* gt, grpc_error* error_ignored) {
|
|||
|
||||
static void write_action(void* gt, grpc_error* error) {
|
||||
GPR_TIMER_SCOPE("write_action", 0);
|
||||
grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
|
||||
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(gt);
|
||||
grpc_endpoint_write(
|
||||
t->ep, &t->outbuf,
|
||||
GRPC_CLOSURE_INIT(&t->write_action_end_locked, write_action_end_locked, t,
|
||||
|
|
@ -1014,7 +1014,7 @@ static void write_action(void* gt, grpc_error* error) {
|
|||
|
||||
static void write_action_end_locked(void* tp, grpc_error* error) {
|
||||
GPR_TIMER_SCOPE("terminate_writing_with_lock", 0);
|
||||
grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
|
||||
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(tp);
|
||||
|
||||
if (error != GRPC_ERROR_NONE) {
|
||||
close_transport_locked(t, GRPC_ERROR_REF(error));
|
||||
|
|
@ -1083,7 +1083,7 @@ void grpc_chttp2_add_incoming_goaway(grpc_chttp2_transport* t,
|
|||
t->goaway_error = grpc_error_set_str(
|
||||
grpc_error_set_int(
|
||||
GRPC_ERROR_CREATE_FROM_STATIC_STRING("GOAWAY received"),
|
||||
GRPC_ERROR_INT_HTTP2_ERROR, (intptr_t)goaway_error),
|
||||
GRPC_ERROR_INT_HTTP2_ERROR, static_cast<intptr_t>(goaway_error)),
|
||||
GRPC_ERROR_STR_RAW_BYTES, goaway_text);
|
||||
|
||||
/* When a client receives a GOAWAY with error code ENHANCE_YOUR_CALM and debug
|
||||
|
|
@ -1095,11 +1095,11 @@ void grpc_chttp2_add_incoming_goaway(grpc_chttp2_transport* t,
|
|||
gpr_log(GPR_ERROR,
|
||||
"Received a GOAWAY with error code ENHANCE_YOUR_CALM and debug "
|
||||
"data equal to \"too_many_pings\"");
|
||||
double current_keepalive_time_ms = (double)t->keepalive_time;
|
||||
double current_keepalive_time_ms = static_cast<double>(t->keepalive_time);
|
||||
t->keepalive_time =
|
||||
current_keepalive_time_ms > INT_MAX / KEEPALIVE_TIME_BACKOFF_MULTIPLIER
|
||||
? GRPC_MILLIS_INF_FUTURE
|
||||
: (grpc_millis)(current_keepalive_time_ms *
|
||||
: static_cast<grpc_millis>(current_keepalive_time_ms *
|
||||
KEEPALIVE_TIME_BACKOFF_MULTIPLIER);
|
||||
}
|
||||
|
||||
|
|
@ -1189,8 +1189,8 @@ void grpc_chttp2_complete_closure_step(grpc_chttp2_transport* t,
|
|||
"complete_closure_step: t=%p %p refs=%d flags=0x%04x desc=%s err=%s "
|
||||
"write_state=%s",
|
||||
t, closure,
|
||||
(int)(closure->next_data.scratch / CLOSURE_BARRIER_FIRST_REF_BIT),
|
||||
(int)(closure->next_data.scratch % CLOSURE_BARRIER_FIRST_REF_BIT), desc,
|
||||
static_cast<int>(closure->next_data.scratch / CLOSURE_BARRIER_FIRST_REF_BIT),
|
||||
static_cast<int>(closure->next_data.scratch % CLOSURE_BARRIER_FIRST_REF_BIT), desc,
|
||||
errstr, write_state_name(t->write_state));
|
||||
}
|
||||
if (error != GRPC_ERROR_NONE) {
|
||||
|
|
@ -1239,7 +1239,7 @@ static void maybe_become_writable_due_to_send_msg(grpc_chttp2_transport* t,
|
|||
static void add_fetched_slice_locked(grpc_chttp2_transport* t,
|
||||
grpc_chttp2_stream* s) {
|
||||
s->fetched_send_message_length +=
|
||||
(uint32_t)GRPC_SLICE_LENGTH(s->fetching_slice);
|
||||
static_cast<uint32_t>GRPC_SLICE_LENGTH(s->fetching_slice);
|
||||
grpc_slice_buffer_add(&s->flow_controlled_buffer, s->fetching_slice);
|
||||
maybe_become_writable_due_to_send_msg(t, s);
|
||||
}
|
||||
|
|
@ -1262,7 +1262,7 @@ static void continue_fetching_send_locked(grpc_chttp2_transport* t,
|
|||
} else {
|
||||
grpc_chttp2_write_cb* cb = t->write_cb_pool;
|
||||
if (cb == nullptr) {
|
||||
cb = (grpc_chttp2_write_cb*)gpr_malloc(sizeof(*cb));
|
||||
cb = static_cast<grpc_chttp2_write_cb*>(gpr_malloc(sizeof(*cb)));
|
||||
} else {
|
||||
t->write_cb_pool = cb->next;
|
||||
}
|
||||
|
|
@ -1293,7 +1293,7 @@ static void continue_fetching_send_locked(grpc_chttp2_transport* t,
|
|||
}
|
||||
|
||||
static void complete_fetch_locked(void* gs, grpc_error* error) {
|
||||
grpc_chttp2_stream* s = (grpc_chttp2_stream*)gs;
|
||||
grpc_chttp2_stream* s = static_cast<grpc_chttp2_stream*>(gs);
|
||||
grpc_chttp2_transport* t = s->t;
|
||||
if (error == GRPC_ERROR_NONE) {
|
||||
error = grpc_byte_stream_pull(s->fetching_send_message, &s->fetching_slice);
|
||||
|
|
@ -1328,8 +1328,8 @@ static void perform_stream_op_locked(void* stream_op,
|
|||
GPR_TIMER_SCOPE("perform_stream_op_locked", 0);
|
||||
|
||||
grpc_transport_stream_op_batch* op =
|
||||
(grpc_transport_stream_op_batch*)stream_op;
|
||||
grpc_chttp2_stream* s = (grpc_chttp2_stream*)op->handler_private.extra_arg;
|
||||
static_cast<grpc_transport_stream_op_batch*>(stream_op);
|
||||
grpc_chttp2_stream* s = static_cast<grpc_chttp2_stream*>(op->handler_private.extra_arg);
|
||||
grpc_transport_stream_op_batch_payload* op_payload = op->payload;
|
||||
grpc_chttp2_transport* t = s->t;
|
||||
|
||||
|
|
@ -1408,8 +1408,8 @@ static void perform_stream_op_locked(void* stream_op,
|
|||
"to-be-sent initial metadata size "
|
||||
"exceeds peer limit"),
|
||||
GRPC_ERROR_INT_SIZE,
|
||||
(intptr_t)metadata_size),
|
||||
GRPC_ERROR_INT_LIMIT, (intptr_t)metadata_peer_limit),
|
||||
static_cast<intptr_t>(metadata_size)),
|
||||
GRPC_ERROR_INT_LIMIT, static_cast<intptr_t>(metadata_peer_limit)),
|
||||
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_RESOURCE_EXHAUSTED));
|
||||
} else {
|
||||
if (contains_non_ok_status(s->send_initial_metadata)) {
|
||||
|
|
@ -1482,15 +1482,15 @@ static void perform_stream_op_locked(void* stream_op,
|
|||
uint32_t flags = op_payload->send_message.send_message->flags;
|
||||
frame_hdr[0] = (flags & GRPC_WRITE_INTERNAL_COMPRESS) != 0;
|
||||
size_t len = op_payload->send_message.send_message->length;
|
||||
frame_hdr[1] = (uint8_t)(len >> 24);
|
||||
frame_hdr[2] = (uint8_t)(len >> 16);
|
||||
frame_hdr[3] = (uint8_t)(len >> 8);
|
||||
frame_hdr[4] = (uint8_t)(len);
|
||||
frame_hdr[1] = static_cast<uint8_t>(len >> 24);
|
||||
frame_hdr[2] = static_cast<uint8_t>(len >> 16);
|
||||
frame_hdr[3] = static_cast<uint8_t>(len >> 8);
|
||||
frame_hdr[4] = static_cast<uint8_t>(len);
|
||||
s->fetching_send_message = op_payload->send_message.send_message;
|
||||
s->fetched_send_message_length = 0;
|
||||
s->next_message_end_offset = s->flow_controlled_bytes_written +
|
||||
(int64_t)s->flow_controlled_buffer.length +
|
||||
(int64_t)len;
|
||||
static_cast<int64_t>(s->flow_controlled_buffer.length) +
|
||||
static_cast<int64_t>(len);
|
||||
if (flags & GRPC_WRITE_BUFFER_HINT) {
|
||||
s->next_message_end_offset -= t->write_buffer_size;
|
||||
s->write_buffering = true;
|
||||
|
|
@ -1524,8 +1524,8 @@ static void perform_stream_op_locked(void* stream_op,
|
|||
"to-be-sent trailing metadata size "
|
||||
"exceeds peer limit"),
|
||||
GRPC_ERROR_INT_SIZE,
|
||||
(intptr_t)metadata_size),
|
||||
GRPC_ERROR_INT_LIMIT, (intptr_t)metadata_peer_limit),
|
||||
static_cast<intptr_t>(metadata_size)),
|
||||
GRPC_ERROR_INT_LIMIT, static_cast<intptr_t>(metadata_peer_limit)),
|
||||
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_RESOURCE_EXHAUSTED));
|
||||
} else {
|
||||
if (contains_non_ok_status(s->send_trailing_metadata)) {
|
||||
|
|
@ -1605,8 +1605,8 @@ static void perform_stream_op_locked(void* stream_op,
|
|||
static void perform_stream_op(grpc_transport* gt, grpc_stream* gs,
|
||||
grpc_transport_stream_op_batch* op) {
|
||||
GPR_TIMER_SCOPE("perform_stream_op", 0);
|
||||
grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
|
||||
grpc_chttp2_stream* s = (grpc_chttp2_stream*)gs;
|
||||
grpc_chttp2_transport* t = reinterpret_cast<grpc_chttp2_transport*>(gt);
|
||||
grpc_chttp2_stream* s = reinterpret_cast<grpc_chttp2_stream*>(gs);
|
||||
|
||||
if (!t->is_client) {
|
||||
if (op->send_initial_metadata) {
|
||||
|
|
@ -1662,7 +1662,7 @@ static void send_ping_locked(grpc_chttp2_transport* t,
|
|||
}
|
||||
|
||||
static void retry_initiate_ping_locked(void* tp, grpc_error* error) {
|
||||
grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
|
||||
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(tp);
|
||||
t->ping_state.is_delayed_ping_timer_set = false;
|
||||
if (error == GRPC_ERROR_NONE) {
|
||||
grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_RETRY_SEND_PING);
|
||||
|
|
@ -1690,7 +1690,7 @@ static void send_goaway(grpc_chttp2_transport* t, grpc_error* error) {
|
|||
grpc_slice slice;
|
||||
grpc_error_get_status(error, GRPC_MILLIS_INF_FUTURE, nullptr, &slice,
|
||||
&http_error, nullptr);
|
||||
grpc_chttp2_goaway_append(t->last_new_stream_id, (uint32_t)http_error,
|
||||
grpc_chttp2_goaway_append(t->last_new_stream_id, static_cast<uint32_t>(http_error),
|
||||
grpc_slice_ref_internal(slice), &t->qbuf);
|
||||
grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_GOAWAY_SENT);
|
||||
GRPC_ERROR_UNREF(error);
|
||||
|
|
@ -1714,9 +1714,9 @@ void grpc_chttp2_add_ping_strike(grpc_chttp2_transport* t) {
|
|||
|
||||
static void perform_transport_op_locked(void* stream_op,
|
||||
grpc_error* error_ignored) {
|
||||
grpc_transport_op* op = (grpc_transport_op*)stream_op;
|
||||
grpc_transport_op* op = static_cast<grpc_transport_op*>(stream_op);
|
||||
grpc_chttp2_transport* t =
|
||||
(grpc_chttp2_transport*)op->handler_private.extra_arg;
|
||||
static_cast<grpc_chttp2_transport*>(op->handler_private.extra_arg);
|
||||
|
||||
if (op->goaway_error) {
|
||||
send_goaway(t, op->goaway_error);
|
||||
|
|
@ -1757,7 +1757,7 @@ static void perform_transport_op_locked(void* stream_op,
|
|||
}
|
||||
|
||||
static void perform_transport_op(grpc_transport* gt, grpc_transport_op* op) {
|
||||
grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
|
||||
grpc_chttp2_transport* t = reinterpret_cast<grpc_chttp2_transport*>(gt);
|
||||
char* msg = grpc_transport_op_string(op);
|
||||
gpr_free(msg);
|
||||
op->handler_private.extra_arg = gt;
|
||||
|
|
@ -1926,7 +1926,7 @@ void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_chttp2_transport* t,
|
|||
static void remove_stream(grpc_chttp2_transport* t, uint32_t id,
|
||||
grpc_error* error) {
|
||||
grpc_chttp2_stream* s =
|
||||
(grpc_chttp2_stream*)grpc_chttp2_stream_map_delete(&t->stream_map, id);
|
||||
static_cast<grpc_chttp2_stream*>(grpc_chttp2_stream_map_delete(&t->stream_map, id));
|
||||
GPR_ASSERT(s);
|
||||
if (t->incoming_stream == s) {
|
||||
t->incoming_stream = nullptr;
|
||||
|
|
@ -1978,7 +1978,7 @@ void grpc_chttp2_cancel_stream(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
|
|||
grpc_error_get_status(due_to_error, s->deadline, nullptr, nullptr,
|
||||
&http_error, nullptr);
|
||||
grpc_slice_buffer_add(
|
||||
&t->qbuf, grpc_chttp2_rst_stream_create(s->id, (uint32_t)http_error,
|
||||
&t->qbuf, grpc_chttp2_rst_stream_create(s->id, static_cast<uint32_t>(http_error),
|
||||
&s->stats.outgoing));
|
||||
grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_RST_STREAM);
|
||||
}
|
||||
|
|
@ -2180,7 +2180,7 @@ static void close_from_api(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
|
|||
*p++ = '0';
|
||||
*p++ = '0';
|
||||
GPR_ASSERT(p == GRPC_SLICE_END_PTR(http_status_hdr));
|
||||
len += (uint32_t)GRPC_SLICE_LENGTH(http_status_hdr);
|
||||
len += static_cast<uint32_t>GRPC_SLICE_LENGTH(http_status_hdr);
|
||||
|
||||
content_type_hdr = GRPC_SLICE_MALLOC(31);
|
||||
p = GRPC_SLICE_START_PTR(content_type_hdr);
|
||||
|
|
@ -2216,7 +2216,7 @@ static void close_from_api(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
|
|||
*p++ = 'p';
|
||||
*p++ = 'c';
|
||||
GPR_ASSERT(p == GRPC_SLICE_END_PTR(content_type_hdr));
|
||||
len += (uint32_t)GRPC_SLICE_LENGTH(content_type_hdr);
|
||||
len += static_cast<uint32_t>GRPC_SLICE_LENGTH(content_type_hdr);
|
||||
}
|
||||
|
||||
status_hdr = GRPC_SLICE_MALLOC(15 + (grpc_status >= 10));
|
||||
|
|
@ -2236,14 +2236,14 @@ static void close_from_api(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
|
|||
*p++ = 's';
|
||||
if (grpc_status < 10) {
|
||||
*p++ = 1;
|
||||
*p++ = (uint8_t)('0' + grpc_status);
|
||||
*p++ = static_cast<uint8_t>('0' + grpc_status);
|
||||
} else {
|
||||
*p++ = 2;
|
||||
*p++ = (uint8_t)('0' + (grpc_status / 10));
|
||||
*p++ = (uint8_t)('0' + (grpc_status % 10));
|
||||
*p++ = static_cast<uint8_t>('0' + (grpc_status / 10));
|
||||
*p++ = static_cast<uint8_t>('0' + (grpc_status % 10));
|
||||
}
|
||||
GPR_ASSERT(p == GRPC_SLICE_END_PTR(status_hdr));
|
||||
len += (uint32_t)GRPC_SLICE_LENGTH(status_hdr);
|
||||
len += static_cast<uint32_t>GRPC_SLICE_LENGTH(status_hdr);
|
||||
|
||||
size_t msg_len = GRPC_SLICE_LENGTH(slice);
|
||||
GPR_ASSERT(msg_len <= UINT32_MAX);
|
||||
|
|
@ -2267,20 +2267,20 @@ static void close_from_api(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
|
|||
GRPC_CHTTP2_WRITE_VARINT((uint32_t)msg_len, 1, 0, p, (uint32_t)msg_len_len);
|
||||
p += msg_len_len;
|
||||
GPR_ASSERT(p == GRPC_SLICE_END_PTR(message_pfx));
|
||||
len += (uint32_t)GRPC_SLICE_LENGTH(message_pfx);
|
||||
len += (uint32_t)msg_len;
|
||||
len += static_cast<uint32_t>GRPC_SLICE_LENGTH(message_pfx);
|
||||
len += static_cast<uint32_t>(msg_len);
|
||||
|
||||
hdr = GRPC_SLICE_MALLOC(9);
|
||||
p = GRPC_SLICE_START_PTR(hdr);
|
||||
*p++ = (uint8_t)(len >> 16);
|
||||
*p++ = (uint8_t)(len >> 8);
|
||||
*p++ = (uint8_t)(len);
|
||||
*p++ = static_cast<uint8_t>(len >> 16);
|
||||
*p++ = static_cast<uint8_t>(len >> 8);
|
||||
*p++ = static_cast<uint8_t>(len);
|
||||
*p++ = GRPC_CHTTP2_FRAME_HEADER;
|
||||
*p++ = GRPC_CHTTP2_DATA_FLAG_END_STREAM | GRPC_CHTTP2_DATA_FLAG_END_HEADERS;
|
||||
*p++ = (uint8_t)(s->id >> 24);
|
||||
*p++ = (uint8_t)(s->id >> 16);
|
||||
*p++ = (uint8_t)(s->id >> 8);
|
||||
*p++ = (uint8_t)(s->id);
|
||||
*p++ = static_cast<uint8_t>(s->id >> 24);
|
||||
*p++ = static_cast<uint8_t>(s->id >> 16);
|
||||
*p++ = static_cast<uint8_t>(s->id >> 8);
|
||||
*p++ = static_cast<uint8_t>(s->id);
|
||||
GPR_ASSERT(p == GRPC_SLICE_END_PTR(hdr));
|
||||
|
||||
grpc_slice_buffer_add(&t->qbuf, hdr);
|
||||
|
|
@ -2305,8 +2305,8 @@ typedef struct {
|
|||
} cancel_stream_cb_args;
|
||||
|
||||
static void cancel_stream_cb(void* user_data, uint32_t key, void* stream) {
|
||||
cancel_stream_cb_args* args = (cancel_stream_cb_args*)user_data;
|
||||
grpc_chttp2_stream* s = (grpc_chttp2_stream*)stream;
|
||||
cancel_stream_cb_args* args = static_cast<cancel_stream_cb_args*>(user_data);
|
||||
grpc_chttp2_stream* s = static_cast<grpc_chttp2_stream*>(stream);
|
||||
grpc_chttp2_cancel_stream(args->t, s, GRPC_ERROR_REF(args->error));
|
||||
}
|
||||
|
||||
|
|
@ -2389,7 +2389,7 @@ static grpc_error* try_http_parsing(grpc_chttp2_transport* t) {
|
|||
static void read_action_locked(void* tp, grpc_error* error) {
|
||||
GPR_TIMER_SCOPE("reading_action_locked", 0);
|
||||
|
||||
grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
|
||||
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(tp);
|
||||
|
||||
GRPC_ERROR_REF(error);
|
||||
|
||||
|
|
@ -2411,7 +2411,7 @@ static void read_action_locked(void* tp, grpc_error* error) {
|
|||
grpc_core::BdpEstimator* bdp_est = t->flow_control->bdp_estimator();
|
||||
if (bdp_est) {
|
||||
bdp_est->AddIncomingBytes(
|
||||
(int64_t)GRPC_SLICE_LENGTH(t->read_buffer.slices[i]));
|
||||
static_cast<int64_t>GRPC_SLICE_LENGTH(t->read_buffer.slices[i]));
|
||||
}
|
||||
errors[1] = grpc_chttp2_perform_read(t, t->read_buffer.slices[i]);
|
||||
}
|
||||
|
|
@ -2480,7 +2480,7 @@ static void schedule_bdp_ping_locked(grpc_chttp2_transport* t) {
|
|||
}
|
||||
|
||||
static void start_bdp_ping_locked(void* tp, grpc_error* error) {
|
||||
grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
|
||||
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(tp);
|
||||
if (grpc_http_trace.enabled()) {
|
||||
gpr_log(GPR_DEBUG, "%s: Start BDP ping err=%s", t->peer_string,
|
||||
grpc_error_string(error));
|
||||
|
|
@ -2493,7 +2493,7 @@ static void start_bdp_ping_locked(void* tp, grpc_error* error) {
|
|||
}
|
||||
|
||||
static void finish_bdp_ping_locked(void* tp, grpc_error* error) {
|
||||
grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
|
||||
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(tp);
|
||||
if (grpc_http_trace.enabled()) {
|
||||
gpr_log(GPR_DEBUG, "%s: Complete BDP ping err=%s", t->peer_string,
|
||||
grpc_error_string(error));
|
||||
|
|
@ -2512,7 +2512,7 @@ static void finish_bdp_ping_locked(void* tp, grpc_error* error) {
|
|||
}
|
||||
|
||||
static void next_bdp_ping_timer_expired_locked(void* tp, grpc_error* error) {
|
||||
grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
|
||||
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(tp);
|
||||
GPR_ASSERT(t->have_next_bdp_ping_timer);
|
||||
t->have_next_bdp_ping_timer = false;
|
||||
if (error != GRPC_ERROR_NONE) {
|
||||
|
|
@ -2550,11 +2550,11 @@ void grpc_chttp2_config_default_keepalive_args(grpc_channel_args* args,
|
|||
}
|
||||
} else if (0 == strcmp(args->args[i].key,
|
||||
GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS)) {
|
||||
const bool value = (uint32_t)grpc_channel_arg_get_integer(
|
||||
const bool value = static_cast<uint32_t>(grpc_channel_arg_get_integer(
|
||||
&args->args[i],
|
||||
{is_client ? g_default_client_keepalive_permit_without_calls
|
||||
: g_default_server_keepalive_timeout_ms,
|
||||
0, 1});
|
||||
0, 1}));
|
||||
if (is_client) {
|
||||
g_default_client_keepalive_permit_without_calls = value;
|
||||
} else {
|
||||
|
|
@ -2590,7 +2590,7 @@ void grpc_chttp2_config_default_keepalive_args(grpc_channel_args* args,
|
|||
}
|
||||
|
||||
static void init_keepalive_ping_locked(void* arg, grpc_error* error) {
|
||||
grpc_chttp2_transport* t = (grpc_chttp2_transport*)arg;
|
||||
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(arg);
|
||||
GPR_ASSERT(t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_WAITING);
|
||||
if (t->destroying || t->closed_with_error != GRPC_ERROR_NONE) {
|
||||
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_DYING;
|
||||
|
|
@ -2619,7 +2619,7 @@ static void init_keepalive_ping_locked(void* arg, grpc_error* error) {
|
|||
}
|
||||
|
||||
static void start_keepalive_ping_locked(void* arg, grpc_error* error) {
|
||||
grpc_chttp2_transport* t = (grpc_chttp2_transport*)arg;
|
||||
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(arg);
|
||||
GRPC_CHTTP2_REF_TRANSPORT(t, "keepalive watchdog");
|
||||
grpc_timer_init(&t->keepalive_watchdog_timer,
|
||||
grpc_core::ExecCtx::Get()->Now() + t->keepalive_time,
|
||||
|
|
@ -2627,7 +2627,7 @@ static void start_keepalive_ping_locked(void* arg, grpc_error* error) {
|
|||
}
|
||||
|
||||
static void finish_keepalive_ping_locked(void* arg, grpc_error* error) {
|
||||
grpc_chttp2_transport* t = (grpc_chttp2_transport*)arg;
|
||||
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(arg);
|
||||
if (t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_PINGING) {
|
||||
if (error == GRPC_ERROR_NONE) {
|
||||
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_WAITING;
|
||||
|
|
@ -2642,7 +2642,7 @@ static void finish_keepalive_ping_locked(void* arg, grpc_error* error) {
|
|||
}
|
||||
|
||||
static void keepalive_watchdog_fired_locked(void* arg, grpc_error* error) {
|
||||
grpc_chttp2_transport* t = (grpc_chttp2_transport*)arg;
|
||||
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(arg);
|
||||
if (t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_PINGING) {
|
||||
if (error == GRPC_ERROR_NONE) {
|
||||
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_DYING;
|
||||
|
|
@ -2682,13 +2682,13 @@ static void connectivity_state_set(grpc_chttp2_transport* t,
|
|||
|
||||
static void set_pollset(grpc_transport* gt, grpc_stream* gs,
|
||||
grpc_pollset* pollset) {
|
||||
grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
|
||||
grpc_chttp2_transport* t = reinterpret_cast<grpc_chttp2_transport*>(gt);
|
||||
grpc_endpoint_add_to_pollset(t->ep, pollset);
|
||||
}
|
||||
|
||||
static void set_pollset_set(grpc_transport* gt, grpc_stream* gs,
|
||||
grpc_pollset_set* pollset_set) {
|
||||
grpc_chttp2_transport* t = (grpc_chttp2_transport*)gt;
|
||||
grpc_chttp2_transport* t = reinterpret_cast<grpc_chttp2_transport*>(gt);
|
||||
grpc_endpoint_add_to_pollset_set(t->ep, pollset_set);
|
||||
}
|
||||
|
||||
|
|
@ -2697,7 +2697,7 @@ static void set_pollset_set(grpc_transport* gt, grpc_stream* gs,
|
|||
*/
|
||||
|
||||
static void reset_byte_stream(void* arg, grpc_error* error) {
|
||||
grpc_chttp2_stream* s = (grpc_chttp2_stream*)arg;
|
||||
grpc_chttp2_stream* s = static_cast<grpc_chttp2_stream*>(arg);
|
||||
|
||||
s->pending_byte_stream = false;
|
||||
if (error == GRPC_ERROR_NONE) {
|
||||
|
|
@ -2723,7 +2723,7 @@ static void incoming_byte_stream_unref(grpc_chttp2_incoming_byte_stream* bs) {
|
|||
static void incoming_byte_stream_next_locked(void* argp,
|
||||
grpc_error* error_ignored) {
|
||||
grpc_chttp2_incoming_byte_stream* bs =
|
||||
(grpc_chttp2_incoming_byte_stream*)argp;
|
||||
static_cast<grpc_chttp2_incoming_byte_stream*>(argp);
|
||||
grpc_chttp2_transport* t = bs->transport;
|
||||
grpc_chttp2_stream* s = bs->stream;
|
||||
|
||||
|
|
@ -2771,7 +2771,7 @@ static bool incoming_byte_stream_next(grpc_byte_stream* byte_stream,
|
|||
grpc_closure* on_complete) {
|
||||
GPR_TIMER_SCOPE("incoming_byte_stream_next", 0);
|
||||
grpc_chttp2_incoming_byte_stream* bs =
|
||||
(grpc_chttp2_incoming_byte_stream*)byte_stream;
|
||||
reinterpret_cast<grpc_chttp2_incoming_byte_stream*>(byte_stream);
|
||||
grpc_chttp2_stream* s = bs->stream;
|
||||
if (s->unprocessed_incoming_frames_buffer.length > 0) {
|
||||
return true;
|
||||
|
|
@ -2792,7 +2792,7 @@ static grpc_error* incoming_byte_stream_pull(grpc_byte_stream* byte_stream,
|
|||
grpc_slice* slice) {
|
||||
GPR_TIMER_SCOPE("incoming_byte_stream_pull", 0);
|
||||
grpc_chttp2_incoming_byte_stream* bs =
|
||||
(grpc_chttp2_incoming_byte_stream*)byte_stream;
|
||||
reinterpret_cast<grpc_chttp2_incoming_byte_stream*>(byte_stream);
|
||||
grpc_chttp2_stream* s = bs->stream;
|
||||
grpc_error* error;
|
||||
|
||||
|
|
@ -2843,7 +2843,7 @@ static void incoming_byte_stream_destroy_locked(void* byte_stream,
|
|||
static void incoming_byte_stream_destroy(grpc_byte_stream* byte_stream) {
|
||||
GPR_TIMER_SCOPE("incoming_byte_stream_destroy", 0);
|
||||
grpc_chttp2_incoming_byte_stream* bs =
|
||||
(grpc_chttp2_incoming_byte_stream*)byte_stream;
|
||||
reinterpret_cast<grpc_chttp2_incoming_byte_stream*>(byte_stream);
|
||||
GRPC_CLOSURE_SCHED(
|
||||
GRPC_CLOSURE_INIT(&bs->destroy_action,
|
||||
incoming_byte_stream_destroy_locked, bs,
|
||||
|
|
@ -2876,7 +2876,7 @@ grpc_error* grpc_chttp2_incoming_byte_stream_push(
|
|||
grpc_slice_unref_internal(slice);
|
||||
return error;
|
||||
} else {
|
||||
bs->remaining_bytes -= (uint32_t)GRPC_SLICE_LENGTH(slice);
|
||||
bs->remaining_bytes -= static_cast<uint32_t>GRPC_SLICE_LENGTH(slice);
|
||||
if (slice_out != nullptr) {
|
||||
*slice_out = slice;
|
||||
}
|
||||
|
|
@ -2904,7 +2904,7 @@ grpc_error* grpc_chttp2_incoming_byte_stream_finished(
|
|||
static void incoming_byte_stream_shutdown(grpc_byte_stream* byte_stream,
|
||||
grpc_error* error) {
|
||||
grpc_chttp2_incoming_byte_stream* bs =
|
||||
(grpc_chttp2_incoming_byte_stream*)byte_stream;
|
||||
reinterpret_cast<grpc_chttp2_incoming_byte_stream*>(byte_stream);
|
||||
GRPC_ERROR_UNREF(grpc_chttp2_incoming_byte_stream_finished(
|
||||
bs, error, true /* reset_on_error */));
|
||||
}
|
||||
|
|
@ -2916,7 +2916,7 @@ static const grpc_byte_stream_vtable grpc_chttp2_incoming_byte_stream_vtable = {
|
|||
static void incoming_byte_stream_destroy_locked(void* byte_stream,
|
||||
grpc_error* error_ignored) {
|
||||
grpc_chttp2_incoming_byte_stream* bs =
|
||||
(grpc_chttp2_incoming_byte_stream*)byte_stream;
|
||||
static_cast<grpc_chttp2_incoming_byte_stream*>(byte_stream);
|
||||
grpc_chttp2_stream* s = bs->stream;
|
||||
grpc_chttp2_transport* t = s->t;
|
||||
|
||||
|
|
@ -2931,8 +2931,8 @@ grpc_chttp2_incoming_byte_stream* grpc_chttp2_incoming_byte_stream_create(
|
|||
grpc_chttp2_transport* t, grpc_chttp2_stream* s, uint32_t frame_size,
|
||||
uint32_t flags) {
|
||||
grpc_chttp2_incoming_byte_stream* incoming_byte_stream =
|
||||
(grpc_chttp2_incoming_byte_stream*)gpr_malloc(
|
||||
sizeof(*incoming_byte_stream));
|
||||
static_cast<grpc_chttp2_incoming_byte_stream*>(gpr_malloc(
|
||||
sizeof(*incoming_byte_stream)));
|
||||
incoming_byte_stream->base.length = frame_size;
|
||||
incoming_byte_stream->remaining_bytes = frame_size;
|
||||
incoming_byte_stream->base.flags = flags;
|
||||
|
|
@ -2968,7 +2968,7 @@ static void post_destructive_reclaimer(grpc_chttp2_transport* t) {
|
|||
}
|
||||
|
||||
static void benign_reclaimer_locked(void* arg, grpc_error* error) {
|
||||
grpc_chttp2_transport* t = (grpc_chttp2_transport*)arg;
|
||||
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(arg);
|
||||
if (error == GRPC_ERROR_NONE &&
|
||||
grpc_chttp2_stream_map_size(&t->stream_map) == 0) {
|
||||
/* Channel with no active streams: send a goaway to try and make it
|
||||
|
|
@ -2996,12 +2996,12 @@ static void benign_reclaimer_locked(void* arg, grpc_error* error) {
|
|||
}
|
||||
|
||||
static void destructive_reclaimer_locked(void* arg, grpc_error* error) {
|
||||
grpc_chttp2_transport* t = (grpc_chttp2_transport*)arg;
|
||||
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(arg);
|
||||
size_t n = grpc_chttp2_stream_map_size(&t->stream_map);
|
||||
t->destructive_reclaimer_registered = false;
|
||||
if (error == GRPC_ERROR_NONE && n > 0) {
|
||||
grpc_chttp2_stream* s =
|
||||
(grpc_chttp2_stream*)grpc_chttp2_stream_map_rand(&t->stream_map);
|
||||
static_cast<grpc_chttp2_stream*>(grpc_chttp2_stream_map_rand(&t->stream_map));
|
||||
if (grpc_resource_quota_trace.enabled()) {
|
||||
gpr_log(GPR_DEBUG, "HTTP2: %s - abandon stream id %d", t->peer_string,
|
||||
s->id);
|
||||
|
|
@ -3078,7 +3078,7 @@ const char* grpc_chttp2_initiate_write_reason_string(
|
|||
}
|
||||
|
||||
static grpc_endpoint* chttp2_get_endpoint(grpc_transport* t) {
|
||||
return ((grpc_chttp2_transport*)t)->ep;
|
||||
return (reinterpret_cast<grpc_chttp2_transport*>(t))->ep;
|
||||
}
|
||||
|
||||
static const grpc_transport_vtable vtable = {sizeof(grpc_chttp2_stream),
|
||||
|
|
@ -3097,7 +3097,7 @@ static const grpc_transport_vtable* get_vtable(void) { return &vtable; }
|
|||
grpc_transport* grpc_create_chttp2_transport(
|
||||
const grpc_channel_args* channel_args, grpc_endpoint* ep, bool is_client) {
|
||||
grpc_chttp2_transport* t =
|
||||
(grpc_chttp2_transport*)gpr_zalloc(sizeof(grpc_chttp2_transport));
|
||||
static_cast<grpc_chttp2_transport*>(gpr_zalloc(sizeof(grpc_chttp2_transport)));
|
||||
init_transport(t, channel_args, ep, is_client);
|
||||
return &t->base;
|
||||
}
|
||||
|
|
@ -3105,7 +3105,7 @@ grpc_transport* grpc_create_chttp2_transport(
|
|||
void grpc_chttp2_transport_start_reading(
|
||||
grpc_transport* transport, grpc_slice_buffer* read_buffer,
|
||||
grpc_closure* notify_on_receive_settings) {
|
||||
grpc_chttp2_transport* t = (grpc_chttp2_transport*)transport;
|
||||
grpc_chttp2_transport* t = reinterpret_cast<grpc_chttp2_transport*>(transport);
|
||||
GRPC_CHTTP2_REF_TRANSPORT(
|
||||
t, "reading_action"); /* matches unref inside reading_action */
|
||||
if (read_buffer != nullptr) {
|
||||
|
|
|
|||
|
|
@ -184,10 +184,10 @@ TransportFlowControl::TransportFlowControl(const grpc_chttp2_transport* t,
|
|||
|
||||
uint32_t TransportFlowControl::MaybeSendUpdate(bool writing_anyway) {
|
||||
FlowControlTrace trace("t updt sent", this, nullptr);
|
||||
const uint32_t target_announced_window = (const uint32_t)target_window();
|
||||
const uint32_t target_announced_window = static_cast<const uint32_t>(target_window());
|
||||
if ((writing_anyway || announced_window_ <= target_announced_window / 2) &&
|
||||
announced_window_ != target_announced_window) {
|
||||
const uint32_t announce = (uint32_t)GPR_CLAMP(
|
||||
const uint32_t announce = static_cast<uint32_t>GPR_CLAMP(
|
||||
target_announced_window - announced_window_, 0, UINT32_MAX);
|
||||
announced_window_ += announce;
|
||||
return announce;
|
||||
|
|
@ -261,7 +261,7 @@ grpc_error* StreamFlowControl::RecvData(int64_t incoming_frame_size) {
|
|||
uint32_t StreamFlowControl::MaybeSendUpdate() {
|
||||
FlowControlTrace trace("s updt sent", tfc_, this);
|
||||
if (local_window_delta_ > announced_window_delta_) {
|
||||
uint32_t announce = (uint32_t)GPR_CLAMP(
|
||||
uint32_t announce = static_cast<uint32_t>GPR_CLAMP(
|
||||
local_window_delta_ - announced_window_delta_, 0, UINT32_MAX);
|
||||
UpdateAnnouncedWindowDelta(tfc_, announce);
|
||||
return announce;
|
||||
|
|
@ -281,12 +281,12 @@ void StreamFlowControl::IncomingByteStreamUpdate(size_t max_size_hint,
|
|||
if (max_size_hint >= UINT32_MAX - sent_init_window) {
|
||||
max_recv_bytes = UINT32_MAX - sent_init_window;
|
||||
} else {
|
||||
max_recv_bytes = (uint32_t)max_size_hint;
|
||||
max_recv_bytes = static_cast<uint32_t>(max_size_hint);
|
||||
}
|
||||
|
||||
/* account for bytes already received but unknown to higher layers */
|
||||
if (max_recv_bytes >= have_already) {
|
||||
max_recv_bytes -= (uint32_t)have_already;
|
||||
max_recv_bytes -= static_cast<uint32_t>(have_already);
|
||||
} else {
|
||||
max_recv_bytes = 0;
|
||||
}
|
||||
|
|
@ -295,7 +295,7 @@ void StreamFlowControl::IncomingByteStreamUpdate(size_t max_size_hint,
|
|||
GPR_ASSERT(max_recv_bytes <= UINT32_MAX - sent_init_window);
|
||||
if (local_window_delta_ < max_recv_bytes) {
|
||||
uint32_t add_max_recv_bytes =
|
||||
(uint32_t)(max_recv_bytes - local_window_delta_);
|
||||
static_cast<uint32_t>(max_recv_bytes - local_window_delta_);
|
||||
local_window_delta_ += add_max_recv_bytes;
|
||||
}
|
||||
}
|
||||
|
|
@ -328,7 +328,7 @@ double TransportFlowControl::TargetLogBdp() {
|
|||
double TransportFlowControl::SmoothLogBdp(double value) {
|
||||
grpc_millis now = grpc_core::ExecCtx::Get()->Now();
|
||||
double bdp_error = value - pid_controller_.last_control_value();
|
||||
const double dt = (double)(now - last_pid_update_) * 1e-3;
|
||||
const double dt = static_cast<double>(now - last_pid_update_) * 1e-3;
|
||||
last_pid_update_ = now;
|
||||
// Limit dt to 100ms
|
||||
const double kMaxDt = 0.1;
|
||||
|
|
@ -338,7 +338,7 @@ double TransportFlowControl::SmoothLogBdp(double value) {
|
|||
FlowControlAction::Urgency TransportFlowControl::DeltaUrgency(
|
||||
int64_t value, grpc_chttp2_setting_id setting_id) {
|
||||
int64_t delta =
|
||||
(int64_t)value - (int64_t)t_->settings[GRPC_LOCAL_SETTINGS][setting_id];
|
||||
value - static_cast<int64_t>(t_->settings[GRPC_LOCAL_SETTINGS][setting_id]);
|
||||
// TODO(ncteisen): tune this
|
||||
if (delta != 0 && (delta <= -value / 5 || delta >= value / 5)) {
|
||||
return FlowControlAction::Urgency::QUEUE_UPDATE;
|
||||
|
|
@ -357,22 +357,22 @@ FlowControlAction TransportFlowControl::PeriodicUpdate() {
|
|||
const double target = pow(2, SmoothLogBdp(TargetLogBdp()));
|
||||
|
||||
// Though initial window 'could' drop to 0, we keep the floor at 128
|
||||
target_initial_window_size_ = (int32_t)GPR_CLAMP(target, 128, INT32_MAX);
|
||||
target_initial_window_size_ = static_cast<int32_t>GPR_CLAMP(target, 128, INT32_MAX);
|
||||
|
||||
action.set_send_initial_window_update(
|
||||
DeltaUrgency(target_initial_window_size_,
|
||||
GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE),
|
||||
(uint32_t)target_initial_window_size_);
|
||||
static_cast<uint32_t>(target_initial_window_size_));
|
||||
|
||||
// get bandwidth estimate and update max_frame accordingly.
|
||||
double bw_dbl = bdp_estimator_.EstimateBandwidth();
|
||||
// we target the max of BDP or bandwidth in microseconds.
|
||||
int32_t frame_size = (int32_t)GPR_CLAMP(
|
||||
int32_t frame_size = static_cast<int32_t>GPR_CLAMP(
|
||||
GPR_MAX((int32_t)GPR_CLAMP(bw_dbl, 0, INT_MAX) / 1000,
|
||||
target_initial_window_size_),
|
||||
16384, 16777215);
|
||||
action.set_send_max_frame_size_update(
|
||||
DeltaUrgency((int64_t)frame_size, GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE),
|
||||
DeltaUrgency(static_cast<int64_t>(frame_size), GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE),
|
||||
frame_size);
|
||||
}
|
||||
return UpdateAction(action);
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ namespace grpc_core {
|
|||
namespace chttp2 {
|
||||
|
||||
static constexpr uint32_t kDefaultWindow = 65535;
|
||||
static constexpr int64_t kMaxWindow = (int64_t)((1u << 31) - 1);
|
||||
static constexpr int64_t kMaxWindow = static_cast<int64_t>((1u << 31) - 1);
|
||||
// TODO(ncteisen): Tune this
|
||||
static constexpr uint32_t kFrameSize = 1024 * 1024;
|
||||
|
||||
|
|
@ -271,7 +271,7 @@ class TransportFlowControl final : public TransportFlowControlBase {
|
|||
// See comment above announced_stream_total_over_incoming_window_ for the
|
||||
// logic behind this decision.
|
||||
int64_t target_window() const override {
|
||||
return (uint32_t)GPR_MIN((int64_t)((1u << 31) - 1),
|
||||
return static_cast<uint32_t>GPR_MIN((int64_t)((1u << 31) - 1),
|
||||
announced_stream_total_over_incoming_window_ +
|
||||
target_initial_window_size_);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ grpc_error* grpc_chttp2_data_parser_begin_frame(grpc_chttp2_data_parser* parser,
|
|||
gpr_asprintf(&msg, "unsupported data flags: 0x%02x", flags);
|
||||
grpc_error* err =
|
||||
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg),
|
||||
GRPC_ERROR_INT_STREAM_ID, (intptr_t)stream_id);
|
||||
GRPC_ERROR_INT_STREAM_ID, static_cast<intptr_t>(stream_id));
|
||||
gpr_free(msg);
|
||||
return err;
|
||||
}
|
||||
|
|
@ -78,15 +78,15 @@ void grpc_chttp2_encode_data(uint32_t id, grpc_slice_buffer* inbuf,
|
|||
hdr = GRPC_SLICE_MALLOC(header_size);
|
||||
p = GRPC_SLICE_START_PTR(hdr);
|
||||
GPR_ASSERT(write_bytes < (1 << 24));
|
||||
*p++ = (uint8_t)(write_bytes >> 16);
|
||||
*p++ = (uint8_t)(write_bytes >> 8);
|
||||
*p++ = (uint8_t)(write_bytes);
|
||||
*p++ = static_cast<uint8_t>(write_bytes >> 16);
|
||||
*p++ = static_cast<uint8_t>(write_bytes >> 8);
|
||||
*p++ = static_cast<uint8_t>(write_bytes);
|
||||
*p++ = GRPC_CHTTP2_FRAME_DATA;
|
||||
*p++ = is_eof ? GRPC_CHTTP2_DATA_FLAG_END_STREAM : 0;
|
||||
*p++ = (uint8_t)(id >> 24);
|
||||
*p++ = (uint8_t)(id >> 16);
|
||||
*p++ = (uint8_t)(id >> 8);
|
||||
*p++ = (uint8_t)(id);
|
||||
*p++ = static_cast<uint8_t>(id >> 24);
|
||||
*p++ = static_cast<uint8_t>(id >> 16);
|
||||
*p++ = static_cast<uint8_t>(id >> 8);
|
||||
*p++ = static_cast<uint8_t>(id);
|
||||
grpc_slice_buffer_add(outbuf, hdr);
|
||||
|
||||
grpc_slice_buffer_move_first_no_ref(inbuf, write_bytes, outbuf);
|
||||
|
|
@ -139,7 +139,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
|
|||
gpr_asprintf(&msg, "Bad GRPC frame type 0x%02x", p->frame_type);
|
||||
p->error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
|
||||
p->error = grpc_error_set_int(p->error, GRPC_ERROR_INT_STREAM_ID,
|
||||
(intptr_t)s->id);
|
||||
static_cast<intptr_t>(s->id));
|
||||
gpr_free(msg);
|
||||
msg = grpc_dump_slice(slice, GPR_DUMP_HEX | GPR_DUMP_ASCII);
|
||||
p->error = grpc_error_set_str(p->error, GRPC_ERROR_STR_RAW_BYTES,
|
||||
|
|
@ -159,7 +159,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
|
|||
/* fallthrough */
|
||||
case GRPC_CHTTP2_DATA_FH_1:
|
||||
s->stats.incoming.framing_bytes++;
|
||||
p->frame_size = ((uint32_t)*cur) << 24;
|
||||
p->frame_size = (static_cast<uint32_t>(*cur)) << 24;
|
||||
if (++cur == end) {
|
||||
p->state = GRPC_CHTTP2_DATA_FH_2;
|
||||
grpc_slice_unref_internal(slice);
|
||||
|
|
@ -168,7 +168,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
|
|||
/* fallthrough */
|
||||
case GRPC_CHTTP2_DATA_FH_2:
|
||||
s->stats.incoming.framing_bytes++;
|
||||
p->frame_size |= ((uint32_t)*cur) << 16;
|
||||
p->frame_size |= (static_cast<uint32_t>(*cur)) << 16;
|
||||
if (++cur == end) {
|
||||
p->state = GRPC_CHTTP2_DATA_FH_3;
|
||||
grpc_slice_unref_internal(slice);
|
||||
|
|
@ -177,7 +177,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
|
|||
/* fallthrough */
|
||||
case GRPC_CHTTP2_DATA_FH_3:
|
||||
s->stats.incoming.framing_bytes++;
|
||||
p->frame_size |= ((uint32_t)*cur) << 8;
|
||||
p->frame_size |= (static_cast<uint32_t>(*cur)) << 8;
|
||||
if (++cur == end) {
|
||||
p->state = GRPC_CHTTP2_DATA_FH_4;
|
||||
grpc_slice_unref_internal(slice);
|
||||
|
|
@ -188,7 +188,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
|
|||
s->stats.incoming.framing_bytes++;
|
||||
GPR_ASSERT(stream_out != nullptr);
|
||||
GPR_ASSERT(p->parsing_frame == nullptr);
|
||||
p->frame_size |= ((uint32_t)*cur);
|
||||
p->frame_size |= (static_cast<uint32_t>(*cur));
|
||||
p->state = GRPC_CHTTP2_DATA_FRAME;
|
||||
++cur;
|
||||
message_flags = 0;
|
||||
|
|
@ -209,7 +209,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
|
|||
if (cur != end) {
|
||||
grpc_slice_buffer_undo_take_first(
|
||||
slices,
|
||||
grpc_slice_sub(slice, (size_t)(cur - beg), (size_t)(end - beg)));
|
||||
grpc_slice_sub(slice, static_cast<size_t>(cur - beg), static_cast<size_t>(end - beg)));
|
||||
}
|
||||
grpc_slice_unref_internal(slice);
|
||||
return GRPC_ERROR_NONE;
|
||||
|
|
@ -220,13 +220,13 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
|
|||
grpc_slice_unref_internal(slice);
|
||||
continue;
|
||||
}
|
||||
uint32_t remaining = (uint32_t)(end - cur);
|
||||
uint32_t remaining = static_cast<uint32_t>(end - cur);
|
||||
if (remaining == p->frame_size) {
|
||||
s->stats.incoming.data_bytes += remaining;
|
||||
if (GRPC_ERROR_NONE != (error = grpc_chttp2_incoming_byte_stream_push(
|
||||
p->parsing_frame,
|
||||
grpc_slice_sub(slice, (size_t)(cur - beg),
|
||||
(size_t)(end - beg)),
|
||||
grpc_slice_sub(slice, static_cast<size_t>(cur - beg),
|
||||
static_cast<size_t>(end - beg)),
|
||||
slice_out))) {
|
||||
grpc_slice_unref_internal(slice);
|
||||
return error;
|
||||
|
|
@ -245,8 +245,8 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
|
|||
s->stats.incoming.data_bytes += remaining;
|
||||
if (GRPC_ERROR_NONE != (error = grpc_chttp2_incoming_byte_stream_push(
|
||||
p->parsing_frame,
|
||||
grpc_slice_sub(slice, (size_t)(cur - beg),
|
||||
(size_t)(end - beg)),
|
||||
grpc_slice_sub(slice, static_cast<size_t>(cur - beg),
|
||||
static_cast<size_t>(end - beg)),
|
||||
slice_out))) {
|
||||
return error;
|
||||
}
|
||||
|
|
@ -259,8 +259,8 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
|
|||
if (GRPC_ERROR_NONE !=
|
||||
(grpc_chttp2_incoming_byte_stream_push(
|
||||
p->parsing_frame,
|
||||
grpc_slice_sub(slice, (size_t)(cur - beg),
|
||||
(size_t)(cur + p->frame_size - beg)),
|
||||
grpc_slice_sub(slice, static_cast<size_t>(cur - beg),
|
||||
static_cast<size_t>(cur + p->frame_size - beg)),
|
||||
slice_out))) {
|
||||
grpc_slice_unref_internal(slice);
|
||||
return error;
|
||||
|
|
@ -276,7 +276,7 @@ grpc_error* grpc_deframe_unprocessed_incoming_frames(
|
|||
cur += p->frame_size;
|
||||
grpc_slice_buffer_undo_take_first(
|
||||
slices,
|
||||
grpc_slice_sub(slice, (size_t)(cur - beg), (size_t)(end - beg)));
|
||||
grpc_slice_sub(slice, static_cast<size_t>(cur - beg), static_cast<size_t>(end - beg)));
|
||||
grpc_slice_unref_internal(slice);
|
||||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ grpc_error* grpc_chttp2_goaway_parser_begin_frame(grpc_chttp2_goaway_parser* p,
|
|||
|
||||
gpr_free(p->debug_data);
|
||||
p->debug_length = length - 8;
|
||||
p->debug_data = (char*)gpr_malloc(p->debug_length);
|
||||
p->debug_data = static_cast<char*>(gpr_malloc(p->debug_length));
|
||||
p->debug_pos = 0;
|
||||
p->state = GRPC_CHTTP2_GOAWAY_LSI0;
|
||||
return GRPC_ERROR_NONE;
|
||||
|
|
@ -59,7 +59,7 @@ grpc_error* grpc_chttp2_goaway_parser_parse(void* parser,
|
|||
uint8_t* const beg = GRPC_SLICE_START_PTR(slice);
|
||||
uint8_t* const end = GRPC_SLICE_END_PTR(slice);
|
||||
uint8_t* cur = beg;
|
||||
grpc_chttp2_goaway_parser* p = (grpc_chttp2_goaway_parser*)parser;
|
||||
grpc_chttp2_goaway_parser* p = static_cast<grpc_chttp2_goaway_parser*>(parser);
|
||||
|
||||
switch (p->state) {
|
||||
case GRPC_CHTTP2_GOAWAY_LSI0:
|
||||
|
|
@ -67,7 +67,7 @@ grpc_error* grpc_chttp2_goaway_parser_parse(void* parser,
|
|||
p->state = GRPC_CHTTP2_GOAWAY_LSI0;
|
||||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
p->last_stream_id = ((uint32_t)*cur) << 24;
|
||||
p->last_stream_id = (static_cast<uint32_t>(*cur)) << 24;
|
||||
++cur;
|
||||
/* fallthrough */
|
||||
case GRPC_CHTTP2_GOAWAY_LSI1:
|
||||
|
|
@ -75,7 +75,7 @@ grpc_error* grpc_chttp2_goaway_parser_parse(void* parser,
|
|||
p->state = GRPC_CHTTP2_GOAWAY_LSI1;
|
||||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
p->last_stream_id |= ((uint32_t)*cur) << 16;
|
||||
p->last_stream_id |= (static_cast<uint32_t>(*cur)) << 16;
|
||||
++cur;
|
||||
/* fallthrough */
|
||||
case GRPC_CHTTP2_GOAWAY_LSI2:
|
||||
|
|
@ -83,7 +83,7 @@ grpc_error* grpc_chttp2_goaway_parser_parse(void* parser,
|
|||
p->state = GRPC_CHTTP2_GOAWAY_LSI2;
|
||||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
p->last_stream_id |= ((uint32_t)*cur) << 8;
|
||||
p->last_stream_id |= (static_cast<uint32_t>(*cur)) << 8;
|
||||
++cur;
|
||||
/* fallthrough */
|
||||
case GRPC_CHTTP2_GOAWAY_LSI3:
|
||||
|
|
@ -91,7 +91,7 @@ grpc_error* grpc_chttp2_goaway_parser_parse(void* parser,
|
|||
p->state = GRPC_CHTTP2_GOAWAY_LSI3;
|
||||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
p->last_stream_id |= ((uint32_t)*cur);
|
||||
p->last_stream_id |= (static_cast<uint32_t>(*cur));
|
||||
++cur;
|
||||
/* fallthrough */
|
||||
case GRPC_CHTTP2_GOAWAY_ERR0:
|
||||
|
|
@ -99,7 +99,7 @@ grpc_error* grpc_chttp2_goaway_parser_parse(void* parser,
|
|||
p->state = GRPC_CHTTP2_GOAWAY_ERR0;
|
||||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
p->error_code = ((uint32_t)*cur) << 24;
|
||||
p->error_code = (static_cast<uint32_t>(*cur)) << 24;
|
||||
++cur;
|
||||
/* fallthrough */
|
||||
case GRPC_CHTTP2_GOAWAY_ERR1:
|
||||
|
|
@ -107,7 +107,7 @@ grpc_error* grpc_chttp2_goaway_parser_parse(void* parser,
|
|||
p->state = GRPC_CHTTP2_GOAWAY_ERR1;
|
||||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
p->error_code |= ((uint32_t)*cur) << 16;
|
||||
p->error_code |= (static_cast<uint32_t>(*cur)) << 16;
|
||||
++cur;
|
||||
/* fallthrough */
|
||||
case GRPC_CHTTP2_GOAWAY_ERR2:
|
||||
|
|
@ -115,7 +115,7 @@ grpc_error* grpc_chttp2_goaway_parser_parse(void* parser,
|
|||
p->state = GRPC_CHTTP2_GOAWAY_ERR2;
|
||||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
p->error_code |= ((uint32_t)*cur) << 8;
|
||||
p->error_code |= (static_cast<uint32_t>(*cur)) << 8;
|
||||
++cur;
|
||||
/* fallthrough */
|
||||
case GRPC_CHTTP2_GOAWAY_ERR3:
|
||||
|
|
@ -123,18 +123,18 @@ grpc_error* grpc_chttp2_goaway_parser_parse(void* parser,
|
|||
p->state = GRPC_CHTTP2_GOAWAY_ERR3;
|
||||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
p->error_code |= ((uint32_t)*cur);
|
||||
p->error_code |= (static_cast<uint32_t>(*cur));
|
||||
++cur;
|
||||
/* fallthrough */
|
||||
case GRPC_CHTTP2_GOAWAY_DEBUG:
|
||||
if (end != cur)
|
||||
memcpy(p->debug_data + p->debug_pos, cur, (size_t)(end - cur));
|
||||
memcpy(p->debug_data + p->debug_pos, cur, static_cast<size_t>(end - cur));
|
||||
GPR_ASSERT((size_t)(end - cur) < UINT32_MAX - p->debug_pos);
|
||||
p->debug_pos += (uint32_t)(end - cur);
|
||||
p->debug_pos += static_cast<uint32_t>(end - cur);
|
||||
p->state = GRPC_CHTTP2_GOAWAY_DEBUG;
|
||||
if (is_last) {
|
||||
grpc_chttp2_add_incoming_goaway(
|
||||
t, (uint32_t)p->error_code,
|
||||
t, p->error_code,
|
||||
grpc_slice_new(p->debug_data, p->debug_length, gpr_free));
|
||||
p->debug_data = nullptr;
|
||||
}
|
||||
|
|
@ -151,12 +151,12 @@ void grpc_chttp2_goaway_append(uint32_t last_stream_id, uint32_t error_code,
|
|||
uint8_t* p = GRPC_SLICE_START_PTR(header);
|
||||
uint32_t frame_length;
|
||||
GPR_ASSERT(GRPC_SLICE_LENGTH(debug_data) < UINT32_MAX - 4 - 4);
|
||||
frame_length = 4 + 4 + (uint32_t)GRPC_SLICE_LENGTH(debug_data);
|
||||
frame_length = 4 + 4 + static_cast<uint32_t>GRPC_SLICE_LENGTH(debug_data);
|
||||
|
||||
/* frame header: length */
|
||||
*p++ = (uint8_t)(frame_length >> 16);
|
||||
*p++ = (uint8_t)(frame_length >> 8);
|
||||
*p++ = (uint8_t)(frame_length);
|
||||
*p++ = static_cast<uint8_t>(frame_length >> 16);
|
||||
*p++ = static_cast<uint8_t>(frame_length >> 8);
|
||||
*p++ = static_cast<uint8_t>(frame_length);
|
||||
/* frame header: type */
|
||||
*p++ = GRPC_CHTTP2_FRAME_GOAWAY;
|
||||
/* frame header: flags */
|
||||
|
|
@ -167,15 +167,15 @@ void grpc_chttp2_goaway_append(uint32_t last_stream_id, uint32_t error_code,
|
|||
*p++ = 0;
|
||||
*p++ = 0;
|
||||
/* payload: last stream id */
|
||||
*p++ = (uint8_t)(last_stream_id >> 24);
|
||||
*p++ = (uint8_t)(last_stream_id >> 16);
|
||||
*p++ = (uint8_t)(last_stream_id >> 8);
|
||||
*p++ = (uint8_t)(last_stream_id);
|
||||
*p++ = static_cast<uint8_t>(last_stream_id >> 24);
|
||||
*p++ = static_cast<uint8_t>(last_stream_id >> 16);
|
||||
*p++ = static_cast<uint8_t>(last_stream_id >> 8);
|
||||
*p++ = static_cast<uint8_t>(last_stream_id);
|
||||
/* payload: error code */
|
||||
*p++ = (uint8_t)(error_code >> 24);
|
||||
*p++ = (uint8_t)(error_code >> 16);
|
||||
*p++ = (uint8_t)(error_code >> 8);
|
||||
*p++ = (uint8_t)(error_code);
|
||||
*p++ = static_cast<uint8_t>(error_code >> 24);
|
||||
*p++ = static_cast<uint8_t>(error_code >> 16);
|
||||
*p++ = static_cast<uint8_t>(error_code >> 8);
|
||||
*p++ = static_cast<uint8_t>(error_code);
|
||||
GPR_ASSERT(p == GRPC_SLICE_END_PTR(header));
|
||||
grpc_slice_buffer_add(slice_buffer, header);
|
||||
grpc_slice_buffer_add(slice_buffer, debug_data);
|
||||
|
|
|
|||
|
|
@ -40,14 +40,14 @@ grpc_slice grpc_chttp2_ping_create(uint8_t ack, uint64_t opaque_8bytes) {
|
|||
*p++ = 0;
|
||||
*p++ = 0;
|
||||
*p++ = 0;
|
||||
*p++ = (uint8_t)(opaque_8bytes >> 56);
|
||||
*p++ = (uint8_t)(opaque_8bytes >> 48);
|
||||
*p++ = (uint8_t)(opaque_8bytes >> 40);
|
||||
*p++ = (uint8_t)(opaque_8bytes >> 32);
|
||||
*p++ = (uint8_t)(opaque_8bytes >> 24);
|
||||
*p++ = (uint8_t)(opaque_8bytes >> 16);
|
||||
*p++ = (uint8_t)(opaque_8bytes >> 8);
|
||||
*p++ = (uint8_t)(opaque_8bytes);
|
||||
*p++ = static_cast<uint8_t>(opaque_8bytes >> 56);
|
||||
*p++ = static_cast<uint8_t>(opaque_8bytes >> 48);
|
||||
*p++ = static_cast<uint8_t>(opaque_8bytes >> 40);
|
||||
*p++ = static_cast<uint8_t>(opaque_8bytes >> 32);
|
||||
*p++ = static_cast<uint8_t>(opaque_8bytes >> 24);
|
||||
*p++ = static_cast<uint8_t>(opaque_8bytes >> 16);
|
||||
*p++ = static_cast<uint8_t>(opaque_8bytes >> 8);
|
||||
*p++ = static_cast<uint8_t>(opaque_8bytes);
|
||||
|
||||
return slice;
|
||||
}
|
||||
|
|
@ -75,10 +75,10 @@ grpc_error* grpc_chttp2_ping_parser_parse(void* parser,
|
|||
uint8_t* const beg = GRPC_SLICE_START_PTR(slice);
|
||||
uint8_t* const end = GRPC_SLICE_END_PTR(slice);
|
||||
uint8_t* cur = beg;
|
||||
grpc_chttp2_ping_parser* p = (grpc_chttp2_ping_parser*)parser;
|
||||
grpc_chttp2_ping_parser* p = static_cast<grpc_chttp2_ping_parser*>(parser);
|
||||
|
||||
while (p->byte != 8 && cur != end) {
|
||||
p->opaque_8bytes |= (((uint64_t)*cur) << (56 - 8 * p->byte));
|
||||
p->opaque_8bytes |= ((static_cast<uint64_t>(*cur)) << (56 - 8 * p->byte));
|
||||
cur++;
|
||||
p->byte++;
|
||||
}
|
||||
|
|
@ -112,8 +112,8 @@ grpc_error* grpc_chttp2_ping_parser_parse(void* parser,
|
|||
if (!g_disable_ping_ack) {
|
||||
if (t->ping_ack_count == t->ping_ack_capacity) {
|
||||
t->ping_ack_capacity = GPR_MAX(t->ping_ack_capacity * 3 / 2, 3);
|
||||
t->ping_acks = (uint64_t*)gpr_realloc(
|
||||
t->ping_acks, t->ping_ack_capacity * sizeof(*t->ping_acks));
|
||||
t->ping_acks = static_cast<uint64_t*>(gpr_realloc(
|
||||
t->ping_acks, t->ping_ack_capacity * sizeof(*t->ping_acks)));
|
||||
}
|
||||
t->ping_acks[t->ping_ack_count++] = p->opaque_8bytes;
|
||||
grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_PING_RESPONSE);
|
||||
|
|
|
|||
|
|
@ -42,15 +42,15 @@ grpc_slice grpc_chttp2_rst_stream_create(uint32_t id, uint32_t code,
|
|||
// Flags.
|
||||
*p++ = 0;
|
||||
// Stream ID.
|
||||
*p++ = (uint8_t)(id >> 24);
|
||||
*p++ = (uint8_t)(id >> 16);
|
||||
*p++ = (uint8_t)(id >> 8);
|
||||
*p++ = (uint8_t)(id);
|
||||
*p++ = static_cast<uint8_t>(id >> 24);
|
||||
*p++ = static_cast<uint8_t>(id >> 16);
|
||||
*p++ = static_cast<uint8_t>(id >> 8);
|
||||
*p++ = static_cast<uint8_t>(id);
|
||||
// Error code.
|
||||
*p++ = (uint8_t)(code >> 24);
|
||||
*p++ = (uint8_t)(code >> 16);
|
||||
*p++ = (uint8_t)(code >> 8);
|
||||
*p++ = (uint8_t)(code);
|
||||
*p++ = static_cast<uint8_t>(code >> 24);
|
||||
*p++ = static_cast<uint8_t>(code >> 16);
|
||||
*p++ = static_cast<uint8_t>(code >> 8);
|
||||
*p++ = static_cast<uint8_t>(code);
|
||||
|
||||
return slice;
|
||||
}
|
||||
|
|
@ -76,21 +76,21 @@ grpc_error* grpc_chttp2_rst_stream_parser_parse(void* parser,
|
|||
uint8_t* const beg = GRPC_SLICE_START_PTR(slice);
|
||||
uint8_t* const end = GRPC_SLICE_END_PTR(slice);
|
||||
uint8_t* cur = beg;
|
||||
grpc_chttp2_rst_stream_parser* p = (grpc_chttp2_rst_stream_parser*)parser;
|
||||
grpc_chttp2_rst_stream_parser* p = static_cast<grpc_chttp2_rst_stream_parser*>(parser);
|
||||
|
||||
while (p->byte != 4 && cur != end) {
|
||||
p->reason_bytes[p->byte] = *cur;
|
||||
cur++;
|
||||
p->byte++;
|
||||
}
|
||||
s->stats.incoming.framing_bytes += (uint64_t)(end - cur);
|
||||
s->stats.incoming.framing_bytes += static_cast<uint64_t>(end - cur);
|
||||
|
||||
if (p->byte == 4) {
|
||||
GPR_ASSERT(is_last);
|
||||
uint32_t reason = (((uint32_t)p->reason_bytes[0]) << 24) |
|
||||
(((uint32_t)p->reason_bytes[1]) << 16) |
|
||||
(((uint32_t)p->reason_bytes[2]) << 8) |
|
||||
(((uint32_t)p->reason_bytes[3]));
|
||||
uint32_t reason = ((static_cast<uint32_t>(p->reason_bytes[0])) << 24) |
|
||||
((static_cast<uint32_t>(p->reason_bytes[1])) << 16) |
|
||||
((static_cast<uint32_t>(p->reason_bytes[2])) << 8) |
|
||||
((static_cast<uint32_t>(p->reason_bytes[3])));
|
||||
grpc_error* error = GRPC_ERROR_NONE;
|
||||
if (reason != GRPC_HTTP2_NO_ERROR || s->metadata_buffer[1].size == 0) {
|
||||
char* message;
|
||||
|
|
@ -99,7 +99,7 @@ grpc_error* grpc_chttp2_rst_stream_parser_parse(void* parser,
|
|||
grpc_error_set_str(GRPC_ERROR_CREATE_FROM_STATIC_STRING("RST_STREAM"),
|
||||
GRPC_ERROR_STR_GRPC_MESSAGE,
|
||||
grpc_slice_from_copied_string(message)),
|
||||
GRPC_ERROR_INT_HTTP2_ERROR, (intptr_t)reason);
|
||||
GRPC_ERROR_INT_HTTP2_ERROR, static_cast<intptr_t>(reason));
|
||||
gpr_free(message);
|
||||
}
|
||||
grpc_chttp2_mark_stream_closed(t, s, true, true, error);
|
||||
|
|
|
|||
|
|
@ -31,9 +31,9 @@
|
|||
#include "src/core/lib/transport/http2_errors.h"
|
||||
|
||||
static uint8_t* fill_header(uint8_t* out, uint32_t length, uint8_t flags) {
|
||||
*out++ = (uint8_t)(length >> 16);
|
||||
*out++ = (uint8_t)(length >> 8);
|
||||
*out++ = (uint8_t)(length);
|
||||
*out++ = static_cast<uint8_t>(length >> 16);
|
||||
*out++ = static_cast<uint8_t>(length >> 8);
|
||||
*out++ = static_cast<uint8_t>(length);
|
||||
*out++ = GRPC_CHTTP2_FRAME_SETTINGS;
|
||||
*out++ = flags;
|
||||
*out++ = 0;
|
||||
|
|
@ -60,12 +60,12 @@ grpc_slice grpc_chttp2_settings_create(uint32_t* old_settings,
|
|||
|
||||
for (i = 0; i < count; i++) {
|
||||
if (new_settings[i] != old_settings[i] || (force_mask & (1u << i)) != 0) {
|
||||
*p++ = (uint8_t)(grpc_setting_id_to_wire_id[i] >> 8);
|
||||
*p++ = (uint8_t)(grpc_setting_id_to_wire_id[i]);
|
||||
*p++ = (uint8_t)(new_settings[i] >> 24);
|
||||
*p++ = (uint8_t)(new_settings[i] >> 16);
|
||||
*p++ = (uint8_t)(new_settings[i] >> 8);
|
||||
*p++ = (uint8_t)(new_settings[i]);
|
||||
*p++ = static_cast<uint8_t>(grpc_setting_id_to_wire_id[i] >> 8);
|
||||
*p++ = static_cast<uint8_t>(grpc_setting_id_to_wire_id[i]);
|
||||
*p++ = static_cast<uint8_t>(new_settings[i] >> 24);
|
||||
*p++ = static_cast<uint8_t>(new_settings[i] >> 16);
|
||||
*p++ = static_cast<uint8_t>(new_settings[i] >> 8);
|
||||
*p++ = static_cast<uint8_t>(new_settings[i]);
|
||||
old_settings[i] = new_settings[i];
|
||||
}
|
||||
}
|
||||
|
|
@ -110,7 +110,7 @@ grpc_error* grpc_chttp2_settings_parser_begin_frame(
|
|||
grpc_error* grpc_chttp2_settings_parser_parse(void* p, grpc_chttp2_transport* t,
|
||||
grpc_chttp2_stream* s,
|
||||
grpc_slice slice, int is_last) {
|
||||
grpc_chttp2_settings_parser* parser = (grpc_chttp2_settings_parser*)p;
|
||||
grpc_chttp2_settings_parser* parser = static_cast<grpc_chttp2_settings_parser*>(p);
|
||||
const uint8_t* cur = GRPC_SLICE_START_PTR(slice);
|
||||
const uint8_t* end = GRPC_SLICE_END_PTR(slice);
|
||||
char* msg;
|
||||
|
|
@ -137,7 +137,7 @@ grpc_error* grpc_chttp2_settings_parser_parse(void* p, grpc_chttp2_transport* t,
|
|||
}
|
||||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
parser->id = (uint16_t)(((uint16_t)*cur) << 8);
|
||||
parser->id = static_cast<uint16_t>((static_cast<uint16_t>(*cur)) << 8);
|
||||
cur++;
|
||||
/* fallthrough */
|
||||
case GRPC_CHTTP2_SPS_ID1:
|
||||
|
|
@ -145,7 +145,7 @@ grpc_error* grpc_chttp2_settings_parser_parse(void* p, grpc_chttp2_transport* t,
|
|||
parser->state = GRPC_CHTTP2_SPS_ID1;
|
||||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
parser->id = (uint16_t)(parser->id | (*cur));
|
||||
parser->id = static_cast<uint16_t>(parser->id | (*cur));
|
||||
cur++;
|
||||
/* fallthrough */
|
||||
case GRPC_CHTTP2_SPS_VAL0:
|
||||
|
|
@ -153,7 +153,7 @@ grpc_error* grpc_chttp2_settings_parser_parse(void* p, grpc_chttp2_transport* t,
|
|||
parser->state = GRPC_CHTTP2_SPS_VAL0;
|
||||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
parser->value = ((uint32_t)*cur) << 24;
|
||||
parser->value = (static_cast<uint32_t>(*cur)) << 24;
|
||||
cur++;
|
||||
/* fallthrough */
|
||||
case GRPC_CHTTP2_SPS_VAL1:
|
||||
|
|
@ -161,7 +161,7 @@ grpc_error* grpc_chttp2_settings_parser_parse(void* p, grpc_chttp2_transport* t,
|
|||
parser->state = GRPC_CHTTP2_SPS_VAL1;
|
||||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
parser->value |= ((uint32_t)*cur) << 16;
|
||||
parser->value |= (static_cast<uint32_t>(*cur)) << 16;
|
||||
cur++;
|
||||
/* fallthrough */
|
||||
case GRPC_CHTTP2_SPS_VAL2:
|
||||
|
|
@ -169,7 +169,7 @@ grpc_error* grpc_chttp2_settings_parser_parse(void* p, grpc_chttp2_transport* t,
|
|||
parser->state = GRPC_CHTTP2_SPS_VAL2;
|
||||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
parser->value |= ((uint32_t)*cur) << 8;
|
||||
parser->value |= (static_cast<uint32_t>(*cur)) << 8;
|
||||
cur++;
|
||||
/* fallthrough */
|
||||
case GRPC_CHTTP2_SPS_VAL3:
|
||||
|
|
@ -212,11 +212,11 @@ grpc_error* grpc_chttp2_settings_parser_parse(void* p, grpc_chttp2_transport* t,
|
|||
if (id == GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE &&
|
||||
parser->incoming_settings[id] != parser->value) {
|
||||
t->initial_window_update +=
|
||||
(int64_t)parser->value - parser->incoming_settings[id];
|
||||
static_cast<int64_t>(parser->value) - parser->incoming_settings[id];
|
||||
if (grpc_http_trace.enabled() || grpc_flowctl_trace.enabled()) {
|
||||
gpr_log(GPR_DEBUG, "%p[%s] adding %d for initial_window change",
|
||||
t, t->is_client ? "cli" : "svr",
|
||||
(int)t->initial_window_update);
|
||||
static_cast<int>(t->initial_window_update));
|
||||
}
|
||||
}
|
||||
parser->incoming_settings[id] = parser->value;
|
||||
|
|
|
|||
|
|
@ -37,14 +37,14 @@ grpc_slice grpc_chttp2_window_update_create(
|
|||
*p++ = 4;
|
||||
*p++ = GRPC_CHTTP2_FRAME_WINDOW_UPDATE;
|
||||
*p++ = 0;
|
||||
*p++ = (uint8_t)(id >> 24);
|
||||
*p++ = (uint8_t)(id >> 16);
|
||||
*p++ = (uint8_t)(id >> 8);
|
||||
*p++ = (uint8_t)(id);
|
||||
*p++ = (uint8_t)(window_update >> 24);
|
||||
*p++ = (uint8_t)(window_update >> 16);
|
||||
*p++ = (uint8_t)(window_update >> 8);
|
||||
*p++ = (uint8_t)(window_update);
|
||||
*p++ = static_cast<uint8_t>(id >> 24);
|
||||
*p++ = static_cast<uint8_t>(id >> 16);
|
||||
*p++ = static_cast<uint8_t>(id >> 8);
|
||||
*p++ = static_cast<uint8_t>(id);
|
||||
*p++ = static_cast<uint8_t>(window_update >> 24);
|
||||
*p++ = static_cast<uint8_t>(window_update >> 16);
|
||||
*p++ = static_cast<uint8_t>(window_update >> 8);
|
||||
*p++ = static_cast<uint8_t>(window_update);
|
||||
|
||||
return slice;
|
||||
}
|
||||
|
|
@ -73,16 +73,16 @@ grpc_error* grpc_chttp2_window_update_parser_parse(void* parser,
|
|||
uint8_t* const end = GRPC_SLICE_END_PTR(slice);
|
||||
uint8_t* cur = beg;
|
||||
grpc_chttp2_window_update_parser* p =
|
||||
(grpc_chttp2_window_update_parser*)parser;
|
||||
static_cast<grpc_chttp2_window_update_parser*>(parser);
|
||||
|
||||
while (p->byte != 4 && cur != end) {
|
||||
p->amount |= ((uint32_t)*cur) << (8 * (3 - p->byte));
|
||||
p->amount |= (static_cast<uint32_t>(*cur)) << (8 * (3 - p->byte));
|
||||
cur++;
|
||||
p->byte++;
|
||||
}
|
||||
|
||||
if (s != nullptr) {
|
||||
s->stats.incoming.framing_bytes += (uint32_t)(end - cur);
|
||||
s->stats.incoming.framing_bytes += static_cast<uint32_t>(end - cur);
|
||||
}
|
||||
|
||||
if (p->byte == 4) {
|
||||
|
|
|
|||
|
|
@ -78,15 +78,15 @@ typedef struct {
|
|||
static void fill_header(uint8_t* p, uint8_t type, uint32_t id, size_t len,
|
||||
uint8_t flags) {
|
||||
GPR_ASSERT(len < 16777316);
|
||||
*p++ = (uint8_t)(len >> 16);
|
||||
*p++ = (uint8_t)(len >> 8);
|
||||
*p++ = (uint8_t)(len);
|
||||
*p++ = static_cast<uint8_t>(len >> 16);
|
||||
*p++ = static_cast<uint8_t>(len >> 8);
|
||||
*p++ = static_cast<uint8_t>(len);
|
||||
*p++ = type;
|
||||
*p++ = flags;
|
||||
*p++ = (uint8_t)(id >> 24);
|
||||
*p++ = (uint8_t)(id >> 16);
|
||||
*p++ = (uint8_t)(id >> 8);
|
||||
*p++ = (uint8_t)(id);
|
||||
*p++ = static_cast<uint8_t>(id >> 24);
|
||||
*p++ = static_cast<uint8_t>(id >> 16);
|
||||
*p++ = static_cast<uint8_t>(id >> 8);
|
||||
*p++ = static_cast<uint8_t>(id);
|
||||
}
|
||||
|
||||
/* finish a frame - fill in the previously reserved header */
|
||||
|
|
@ -98,7 +98,7 @@ static void finish_frame(framer_state* st, int is_header_boundary,
|
|||
fill_header(
|
||||
GRPC_SLICE_START_PTR(st->output->slices[st->header_idx]), type,
|
||||
st->stream_id, st->output->length - st->output_length_at_start_of_frame,
|
||||
(uint8_t)((is_last_in_stream ? GRPC_CHTTP2_DATA_FLAG_END_STREAM : 0) |
|
||||
static_cast<uint8_t>((is_last_in_stream ? GRPC_CHTTP2_DATA_FLAG_END_STREAM : 0) |
|
||||
(is_header_boundary ? GRPC_CHTTP2_DATA_FLAG_END_HEADERS : 0)));
|
||||
st->stats->framing_bytes += 9;
|
||||
st->is_first_frame = 0;
|
||||
|
|
@ -170,7 +170,7 @@ static void evict_entry(grpc_chttp2_hpack_compressor* c) {
|
|||
c->table_elem_size[c->tail_remote_index % c->cap_table_elems]);
|
||||
GPR_ASSERT(c->table_elems > 0);
|
||||
c->table_size =
|
||||
(uint16_t)(c->table_size -
|
||||
static_cast<uint16_t>(c->table_size -
|
||||
c->table_elem_size[c->tail_remote_index % c->cap_table_elems]);
|
||||
c->table_elems--;
|
||||
}
|
||||
|
|
@ -197,8 +197,8 @@ static uint32_t prepare_space_for_new_elem(grpc_chttp2_hpack_compressor* c,
|
|||
evict_entry(c);
|
||||
}
|
||||
GPR_ASSERT(c->table_elems < c->max_table_size);
|
||||
c->table_elem_size[new_index % c->cap_table_elems] = (uint16_t)elem_size;
|
||||
c->table_size = (uint16_t)(c->table_size + elem_size);
|
||||
c->table_elem_size[new_index % c->cap_table_elems] = static_cast<uint16_t>(elem_size);
|
||||
c->table_size = static_cast<uint16_t>(c->table_size + elem_size);
|
||||
c->table_elems++;
|
||||
|
||||
return new_index;
|
||||
|
|
@ -394,9 +394,9 @@ static void emit_lithdr_incidx_v(grpc_chttp2_hpack_compressor* c,
|
|||
GPR_ASSERT(unused_index == 0);
|
||||
GRPC_STATS_INC_HPACK_SEND_LITHDR_INCIDX_V();
|
||||
GRPC_STATS_INC_HPACK_SEND_UNCOMPRESSED();
|
||||
uint32_t len_key = (uint32_t)GRPC_SLICE_LENGTH(GRPC_MDKEY(elem));
|
||||
uint32_t len_key = static_cast<uint32_t>GRPC_SLICE_LENGTH(GRPC_MDKEY(elem));
|
||||
wire_value value = get_wire_value(elem, st->use_true_binary_metadata);
|
||||
uint32_t len_val = (uint32_t)wire_value_length(value);
|
||||
uint32_t len_val = static_cast<uint32_t>(wire_value_length(value));
|
||||
uint32_t len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1);
|
||||
uint32_t len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1);
|
||||
GPR_ASSERT(len_key <= UINT32_MAX);
|
||||
|
|
@ -416,9 +416,9 @@ static void emit_lithdr_noidx_v(grpc_chttp2_hpack_compressor* c,
|
|||
GPR_ASSERT(unused_index == 0);
|
||||
GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX_V();
|
||||
GRPC_STATS_INC_HPACK_SEND_UNCOMPRESSED();
|
||||
uint32_t len_key = (uint32_t)GRPC_SLICE_LENGTH(GRPC_MDKEY(elem));
|
||||
uint32_t len_key = static_cast<uint32_t>GRPC_SLICE_LENGTH(GRPC_MDKEY(elem));
|
||||
wire_value value = get_wire_value(elem, st->use_true_binary_metadata);
|
||||
uint32_t len_val = (uint32_t)wire_value_length(value);
|
||||
uint32_t len_val = static_cast<uint32_t>(wire_value_length(value));
|
||||
uint32_t len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1);
|
||||
uint32_t len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1);
|
||||
GPR_ASSERT(len_key <= UINT32_MAX);
|
||||
|
|
@ -584,7 +584,7 @@ void grpc_chttp2_hpack_compressor_init(grpc_chttp2_hpack_compressor* c) {
|
|||
c->max_table_elems = c->cap_table_elems;
|
||||
c->max_usable_size = GRPC_CHTTP2_HPACKC_INITIAL_TABLE_SIZE;
|
||||
c->table_elem_size =
|
||||
(uint16_t*)gpr_malloc(sizeof(*c->table_elem_size) * c->cap_table_elems);
|
||||
static_cast<uint16_t*>(gpr_malloc(sizeof(*c->table_elem_size) * c->cap_table_elems));
|
||||
memset(c->table_elem_size, 0,
|
||||
sizeof(*c->table_elem_size) * c->cap_table_elems);
|
||||
for (size_t i = 0; i < GPR_ARRAY_SIZE(c->entries_keys); i++) {
|
||||
|
|
@ -612,7 +612,7 @@ void grpc_chttp2_hpack_compressor_set_max_usable_size(
|
|||
|
||||
static void rebuild_elems(grpc_chttp2_hpack_compressor* c, uint32_t new_cap) {
|
||||
uint16_t* table_elem_size =
|
||||
(uint16_t*)gpr_malloc(sizeof(*table_elem_size) * new_cap);
|
||||
static_cast<uint16_t*>(gpr_malloc(sizeof(*table_elem_size) * new_cap));
|
||||
uint32_t i;
|
||||
|
||||
memset(table_elem_size, 0, sizeof(*table_elem_size) * new_cap);
|
||||
|
|
|
|||
|
|
@ -757,8 +757,8 @@ static grpc_error* finish_indexed_field(grpc_chttp2_hpack_parser* p,
|
|||
return grpc_error_set_int(
|
||||
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
||||
"Invalid HPACK index received"),
|
||||
GRPC_ERROR_INT_INDEX, (intptr_t)p->index),
|
||||
GRPC_ERROR_INT_SIZE, (intptr_t)p->table.num_ents);
|
||||
GRPC_ERROR_INT_INDEX, static_cast<intptr_t>(p->index)),
|
||||
GRPC_ERROR_INT_SIZE, static_cast<intptr_t>(p->table.num_ents));
|
||||
}
|
||||
GRPC_MDELEM_REF(md);
|
||||
GRPC_STATS_INC_HPACK_RECV_INDEXED();
|
||||
|
|
@ -1087,7 +1087,7 @@ static grpc_error* parse_value1(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
|
|||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
|
||||
*p->parsing.value += (((uint32_t)*cur) & 0x7f) << 7;
|
||||
*p->parsing.value += ((static_cast<uint32_t>(*cur)) & 0x7f) << 7;
|
||||
|
||||
if ((*cur) & 0x80) {
|
||||
return parse_value2(p, cur + 1, end);
|
||||
|
|
@ -1105,7 +1105,7 @@ static grpc_error* parse_value2(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
|
|||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
|
||||
*p->parsing.value += (((uint32_t)*cur) & 0x7f) << 14;
|
||||
*p->parsing.value += ((static_cast<uint32_t>(*cur)) & 0x7f) << 14;
|
||||
|
||||
if ((*cur) & 0x80) {
|
||||
return parse_value3(p, cur + 1, end);
|
||||
|
|
@ -1123,7 +1123,7 @@ static grpc_error* parse_value3(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
|
|||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
|
||||
*p->parsing.value += (((uint32_t)*cur) & 0x7f) << 21;
|
||||
*p->parsing.value += ((static_cast<uint32_t>(*cur)) & 0x7f) << 21;
|
||||
|
||||
if ((*cur) & 0x80) {
|
||||
return parse_value4(p, cur + 1, end);
|
||||
|
|
@ -1152,7 +1152,7 @@ static grpc_error* parse_value4(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
|
|||
}
|
||||
|
||||
cur_value = *p->parsing.value;
|
||||
add_value = ((uint32_t)c) << 28;
|
||||
add_value = (static_cast<uint32_t>(c)) << 28;
|
||||
if (add_value > 0xffffffffu - cur_value) {
|
||||
goto error;
|
||||
}
|
||||
|
|
@ -1227,13 +1227,13 @@ static void append_bytes(grpc_chttp2_hpack_parser_string* str,
|
|||
if (length == 0) return;
|
||||
if (length + str->data.copied.length > str->data.copied.capacity) {
|
||||
GPR_ASSERT(str->data.copied.length + length <= UINT32_MAX);
|
||||
str->data.copied.capacity = (uint32_t)(str->data.copied.length + length);
|
||||
str->data.copied.capacity = static_cast<uint32_t>(str->data.copied.length + length);
|
||||
str->data.copied.str =
|
||||
(char*)gpr_realloc(str->data.copied.str, str->data.copied.capacity);
|
||||
static_cast<char*>(gpr_realloc(str->data.copied.str, str->data.copied.capacity));
|
||||
}
|
||||
memcpy(str->data.copied.str + str->data.copied.length, data, length);
|
||||
GPR_ASSERT(length <= UINT32_MAX - str->data.copied.length);
|
||||
str->data.copied.length += (uint32_t)length;
|
||||
str->data.copied.length += static_cast<uint32_t>(length);
|
||||
}
|
||||
|
||||
static grpc_error* append_string(grpc_chttp2_hpack_parser* p,
|
||||
|
|
@ -1241,9 +1241,9 @@ static grpc_error* append_string(grpc_chttp2_hpack_parser* p,
|
|||
grpc_chttp2_hpack_parser_string* str = p->parsing.str;
|
||||
uint32_t bits;
|
||||
uint8_t decoded[3];
|
||||
switch ((binary_state)p->binary) {
|
||||
switch (static_cast<binary_state>(p->binary)) {
|
||||
case NOT_BINARY:
|
||||
append_bytes(str, cur, (size_t)(end - cur));
|
||||
append_bytes(str, cur, static_cast<size_t>(end - cur));
|
||||
return GRPC_ERROR_NONE;
|
||||
case BINARY_BEGIN:
|
||||
if (cur == end) {
|
||||
|
|
@ -1255,7 +1255,7 @@ static grpc_error* append_string(grpc_chttp2_hpack_parser* p,
|
|||
++cur;
|
||||
p->binary = NOT_BINARY;
|
||||
GRPC_STATS_INC_HPACK_RECV_BINARY();
|
||||
append_bytes(str, cur, (size_t)(end - cur));
|
||||
append_bytes(str, cur, static_cast<size_t>(end - cur));
|
||||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
GRPC_STATS_INC_HPACK_RECV_BINARY_BASE64();
|
||||
|
|
@ -1324,9 +1324,9 @@ static grpc_error* append_string(grpc_chttp2_hpack_parser* p,
|
|||
goto b64_byte3;
|
||||
p->base64_buffer |= bits;
|
||||
bits = p->base64_buffer;
|
||||
decoded[0] = (uint8_t)(bits >> 16);
|
||||
decoded[1] = (uint8_t)(bits >> 8);
|
||||
decoded[2] = (uint8_t)(bits);
|
||||
decoded[0] = static_cast<uint8_t>(bits >> 16);
|
||||
decoded[1] = static_cast<uint8_t>(bits >> 8);
|
||||
decoded[2] = static_cast<uint8_t>(bits);
|
||||
append_bytes(str, decoded, 3);
|
||||
goto b64_byte0;
|
||||
}
|
||||
|
|
@ -1340,7 +1340,7 @@ static grpc_error* finish_str(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
|
|||
uint8_t decoded[2];
|
||||
uint32_t bits;
|
||||
grpc_chttp2_hpack_parser_string* str = p->parsing.str;
|
||||
switch ((binary_state)p->binary) {
|
||||
switch (static_cast<binary_state>(p->binary)) {
|
||||
case NOT_BINARY:
|
||||
break;
|
||||
case BINARY_BEGIN:
|
||||
|
|
@ -1361,7 +1361,7 @@ static grpc_error* finish_str(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
|
|||
gpr_free(msg);
|
||||
return parse_error(p, cur, end, err);
|
||||
}
|
||||
decoded[0] = (uint8_t)(bits >> 16);
|
||||
decoded[0] = static_cast<uint8_t>(bits >> 16);
|
||||
append_bytes(str, decoded, 1);
|
||||
break;
|
||||
case B64_BYTE3:
|
||||
|
|
@ -1374,8 +1374,8 @@ static grpc_error* finish_str(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
|
|||
gpr_free(msg);
|
||||
return parse_error(p, cur, end, err);
|
||||
}
|
||||
decoded[0] = (uint8_t)(bits >> 16);
|
||||
decoded[1] = (uint8_t)(bits >> 8);
|
||||
decoded[0] = static_cast<uint8_t>(bits >> 16);
|
||||
decoded[1] = static_cast<uint8_t>(bits >> 8);
|
||||
append_bytes(str, decoded, 2);
|
||||
break;
|
||||
}
|
||||
|
|
@ -1388,7 +1388,7 @@ static grpc_error* huff_nibble(grpc_chttp2_hpack_parser* p, uint8_t nibble) {
|
|||
int16_t next = next_sub_tbl[16 * next_tbl[p->huff_state] + nibble];
|
||||
if (emit != -1) {
|
||||
if (emit >= 0 && emit < 256) {
|
||||
uint8_t c = (uint8_t)emit;
|
||||
uint8_t c = static_cast<uint8_t>(emit);
|
||||
grpc_error* err = append_string(p, &c, (&c) + 1);
|
||||
if (err != GRPC_ERROR_NONE) return err;
|
||||
} else {
|
||||
|
|
@ -1426,7 +1426,7 @@ static grpc_error* add_str_bytes(grpc_chttp2_hpack_parser* p,
|
|||
static grpc_error* parse_string(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
|
||||
const uint8_t* end) {
|
||||
size_t remaining = p->strlen - p->strgot;
|
||||
size_t given = (size_t)(end - cur);
|
||||
size_t given = static_cast<size_t>(end - cur);
|
||||
if (remaining <= given) {
|
||||
grpc_error* err = add_str_bytes(p, cur, cur + remaining);
|
||||
if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err);
|
||||
|
|
@ -1437,7 +1437,7 @@ static grpc_error* parse_string(grpc_chttp2_hpack_parser* p, const uint8_t* cur,
|
|||
grpc_error* err = add_str_bytes(p, cur, cur + given);
|
||||
if (err != GRPC_ERROR_NONE) return parse_error(p, cur, end, err);
|
||||
GPR_ASSERT(given <= UINT32_MAX - p->strgot);
|
||||
p->strgot += (uint32_t)given;
|
||||
p->strgot += static_cast<uint32_t>(given);
|
||||
p->state = parse_string;
|
||||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
|
|
@ -1448,12 +1448,12 @@ static grpc_error* begin_parse_string(grpc_chttp2_hpack_parser* p,
|
|||
const uint8_t* cur, const uint8_t* end,
|
||||
uint8_t binary,
|
||||
grpc_chttp2_hpack_parser_string* str) {
|
||||
if (!p->huff && binary == NOT_BINARY && (end - cur) >= (intptr_t)p->strlen &&
|
||||
if (!p->huff && binary == NOT_BINARY && (end - cur) >= static_cast<intptr_t>(p->strlen) &&
|
||||
p->current_slice_refcount != nullptr) {
|
||||
GRPC_STATS_INC_HPACK_RECV_UNCOMPRESSED();
|
||||
str->copied = false;
|
||||
str->data.referenced.refcount = p->current_slice_refcount;
|
||||
str->data.referenced.data.refcounted.bytes = (uint8_t*)cur;
|
||||
str->data.referenced.data.refcounted.bytes = const_cast<uint8_t*>(cur);
|
||||
str->data.referenced.data.refcounted.length = p->strlen;
|
||||
grpc_slice_ref_internal(str->data.referenced);
|
||||
return parse_next(p, cur + p->strlen, end);
|
||||
|
|
@ -1503,8 +1503,8 @@ static grpc_error* is_binary_indexed_header(grpc_chttp2_hpack_parser* p,
|
|||
return grpc_error_set_int(
|
||||
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
||||
"Invalid HPACK index received"),
|
||||
GRPC_ERROR_INT_INDEX, (intptr_t)p->index),
|
||||
GRPC_ERROR_INT_SIZE, (intptr_t)p->table.num_ents);
|
||||
GRPC_ERROR_INT_INDEX, static_cast<intptr_t>(p->index)),
|
||||
GRPC_ERROR_INT_SIZE, static_cast<intptr_t>(p->table.num_ents));
|
||||
}
|
||||
*is = grpc_is_binary_header(GRPC_MDKEY(elem));
|
||||
return GRPC_ERROR_NONE;
|
||||
|
|
@ -1589,7 +1589,7 @@ static const maybe_complete_func_type maybe_complete_funcs[] = {
|
|||
grpc_chttp2_maybe_complete_recv_trailing_metadata};
|
||||
|
||||
static void force_client_rst_stream(void* sp, grpc_error* error) {
|
||||
grpc_chttp2_stream* s = (grpc_chttp2_stream*)sp;
|
||||
grpc_chttp2_stream* s = static_cast<grpc_chttp2_stream*>(sp);
|
||||
grpc_chttp2_transport* t = s->t;
|
||||
if (!s->write_closed) {
|
||||
grpc_slice_buffer_add(
|
||||
|
|
@ -1618,7 +1618,7 @@ grpc_error* grpc_chttp2_header_parser_parse(void* hpack_parser,
|
|||
grpc_chttp2_stream* s,
|
||||
grpc_slice slice, int is_last) {
|
||||
GPR_TIMER_SCOPE("grpc_chttp2_hpack_parser_parse", 0);
|
||||
grpc_chttp2_hpack_parser* parser = (grpc_chttp2_hpack_parser*)hpack_parser;
|
||||
grpc_chttp2_hpack_parser* parser = static_cast<grpc_chttp2_hpack_parser*>(hpack_parser);
|
||||
if (s != nullptr) {
|
||||
s->stats.incoming.header_bytes += GRPC_SLICE_LENGTH(slice);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ void grpc_chttp2_hptbl_init(grpc_chttp2_hptbl* tbl) {
|
|||
GRPC_CHTTP2_INITIAL_HPACK_TABLE_SIZE;
|
||||
tbl->max_entries = tbl->cap_entries =
|
||||
entries_for_bytes(tbl->current_table_bytes);
|
||||
tbl->ents = (grpc_mdelem*)gpr_malloc(sizeof(*tbl->ents) * tbl->cap_entries);
|
||||
tbl->ents = static_cast<grpc_mdelem*>(gpr_malloc(sizeof(*tbl->ents) * tbl->cap_entries));
|
||||
memset(tbl->ents, 0, sizeof(*tbl->ents) * tbl->cap_entries);
|
||||
for (i = 1; i <= GRPC_CHTTP2_LAST_STATIC_ENTRY; i++) {
|
||||
tbl->static_ents[i - 1] = grpc_mdelem_from_slices(
|
||||
|
|
@ -218,14 +218,14 @@ static void evict1(grpc_chttp2_hptbl* tbl) {
|
|||
GRPC_SLICE_LENGTH(GRPC_MDVALUE(first_ent)) +
|
||||
GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD;
|
||||
GPR_ASSERT(elem_bytes <= tbl->mem_used);
|
||||
tbl->mem_used -= (uint32_t)elem_bytes;
|
||||
tbl->mem_used -= static_cast<uint32_t>(elem_bytes);
|
||||
tbl->first_ent = ((tbl->first_ent + 1) % tbl->cap_entries);
|
||||
tbl->num_ents--;
|
||||
GRPC_MDELEM_UNREF(first_ent);
|
||||
}
|
||||
|
||||
static void rebuild_ents(grpc_chttp2_hptbl* tbl, uint32_t new_cap) {
|
||||
grpc_mdelem* ents = (grpc_mdelem*)gpr_malloc(sizeof(*ents) * new_cap);
|
||||
grpc_mdelem* ents = static_cast<grpc_mdelem*>(gpr_malloc(sizeof(*ents) * new_cap));
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < tbl->num_ents; i++) {
|
||||
|
|
@ -320,7 +320,7 @@ grpc_error* grpc_chttp2_hptbl_add(grpc_chttp2_hptbl* tbl, grpc_mdelem md) {
|
|||
}
|
||||
|
||||
/* evict entries to ensure no overflow */
|
||||
while (elem_bytes > (size_t)tbl->current_table_bytes - tbl->mem_used) {
|
||||
while (elem_bytes > static_cast<size_t>(tbl->current_table_bytes) - tbl->mem_used) {
|
||||
evict1(tbl);
|
||||
}
|
||||
|
||||
|
|
@ -330,7 +330,7 @@ grpc_error* grpc_chttp2_hptbl_add(grpc_chttp2_hptbl* tbl, grpc_mdelem md) {
|
|||
|
||||
/* update accounting values */
|
||||
tbl->num_ents++;
|
||||
tbl->mem_used += (uint32_t)elem_bytes;
|
||||
tbl->mem_used += static_cast<uint32_t>(elem_bytes);
|
||||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
|
||||
|
|
@ -351,7 +351,7 @@ grpc_chttp2_hptbl_find_result grpc_chttp2_hptbl_find(
|
|||
/* Scan the dynamic table */
|
||||
for (i = 0; i < tbl->num_ents; i++) {
|
||||
uint32_t idx =
|
||||
(uint32_t)(tbl->num_ents - i + GRPC_CHTTP2_LAST_STATIC_ENTRY);
|
||||
static_cast<uint32_t>(tbl->num_ents - i + GRPC_CHTTP2_LAST_STATIC_ENTRY);
|
||||
grpc_mdelem ent = tbl->ents[(tbl->first_ent + i) % tbl->cap_entries];
|
||||
if (!grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDKEY(ent))) continue;
|
||||
r.index = idx;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ bool grpc_wire_id_to_setting_id(uint32_t wire_id, grpc_chttp2_setting_id* out) {
|
|||
h += 4;
|
||||
break;
|
||||
}
|
||||
*out = (grpc_chttp2_setting_id)h;
|
||||
*out = static_cast<grpc_chttp2_setting_id>(h);
|
||||
return h < GPR_ARRAY_SIZE(grpc_setting_id_to_wire_id) &&
|
||||
grpc_setting_id_to_wire_id[h] == wire_id;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,8 +42,8 @@ grpc_error* grpc_chttp2_incoming_metadata_buffer_add(
|
|||
buffer->size += GRPC_MDELEM_LENGTH(elem);
|
||||
return grpc_metadata_batch_add_tail(
|
||||
&buffer->batch,
|
||||
(grpc_linked_mdelem*)gpr_arena_alloc(buffer->arena,
|
||||
sizeof(grpc_linked_mdelem)),
|
||||
static_cast<grpc_linked_mdelem*>(gpr_arena_alloc(buffer->arena,
|
||||
sizeof(grpc_linked_mdelem))),
|
||||
elem);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -88,15 +88,15 @@ grpc_error* grpc_chttp2_perform_read(grpc_chttp2_transport* t,
|
|||
"Connect string mismatch: expected '%c' (%d) got '%c' (%d) "
|
||||
"at byte %d",
|
||||
GRPC_CHTTP2_CLIENT_CONNECT_STRING[t->deframe_state],
|
||||
(int)(uint8_t)GRPC_CHTTP2_CLIENT_CONNECT_STRING[t->deframe_state],
|
||||
*cur, (int)*cur, t->deframe_state);
|
||||
static_cast<int>(static_cast<uint8_t>(GRPC_CHTTP2_CLIENT_CONNECT_STRING[t->deframe_state])),
|
||||
*cur, static_cast<int>(*cur), t->deframe_state);
|
||||
err = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
|
||||
gpr_free(msg);
|
||||
return err;
|
||||
}
|
||||
++cur;
|
||||
t->deframe_state =
|
||||
(grpc_chttp2_deframe_transport_state)(1 + (int)t->deframe_state);
|
||||
static_cast<grpc_chttp2_deframe_transport_state>(1 + static_cast<int>(t->deframe_state));
|
||||
}
|
||||
if (cur == end) {
|
||||
return GRPC_ERROR_NONE;
|
||||
|
|
@ -105,7 +105,7 @@ grpc_error* grpc_chttp2_perform_read(grpc_chttp2_transport* t,
|
|||
dts_fh_0:
|
||||
case GRPC_DTS_FH_0:
|
||||
GPR_ASSERT(cur < end);
|
||||
t->incoming_frame_size = ((uint32_t)*cur) << 16;
|
||||
t->incoming_frame_size = (static_cast<uint32_t>(*cur)) << 16;
|
||||
if (++cur == end) {
|
||||
t->deframe_state = GRPC_DTS_FH_1;
|
||||
return GRPC_ERROR_NONE;
|
||||
|
|
@ -113,7 +113,7 @@ grpc_error* grpc_chttp2_perform_read(grpc_chttp2_transport* t,
|
|||
/* fallthrough */
|
||||
case GRPC_DTS_FH_1:
|
||||
GPR_ASSERT(cur < end);
|
||||
t->incoming_frame_size |= ((uint32_t)*cur) << 8;
|
||||
t->incoming_frame_size |= (static_cast<uint32_t>(*cur)) << 8;
|
||||
if (++cur == end) {
|
||||
t->deframe_state = GRPC_DTS_FH_2;
|
||||
return GRPC_ERROR_NONE;
|
||||
|
|
@ -145,7 +145,7 @@ grpc_error* grpc_chttp2_perform_read(grpc_chttp2_transport* t,
|
|||
/* fallthrough */
|
||||
case GRPC_DTS_FH_5:
|
||||
GPR_ASSERT(cur < end);
|
||||
t->incoming_stream_id = (((uint32_t)*cur) & 0x7f) << 24;
|
||||
t->incoming_stream_id = ((static_cast<uint32_t>(*cur)) & 0x7f) << 24;
|
||||
if (++cur == end) {
|
||||
t->deframe_state = GRPC_DTS_FH_6;
|
||||
return GRPC_ERROR_NONE;
|
||||
|
|
@ -153,7 +153,7 @@ grpc_error* grpc_chttp2_perform_read(grpc_chttp2_transport* t,
|
|||
/* fallthrough */
|
||||
case GRPC_DTS_FH_6:
|
||||
GPR_ASSERT(cur < end);
|
||||
t->incoming_stream_id |= ((uint32_t)*cur) << 16;
|
||||
t->incoming_stream_id |= (static_cast<uint32_t>(*cur)) << 16;
|
||||
if (++cur == end) {
|
||||
t->deframe_state = GRPC_DTS_FH_7;
|
||||
return GRPC_ERROR_NONE;
|
||||
|
|
@ -161,7 +161,7 @@ grpc_error* grpc_chttp2_perform_read(grpc_chttp2_transport* t,
|
|||
/* fallthrough */
|
||||
case GRPC_DTS_FH_7:
|
||||
GPR_ASSERT(cur < end);
|
||||
t->incoming_stream_id |= ((uint32_t)*cur) << 8;
|
||||
t->incoming_stream_id |= (static_cast<uint32_t>(*cur)) << 8;
|
||||
if (++cur == end) {
|
||||
t->deframe_state = GRPC_DTS_FH_8;
|
||||
return GRPC_ERROR_NONE;
|
||||
|
|
@ -169,7 +169,7 @@ grpc_error* grpc_chttp2_perform_read(grpc_chttp2_transport* t,
|
|||
/* fallthrough */
|
||||
case GRPC_DTS_FH_8:
|
||||
GPR_ASSERT(cur < end);
|
||||
t->incoming_stream_id |= ((uint32_t)*cur);
|
||||
t->incoming_stream_id |= (static_cast<uint32_t>(*cur));
|
||||
t->deframe_state = GRPC_DTS_FRAME;
|
||||
err = init_frame_parser(t);
|
||||
if (err != GRPC_ERROR_NONE) {
|
||||
|
|
@ -205,11 +205,11 @@ grpc_error* grpc_chttp2_perform_read(grpc_chttp2_transport* t,
|
|||
/* fallthrough */
|
||||
case GRPC_DTS_FRAME:
|
||||
GPR_ASSERT(cur < end);
|
||||
if ((uint32_t)(end - cur) == t->incoming_frame_size) {
|
||||
if (static_cast<uint32_t>(end - cur) == t->incoming_frame_size) {
|
||||
err =
|
||||
parse_frame_slice(t,
|
||||
grpc_slice_sub_no_ref(slice, (size_t)(cur - beg),
|
||||
(size_t)(end - beg)),
|
||||
grpc_slice_sub_no_ref(slice, static_cast<size_t>(cur - beg),
|
||||
static_cast<size_t>(end - beg)),
|
||||
1);
|
||||
if (err != GRPC_ERROR_NONE) {
|
||||
return err;
|
||||
|
|
@ -217,8 +217,8 @@ grpc_error* grpc_chttp2_perform_read(grpc_chttp2_transport* t,
|
|||
t->deframe_state = GRPC_DTS_FH_0;
|
||||
t->incoming_stream = nullptr;
|
||||
return GRPC_ERROR_NONE;
|
||||
} else if ((uint32_t)(end - cur) > t->incoming_frame_size) {
|
||||
size_t cur_offset = (size_t)(cur - beg);
|
||||
} else if (static_cast<uint32_t>(end - cur) > t->incoming_frame_size) {
|
||||
size_t cur_offset = static_cast<size_t>(cur - beg);
|
||||
err = parse_frame_slice(
|
||||
t,
|
||||
grpc_slice_sub_no_ref(slice, cur_offset,
|
||||
|
|
@ -233,13 +233,13 @@ grpc_error* grpc_chttp2_perform_read(grpc_chttp2_transport* t,
|
|||
} else {
|
||||
err =
|
||||
parse_frame_slice(t,
|
||||
grpc_slice_sub_no_ref(slice, (size_t)(cur - beg),
|
||||
(size_t)(end - beg)),
|
||||
grpc_slice_sub_no_ref(slice, static_cast<size_t>(cur - beg),
|
||||
static_cast<size_t>(end - beg)),
|
||||
0);
|
||||
if (err != GRPC_ERROR_NONE) {
|
||||
return err;
|
||||
}
|
||||
t->incoming_frame_size -= (uint32_t)(end - cur);
|
||||
t->incoming_frame_size -= static_cast<uint32_t>(end - cur);
|
||||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
GPR_UNREACHABLE_CODE(return nullptr);
|
||||
|
|
@ -325,7 +325,7 @@ static grpc_error* init_skip_frame_parser(grpc_chttp2_transport* t,
|
|||
t->hpack_parser.on_header = skip_header;
|
||||
t->hpack_parser.on_header_user_data = nullptr;
|
||||
t->hpack_parser.is_boundary = is_eoh;
|
||||
t->hpack_parser.is_eof = (uint8_t)(is_eoh ? t->header_eof : 0);
|
||||
t->hpack_parser.is_eof = static_cast<uint8_t>(is_eoh ? t->header_eof : 0);
|
||||
} else {
|
||||
t->parser = skip_parser;
|
||||
}
|
||||
|
|
@ -394,7 +394,7 @@ static void free_timeout(void* p) { gpr_free(p); }
|
|||
static void on_initial_header(void* tp, grpc_mdelem md) {
|
||||
GPR_TIMER_SCOPE("on_initial_header", 0);
|
||||
|
||||
grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
|
||||
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(tp);
|
||||
grpc_chttp2_stream* s = t->incoming_stream;
|
||||
GPR_ASSERT(s != nullptr);
|
||||
|
||||
|
|
@ -429,7 +429,7 @@ static void on_initial_header(void* tp, grpc_mdelem md) {
|
|||
}
|
||||
if (GRPC_MDELEM_IS_INTERNED(md)) {
|
||||
/* store the result */
|
||||
cached_timeout = (grpc_millis*)gpr_malloc(sizeof(grpc_millis));
|
||||
cached_timeout = static_cast<grpc_millis*>(gpr_malloc(sizeof(grpc_millis)));
|
||||
*cached_timeout = timeout;
|
||||
grpc_mdelem_set_user_data(md, free_timeout, cached_timeout);
|
||||
}
|
||||
|
|
@ -474,7 +474,7 @@ static void on_initial_header(void* tp, grpc_mdelem md) {
|
|||
static void on_trailing_header(void* tp, grpc_mdelem md) {
|
||||
GPR_TIMER_SCOPE("on_trailing_header", 0);
|
||||
|
||||
grpc_chttp2_transport* t = (grpc_chttp2_transport*)tp;
|
||||
grpc_chttp2_transport* t = static_cast<grpc_chttp2_transport*>(tp);
|
||||
grpc_chttp2_stream* s = t->incoming_stream;
|
||||
GPR_ASSERT(s != nullptr);
|
||||
|
||||
|
|
@ -634,7 +634,7 @@ static grpc_error* init_header_frame_parser(grpc_chttp2_transport* t,
|
|||
}
|
||||
t->hpack_parser.on_header_user_data = t;
|
||||
t->hpack_parser.is_boundary = is_eoh;
|
||||
t->hpack_parser.is_eof = (uint8_t)(is_eoh ? t->header_eof : 0);
|
||||
t->hpack_parser.is_eof = static_cast<uint8_t>(is_eoh ? t->header_eof : 0);
|
||||
if (!is_continuation &&
|
||||
(t->incoming_frame_flags & GRPC_CHTTP2_FLAG_HAS_PRIORITY)) {
|
||||
grpc_chttp2_hpack_parser_set_has_priority(&t->hpack_parser);
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@
|
|||
void grpc_chttp2_stream_map_init(grpc_chttp2_stream_map* map,
|
||||
size_t initial_capacity) {
|
||||
GPR_ASSERT(initial_capacity > 1);
|
||||
map->keys = (uint32_t*)gpr_malloc(sizeof(uint32_t) * initial_capacity);
|
||||
map->values = (void**)gpr_malloc(sizeof(void*) * initial_capacity);
|
||||
map->keys = static_cast<uint32_t*>(gpr_malloc(sizeof(uint32_t) * initial_capacity));
|
||||
map->values = static_cast<void**>(gpr_malloc(sizeof(void*) * initial_capacity));
|
||||
map->count = 0;
|
||||
map->free = 0;
|
||||
map->capacity = initial_capacity;
|
||||
|
|
@ -72,9 +72,9 @@ void grpc_chttp2_stream_map_add(grpc_chttp2_stream_map* map, uint32_t key,
|
|||
won't help much */
|
||||
map->capacity = capacity = 3 * capacity / 2;
|
||||
map->keys = keys =
|
||||
(uint32_t*)gpr_realloc(keys, capacity * sizeof(uint32_t));
|
||||
static_cast<uint32_t*>(gpr_realloc(keys, capacity * sizeof(uint32_t)));
|
||||
map->values = values =
|
||||
(void**)gpr_realloc(values, capacity * sizeof(void*));
|
||||
static_cast<void**>(gpr_realloc(values, capacity * sizeof(void*)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -146,7 +146,7 @@ void* grpc_chttp2_stream_map_rand(grpc_chttp2_stream_map* map) {
|
|||
map->free = 0;
|
||||
GPR_ASSERT(map->count > 0);
|
||||
}
|
||||
return map->values[((size_t)rand()) % map->count];
|
||||
return map->values[(static_cast<size_t>(rand())) % map->count];
|
||||
}
|
||||
|
||||
void grpc_chttp2_stream_map_for_each(grpc_chttp2_stream_map* map,
|
||||
|
|
|
|||
|
|
@ -36,19 +36,19 @@ void grpc_chttp2_hpack_write_varint_tail(uint32_t tail_value, uint8_t* target,
|
|||
uint32_t tail_length) {
|
||||
switch (tail_length) {
|
||||
case 5:
|
||||
target[4] = (uint8_t)((tail_value >> 28) | 0x80);
|
||||
target[4] = static_cast<uint8_t>((tail_value >> 28) | 0x80);
|
||||
/* fallthrough */
|
||||
case 4:
|
||||
target[3] = (uint8_t)((tail_value >> 21) | 0x80);
|
||||
target[3] = static_cast<uint8_t>((tail_value >> 21) | 0x80);
|
||||
/* fallthrough */
|
||||
case 3:
|
||||
target[2] = (uint8_t)((tail_value >> 14) | 0x80);
|
||||
target[2] = static_cast<uint8_t>((tail_value >> 14) | 0x80);
|
||||
/* fallthrough */
|
||||
case 2:
|
||||
target[1] = (uint8_t)((tail_value >> 7) | 0x80);
|
||||
target[1] = static_cast<uint8_t>((tail_value >> 7) | 0x80);
|
||||
/* fallthrough */
|
||||
case 1:
|
||||
target[0] = (uint8_t)((tail_value) | 0x80);
|
||||
target[0] = static_cast<uint8_t>((tail_value) | 0x80);
|
||||
}
|
||||
target[tail_length - 1] &= 0x7f;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,8 +83,8 @@ static void maybe_initiate_ping(grpc_chttp2_transport* t) {
|
|||
"%s: Ping delayed [%p]: not enough time elapsed since last ping. "
|
||||
" Last ping %f: Next ping %f: Now %f",
|
||||
t->is_client ? "CLIENT" : "SERVER", t->peer_string,
|
||||
(double)t->ping_state.last_ping_sent_time,
|
||||
(double)next_allowed_ping, (double)now);
|
||||
static_cast<double>(t->ping_state.last_ping_sent_time),
|
||||
static_cast<double>(next_allowed_ping), static_cast<double>(now));
|
||||
}
|
||||
if (!t->ping_state.is_delayed_ping_timer_set) {
|
||||
t->ping_state.is_delayed_ping_timer_set = true;
|
||||
|
|
@ -147,7 +147,7 @@ static void report_stall(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
|
|||
t->settings[GRPC_ACKED_SETTINGS]
|
||||
[GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE],
|
||||
t->flow_control->remote_window(),
|
||||
(uint32_t)GPR_MAX(
|
||||
static_cast<uint32_t>GPR_MAX(
|
||||
0,
|
||||
s->flow_control->remote_window_delta() +
|
||||
(int64_t)t->settings[GRPC_PEER_SETTINGS]
|
||||
|
|
@ -310,14 +310,14 @@ class DataSendContext {
|
|||
sending_bytes_before_(s_->sending_bytes) {}
|
||||
|
||||
uint32_t stream_remote_window() const {
|
||||
return (uint32_t)GPR_MAX(
|
||||
return static_cast<uint32_t>GPR_MAX(
|
||||
0, s_->flow_control->remote_window_delta() +
|
||||
(int64_t)t_->settings[GRPC_PEER_SETTINGS]
|
||||
[GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]);
|
||||
}
|
||||
|
||||
uint32_t max_outgoing() const {
|
||||
return (uint32_t)GPR_MIN(
|
||||
return static_cast<uint32_t>GPR_MIN(
|
||||
t_->settings[GRPC_PEER_SETTINGS][GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE],
|
||||
GPR_MIN(stream_remote_window(), t_->flow_control->remote_window()));
|
||||
}
|
||||
|
|
@ -326,7 +326,7 @@ class DataSendContext {
|
|||
|
||||
void FlushCompressedBytes() {
|
||||
uint32_t send_bytes =
|
||||
(uint32_t)GPR_MIN(max_outgoing(), s_->compressed_data_buffer.length);
|
||||
static_cast<uint32_t>GPR_MIN(max_outgoing(), s_->compressed_data_buffer.length);
|
||||
bool is_last_data_frame =
|
||||
(send_bytes == s_->compressed_data_buffer.length &&
|
||||
s_->flow_controlled_buffer.length == 0 &&
|
||||
|
|
@ -376,7 +376,7 @@ class DataSendContext {
|
|||
|
||||
void CallCallbacks() {
|
||||
if (update_list(t_, s_,
|
||||
(int64_t)(s_->sending_bytes - sending_bytes_before_),
|
||||
static_cast<int64_t>(s_->sending_bytes - sending_bytes_before_),
|
||||
&s_->on_flow_controlled_cbs,
|
||||
&s_->flow_controlled_bytes_flowed, GRPC_ERROR_NONE)) {
|
||||
write_context_->NoteScheduledResults();
|
||||
|
|
@ -624,7 +624,7 @@ void grpc_chttp2_end_write(grpc_chttp2_transport* t, grpc_error* error) {
|
|||
|
||||
while (grpc_chttp2_list_pop_writing_stream(t, &s)) {
|
||||
if (s->sending_bytes != 0) {
|
||||
update_list(t, s, (int64_t)s->sending_bytes, &s->on_write_finished_cbs,
|
||||
update_list(t, s, static_cast<int64_t>(s->sending_bytes), &s->on_write_finished_cbs,
|
||||
&s->flow_controlled_bytes_written, GRPC_ERROR_REF(error));
|
||||
s->sending_bytes = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -284,7 +284,7 @@ static void maybe_flush_read(stream_obj* s) {
|
|||
CRONET_LOG(GPR_DEBUG, "%p: Flush read", s);
|
||||
s->state.flush_read = true;
|
||||
null_and_maybe_free_read_buffer(s);
|
||||
s->state.rs.read_buffer = (char*)gpr_malloc(GRPC_FLUSH_READ_SIZE);
|
||||
s->state.rs.read_buffer = static_cast<char*>(gpr_malloc(GRPC_FLUSH_READ_SIZE));
|
||||
if (!s->state.pending_read_from_cronet) {
|
||||
CRONET_LOG(GPR_DEBUG, "bidirectional_stream_read(%p)", s->cbs);
|
||||
bidirectional_stream_read(s->cbs, s->state.rs.read_buffer,
|
||||
|
|
@ -310,7 +310,7 @@ static void add_to_storage(struct stream_obj* s,
|
|||
/* add new op at the beginning of the linked list. The memory is freed
|
||||
in remove_from_storage */
|
||||
struct op_and_state* new_op =
|
||||
(struct op_and_state*)gpr_malloc(sizeof(struct op_and_state));
|
||||
static_cast<struct op_and_state*>(gpr_malloc(sizeof(struct op_and_state)));
|
||||
memcpy(&new_op->op, op, sizeof(grpc_transport_stream_op_batch));
|
||||
memset(&new_op->state, 0, sizeof(new_op->state));
|
||||
new_op->s = s;
|
||||
|
|
@ -399,7 +399,7 @@ static void on_failed(bidirectional_stream* stream, int net_error) {
|
|||
gpr_log(GPR_ERROR, "on_failed(%p, %d)", stream, net_error);
|
||||
grpc_core::ExecCtx exec_ctx;
|
||||
|
||||
stream_obj* s = (stream_obj*)stream->annotation;
|
||||
stream_obj* s = static_cast<stream_obj*>(stream->annotation);
|
||||
gpr_mu_lock(&s->mu);
|
||||
bidirectional_stream_destroy(s->cbs);
|
||||
s->state.state_callback_received[OP_FAILED] = true;
|
||||
|
|
@ -425,7 +425,7 @@ static void on_canceled(bidirectional_stream* stream) {
|
|||
CRONET_LOG(GPR_DEBUG, "on_canceled(%p)", stream);
|
||||
grpc_core::ExecCtx exec_ctx;
|
||||
|
||||
stream_obj* s = (stream_obj*)stream->annotation;
|
||||
stream_obj* s = static_cast<stream_obj*>(stream->annotation);
|
||||
gpr_mu_lock(&s->mu);
|
||||
bidirectional_stream_destroy(s->cbs);
|
||||
s->state.state_callback_received[OP_CANCELED] = true;
|
||||
|
|
@ -451,7 +451,7 @@ static void on_succeeded(bidirectional_stream* stream) {
|
|||
CRONET_LOG(GPR_DEBUG, "on_succeeded(%p)", stream);
|
||||
grpc_core::ExecCtx exec_ctx;
|
||||
|
||||
stream_obj* s = (stream_obj*)stream->annotation;
|
||||
stream_obj* s = static_cast<stream_obj*>(stream->annotation);
|
||||
gpr_mu_lock(&s->mu);
|
||||
bidirectional_stream_destroy(s->cbs);
|
||||
s->state.state_callback_received[OP_SUCCEEDED] = true;
|
||||
|
|
@ -468,8 +468,8 @@ static void on_succeeded(bidirectional_stream* stream) {
|
|||
static void on_stream_ready(bidirectional_stream* stream) {
|
||||
CRONET_LOG(GPR_DEBUG, "W: on_stream_ready(%p)", stream);
|
||||
grpc_core::ExecCtx exec_ctx;
|
||||
stream_obj* s = (stream_obj*)stream->annotation;
|
||||
grpc_cronet_transport* t = (grpc_cronet_transport*)s->curr_ct;
|
||||
stream_obj* s = static_cast<stream_obj*>(stream->annotation);
|
||||
grpc_cronet_transport* t = s->curr_ct;
|
||||
gpr_mu_lock(&s->mu);
|
||||
s->state.state_op_done[OP_SEND_INITIAL_METADATA] = true;
|
||||
s->state.state_callback_received[OP_SEND_INITIAL_METADATA] = true;
|
||||
|
|
@ -500,7 +500,7 @@ static void on_response_headers_received(
|
|||
grpc_core::ExecCtx exec_ctx;
|
||||
CRONET_LOG(GPR_DEBUG, "R: on_response_headers_received(%p, %p, %s)", stream,
|
||||
headers, negotiated_protocol);
|
||||
stream_obj* s = (stream_obj*)stream->annotation;
|
||||
stream_obj* s = static_cast<stream_obj*>(stream->annotation);
|
||||
|
||||
/* Identify if this is a header or a trailer (in a trailer-only response case)
|
||||
*/
|
||||
|
|
@ -550,7 +550,7 @@ static void on_response_headers_received(
|
|||
*/
|
||||
static void on_write_completed(bidirectional_stream* stream, const char* data) {
|
||||
grpc_core::ExecCtx exec_ctx;
|
||||
stream_obj* s = (stream_obj*)stream->annotation;
|
||||
stream_obj* s = static_cast<stream_obj*>(stream->annotation);
|
||||
CRONET_LOG(GPR_DEBUG, "W: on_write_completed(%p, %s)", stream, data);
|
||||
gpr_mu_lock(&s->mu);
|
||||
if (s->state.ws.write_buffer) {
|
||||
|
|
@ -568,7 +568,7 @@ static void on_write_completed(bidirectional_stream* stream, const char* data) {
|
|||
static void on_read_completed(bidirectional_stream* stream, char* data,
|
||||
int count) {
|
||||
grpc_core::ExecCtx exec_ctx;
|
||||
stream_obj* s = (stream_obj*)stream->annotation;
|
||||
stream_obj* s = static_cast<stream_obj*>(stream->annotation);
|
||||
CRONET_LOG(GPR_DEBUG, "R: on_read_completed(%p, %p, %d)", stream, data,
|
||||
count);
|
||||
gpr_mu_lock(&s->mu);
|
||||
|
|
@ -612,8 +612,8 @@ static void on_response_trailers_received(
|
|||
grpc_core::ExecCtx exec_ctx;
|
||||
CRONET_LOG(GPR_DEBUG, "R: on_response_trailers_received(%p,%p)", stream,
|
||||
trailers);
|
||||
stream_obj* s = (stream_obj*)stream->annotation;
|
||||
grpc_cronet_transport* t = (grpc_cronet_transport*)s->curr_ct;
|
||||
stream_obj* s = static_cast<stream_obj*>(stream->annotation);
|
||||
grpc_cronet_transport* t = s->curr_ct;
|
||||
gpr_mu_lock(&s->mu);
|
||||
memset(&s->state.rs.trailing_metadata, 0,
|
||||
sizeof(s->state.rs.trailing_metadata));
|
||||
|
|
@ -671,17 +671,17 @@ static void create_grpc_frame(grpc_slice_buffer* write_slice_buffer,
|
|||
size_t length = GRPC_SLICE_LENGTH(slice);
|
||||
*p_write_buffer_size = length + GRPC_HEADER_SIZE_IN_BYTES;
|
||||
/* This is freed in the on_write_completed callback */
|
||||
char* write_buffer = (char*)gpr_malloc(length + GRPC_HEADER_SIZE_IN_BYTES);
|
||||
char* write_buffer = static_cast<char*>(gpr_malloc(length + GRPC_HEADER_SIZE_IN_BYTES));
|
||||
*pp_write_buffer = write_buffer;
|
||||
uint8_t* p = (uint8_t*)write_buffer;
|
||||
uint8_t* p = reinterpret_cast<uint8_t*>(write_buffer);
|
||||
/* Append 5 byte header */
|
||||
/* Compressed flag */
|
||||
*p++ = (uint8_t)((flags & GRPC_WRITE_INTERNAL_COMPRESS) ? 1 : 0);
|
||||
*p++ = static_cast<uint8_t>((flags & GRPC_WRITE_INTERNAL_COMPRESS) ? 1 : 0);
|
||||
/* Message length */
|
||||
*p++ = (uint8_t)(length >> 24);
|
||||
*p++ = (uint8_t)(length >> 16);
|
||||
*p++ = (uint8_t)(length >> 8);
|
||||
*p++ = (uint8_t)(length);
|
||||
*p++ = static_cast<uint8_t>(length >> 24);
|
||||
*p++ = static_cast<uint8_t>(length >> 16);
|
||||
*p++ = static_cast<uint8_t>(length >> 8);
|
||||
*p++ = static_cast<uint8_t>(length);
|
||||
/* append actual data */
|
||||
memcpy(p, GRPC_SLICE_START_PTR(slice), length);
|
||||
grpc_slice_unref_internal(slice);
|
||||
|
|
@ -704,8 +704,8 @@ static void convert_metadata_to_cronet_headers(
|
|||
/* Allocate enough memory. It is freed in the on_stream_ready callback
|
||||
*/
|
||||
bidirectional_stream_header* headers =
|
||||
(bidirectional_stream_header*)gpr_malloc(
|
||||
sizeof(bidirectional_stream_header) * num_headers_available);
|
||||
static_cast<bidirectional_stream_header*>(gpr_malloc(
|
||||
sizeof(bidirectional_stream_header) * num_headers_available));
|
||||
*pp_headers = headers;
|
||||
|
||||
/* Walk the linked list again, this time copying the header fields.
|
||||
|
|
@ -753,7 +753,7 @@ static void convert_metadata_to_cronet_headers(
|
|||
break;
|
||||
}
|
||||
}
|
||||
*p_num_headers = (size_t)num_headers;
|
||||
*p_num_headers = num_headers;
|
||||
}
|
||||
|
||||
static void parse_grpc_header(const uint8_t* data, int* length,
|
||||
|
|
@ -762,10 +762,10 @@ static void parse_grpc_header(const uint8_t* data, int* length,
|
|||
const uint8_t* p = data + 1;
|
||||
*compressed = ((c & 0x01) == 0x01);
|
||||
*length = 0;
|
||||
*length |= ((uint8_t)*p++) << 24;
|
||||
*length |= ((uint8_t)*p++) << 16;
|
||||
*length |= ((uint8_t)*p++) << 8;
|
||||
*length |= ((uint8_t)*p++);
|
||||
*length |= (*p++) << 24;
|
||||
*length |= (*p++) << 16;
|
||||
*length |= (*p++) << 8;
|
||||
*length |= (*p++);
|
||||
}
|
||||
|
||||
static bool header_has_authority(grpc_linked_mdelem* head) {
|
||||
|
|
@ -968,7 +968,7 @@ static bool op_can_be_run(grpc_transport_stream_op_batch* curr_op,
|
|||
static enum e_op_result execute_stream_op(struct op_and_state* oas) {
|
||||
grpc_transport_stream_op_batch* stream_op = &oas->op;
|
||||
struct stream_obj* s = oas->s;
|
||||
grpc_cronet_transport* t = (grpc_cronet_transport*)s->curr_ct;
|
||||
grpc_cronet_transport* t = s->curr_ct;
|
||||
struct op_state* stream_state = &s->state;
|
||||
enum e_op_result result = NO_ACTION_POSSIBLE;
|
||||
if (stream_op->send_initial_metadata &&
|
||||
|
|
@ -1050,7 +1050,7 @@ static enum e_op_result execute_stream_op(struct op_and_state* oas) {
|
|||
stream_state->ws.write_buffer);
|
||||
stream_state->state_callback_received[OP_SEND_MESSAGE] = false;
|
||||
bidirectional_stream_write(s->cbs, stream_state->ws.write_buffer,
|
||||
(int)write_buffer_size, false);
|
||||
static_cast<int>(write_buffer_size), false);
|
||||
grpc_slice_buffer_destroy_internal(&write_slice_buffer);
|
||||
if (t->use_packet_coalescing) {
|
||||
if (!stream_op->send_trailing_metadata) {
|
||||
|
|
@ -1151,14 +1151,14 @@ static enum e_op_result execute_stream_op(struct op_and_state* oas) {
|
|||
stream_state->rs.remaining_bytes == 0) {
|
||||
/* Start a read operation for data */
|
||||
stream_state->rs.length_field_received = true;
|
||||
parse_grpc_header((const uint8_t*)stream_state->rs.read_buffer,
|
||||
parse_grpc_header(reinterpret_cast<const uint8_t*>(stream_state->rs.read_buffer),
|
||||
&stream_state->rs.length_field,
|
||||
&stream_state->rs.compressed);
|
||||
CRONET_LOG(GPR_DEBUG, "length field = %d",
|
||||
stream_state->rs.length_field);
|
||||
if (stream_state->rs.length_field > 0) {
|
||||
stream_state->rs.read_buffer =
|
||||
(char*)gpr_malloc((size_t)stream_state->rs.length_field);
|
||||
static_cast<char*>(gpr_malloc(static_cast<size_t>(stream_state->rs.length_field)));
|
||||
GPR_ASSERT(stream_state->rs.read_buffer);
|
||||
stream_state->rs.remaining_bytes = stream_state->rs.length_field;
|
||||
stream_state->rs.received_bytes = 0;
|
||||
|
|
@ -1181,8 +1181,8 @@ static enum e_op_result execute_stream_op(struct op_and_state* oas) {
|
|||
if (stream_state->rs.compressed) {
|
||||
stream_state->rs.sbs.base.flags |= GRPC_WRITE_INTERNAL_COMPRESS;
|
||||
}
|
||||
*((grpc_byte_buffer**)stream_op->payload->recv_message.recv_message) =
|
||||
(grpc_byte_buffer*)&stream_state->rs.sbs;
|
||||
*(reinterpret_cast<grpc_byte_buffer**>(stream_op->payload->recv_message.recv_message)) =
|
||||
reinterpret_cast<grpc_byte_buffer*>(&stream_state->rs.sbs);
|
||||
GRPC_CLOSURE_SCHED(
|
||||
stream_op->payload->recv_message.recv_message_ready,
|
||||
GRPC_ERROR_NONE);
|
||||
|
|
@ -1225,7 +1225,7 @@ static enum e_op_result execute_stream_op(struct op_and_state* oas) {
|
|||
GRPC_SLICE_MALLOC((uint32_t)stream_state->rs.length_field);
|
||||
uint8_t* dst_p = GRPC_SLICE_START_PTR(read_data_slice);
|
||||
memcpy(dst_p, stream_state->rs.read_buffer,
|
||||
(size_t)stream_state->rs.length_field);
|
||||
static_cast<size_t>(stream_state->rs.length_field));
|
||||
null_and_maybe_free_read_buffer(s);
|
||||
/* Clean up read_slice_buffer in case there is unread data. */
|
||||
grpc_slice_buffer_destroy_internal(&stream_state->rs.read_slice_buffer);
|
||||
|
|
@ -1237,8 +1237,8 @@ static enum e_op_result execute_stream_op(struct op_and_state* oas) {
|
|||
if (stream_state->rs.compressed) {
|
||||
stream_state->rs.sbs.base.flags = GRPC_WRITE_INTERNAL_COMPRESS;
|
||||
}
|
||||
*((grpc_byte_buffer**)stream_op->payload->recv_message.recv_message) =
|
||||
(grpc_byte_buffer*)&stream_state->rs.sbs;
|
||||
*(reinterpret_cast<grpc_byte_buffer**>(stream_op->payload->recv_message.recv_message)) =
|
||||
reinterpret_cast<grpc_byte_buffer*>(&stream_state->rs.sbs);
|
||||
GRPC_CLOSURE_SCHED(stream_op->payload->recv_message.recv_message_ready,
|
||||
GRPC_ERROR_NONE);
|
||||
stream_state->state_op_done[OP_RECV_MESSAGE] = true;
|
||||
|
|
@ -1325,7 +1325,7 @@ static enum e_op_result execute_stream_op(struct op_and_state* oas) {
|
|||
static int init_stream(grpc_transport* gt, grpc_stream* gs,
|
||||
grpc_stream_refcount* refcount, const void* server_data,
|
||||
gpr_arena* arena) {
|
||||
stream_obj* s = (stream_obj*)gs;
|
||||
stream_obj* s = reinterpret_cast<stream_obj*>(gs);
|
||||
|
||||
s->refcount = refcount;
|
||||
GRPC_CRONET_STREAM_REF(s, "cronet transport");
|
||||
|
|
@ -1348,7 +1348,7 @@ static int init_stream(grpc_transport* gt, grpc_stream* gs,
|
|||
s->state.pending_read_from_cronet = false;
|
||||
|
||||
s->curr_gs = gs;
|
||||
s->curr_ct = (grpc_cronet_transport*)gt;
|
||||
s->curr_ct = reinterpret_cast<grpc_cronet_transport*>(gt);
|
||||
s->arena = arena;
|
||||
|
||||
gpr_mu_init(&s->mu);
|
||||
|
|
@ -1381,14 +1381,14 @@ static void perform_stream_op(grpc_transport* gt, grpc_stream* gs,
|
|||
GRPC_CLOSURE_SCHED(op->on_complete, GRPC_ERROR_CANCELLED);
|
||||
return;
|
||||
}
|
||||
stream_obj* s = (stream_obj*)gs;
|
||||
stream_obj* s = reinterpret_cast<stream_obj*>(gs);
|
||||
add_to_storage(s, op);
|
||||
execute_from_storage(s);
|
||||
}
|
||||
|
||||
static void destroy_stream(grpc_transport* gt, grpc_stream* gs,
|
||||
grpc_closure* then_schedule_closure) {
|
||||
stream_obj* s = (stream_obj*)gs;
|
||||
stream_obj* s = reinterpret_cast<stream_obj*>(gs);
|
||||
null_and_maybe_free_read_buffer(s);
|
||||
/* Clean up read_slice_buffer in case there is unread data. */
|
||||
grpc_slice_buffer_destroy_internal(&s->state.rs.read_slice_buffer);
|
||||
|
|
@ -1418,13 +1418,13 @@ grpc_transport* grpc_create_cronet_transport(void* engine, const char* target,
|
|||
const grpc_channel_args* args,
|
||||
void* reserved) {
|
||||
grpc_cronet_transport* ct =
|
||||
(grpc_cronet_transport*)gpr_malloc(sizeof(grpc_cronet_transport));
|
||||
static_cast<grpc_cronet_transport*>(gpr_malloc(sizeof(grpc_cronet_transport)));
|
||||
if (!ct) {
|
||||
goto error;
|
||||
}
|
||||
ct->base.vtable = &grpc_cronet_vtable;
|
||||
ct->engine = (stream_engine*)engine;
|
||||
ct->host = (char*)gpr_malloc(strlen(target) + 1);
|
||||
ct->engine = static_cast<stream_engine*>(engine);
|
||||
ct->host = static_cast<char*>(gpr_malloc(strlen(target) + 1));
|
||||
if (!ct->host) {
|
||||
goto error;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ static grpc_error* fill_in_metadata(inproc_stream* s,
|
|||
for (grpc_linked_mdelem* elem = metadata->list.head;
|
||||
(elem != nullptr) && (error == GRPC_ERROR_NONE); elem = elem->next) {
|
||||
grpc_linked_mdelem* nelem =
|
||||
(grpc_linked_mdelem*)gpr_arena_alloc(s->arena, sizeof(*nelem));
|
||||
static_cast<grpc_linked_mdelem*>(gpr_arena_alloc(s->arena, sizeof(*nelem)));
|
||||
nelem->md =
|
||||
grpc_mdelem_from_slices(grpc_slice_intern(GRPC_MDKEY(elem->md)),
|
||||
grpc_slice_intern(GRPC_MDVALUE(elem->md)));
|
||||
|
|
@ -223,8 +223,8 @@ static int init_stream(grpc_transport* gt, grpc_stream* gs,
|
|||
grpc_stream_refcount* refcount, const void* server_data,
|
||||
gpr_arena* arena) {
|
||||
INPROC_LOG(GPR_DEBUG, "init_stream %p %p %p", gt, gs, server_data);
|
||||
inproc_transport* t = (inproc_transport*)gt;
|
||||
inproc_stream* s = (inproc_stream*)gs;
|
||||
inproc_transport* t = reinterpret_cast<inproc_transport*>(gt);
|
||||
inproc_stream* s = reinterpret_cast<inproc_stream*>(gs);
|
||||
s->arena = arena;
|
||||
|
||||
s->refs = refcount;
|
||||
|
|
@ -368,11 +368,11 @@ static void close_other_side_locked(inproc_stream* s, const char* reason) {
|
|||
static void complete_if_batch_end_locked(inproc_stream* s, grpc_error* error,
|
||||
grpc_transport_stream_op_batch* op,
|
||||
const char* msg) {
|
||||
int is_sm = (int)(op == s->send_message_op);
|
||||
int is_stm = (int)(op == s->send_trailing_md_op);
|
||||
int is_rim = (int)(op == s->recv_initial_md_op);
|
||||
int is_rm = (int)(op == s->recv_message_op);
|
||||
int is_rtm = (int)(op == s->recv_trailing_md_op);
|
||||
int is_sm = static_cast<int>(op == s->send_message_op);
|
||||
int is_stm = static_cast<int>(op == s->send_trailing_md_op);
|
||||
int is_rim = static_cast<int>(op == s->recv_initial_md_op);
|
||||
int is_rm = static_cast<int>(op == s->recv_message_op);
|
||||
int is_rtm = static_cast<int>(op == s->recv_trailing_md_op);
|
||||
|
||||
if ((is_sm + is_stm + is_rim + is_rm + is_rtm) == 1) {
|
||||
INPROC_LOG(GPR_DEBUG, "%s %p %p %p", msg, s, op, error);
|
||||
|
|
@ -426,12 +426,12 @@ static void fail_helper_locked(inproc_stream* s, grpc_error* error) {
|
|||
grpc_metadata_batch fake_md;
|
||||
grpc_metadata_batch_init(&fake_md);
|
||||
grpc_linked_mdelem* path_md =
|
||||
(grpc_linked_mdelem*)gpr_arena_alloc(s->arena, sizeof(*path_md));
|
||||
static_cast<grpc_linked_mdelem*>(gpr_arena_alloc(s->arena, sizeof(*path_md)));
|
||||
path_md->md = grpc_mdelem_from_slices(g_fake_path_key, g_fake_path_value);
|
||||
GPR_ASSERT(grpc_metadata_batch_link_tail(&fake_md, path_md) ==
|
||||
GRPC_ERROR_NONE);
|
||||
grpc_linked_mdelem* auth_md =
|
||||
(grpc_linked_mdelem*)gpr_arena_alloc(s->arena, sizeof(*auth_md));
|
||||
static_cast<grpc_linked_mdelem*>(gpr_arena_alloc(s->arena, sizeof(*auth_md)));
|
||||
auth_md->md = grpc_mdelem_from_slices(g_fake_auth_key, g_fake_auth_value);
|
||||
GPR_ASSERT(grpc_metadata_batch_link_tail(&fake_md, auth_md) ==
|
||||
GRPC_ERROR_NONE);
|
||||
|
|
@ -566,7 +566,7 @@ static void op_state_machine(void* arg, grpc_error* error) {
|
|||
bool needs_close = false;
|
||||
|
||||
INPROC_LOG(GPR_DEBUG, "op_state_machine %p", arg);
|
||||
inproc_stream* s = (inproc_stream*)arg;
|
||||
inproc_stream* s = static_cast<inproc_stream*>(arg);
|
||||
gpr_mu* mu = &s->t->mu->mu; // keep aside in case s gets closed
|
||||
gpr_mu_lock(mu);
|
||||
s->op_closure_scheduled = false;
|
||||
|
|
@ -863,7 +863,7 @@ static bool cancel_stream_locked(inproc_stream* s, grpc_error* error) {
|
|||
static void perform_stream_op(grpc_transport* gt, grpc_stream* gs,
|
||||
grpc_transport_stream_op_batch* op) {
|
||||
INPROC_LOG(GPR_DEBUG, "perform_stream_op %p %p %p", gt, gs, op);
|
||||
inproc_stream* s = (inproc_stream*)gs;
|
||||
inproc_stream* s = reinterpret_cast<inproc_stream*>(gs);
|
||||
gpr_mu* mu = &s->t->mu->mu; // save aside in case s gets closed
|
||||
gpr_mu_lock(mu);
|
||||
|
||||
|
|
@ -1047,7 +1047,7 @@ static void close_transport_locked(inproc_transport* t) {
|
|||
}
|
||||
|
||||
static void perform_transport_op(grpc_transport* gt, grpc_transport_op* op) {
|
||||
inproc_transport* t = (inproc_transport*)gt;
|
||||
inproc_transport* t = reinterpret_cast<inproc_transport*>(gt);
|
||||
INPROC_LOG(GPR_DEBUG, "perform_transport_op %p %p", t, op);
|
||||
gpr_mu_lock(&t->mu->mu);
|
||||
if (op->on_connectivity_state_change) {
|
||||
|
|
@ -1082,13 +1082,13 @@ static void perform_transport_op(grpc_transport* gt, grpc_transport_op* op) {
|
|||
static void destroy_stream(grpc_transport* gt, grpc_stream* gs,
|
||||
grpc_closure* then_schedule_closure) {
|
||||
INPROC_LOG(GPR_DEBUG, "destroy_stream %p %p", gs, then_schedule_closure);
|
||||
inproc_stream* s = (inproc_stream*)gs;
|
||||
inproc_stream* s = reinterpret_cast<inproc_stream*>(gs);
|
||||
s->closure_at_destroy = then_schedule_closure;
|
||||
really_destroy_stream(s);
|
||||
}
|
||||
|
||||
static void destroy_transport(grpc_transport* gt) {
|
||||
inproc_transport* t = (inproc_transport*)gt;
|
||||
inproc_transport* t = reinterpret_cast<inproc_transport*>(gt);
|
||||
INPROC_LOG(GPR_DEBUG, "destroy_transport %p", t);
|
||||
gpr_mu_lock(&t->mu->mu);
|
||||
close_transport_locked(t);
|
||||
|
|
@ -1151,10 +1151,10 @@ static void inproc_transports_create(grpc_transport** server_transport,
|
|||
grpc_transport** client_transport,
|
||||
const grpc_channel_args* client_args) {
|
||||
INPROC_LOG(GPR_DEBUG, "inproc_transports_create");
|
||||
inproc_transport* st = (inproc_transport*)gpr_zalloc(sizeof(*st));
|
||||
inproc_transport* ct = (inproc_transport*)gpr_zalloc(sizeof(*ct));
|
||||
inproc_transport* st = static_cast<inproc_transport*>(gpr_zalloc(sizeof(*st)));
|
||||
inproc_transport* ct = static_cast<inproc_transport*>(gpr_zalloc(sizeof(*ct)));
|
||||
// Share one lock between both sides since both sides get affected
|
||||
st->mu = ct->mu = (shared_mu*)gpr_malloc(sizeof(*st->mu));
|
||||
st->mu = ct->mu = static_cast<shared_mu*>(gpr_malloc(sizeof(*st->mu)));
|
||||
gpr_mu_init(&st->mu->mu);
|
||||
gpr_ref_init(&st->mu->refs, 2);
|
||||
st->base.vtable = &inproc_vtable;
|
||||
|
|
@ -1173,8 +1173,8 @@ static void inproc_transports_create(grpc_transport** server_transport,
|
|||
ct->other_side = st;
|
||||
st->stream_list = nullptr;
|
||||
ct->stream_list = nullptr;
|
||||
*server_transport = (grpc_transport*)st;
|
||||
*client_transport = (grpc_transport*)ct;
|
||||
*server_transport = reinterpret_cast<grpc_transport*>(st);
|
||||
*client_transport = reinterpret_cast<grpc_transport*>(ct);
|
||||
}
|
||||
|
||||
grpc_channel* grpc_inproc_channel_create(grpc_server* server,
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ static grpc_avl_node* assert_invariants(grpc_avl_node* n) { return n; }
|
|||
|
||||
grpc_avl_node* new_node(void* key, void* value, grpc_avl_node* left,
|
||||
grpc_avl_node* right) {
|
||||
grpc_avl_node* node = (grpc_avl_node*)gpr_malloc(sizeof(*node));
|
||||
grpc_avl_node* node = static_cast<grpc_avl_node*>(gpr_malloc(sizeof(*node)));
|
||||
gpr_ref_init(&node->refs, 1);
|
||||
node->key = key;
|
||||
node->value = value;
|
||||
|
|
|
|||
|
|
@ -56,12 +56,12 @@ grpc_millis BackOff::NextAttemptTime() {
|
|||
return current_backoff_ + grpc_core::ExecCtx::Get()->Now();
|
||||
}
|
||||
current_backoff_ =
|
||||
(grpc_millis)(std::min(current_backoff_ * options_.multiplier(),
|
||||
(double)options_.max_backoff()));
|
||||
static_cast<grpc_millis>(std::min(current_backoff_ * options_.multiplier(),
|
||||
static_cast<double>(options_.max_backoff())));
|
||||
const double jitter = generate_uniform_random_number_between(
|
||||
&rng_state_, -options_.jitter() * current_backoff_,
|
||||
options_.jitter() * current_backoff_);
|
||||
const grpc_millis next_timeout = (grpc_millis)(current_backoff_ + jitter);
|
||||
const grpc_millis next_timeout = static_cast<grpc_millis>(current_backoff_ + jitter);
|
||||
return next_timeout + grpc_core::ExecCtx::Get()->Now();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -87,13 +87,13 @@ grpc_channel_args* grpc_channel_args_copy_and_add_and_remove(
|
|||
}
|
||||
// Create result.
|
||||
grpc_channel_args* dst =
|
||||
(grpc_channel_args*)gpr_malloc(sizeof(grpc_channel_args));
|
||||
static_cast<grpc_channel_args*>(gpr_malloc(sizeof(grpc_channel_args)));
|
||||
dst->num_args = num_args_to_copy + num_to_add;
|
||||
if (dst->num_args == 0) {
|
||||
dst->args = nullptr;
|
||||
return dst;
|
||||
}
|
||||
dst->args = (grpc_arg*)gpr_malloc(sizeof(grpc_arg) * dst->num_args);
|
||||
dst->args = static_cast<grpc_arg*>(gpr_malloc(sizeof(grpc_arg) * dst->num_args));
|
||||
// Copy args from src that are not being removed.
|
||||
size_t dst_idx = 0;
|
||||
if (src != nullptr) {
|
||||
|
|
@ -118,7 +118,7 @@ grpc_channel_args* grpc_channel_args_copy(const grpc_channel_args* src) {
|
|||
grpc_channel_args* grpc_channel_args_union(const grpc_channel_args* a,
|
||||
const grpc_channel_args* b) {
|
||||
const size_t max_out = (a->num_args + b->num_args);
|
||||
grpc_arg* uniques = (grpc_arg*)gpr_malloc(sizeof(*uniques) * max_out);
|
||||
grpc_arg* uniques = static_cast<grpc_arg*>(gpr_malloc(sizeof(*uniques) * max_out));
|
||||
for (size_t i = 0; i < a->num_args; ++i) uniques[i] = a->args[i];
|
||||
|
||||
size_t uniques_idx = a->num_args;
|
||||
|
|
@ -161,15 +161,15 @@ static int cmp_arg(const grpc_arg* a, const grpc_arg* b) {
|
|||
/* stabilizing comparison function: since channel_args ordering matters for
|
||||
* keys with the same name, we need to preserve that ordering */
|
||||
static int cmp_key_stable(const void* ap, const void* bp) {
|
||||
const grpc_arg* const* a = (const grpc_arg* const*)ap;
|
||||
const grpc_arg* const* b = (const grpc_arg* const*)bp;
|
||||
const grpc_arg* const* a = static_cast<const grpc_arg* const*>(ap);
|
||||
const grpc_arg* const* b = static_cast<const grpc_arg* const*>(bp);
|
||||
int c = strcmp((*a)->key, (*b)->key);
|
||||
if (c == 0) c = GPR_ICMP(*a, *b);
|
||||
return c;
|
||||
}
|
||||
|
||||
grpc_channel_args* grpc_channel_args_normalize(const grpc_channel_args* a) {
|
||||
grpc_arg** args = (grpc_arg**)gpr_malloc(sizeof(grpc_arg*) * a->num_args);
|
||||
grpc_arg** args = static_cast<grpc_arg**>(gpr_malloc(sizeof(grpc_arg*) * a->num_args));
|
||||
for (size_t i = 0; i < a->num_args; i++) {
|
||||
args[i] = &a->args[i];
|
||||
}
|
||||
|
|
@ -177,9 +177,9 @@ grpc_channel_args* grpc_channel_args_normalize(const grpc_channel_args* a) {
|
|||
qsort(args, a->num_args, sizeof(grpc_arg*), cmp_key_stable);
|
||||
|
||||
grpc_channel_args* b =
|
||||
(grpc_channel_args*)gpr_malloc(sizeof(grpc_channel_args));
|
||||
static_cast<grpc_channel_args*>(gpr_malloc(sizeof(grpc_channel_args)));
|
||||
b->num_args = a->num_args;
|
||||
b->args = (grpc_arg*)gpr_malloc(sizeof(grpc_arg) * b->num_args);
|
||||
b->args = static_cast<grpc_arg*>(gpr_malloc(sizeof(grpc_arg) * b->num_args));
|
||||
for (size_t i = 0; i < a->num_args; i++) {
|
||||
b->args[i] = copy_arg(args[i]);
|
||||
}
|
||||
|
|
@ -215,7 +215,7 @@ grpc_compression_algorithm grpc_channel_args_get_compression_algorithm(
|
|||
for (i = 0; i < a->num_args; ++i) {
|
||||
if (a->args[i].type == GRPC_ARG_INTEGER &&
|
||||
!strcmp(GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM, a->args[i].key)) {
|
||||
return (grpc_compression_algorithm)a->args[i].value.integer;
|
||||
return static_cast<grpc_compression_algorithm>(a->args[i].value.integer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -296,7 +296,7 @@ uint32_t grpc_channel_args_compression_algorithm_get_states(
|
|||
const grpc_channel_args* a) {
|
||||
int* states_arg;
|
||||
if (find_compression_algorithm_states_bitset(a, &states_arg)) {
|
||||
return (uint32_t)*states_arg;
|
||||
return static_cast<uint32_t>(*states_arg);
|
||||
} else {
|
||||
return (1u << GRPC_COMPRESS_ALGORITHMS_COUNT) - 1; /* All algs. enabled */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ grpc_error* grpc_channel_stack_init(
|
|||
GRPC_STREAM_REF_INIT(&stack->refcount, initial_refs, destroy, destroy_arg,
|
||||
name);
|
||||
elems = CHANNEL_ELEMS_FROM_STACK(stack);
|
||||
user_data = ((char*)elems) + ROUND_UP_TO_ALIGNMENT_SIZE(
|
||||
user_data = (reinterpret_cast<char*>(elems)) + ROUND_UP_TO_ALIGNMENT_SIZE(
|
||||
filter_count * sizeof(grpc_channel_element));
|
||||
|
||||
/* init per-filter data */
|
||||
|
|
@ -162,7 +162,7 @@ grpc_error* grpc_call_stack_init(grpc_channel_stack* channel_stack,
|
|||
GRPC_STREAM_REF_INIT(&elem_args->call_stack->refcount, initial_refs, destroy,
|
||||
destroy_arg, "CALL_STACK");
|
||||
call_elems = CALL_ELEMS_FROM_STACK(elem_args->call_stack);
|
||||
user_data = ((char*)call_elems) +
|
||||
user_data = (reinterpret_cast<char*>(call_elems)) +
|
||||
ROUND_UP_TO_ALIGNMENT_SIZE(count * sizeof(grpc_call_element));
|
||||
|
||||
/* init per-filter data */
|
||||
|
|
@ -194,7 +194,7 @@ void grpc_call_stack_set_pollset_or_pollset_set(grpc_call_stack* call_stack,
|
|||
size_t i;
|
||||
|
||||
call_elems = CALL_ELEMS_FROM_STACK(call_stack);
|
||||
user_data = ((char*)call_elems) +
|
||||
user_data = (reinterpret_cast<char*>(call_elems)) +
|
||||
ROUND_UP_TO_ALIGNMENT_SIZE(count * sizeof(grpc_call_element));
|
||||
|
||||
/* init per-filter data */
|
||||
|
|
@ -243,11 +243,11 @@ void grpc_channel_next_op(grpc_channel_element* elem, grpc_transport_op* op) {
|
|||
|
||||
grpc_channel_stack* grpc_channel_stack_from_top_element(
|
||||
grpc_channel_element* elem) {
|
||||
return (grpc_channel_stack*)((char*)(elem)-ROUND_UP_TO_ALIGNMENT_SIZE(
|
||||
return reinterpret_cast<grpc_channel_stack*>(reinterpret_cast<char*>(elem)-ROUND_UP_TO_ALIGNMENT_SIZE(
|
||||
sizeof(grpc_channel_stack)));
|
||||
}
|
||||
|
||||
grpc_call_stack* grpc_call_stack_from_top_element(grpc_call_element* elem) {
|
||||
return (grpc_call_stack*)((char*)(elem)-ROUND_UP_TO_ALIGNMENT_SIZE(
|
||||
return reinterpret_cast<grpc_call_stack*>(reinterpret_cast<char*>(elem)-ROUND_UP_TO_ALIGNMENT_SIZE(
|
||||
sizeof(grpc_call_stack)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ struct grpc_channel_stack_builder_iterator {
|
|||
|
||||
grpc_channel_stack_builder* grpc_channel_stack_builder_create(void) {
|
||||
grpc_channel_stack_builder* b =
|
||||
(grpc_channel_stack_builder*)gpr_zalloc(sizeof(*b));
|
||||
static_cast<grpc_channel_stack_builder*>(gpr_zalloc(sizeof(*b)));
|
||||
|
||||
b->begin.filter = nullptr;
|
||||
b->end.filter = nullptr;
|
||||
|
|
@ -78,7 +78,7 @@ const char* grpc_channel_stack_builder_get_target(
|
|||
static grpc_channel_stack_builder_iterator* create_iterator_at_filter_node(
|
||||
grpc_channel_stack_builder* builder, filter_node* node) {
|
||||
grpc_channel_stack_builder_iterator* it =
|
||||
(grpc_channel_stack_builder_iterator*)gpr_malloc(sizeof(*it));
|
||||
static_cast<grpc_channel_stack_builder_iterator*>(gpr_malloc(sizeof(*it)));
|
||||
it->builder = builder;
|
||||
it->node = node;
|
||||
return it;
|
||||
|
|
@ -213,7 +213,7 @@ bool grpc_channel_stack_builder_prepend_filter(
|
|||
static void add_after(filter_node* before, const grpc_channel_filter* filter,
|
||||
grpc_post_filter_create_init_func post_init_func,
|
||||
void* user_data) {
|
||||
filter_node* new_node = (filter_node*)gpr_malloc(sizeof(*new_node));
|
||||
filter_node* new_node = static_cast<filter_node*>(gpr_malloc(sizeof(*new_node)));
|
||||
new_node->next = before->next;
|
||||
new_node->prev = before;
|
||||
new_node->next->prev = new_node->prev->next = new_node;
|
||||
|
|
@ -265,7 +265,7 @@ grpc_error* grpc_channel_stack_builder_finish(
|
|||
|
||||
// create an array of filters
|
||||
const grpc_channel_filter** filters =
|
||||
(const grpc_channel_filter**)gpr_malloc(sizeof(*filters) * num_filters);
|
||||
static_cast<const grpc_channel_filter**>(gpr_malloc(sizeof(*filters) * num_filters));
|
||||
size_t i = 0;
|
||||
for (filter_node* p = builder->begin.next; p != &builder->end; p = p->next) {
|
||||
filters[i++] = p->filter;
|
||||
|
|
@ -278,7 +278,7 @@ grpc_error* grpc_channel_stack_builder_finish(
|
|||
*result = gpr_zalloc(prefix_bytes + channel_stack_size);
|
||||
// fetch a pointer to the channel stack
|
||||
grpc_channel_stack* channel_stack =
|
||||
(grpc_channel_stack*)((char*)(*result) + prefix_bytes);
|
||||
reinterpret_cast<grpc_channel_stack*>(static_cast<char*>(*result) + prefix_bytes);
|
||||
// and initialize it
|
||||
grpc_error* error = grpc_channel_stack_init(
|
||||
initial_refs, destroy, destroy_arg == nullptr ? *result : destroy_arg,
|
||||
|
|
@ -303,7 +303,7 @@ grpc_error* grpc_channel_stack_builder_finish(
|
|||
}
|
||||
|
||||
grpc_channel_stack_builder_destroy(builder);
|
||||
gpr_free((grpc_channel_filter**)filters);
|
||||
gpr_free(const_cast<grpc_channel_filter**>(filters));
|
||||
|
||||
return error;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ typedef struct connected_channel_call_data {
|
|||
} call_data;
|
||||
|
||||
static void run_in_call_combiner(void* arg, grpc_error* error) {
|
||||
callback_state* state = (callback_state*)arg;
|
||||
callback_state* state = static_cast<callback_state*>(arg);
|
||||
GRPC_CALL_COMBINER_START(state->call_combiner, state->original_closure,
|
||||
GRPC_ERROR_REF(error), state->reason);
|
||||
}
|
||||
|
|
@ -96,8 +96,8 @@ static callback_state* get_state_for_batch(
|
|||
into transport stream operations */
|
||||
static void con_start_transport_stream_op_batch(
|
||||
grpc_call_element* elem, grpc_transport_stream_op_batch* batch) {
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
if (batch->recv_initial_metadata) {
|
||||
callback_state* state = &calld->recv_initial_metadata_ready;
|
||||
intercept_callback(
|
||||
|
|
@ -115,7 +115,7 @@ static void con_start_transport_stream_op_batch(
|
|||
// calld->on_complete like we can for the other ops. However,
|
||||
// cancellation isn't in the fast path, so we just allocate a new
|
||||
// closure for each one.
|
||||
callback_state* state = (callback_state*)gpr_malloc(sizeof(*state));
|
||||
callback_state* state = static_cast<callback_state*>(gpr_malloc(sizeof(*state)));
|
||||
intercept_callback(calld, state, true, "on_complete (cancel_stream)",
|
||||
&batch->on_complete);
|
||||
} else {
|
||||
|
|
@ -129,15 +129,15 @@ static void con_start_transport_stream_op_batch(
|
|||
|
||||
static void con_start_transport_op(grpc_channel_element* elem,
|
||||
grpc_transport_op* op) {
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
grpc_transport_perform_op(chand->transport, op);
|
||||
}
|
||||
|
||||
/* Constructor for call_data */
|
||||
static grpc_error* init_call_elem(grpc_call_element* elem,
|
||||
const grpc_call_element_args* args) {
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
calld->call_combiner = args->call_combiner;
|
||||
int r = grpc_transport_init_stream(
|
||||
chand->transport, TRANSPORT_STREAM_FROM_CALL_DATA(calld),
|
||||
|
|
@ -149,8 +149,8 @@ static grpc_error* init_call_elem(grpc_call_element* elem,
|
|||
|
||||
static void set_pollset_or_pollset_set(grpc_call_element* elem,
|
||||
grpc_polling_entity* pollent) {
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
grpc_transport_set_pops(chand->transport,
|
||||
TRANSPORT_STREAM_FROM_CALL_DATA(calld), pollent);
|
||||
}
|
||||
|
|
@ -159,8 +159,8 @@ static void set_pollset_or_pollset_set(grpc_call_element* elem,
|
|||
static void destroy_call_elem(grpc_call_element* elem,
|
||||
const grpc_call_final_info* final_info,
|
||||
grpc_closure* then_schedule_closure) {
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
channel_data* chand = (channel_data*)elem->channel_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
channel_data* chand = static_cast<channel_data*>(elem->channel_data);
|
||||
grpc_transport_destroy_stream(chand->transport,
|
||||
TRANSPORT_STREAM_FROM_CALL_DATA(calld),
|
||||
then_schedule_closure);
|
||||
|
|
@ -169,7 +169,7 @@ static void destroy_call_elem(grpc_call_element* elem,
|
|||
/* Constructor for channel_data */
|
||||
static grpc_error* init_channel_elem(grpc_channel_element* elem,
|
||||
grpc_channel_element_args* args) {
|
||||
channel_data* cd = (channel_data*)elem->channel_data;
|
||||
channel_data* cd = static_cast<channel_data*>(elem->channel_data);
|
||||
GPR_ASSERT(args->is_last);
|
||||
cd->transport = nullptr;
|
||||
return GRPC_ERROR_NONE;
|
||||
|
|
@ -177,7 +177,7 @@ static grpc_error* init_channel_elem(grpc_channel_element* elem,
|
|||
|
||||
/* Destructor for channel_data */
|
||||
static void destroy_channel_elem(grpc_channel_element* elem) {
|
||||
channel_data* cd = (channel_data*)elem->channel_data;
|
||||
channel_data* cd = static_cast<channel_data*>(elem->channel_data);
|
||||
if (cd->transport) {
|
||||
grpc_transport_destroy(cd->transport);
|
||||
}
|
||||
|
|
@ -203,10 +203,10 @@ const grpc_channel_filter grpc_connected_filter = {
|
|||
|
||||
static void bind_transport(grpc_channel_stack* channel_stack,
|
||||
grpc_channel_element* elem, void* t) {
|
||||
channel_data* cd = (channel_data*)elem->channel_data;
|
||||
channel_data* cd = static_cast<channel_data*>(elem->channel_data);
|
||||
GPR_ASSERT(elem->filter == &grpc_connected_filter);
|
||||
GPR_ASSERT(cd->transport == nullptr);
|
||||
cd->transport = (grpc_transport*)t;
|
||||
cd->transport = static_cast<grpc_transport*>(t);
|
||||
|
||||
/* HACK(ctiller): increase call stack size for the channel to make space
|
||||
for channel data. We need a cleaner (but performant) way to do this,
|
||||
|
|
@ -215,7 +215,7 @@ static void bind_transport(grpc_channel_stack* channel_stack,
|
|||
the last call element, and the last call element MUST be the connected
|
||||
channel. */
|
||||
channel_stack->call_stack_size +=
|
||||
grpc_transport_stream_size((grpc_transport*)t);
|
||||
grpc_transport_stream_size(static_cast<grpc_transport*>(t));
|
||||
}
|
||||
|
||||
bool grpc_add_connected_filter(grpc_channel_stack_builder* builder,
|
||||
|
|
@ -228,6 +228,6 @@ bool grpc_add_connected_filter(grpc_channel_stack_builder* builder,
|
|||
}
|
||||
|
||||
grpc_stream* grpc_connected_channel_get_stream(grpc_call_element* elem) {
|
||||
call_data* calld = (call_data*)elem->call_data;
|
||||
call_data* calld = static_cast<call_data*>(elem->call_data);
|
||||
return TRANSPORT_STREAM_FROM_CALL_DATA(calld);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ struct grpc_handshake_manager {
|
|||
|
||||
grpc_handshake_manager* grpc_handshake_manager_create() {
|
||||
grpc_handshake_manager* mgr =
|
||||
(grpc_handshake_manager*)gpr_zalloc(sizeof(grpc_handshake_manager));
|
||||
static_cast<grpc_handshake_manager*>(gpr_zalloc(sizeof(grpc_handshake_manager)));
|
||||
gpr_mu_init(&mgr->mu);
|
||||
gpr_ref_init(&mgr->refs, 1);
|
||||
return mgr;
|
||||
|
|
@ -135,8 +135,8 @@ void grpc_handshake_manager_add(grpc_handshake_manager* mgr,
|
|||
realloc_count = mgr->count * 2;
|
||||
}
|
||||
if (realloc_count > 0) {
|
||||
mgr->handshakers = (grpc_handshaker**)gpr_realloc(
|
||||
mgr->handshakers, realloc_count * sizeof(grpc_handshaker*));
|
||||
mgr->handshakers = static_cast<grpc_handshaker**>(gpr_realloc(
|
||||
mgr->handshakers, realloc_count * sizeof(grpc_handshaker*)));
|
||||
}
|
||||
mgr->handshakers[mgr->count++] = handshaker;
|
||||
gpr_mu_unlock(&mgr->mu);
|
||||
|
|
@ -197,7 +197,7 @@ static bool call_next_handshaker_locked(grpc_handshake_manager* mgr,
|
|||
// A function used as the handshaker-done callback when chaining
|
||||
// handshakers together.
|
||||
static void call_next_handshaker(void* arg, grpc_error* error) {
|
||||
grpc_handshake_manager* mgr = (grpc_handshake_manager*)arg;
|
||||
grpc_handshake_manager* mgr = static_cast<grpc_handshake_manager*>(arg);
|
||||
gpr_mu_lock(&mgr->mu);
|
||||
bool done = call_next_handshaker_locked(mgr, GRPC_ERROR_REF(error));
|
||||
gpr_mu_unlock(&mgr->mu);
|
||||
|
|
@ -211,7 +211,7 @@ static void call_next_handshaker(void* arg, grpc_error* error) {
|
|||
|
||||
// Callback invoked when deadline is exceeded.
|
||||
static void on_timeout(void* arg, grpc_error* error) {
|
||||
grpc_handshake_manager* mgr = (grpc_handshake_manager*)arg;
|
||||
grpc_handshake_manager* mgr = static_cast<grpc_handshake_manager*>(arg);
|
||||
if (error == GRPC_ERROR_NONE) { // Timer fired, rather than being cancelled.
|
||||
grpc_handshake_manager_shutdown(
|
||||
mgr, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Handshake timed out"));
|
||||
|
|
@ -234,7 +234,7 @@ void grpc_handshake_manager_do_handshake(
|
|||
mgr->args.args = grpc_channel_args_copy(channel_args);
|
||||
mgr->args.user_data = user_data;
|
||||
mgr->args.read_buffer =
|
||||
(grpc_slice_buffer*)gpr_malloc(sizeof(*mgr->args.read_buffer));
|
||||
static_cast<grpc_slice_buffer*>(gpr_malloc(sizeof(*mgr->args.read_buffer)));
|
||||
grpc_slice_buffer_init(mgr->args.read_buffer);
|
||||
// Initialize state needed for calling handshakers.
|
||||
mgr->acceptor = acceptor;
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@ typedef struct {
|
|||
static void grpc_handshaker_factory_list_register(
|
||||
grpc_handshaker_factory_list* list, bool at_start,
|
||||
grpc_handshaker_factory* factory) {
|
||||
list->list = (grpc_handshaker_factory**)gpr_realloc(
|
||||
list->list, (list->num_factories + 1) * sizeof(grpc_handshaker_factory*));
|
||||
list->list = static_cast<grpc_handshaker_factory**>(gpr_realloc(
|
||||
list->list, (list->num_factories + 1) * sizeof(grpc_handshaker_factory*)));
|
||||
if (at_start) {
|
||||
memmove(list->list + 1, list->list,
|
||||
sizeof(grpc_handshaker_factory*) * list->num_factories);
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ grpc_message_compression_algorithm grpc_message_compression_algorithm_for_level(
|
|||
GRPC_API_TRACE("grpc_message_compression_algorithm_for_level(level=%d)", 1,
|
||||
((int)level));
|
||||
if (level > GRPC_COMPRESS_LEVEL_HIGH) {
|
||||
gpr_log(GPR_ERROR, "Unknown message compression level %d.", (int)level);
|
||||
gpr_log(GPR_ERROR, "Unknown message compression level %d.", static_cast<int>(level));
|
||||
abort();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,23 +36,23 @@ static int zlib_body(z_stream* zs, grpc_slice_buffer* input,
|
|||
int flush;
|
||||
size_t i;
|
||||
grpc_slice outbuf = GRPC_SLICE_MALLOC(OUTPUT_BLOCK_SIZE);
|
||||
const uInt uint_max = ~(uInt)0;
|
||||
const uInt uint_max = ~static_cast<uInt>(0);
|
||||
|
||||
GPR_ASSERT(GRPC_SLICE_LENGTH(outbuf) <= uint_max);
|
||||
zs->avail_out = (uInt)GRPC_SLICE_LENGTH(outbuf);
|
||||
zs->avail_out = static_cast<uInt>GRPC_SLICE_LENGTH(outbuf);
|
||||
zs->next_out = GRPC_SLICE_START_PTR(outbuf);
|
||||
flush = Z_NO_FLUSH;
|
||||
for (i = 0; i < input->count; i++) {
|
||||
if (i == input->count - 1) flush = Z_FINISH;
|
||||
GPR_ASSERT(GRPC_SLICE_LENGTH(input->slices[i]) <= uint_max);
|
||||
zs->avail_in = (uInt)GRPC_SLICE_LENGTH(input->slices[i]);
|
||||
zs->avail_in = static_cast<uInt>GRPC_SLICE_LENGTH(input->slices[i]);
|
||||
zs->next_in = GRPC_SLICE_START_PTR(input->slices[i]);
|
||||
do {
|
||||
if (zs->avail_out == 0) {
|
||||
grpc_slice_buffer_add_indexed(output, outbuf);
|
||||
outbuf = GRPC_SLICE_MALLOC(OUTPUT_BLOCK_SIZE);
|
||||
GPR_ASSERT(GRPC_SLICE_LENGTH(outbuf) <= uint_max);
|
||||
zs->avail_out = (uInt)GRPC_SLICE_LENGTH(outbuf);
|
||||
zs->avail_out = static_cast<uInt>GRPC_SLICE_LENGTH(outbuf);
|
||||
zs->next_out = GRPC_SLICE_START_PTR(outbuf);
|
||||
}
|
||||
r = flate(zs, flush);
|
||||
|
|
|
|||
|
|
@ -48,11 +48,11 @@ static bool gzip_flate(grpc_stream_compression_context_gzip* ctx,
|
|||
size_t slice_size = max_output_size < OUTPUT_BLOCK_SIZE ? max_output_size
|
||||
: OUTPUT_BLOCK_SIZE;
|
||||
grpc_slice slice_out = GRPC_SLICE_MALLOC(slice_size);
|
||||
ctx->zs.avail_out = (uInt)slice_size;
|
||||
ctx->zs.avail_out = static_cast<uInt>(slice_size);
|
||||
ctx->zs.next_out = GRPC_SLICE_START_PTR(slice_out);
|
||||
while (ctx->zs.avail_out > 0 && in->length > 0 && !eoc) {
|
||||
grpc_slice slice = grpc_slice_buffer_take_first(in);
|
||||
ctx->zs.avail_in = (uInt)GRPC_SLICE_LENGTH(slice);
|
||||
ctx->zs.avail_in = static_cast<uInt>GRPC_SLICE_LENGTH(slice);
|
||||
ctx->zs.next_in = GRPC_SLICE_START_PTR(slice);
|
||||
r = ctx->flate(&ctx->zs, Z_NO_FLUSH);
|
||||
if (r < 0 && r != Z_BUF_ERROR) {
|
||||
|
|
@ -142,7 +142,7 @@ static bool grpc_stream_compress_gzip(grpc_stream_compression_context* ctx,
|
|||
return false;
|
||||
}
|
||||
grpc_stream_compression_context_gzip* gzip_ctx =
|
||||
(grpc_stream_compression_context_gzip*)ctx;
|
||||
reinterpret_cast<grpc_stream_compression_context_gzip*>(ctx);
|
||||
GPR_ASSERT(gzip_ctx->flate == deflate);
|
||||
int gzip_flush;
|
||||
switch (flush) {
|
||||
|
|
@ -172,7 +172,7 @@ static bool grpc_stream_decompress_gzip(grpc_stream_compression_context* ctx,
|
|||
return false;
|
||||
}
|
||||
grpc_stream_compression_context_gzip* gzip_ctx =
|
||||
(grpc_stream_compression_context_gzip*)ctx;
|
||||
reinterpret_cast<grpc_stream_compression_context_gzip*>(ctx);
|
||||
GPR_ASSERT(gzip_ctx->flate == inflate);
|
||||
return gzip_flate(gzip_ctx, in, out, output_size, max_output_size,
|
||||
Z_SYNC_FLUSH, end_of_context);
|
||||
|
|
@ -184,8 +184,8 @@ grpc_stream_compression_context_create_gzip(
|
|||
GPR_ASSERT(method == GRPC_STREAM_COMPRESSION_GZIP_COMPRESS ||
|
||||
method == GRPC_STREAM_COMPRESSION_GZIP_DECOMPRESS);
|
||||
grpc_stream_compression_context_gzip* gzip_ctx =
|
||||
(grpc_stream_compression_context_gzip*)gpr_zalloc(
|
||||
sizeof(grpc_stream_compression_context_gzip));
|
||||
static_cast<grpc_stream_compression_context_gzip*>(gpr_zalloc(
|
||||
sizeof(grpc_stream_compression_context_gzip)));
|
||||
int r;
|
||||
if (gzip_ctx == nullptr) {
|
||||
return nullptr;
|
||||
|
|
@ -204,7 +204,7 @@ grpc_stream_compression_context_create_gzip(
|
|||
}
|
||||
|
||||
gzip_ctx->base.vtable = &grpc_stream_compression_gzip_vtable;
|
||||
return (grpc_stream_compression_context*)gzip_ctx;
|
||||
return reinterpret_cast<grpc_stream_compression_context*>(gzip_ctx);
|
||||
}
|
||||
|
||||
static void grpc_stream_compression_context_destroy_gzip(
|
||||
|
|
@ -213,7 +213,7 @@ static void grpc_stream_compression_context_destroy_gzip(
|
|||
return;
|
||||
}
|
||||
grpc_stream_compression_context_gzip* gzip_ctx =
|
||||
(grpc_stream_compression_context_gzip*)ctx;
|
||||
reinterpret_cast<grpc_stream_compression_context_gzip*>(ctx);
|
||||
if (gzip_ctx->flate == inflate) {
|
||||
inflateEnd(&gzip_ctx->zs);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ grpc_stream_compression_context_create_identity(
|
|||
GPR_ASSERT(method == GRPC_STREAM_COMPRESSION_IDENTITY_COMPRESS ||
|
||||
method == GRPC_STREAM_COMPRESSION_IDENTITY_DECOMPRESS);
|
||||
/* No context needed in this case. Use fake context instead. */
|
||||
return (grpc_stream_compression_context*)&identity_ctx;
|
||||
return &identity_ctx;
|
||||
}
|
||||
|
||||
static void grpc_stream_compression_context_destroy_identity(
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ static size_t g_num_cores;
|
|||
void grpc_stats_init(void) {
|
||||
g_num_cores = GPR_MAX(1, gpr_cpu_num_cores());
|
||||
grpc_stats_per_cpu_storage =
|
||||
(grpc_stats_data*)gpr_zalloc(sizeof(grpc_stats_data) * g_num_cores);
|
||||
static_cast<grpc_stats_data*>(gpr_zalloc(sizeof(grpc_stats_data) * g_num_cores));
|
||||
}
|
||||
|
||||
void grpc_stats_shutdown(void) { gpr_free(grpc_stats_per_cpu_storage); }
|
||||
|
|
@ -76,14 +76,14 @@ int grpc_stats_histo_find_bucket_slow(int value, const int* table,
|
|||
table_size = step;
|
||||
}
|
||||
}
|
||||
return (int)(table - start) - 1;
|
||||
return static_cast<int>(table - start) - 1;
|
||||
}
|
||||
|
||||
size_t grpc_stats_histo_count(const grpc_stats_data* stats,
|
||||
grpc_stats_histograms histogram) {
|
||||
size_t sum = 0;
|
||||
for (int i = 0; i < grpc_stats_histo_buckets[histogram]; i++) {
|
||||
sum += (size_t)stats->histograms[grpc_stats_histo_start[histogram] + i];
|
||||
sum += static_cast<size_t>(stats->histograms[grpc_stats_histo_start[histogram] + i]);
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
|
@ -100,7 +100,7 @@ static double threshold_for_count_below(const gpr_atm* bucket_counts,
|
|||
/* find the lowest bucket that gets us above count_below */
|
||||
count_so_far = 0.0;
|
||||
for (lower_idx = 0; lower_idx < num_buckets; lower_idx++) {
|
||||
count_so_far += (double)bucket_counts[lower_idx];
|
||||
count_so_far += static_cast<double>(bucket_counts[lower_idx]);
|
||||
if (count_so_far >= count_below) {
|
||||
break;
|
||||
}
|
||||
|
|
@ -121,7 +121,7 @@ static double threshold_for_count_below(const gpr_atm* bucket_counts,
|
|||
upper_bound = bucket_boundaries[lower_idx + 1];
|
||||
return upper_bound - (upper_bound - lower_bound) *
|
||||
(count_so_far - count_below) /
|
||||
(double)bucket_counts[lower_idx];
|
||||
static_cast<double>(bucket_counts[lower_idx]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -133,7 +133,7 @@ double grpc_stats_histo_percentile(const grpc_stats_data* stats,
|
|||
return threshold_for_count_below(
|
||||
stats->histograms + grpc_stats_histo_start[histogram],
|
||||
grpc_stats_histo_bucket_boundaries[histogram],
|
||||
grpc_stats_histo_buckets[histogram], (double)count * percentile / 100.0);
|
||||
grpc_stats_histo_buckets[histogram], static_cast<double>(count) * percentile / 100.0);
|
||||
}
|
||||
|
||||
char* grpc_stats_data_as_json(const grpc_stats_data* data) {
|
||||
|
|
|
|||
|
|
@ -88,11 +88,11 @@ static void add(const char* beg, const char* end, char*** ss, size_t* ns) {
|
|||
char* s;
|
||||
size_t len;
|
||||
GPR_ASSERT(end >= beg);
|
||||
len = (size_t)(end - beg);
|
||||
s = (char*)gpr_malloc(len + 1);
|
||||
len = static_cast<size_t>(end - beg);
|
||||
s = static_cast<char*>(gpr_malloc(len + 1));
|
||||
memcpy(s, beg, len);
|
||||
s[len] = 0;
|
||||
*ss = (char**)gpr_realloc(*ss, sizeof(char**) * np);
|
||||
*ss = static_cast<char**>(gpr_realloc(*ss, sizeof(char**) * np));
|
||||
(*ss)[n] = s;
|
||||
*ns = np;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,4 +95,4 @@ void* gpr_malloc_aligned(size_t size, size_t alignment) {
|
|||
return (void*)ret;
|
||||
}
|
||||
|
||||
void gpr_free_aligned(void* ptr) { gpr_free(((void**)ptr)[-1]); }
|
||||
void gpr_free_aligned(void* ptr) { gpr_free((static_cast<void**>(ptr))[-1]); }
|
||||
|
|
|
|||
|
|
@ -51,8 +51,8 @@ static void* zalloc_aligned(size_t size) {
|
|||
|
||||
gpr_arena* gpr_arena_create(size_t initial_size) {
|
||||
initial_size = ROUND_UP_TO_ALIGNMENT_SIZE(initial_size);
|
||||
gpr_arena* a = (gpr_arena*)zalloc_aligned(
|
||||
ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(gpr_arena)) + initial_size);
|
||||
gpr_arena* a = static_cast<gpr_arena*>(zalloc_aligned(
|
||||
ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(gpr_arena)) + initial_size));
|
||||
a->initial_zone.size_end = initial_size;
|
||||
return a;
|
||||
}
|
||||
|
|
@ -66,23 +66,23 @@ size_t gpr_arena_destroy(gpr_arena* arena) {
|
|||
gpr_free_aligned(z);
|
||||
z = next_z;
|
||||
}
|
||||
return (size_t)size;
|
||||
return static_cast<size_t>(size);
|
||||
}
|
||||
|
||||
void* gpr_arena_alloc(gpr_arena* arena, size_t size) {
|
||||
size = ROUND_UP_TO_ALIGNMENT_SIZE(size);
|
||||
size_t start =
|
||||
(size_t)gpr_atm_no_barrier_fetch_add(&arena->size_so_far, size);
|
||||
static_cast<size_t>(gpr_atm_no_barrier_fetch_add(&arena->size_so_far, size));
|
||||
zone* z = &arena->initial_zone;
|
||||
while (start > z->size_end) {
|
||||
zone* next_z = (zone*)gpr_atm_acq_load(&z->next_atm);
|
||||
if (next_z == nullptr) {
|
||||
size_t next_z_size = (size_t)gpr_atm_no_barrier_load(&arena->size_so_far);
|
||||
next_z = (zone*)zalloc_aligned(ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(zone)) +
|
||||
next_z_size);
|
||||
size_t next_z_size = static_cast<size_t>gpr_atm_no_barrier_load(&arena->size_so_far);
|
||||
next_z = static_cast<zone*>(zalloc_aligned(ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(zone)) +
|
||||
next_z_size));
|
||||
next_z->size_begin = z->size_end;
|
||||
next_z->size_end = z->size_end + next_z_size;
|
||||
if (!gpr_atm_rel_cas(&z->next_atm, (gpr_atm)NULL, (gpr_atm)next_z)) {
|
||||
if (!gpr_atm_rel_cas(&z->next_atm, static_cast<gpr_atm>(NULL), (gpr_atm)next_z)) {
|
||||
gpr_free_aligned(next_z);
|
||||
next_z = (zone*)gpr_atm_acq_load(&z->next_atm);
|
||||
}
|
||||
|
|
@ -95,7 +95,7 @@ void* gpr_arena_alloc(gpr_arena* arena, size_t size) {
|
|||
GPR_ASSERT(start >= z->size_begin);
|
||||
GPR_ASSERT(start + size <= z->size_end);
|
||||
char* ptr = (z == &arena->initial_zone)
|
||||
? (char*)arena + ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(gpr_arena))
|
||||
: (char*)z + ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(zone));
|
||||
? reinterpret_cast<char*>(arena) + ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(gpr_arena))
|
||||
: reinterpret_cast<char*>(z) + ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(zone));
|
||||
return ptr + start - z->size_begin;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ static void init_num_cpus() {
|
|||
#endif
|
||||
/* This must be signed. sysconf returns -1 when the number cannot be
|
||||
determined */
|
||||
ncpus = (int)sysconf(_SC_NPROCESSORS_ONLN);
|
||||
ncpus = static_cast<int>(sysconf(_SC_NPROCESSORS_ONLN));
|
||||
if (ncpus < 1) {
|
||||
gpr_log(GPR_ERROR, "Cannot determine number of CPUs: assuming 1");
|
||||
ncpus = 1;
|
||||
|
|
@ -55,7 +55,7 @@ static void init_num_cpus() {
|
|||
unsigned gpr_cpu_num_cores(void) {
|
||||
static gpr_once once = GPR_ONCE_INIT;
|
||||
gpr_once_init(&once, init_num_cpus);
|
||||
return (unsigned)ncpus;
|
||||
return static_cast<unsigned>(ncpus);
|
||||
}
|
||||
|
||||
unsigned gpr_cpu_current_cpu(void) {
|
||||
|
|
@ -71,7 +71,7 @@ unsigned gpr_cpu_current_cpu(void) {
|
|||
gpr_log(GPR_ERROR, "Error determining current CPU: %s\n", strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
return (unsigned)cpu;
|
||||
return static_cast<unsigned>(cpu);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ int gpr_split_host_port(const char* name, char** host, char** port) {
|
|||
return 0;
|
||||
}
|
||||
host_start = name + 1;
|
||||
host_len = (size_t)(rbracket - host_start);
|
||||
host_len = static_cast<size_t>(rbracket - host_start);
|
||||
if (memchr(host_start, ':', host_len) == nullptr) {
|
||||
/* Require all bracketed hosts to contain a colon, because a hostname or
|
||||
IPv4 address should never use brackets. */
|
||||
|
|
@ -73,7 +73,7 @@ int gpr_split_host_port(const char* name, char** host, char** port) {
|
|||
if (colon != nullptr && strchr(colon + 1, ':') == nullptr) {
|
||||
/* Exactly 1 colon. Split into host:port. */
|
||||
host_start = name;
|
||||
host_len = (size_t)(colon - name);
|
||||
host_len = static_cast<size_t>(colon - name);
|
||||
port_start = colon + 1;
|
||||
} else {
|
||||
/* 0 or 2+ colons. Bare hostname or IPv6 litearal. */
|
||||
|
|
@ -84,7 +84,7 @@ int gpr_split_host_port(const char* name, char** host, char** port) {
|
|||
}
|
||||
|
||||
/* Allocate return values. */
|
||||
*host = (char*)gpr_malloc(host_len + 1);
|
||||
*host = static_cast<char*>(gpr_malloc(host_len + 1));
|
||||
memcpy(*host, host_start, host_len);
|
||||
(*host)[host_len] = '\0';
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ const char* gpr_log_severity_string(gpr_log_severity severity) {
|
|||
|
||||
void gpr_log_message(const char* file, int line, gpr_log_severity severity,
|
||||
const char* message) {
|
||||
if ((gpr_atm)severity < gpr_atm_no_barrier_load(&g_min_severity_to_print)) {
|
||||
if (static_cast<gpr_atm>(severity) < gpr_atm_no_barrier_load(&g_min_severity_to_print)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -70,11 +70,11 @@ void gpr_log_verbosity_init() {
|
|||
gpr_atm min_severity_to_print = GPR_LOG_SEVERITY_ERROR;
|
||||
if (verbosity != nullptr) {
|
||||
if (gpr_stricmp(verbosity, "DEBUG") == 0) {
|
||||
min_severity_to_print = (gpr_atm)GPR_LOG_SEVERITY_DEBUG;
|
||||
min_severity_to_print = static_cast<gpr_atm>(GPR_LOG_SEVERITY_DEBUG);
|
||||
} else if (gpr_stricmp(verbosity, "INFO") == 0) {
|
||||
min_severity_to_print = (gpr_atm)GPR_LOG_SEVERITY_INFO;
|
||||
min_severity_to_print = static_cast<gpr_atm>(GPR_LOG_SEVERITY_INFO);
|
||||
} else if (gpr_stricmp(verbosity, "ERROR") == 0) {
|
||||
min_severity_to_print = (gpr_atm)GPR_LOG_SEVERITY_ERROR;
|
||||
min_severity_to_print = static_cast<gpr_atm>(GPR_LOG_SEVERITY_ERROR);
|
||||
}
|
||||
gpr_free(verbosity);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ void gpr_default_log(gpr_log_func_args* args) {
|
|||
static __thread long tid = 0;
|
||||
if (tid == 0) tid = gettid();
|
||||
|
||||
timer = (time_t)now.tv_sec;
|
||||
timer = static_cast<time_t>(now.tv_sec);
|
||||
final_slash = strrchr(args->file, '/');
|
||||
if (final_slash == nullptr)
|
||||
display_file = args->file;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ uint32_t gpr_murmur_hash3(const void* key, size_t len, uint32_t seed) {
|
|||
const uint32_t c1 = 0xcc9e2d51;
|
||||
const uint32_t c2 = 0x1b873593;
|
||||
|
||||
const uint8_t* keyptr = (const uint8_t*)key;
|
||||
const uint8_t* keyptr = static_cast<const uint8_t*>(key);
|
||||
const size_t bsize = sizeof(k1);
|
||||
const size_t nblocks = len / bsize;
|
||||
|
||||
|
|
@ -58,10 +58,10 @@ uint32_t gpr_murmur_hash3(const void* key, size_t len, uint32_t seed) {
|
|||
/* tail */
|
||||
switch (len & 3) {
|
||||
case 3:
|
||||
k1 ^= ((uint32_t)keyptr[2]) << 16;
|
||||
k1 ^= (static_cast<uint32_t>(keyptr[2])) << 16;
|
||||
/* fallthrough */
|
||||
case 2:
|
||||
k1 ^= ((uint32_t)keyptr[1]) << 8;
|
||||
k1 ^= (static_cast<uint32_t>(keyptr[1])) << 8;
|
||||
/* fallthrough */
|
||||
case 1:
|
||||
k1 ^= keyptr[0];
|
||||
|
|
@ -72,7 +72,7 @@ uint32_t gpr_murmur_hash3(const void* key, size_t len, uint32_t seed) {
|
|||
};
|
||||
|
||||
/* finalization */
|
||||
h1 ^= (uint32_t)len;
|
||||
h1 ^= static_cast<uint32_t>(len);
|
||||
FMIX32(h1);
|
||||
return h1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ char* gpr_strdup(const char* src) {
|
|||
}
|
||||
|
||||
len = strlen(src) + 1;
|
||||
dst = (char*)gpr_malloc(len);
|
||||
dst = static_cast<char*>(gpr_malloc(len));
|
||||
|
||||
memcpy(dst, src, len);
|
||||
|
||||
|
|
@ -61,7 +61,7 @@ static dump_out dump_out_create(void) {
|
|||
static void dump_out_append(dump_out* out, char c) {
|
||||
if (out->length == out->capacity) {
|
||||
out->capacity = GPR_MAX(8, 2 * out->capacity);
|
||||
out->data = (char*)gpr_realloc(out->data, out->capacity);
|
||||
out->data = static_cast<char*>(gpr_realloc(out->data, out->capacity));
|
||||
}
|
||||
out->data[out->length++] = c;
|
||||
}
|
||||
|
|
@ -69,7 +69,7 @@ static void dump_out_append(dump_out* out, char c) {
|
|||
static void hexdump(dump_out* out, const char* buf, size_t len) {
|
||||
static const char* hex = "0123456789abcdef";
|
||||
|
||||
const uint8_t* const beg = (const uint8_t*)buf;
|
||||
const uint8_t* const beg = reinterpret_cast<const uint8_t*>(buf);
|
||||
const uint8_t* const end = beg + len;
|
||||
const uint8_t* cur;
|
||||
|
||||
|
|
@ -81,7 +81,7 @@ static void hexdump(dump_out* out, const char* buf, size_t len) {
|
|||
}
|
||||
|
||||
static void asciidump(dump_out* out, const char* buf, size_t len) {
|
||||
const uint8_t* const beg = (const uint8_t*)buf;
|
||||
const uint8_t* const beg = reinterpret_cast<const uint8_t*>(buf);
|
||||
const uint8_t* const end = beg + len;
|
||||
const uint8_t* cur;
|
||||
int out_was_empty = (out->length == 0);
|
||||
|
|
@ -90,7 +90,7 @@ static void asciidump(dump_out* out, const char* buf, size_t len) {
|
|||
dump_out_append(out, '\'');
|
||||
}
|
||||
for (cur = beg; cur != end; ++cur) {
|
||||
dump_out_append(out, (char)(isprint(*cur) ? *(char*)cur : '.'));
|
||||
dump_out_append(out, (isprint(*cur) ? *(char*)cur : '.'));
|
||||
}
|
||||
if (!out_was_empty) {
|
||||
dump_out_append(out, '\'');
|
||||
|
|
@ -118,7 +118,7 @@ int gpr_parse_bytes_to_uint32(const char* buf, size_t len, uint32_t* result) {
|
|||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (buf[i] < '0' || buf[i] > '9') return 0; /* bad char */
|
||||
new_val = 10 * out + (uint32_t)(buf[i] - '0');
|
||||
new_val = 10 * out + static_cast<uint32_t>(buf[i] - '0');
|
||||
if (new_val < out) return 0; /* overflow */
|
||||
out = new_val;
|
||||
}
|
||||
|
|
@ -148,7 +148,7 @@ int gpr_ltoa(long value, char* string) {
|
|||
|
||||
sign = value < 0 ? -1 : 1;
|
||||
while (value) {
|
||||
string[i++] = (char)('0' + sign * (value % 10));
|
||||
string[i++] = static_cast<char>('0' + sign * (value % 10));
|
||||
value /= 10;
|
||||
}
|
||||
if (sign < 0) string[i++] = '-';
|
||||
|
|
@ -169,7 +169,7 @@ int int64_ttoa(int64_t value, char* string) {
|
|||
|
||||
sign = value < 0 ? -1 : 1;
|
||||
while (value) {
|
||||
string[i++] = (char)('0' + sign * (value % 10));
|
||||
string[i++] = static_cast<char>('0' + sign * (value % 10));
|
||||
value /= 10;
|
||||
}
|
||||
if (sign < 0) string[i++] = '-';
|
||||
|
|
@ -182,13 +182,13 @@ int gpr_parse_nonnegative_int(const char* value) {
|
|||
char* end;
|
||||
long result = strtol(value, &end, 0);
|
||||
if (*end != '\0' || result < 0 || result > INT_MAX) return -1;
|
||||
return (int)result;
|
||||
return static_cast<int>(result);
|
||||
}
|
||||
|
||||
char* gpr_leftpad(const char* str, char flag, size_t length) {
|
||||
const size_t str_length = strlen(str);
|
||||
const size_t out_length = str_length > length ? str_length : length;
|
||||
char* out = (char*)gpr_malloc(out_length + 1);
|
||||
char* out = static_cast<char*>(gpr_malloc(out_length + 1));
|
||||
memset(out, flag, out_length - str_length);
|
||||
memcpy(out + out_length - str_length, str, str_length);
|
||||
out[out_length] = 0;
|
||||
|
|
@ -212,7 +212,7 @@ char* gpr_strjoin_sep(const char** strs, size_t nstrs, const char* sep,
|
|||
if (nstrs > 0) {
|
||||
out_length += sep_len * (nstrs - 1); /* separators */
|
||||
}
|
||||
out = (char*)gpr_malloc(out_length);
|
||||
out = static_cast<char*>(gpr_malloc(out_length));
|
||||
out_length = 0;
|
||||
for (i = 0; i < nstrs; i++) {
|
||||
const size_t slen = strlen(strs[i]);
|
||||
|
|
@ -243,7 +243,7 @@ void gpr_strvec_destroy(gpr_strvec* sv) {
|
|||
void gpr_strvec_add(gpr_strvec* sv, char* str) {
|
||||
if (sv->count == sv->capacity) {
|
||||
sv->capacity = GPR_MAX(sv->capacity + 8, sv->capacity * 2);
|
||||
sv->strs = (char**)gpr_realloc(sv->strs, sizeof(char*) * sv->capacity);
|
||||
sv->strs = static_cast<char**>(gpr_realloc(sv->strs, sizeof(char*) * sv->capacity));
|
||||
}
|
||||
sv->strs[sv->count++] = str;
|
||||
}
|
||||
|
|
@ -265,12 +265,12 @@ int gpr_stricmp(const char* a, const char* b) {
|
|||
|
||||
static void add_string_to_split(const char* beg, const char* end, char*** strs,
|
||||
size_t* nstrs, size_t* capstrs) {
|
||||
char* out = (char*)gpr_malloc((size_t)(end - beg) + 1);
|
||||
memcpy(out, beg, (size_t)(end - beg));
|
||||
char* out = static_cast<char*>(gpr_malloc(static_cast<size_t>(end - beg) + 1));
|
||||
memcpy(out, beg, static_cast<size_t>(end - beg));
|
||||
out[end - beg] = 0;
|
||||
if (*nstrs == *capstrs) {
|
||||
*capstrs = GPR_MAX(8, 2 * *capstrs);
|
||||
*strs = (char**)gpr_realloc(*strs, sizeof(*strs) * *capstrs);
|
||||
*strs = static_cast<char**>(gpr_realloc(*strs, sizeof(*strs) * *capstrs));
|
||||
}
|
||||
(*strs)[*nstrs] = out;
|
||||
++*nstrs;
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ int gpr_asprintf(char** strp, const char* format, ...) {
|
|||
}
|
||||
|
||||
/* Allocate a new buffer, with space for the NUL terminator. */
|
||||
strp_buflen = (size_t)ret + 1;
|
||||
if ((*strp = (char*)gpr_malloc(strp_buflen)) == nullptr) {
|
||||
strp_buflen = static_cast<size_t>(ret) + 1;
|
||||
if ((*strp = static_cast<char*>(gpr_malloc(strp_buflen))) == nullptr) {
|
||||
/* This shouldn't happen, because gpr_malloc() calls abort(). */
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -59,7 +59,7 @@ int gpr_asprintf(char** strp, const char* format, ...) {
|
|||
va_start(args, format);
|
||||
ret = vsnprintf(*strp, strp_buflen, format, args);
|
||||
va_end(args);
|
||||
if ((size_t)ret == strp_buflen - 1) {
|
||||
if (static_cast<size_t>(ret) == strp_buflen - 1) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ int gpr_cv_wait(gpr_cv* cv, gpr_mu* mu, gpr_timespec abs_deadline) {
|
|||
#else
|
||||
abs_deadline = gpr_convert_clock_type(abs_deadline, GPR_CLOCK_REALTIME);
|
||||
#endif // GPR_LINUX
|
||||
abs_deadline_ts.tv_sec = (time_t)abs_deadline.tv_sec;
|
||||
abs_deadline_ts.tv_sec = static_cast<time_t>(abs_deadline.tv_sec);
|
||||
abs_deadline_ts.tv_nsec = abs_deadline.tv_nsec;
|
||||
err = pthread_cond_timedwait(cv, mu, &abs_deadline_ts);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ static void dec_thd_count();
|
|||
|
||||
/* Body of every thread started via gpr_thd_new. */
|
||||
static void* thread_body(void* v) {
|
||||
struct thd_arg a = *(struct thd_arg*)v;
|
||||
struct thd_arg a = *static_cast<struct thd_arg*>(v);
|
||||
free(v);
|
||||
if (a.name != nullptr) {
|
||||
#if GPR_APPLE_PTHREAD_NAME
|
||||
|
|
@ -77,7 +77,7 @@ int gpr_thd_new(gpr_thd_id* t, const char* thd_name,
|
|||
pthread_t p;
|
||||
/* don't use gpr_malloc as we may cause an infinite recursion with
|
||||
* the profiling code */
|
||||
struct thd_arg* a = (struct thd_arg*)malloc(sizeof(*a));
|
||||
struct thd_arg* a = static_cast<struct thd_arg*>(malloc(sizeof(*a)));
|
||||
GPR_ASSERT(a != nullptr);
|
||||
a->body = thd_body;
|
||||
a->arg = arg;
|
||||
|
|
@ -99,13 +99,13 @@ int gpr_thd_new(gpr_thd_id* t, const char* thd_name,
|
|||
free(a);
|
||||
dec_thd_count();
|
||||
}
|
||||
*t = (gpr_thd_id)p;
|
||||
*t = static_cast<gpr_thd_id>(p);
|
||||
return thread_started;
|
||||
}
|
||||
|
||||
gpr_thd_id gpr_thd_currentid(void) { return (gpr_thd_id)pthread_self(); }
|
||||
gpr_thd_id gpr_thd_currentid(void) { return static_cast<gpr_thd_id>(pthread_self()); }
|
||||
|
||||
void gpr_thd_join(gpr_thd_id t) { pthread_join((pthread_t)t, nullptr); }
|
||||
void gpr_thd_join(gpr_thd_id t) { pthread_join(static_cast<pthread_t>(t), nullptr); }
|
||||
|
||||
/*****************************************
|
||||
* Only used when fork support is enabled
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ static gpr_timespec to_seconds_from_sub_second_time(int64_t time_in_units,
|
|||
units_per_sec) -
|
||||
1;
|
||||
}
|
||||
out.tv_nsec = (int32_t)((time_in_units - out.tv_sec * units_per_sec) *
|
||||
out.tv_nsec = static_cast<int32_t>((time_in_units - out.tv_sec * units_per_sec) *
|
||||
GPR_NS_PER_SEC / units_per_sec);
|
||||
out.clock_type = type;
|
||||
}
|
||||
|
|
@ -216,12 +216,12 @@ int32_t gpr_time_to_millis(gpr_timespec t) {
|
|||
care?) */
|
||||
return -2147483647;
|
||||
} else {
|
||||
return (int32_t)(t.tv_sec * GPR_MS_PER_SEC + t.tv_nsec / GPR_NS_PER_MS);
|
||||
return static_cast<int32_t>(t.tv_sec * GPR_MS_PER_SEC + t.tv_nsec / GPR_NS_PER_MS);
|
||||
}
|
||||
}
|
||||
|
||||
double gpr_timespec_to_micros(gpr_timespec t) {
|
||||
return (double)t.tv_sec * GPR_US_PER_SEC + t.tv_nsec * 1e-3;
|
||||
return static_cast<double>(t.tv_sec) * GPR_US_PER_SEC + t.tv_nsec * 1e-3;
|
||||
}
|
||||
|
||||
gpr_timespec gpr_convert_clock_type(gpr_timespec t, gpr_clock_type clock_type) {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ static struct timespec timespec_from_gpr(gpr_timespec gts) {
|
|||
/* fine to assert, as this is only used in gpr_sleep_until */
|
||||
GPR_ASSERT(gts.tv_sec <= INT32_MAX && gts.tv_sec >= INT32_MIN);
|
||||
}
|
||||
rv.tv_sec = (time_t)gts.tv_sec;
|
||||
rv.tv_sec = static_cast<time_t>(gts.tv_sec);
|
||||
rv.tv_nsec = gts.tv_nsec;
|
||||
return rv;
|
||||
}
|
||||
|
|
@ -52,7 +52,7 @@ static gpr_timespec gpr_from_timespec(struct timespec ts,
|
|||
*/
|
||||
gpr_timespec rv;
|
||||
rv.tv_sec = ts.tv_sec;
|
||||
rv.tv_nsec = (int32_t)ts.tv_nsec;
|
||||
rv.tv_nsec = static_cast<int32_t>(ts.tv_nsec);
|
||||
rv.clock_type = clock_type;
|
||||
return rv;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ grpc_slice grpc_httpcli_format_post_request(const grpc_httpcli_request* request,
|
|||
if (!has_content_type) {
|
||||
gpr_strvec_add(&out, gpr_strdup("Content-Type: text/plain\r\n"));
|
||||
}
|
||||
gpr_asprintf(&tmp, "Content-Length: %lu\r\n", (unsigned long)body_size);
|
||||
gpr_asprintf(&tmp, "Content-Length: %lu\r\n", static_cast<unsigned long>(body_size));
|
||||
gpr_strvec_add(&out, tmp);
|
||||
}
|
||||
gpr_strvec_add(&out, gpr_strdup("\r\n"));
|
||||
|
|
@ -97,7 +97,7 @@ grpc_slice grpc_httpcli_format_post_request(const grpc_httpcli_request* request,
|
|||
gpr_strvec_destroy(&out);
|
||||
|
||||
if (body_bytes) {
|
||||
tmp = (char*)gpr_realloc(tmp, out_len + body_size);
|
||||
tmp = static_cast<char*>(gpr_realloc(tmp, out_len + body_size));
|
||||
memcpy(tmp + out_len, body_bytes, body_size);
|
||||
out_len += body_size;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ static void do_read(internal_request* req) {
|
|||
}
|
||||
|
||||
static void on_read(void* user_data, grpc_error* error) {
|
||||
internal_request* req = (internal_request*)user_data;
|
||||
internal_request* req = static_cast<internal_request*>(user_data);
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < req->incoming.count; i++) {
|
||||
|
|
@ -150,7 +150,7 @@ static void on_read(void* user_data, grpc_error* error) {
|
|||
static void on_written(internal_request* req) { do_read(req); }
|
||||
|
||||
static void done_write(void* arg, grpc_error* error) {
|
||||
internal_request* req = (internal_request*)arg;
|
||||
internal_request* req = static_cast<internal_request*>(arg);
|
||||
if (error == GRPC_ERROR_NONE) {
|
||||
on_written(req);
|
||||
} else {
|
||||
|
|
@ -165,7 +165,7 @@ static void start_write(internal_request* req) {
|
|||
}
|
||||
|
||||
static void on_handshake_done(void* arg, grpc_endpoint* ep) {
|
||||
internal_request* req = (internal_request*)arg;
|
||||
internal_request* req = static_cast<internal_request*>(arg);
|
||||
|
||||
if (!ep) {
|
||||
next_address(req, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
||||
|
|
@ -178,7 +178,7 @@ static void on_handshake_done(void* arg, grpc_endpoint* ep) {
|
|||
}
|
||||
|
||||
static void on_connected(void* arg, grpc_error* error) {
|
||||
internal_request* req = (internal_request*)arg;
|
||||
internal_request* req = static_cast<internal_request*>(arg);
|
||||
|
||||
if (!req->ep) {
|
||||
next_address(req, GRPC_ERROR_REF(error));
|
||||
|
|
@ -212,7 +212,7 @@ static void next_address(internal_request* req, grpc_error* error) {
|
|||
}
|
||||
|
||||
static void on_resolved(void* arg, grpc_error* error) {
|
||||
internal_request* req = (internal_request*)arg;
|
||||
internal_request* req = static_cast<internal_request*>(arg);
|
||||
if (error != GRPC_ERROR_NONE) {
|
||||
finish(req, GRPC_ERROR_REF(error));
|
||||
return;
|
||||
|
|
@ -229,7 +229,7 @@ static void internal_request_begin(grpc_httpcli_context* context,
|
|||
grpc_httpcli_response* response,
|
||||
const char* name, grpc_slice request_text) {
|
||||
internal_request* req =
|
||||
(internal_request*)gpr_malloc(sizeof(internal_request));
|
||||
static_cast<internal_request*>(gpr_malloc(sizeof(internal_request)));
|
||||
memset(req, 0, sizeof(*req));
|
||||
req->request_text = request_text;
|
||||
grpc_http_parser_init(&req->parser, GRPC_HTTP_RESPONSE, response);
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ typedef struct {
|
|||
|
||||
static void httpcli_ssl_destroy(grpc_security_connector* sc) {
|
||||
grpc_httpcli_ssl_channel_security_connector* c =
|
||||
(grpc_httpcli_ssl_channel_security_connector*)sc;
|
||||
reinterpret_cast<grpc_httpcli_ssl_channel_security_connector*>(sc);
|
||||
if (c->handshaker_factory != nullptr) {
|
||||
tsi_ssl_client_handshaker_factory_unref(c->handshaker_factory);
|
||||
c->handshaker_factory = nullptr;
|
||||
|
|
@ -52,7 +52,7 @@ static void httpcli_ssl_destroy(grpc_security_connector* sc) {
|
|||
static void httpcli_ssl_add_handshakers(grpc_channel_security_connector* sc,
|
||||
grpc_handshake_manager* handshake_mgr) {
|
||||
grpc_httpcli_ssl_channel_security_connector* c =
|
||||
(grpc_httpcli_ssl_channel_security_connector*)sc;
|
||||
reinterpret_cast<grpc_httpcli_ssl_channel_security_connector*>(sc);
|
||||
tsi_handshaker* handshaker = nullptr;
|
||||
if (c->handshaker_factory != nullptr) {
|
||||
tsi_result result = tsi_ssl_client_handshaker_factory_create_handshaker(
|
||||
|
|
@ -71,7 +71,7 @@ static void httpcli_ssl_check_peer(grpc_security_connector* sc, tsi_peer peer,
|
|||
grpc_auth_context** auth_context,
|
||||
grpc_closure* on_peer_checked) {
|
||||
grpc_httpcli_ssl_channel_security_connector* c =
|
||||
(grpc_httpcli_ssl_channel_security_connector*)sc;
|
||||
reinterpret_cast<grpc_httpcli_ssl_channel_security_connector*>(sc);
|
||||
grpc_error* error = GRPC_ERROR_NONE;
|
||||
|
||||
/* Check the peer name. */
|
||||
|
|
@ -90,9 +90,9 @@ static void httpcli_ssl_check_peer(grpc_security_connector* sc, tsi_peer peer,
|
|||
static int httpcli_ssl_cmp(grpc_security_connector* sc1,
|
||||
grpc_security_connector* sc2) {
|
||||
grpc_httpcli_ssl_channel_security_connector* c1 =
|
||||
(grpc_httpcli_ssl_channel_security_connector*)sc1;
|
||||
reinterpret_cast<grpc_httpcli_ssl_channel_security_connector*>(sc1);
|
||||
grpc_httpcli_ssl_channel_security_connector* c2 =
|
||||
(grpc_httpcli_ssl_channel_security_connector*)sc2;
|
||||
reinterpret_cast<grpc_httpcli_ssl_channel_security_connector*>(sc2);
|
||||
return strcmp(c1->secure_peer_name, c2->secure_peer_name);
|
||||
}
|
||||
|
||||
|
|
@ -111,8 +111,8 @@ static grpc_security_status httpcli_ssl_channel_security_connector_create(
|
|||
return GRPC_SECURITY_ERROR;
|
||||
}
|
||||
|
||||
c = (grpc_httpcli_ssl_channel_security_connector*)gpr_zalloc(
|
||||
sizeof(grpc_httpcli_ssl_channel_security_connector));
|
||||
c = static_cast<grpc_httpcli_ssl_channel_security_connector*>(gpr_zalloc(
|
||||
sizeof(grpc_httpcli_ssl_channel_security_connector)));
|
||||
|
||||
gpr_ref_init(&c->base.base.refcount, 1);
|
||||
c->base.base.vtable = &httpcli_ssl_vtable;
|
||||
|
|
@ -146,8 +146,8 @@ typedef struct {
|
|||
} on_done_closure;
|
||||
|
||||
static void on_handshake_done(void* arg, grpc_error* error) {
|
||||
grpc_handshaker_args* args = (grpc_handshaker_args*)arg;
|
||||
on_done_closure* c = (on_done_closure*)args->user_data;
|
||||
grpc_handshaker_args* args = static_cast<grpc_handshaker_args*>(arg);
|
||||
on_done_closure* c = static_cast<on_done_closure*>(args->user_data);
|
||||
if (error != GRPC_ERROR_NONE) {
|
||||
const char* msg = grpc_error_string(error);
|
||||
gpr_log(GPR_ERROR, "Secure transport setup failed: %s", msg);
|
||||
|
|
@ -166,7 +166,7 @@ static void on_handshake_done(void* arg, grpc_error* error) {
|
|||
static void ssl_handshake(void* arg, grpc_endpoint* tcp, const char* host,
|
||||
grpc_millis deadline,
|
||||
void (*on_done)(void* arg, grpc_endpoint* endpoint)) {
|
||||
on_done_closure* c = (on_done_closure*)gpr_malloc(sizeof(*c));
|
||||
on_done_closure* c = static_cast<on_done_closure*>(gpr_malloc(sizeof(*c)));
|
||||
const char* pem_root_certs = grpc_get_default_ssl_roots();
|
||||
if (pem_root_certs == nullptr) {
|
||||
gpr_log(GPR_ERROR, "Could not get default pem root certs.");
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
grpc_core::TraceFlag grpc_http1_trace(false, "http1");
|
||||
|
||||
static char* buf2str(void* buffer, size_t length) {
|
||||
char* out = (char*)gpr_malloc(length + 1);
|
||||
char* out = static_cast<char*>(gpr_malloc(length + 1));
|
||||
memcpy(out, buffer, length);
|
||||
out[length] = 0;
|
||||
return out;
|
||||
|
|
@ -88,14 +88,14 @@ static grpc_error* handle_request_line(grpc_http_parser* parser) {
|
|||
if (cur == end)
|
||||
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
||||
"No method on HTTP request line");
|
||||
parser->http.request->method = buf2str(beg, (size_t)(cur - beg - 1));
|
||||
parser->http.request->method = buf2str(beg, static_cast<size_t>(cur - beg - 1));
|
||||
|
||||
beg = cur;
|
||||
while (cur != end && *cur++ != ' ')
|
||||
;
|
||||
if (cur == end)
|
||||
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("No path on HTTP request line");
|
||||
parser->http.request->path = buf2str(beg, (size_t)(cur - beg - 1));
|
||||
parser->http.request->path = buf2str(beg, static_cast<size_t>(cur - beg - 1));
|
||||
|
||||
if (cur == end || *cur++ != 'H')
|
||||
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Expected 'H'");
|
||||
|
|
@ -107,12 +107,12 @@ static grpc_error* handle_request_line(grpc_http_parser* parser) {
|
|||
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Expected 'P'");
|
||||
if (cur == end || *cur++ != '/')
|
||||
return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Expected '/'");
|
||||
vers_major = (uint8_t)(*cur++ - '1' + 1);
|
||||
vers_major = static_cast<uint8_t>(*cur++ - '1' + 1);
|
||||
++cur;
|
||||
if (cur == end)
|
||||
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
||||
"End of line in HTTP version string");
|
||||
vers_minor = (uint8_t)(*cur++ - '1' + 1);
|
||||
vers_minor = static_cast<uint8_t>(*cur++ - '1' + 1);
|
||||
|
||||
if (vers_major == 1) {
|
||||
if (vers_minor == 0) {
|
||||
|
|
@ -175,14 +175,14 @@ static grpc_error* add_header(grpc_http_parser* parser) {
|
|||
goto done;
|
||||
}
|
||||
GPR_ASSERT(cur >= beg);
|
||||
hdr.key = buf2str(beg, (size_t)(cur - beg));
|
||||
hdr.key = buf2str(beg, static_cast<size_t>(cur - beg));
|
||||
cur++; /* skip : */
|
||||
|
||||
while (cur != end && (*cur == ' ' || *cur == '\t')) {
|
||||
cur++;
|
||||
}
|
||||
GPR_ASSERT((size_t)(end - cur) >= parser->cur_line_end_length);
|
||||
hdr.value = buf2str(cur, (size_t)(end - cur) - parser->cur_line_end_length);
|
||||
hdr.value = buf2str(cur, static_cast<size_t>(end - cur) - parser->cur_line_end_length);
|
||||
|
||||
switch (parser->type) {
|
||||
case GRPC_HTTP_RESPONSE:
|
||||
|
|
@ -198,8 +198,8 @@ static grpc_error* add_header(grpc_http_parser* parser) {
|
|||
if (*hdr_count == parser->hdr_capacity) {
|
||||
parser->hdr_capacity =
|
||||
GPR_MAX(parser->hdr_capacity + 1, parser->hdr_capacity * 3 / 2);
|
||||
*hdrs = (grpc_http_header*)gpr_realloc(
|
||||
*hdrs, parser->hdr_capacity * sizeof(**hdrs));
|
||||
*hdrs = static_cast<grpc_http_header*>(gpr_realloc(
|
||||
*hdrs, parser->hdr_capacity * sizeof(**hdrs)));
|
||||
}
|
||||
(*hdrs)[(*hdr_count)++] = hdr;
|
||||
|
||||
|
|
@ -257,9 +257,9 @@ static grpc_error* addbyte_body(grpc_http_parser* parser, uint8_t byte) {
|
|||
|
||||
if (*body_length == parser->body_capacity) {
|
||||
parser->body_capacity = GPR_MAX(8, parser->body_capacity * 3 / 2);
|
||||
*body = (char*)gpr_realloc((void*)*body, parser->body_capacity);
|
||||
*body = static_cast<char*>(gpr_realloc((void*)*body, parser->body_capacity));
|
||||
}
|
||||
(*body)[*body_length] = (char)byte;
|
||||
(*body)[*body_length] = static_cast<char>(byte);
|
||||
(*body_length)++;
|
||||
|
||||
return GRPC_ERROR_NONE;
|
||||
|
|
|
|||
|
|
@ -28,13 +28,13 @@ grpc_core::TraceFlag grpc_call_combiner_trace(false, "call_combiner");
|
|||
|
||||
static grpc_error* decode_cancel_state_error(gpr_atm cancel_state) {
|
||||
if (cancel_state & 1) {
|
||||
return (grpc_error*)(cancel_state & ~(gpr_atm)1);
|
||||
return (grpc_error*)(cancel_state & ~static_cast<gpr_atm>(1));
|
||||
}
|
||||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
|
||||
static gpr_atm encode_cancel_state_error(grpc_error* error) {
|
||||
return (gpr_atm)1 | (gpr_atm)error;
|
||||
return static_cast<gpr_atm>(1) | (gpr_atm)error;
|
||||
}
|
||||
|
||||
void grpc_call_combiner_init(grpc_call_combiner* call_combiner) {
|
||||
|
|
@ -69,7 +69,7 @@ void grpc_call_combiner_start(grpc_call_combiner* call_combiner,
|
|||
grpc_error_string(error));
|
||||
}
|
||||
size_t prev_size =
|
||||
(size_t)gpr_atm_full_fetch_add(&call_combiner->size, (gpr_atm)1);
|
||||
static_cast<size_t>(gpr_atm_full_fetch_add(&call_combiner->size, (gpr_atm)1));
|
||||
if (grpc_call_combiner_trace.enabled()) {
|
||||
gpr_log(GPR_DEBUG, " size: %" PRIdPTR " -> %" PRIdPTR, prev_size,
|
||||
prev_size + 1);
|
||||
|
|
@ -90,7 +90,7 @@ void grpc_call_combiner_start(grpc_call_combiner* call_combiner,
|
|||
}
|
||||
// Queue was not empty, so add closure to queue.
|
||||
closure->error_data.error = error;
|
||||
gpr_mpscq_push(&call_combiner->queue, (gpr_mpscq_node*)closure);
|
||||
gpr_mpscq_push(&call_combiner->queue, reinterpret_cast<gpr_mpscq_node*>(closure));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -103,7 +103,7 @@ void grpc_call_combiner_stop(grpc_call_combiner* call_combiner DEBUG_ARGS,
|
|||
call_combiner DEBUG_FMT_ARGS, reason);
|
||||
}
|
||||
size_t prev_size =
|
||||
(size_t)gpr_atm_full_fetch_add(&call_combiner->size, (gpr_atm)-1);
|
||||
static_cast<size_t>(gpr_atm_full_fetch_add(&call_combiner->size, (gpr_atm)-1));
|
||||
if (grpc_call_combiner_trace.enabled()) {
|
||||
gpr_log(GPR_DEBUG, " size: %" PRIdPTR " -> %" PRIdPTR, prev_size,
|
||||
prev_size - 1);
|
||||
|
|
@ -115,8 +115,8 @@ void grpc_call_combiner_stop(grpc_call_combiner* call_combiner DEBUG_ARGS,
|
|||
gpr_log(GPR_DEBUG, " checking queue");
|
||||
}
|
||||
bool empty;
|
||||
grpc_closure* closure = (grpc_closure*)gpr_mpscq_pop_and_check_end(
|
||||
&call_combiner->queue, &empty);
|
||||
grpc_closure* closure = reinterpret_cast<grpc_closure*>(gpr_mpscq_pop_and_check_end(
|
||||
&call_combiner->queue, &empty));
|
||||
if (closure == nullptr) {
|
||||
// This can happen either due to a race condition within the mpscq
|
||||
// code or because of a race with grpc_call_combiner_start().
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ typedef struct {
|
|||
} wrapped_closure;
|
||||
|
||||
inline void closure_wrapper(void* arg, grpc_error* error) {
|
||||
wrapped_closure* wc = (wrapped_closure*)arg;
|
||||
wrapped_closure* wc = static_cast<wrapped_closure*>(arg);
|
||||
grpc_iomgr_cb_func cb = wc->cb;
|
||||
void* cb_arg = wc->cb_arg;
|
||||
gpr_free(wc);
|
||||
|
|
@ -161,7 +161,7 @@ inline grpc_closure* grpc_closure_create(grpc_iomgr_cb_func cb, void* cb_arg,
|
|||
grpc_closure_scheduler* scheduler) {
|
||||
#endif
|
||||
closure_impl::wrapped_closure* wc =
|
||||
(closure_impl::wrapped_closure*)gpr_malloc(sizeof(*wc));
|
||||
static_cast<closure_impl::wrapped_closure*>(gpr_malloc(sizeof(*wc)));
|
||||
wc->cb = cb;
|
||||
wc->cb_arg = cb_arg;
|
||||
#ifndef NDEBUG
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ static const grpc_closure_scheduler_vtable finally_scheduler = {
|
|||
static void offload(void* arg, grpc_error* error);
|
||||
|
||||
grpc_combiner* grpc_combiner_create(void) {
|
||||
grpc_combiner* lock = (grpc_combiner*)gpr_zalloc(sizeof(*lock));
|
||||
grpc_combiner* lock = static_cast<grpc_combiner*>(gpr_zalloc(sizeof(*lock)));
|
||||
gpr_ref_init(&lock->refs, 1);
|
||||
lock->scheduler.vtable = &scheduler;
|
||||
lock->finally_scheduler.vtable = &finally_scheduler;
|
||||
|
|
@ -194,7 +194,7 @@ static void move_next() {
|
|||
}
|
||||
|
||||
static void offload(void* arg, grpc_error* error) {
|
||||
grpc_combiner* lock = (grpc_combiner*)arg;
|
||||
grpc_combiner* lock = static_cast<grpc_combiner*>(arg);
|
||||
push_last_on_exec_ctx(lock);
|
||||
}
|
||||
|
||||
|
|
@ -249,7 +249,7 @@ bool grpc_combiner_continue_exec_ctx() {
|
|||
return true;
|
||||
}
|
||||
GPR_TIMER_SCOPE("combiner.exec1", 0);
|
||||
grpc_closure* cl = (grpc_closure*)n;
|
||||
grpc_closure* cl = reinterpret_cast<grpc_closure*>(n);
|
||||
grpc_error* cl_err = cl->error_data.error;
|
||||
#ifndef NDEBUG
|
||||
cl->scheduled = false;
|
||||
|
|
@ -342,7 +342,7 @@ static void combiner_finally_exec(grpc_closure* closure, grpc_error* error) {
|
|||
}
|
||||
|
||||
static void enqueue_finally(void* closure, grpc_error* error) {
|
||||
combiner_finally_exec((grpc_closure*)closure, GRPC_ERROR_REF(error));
|
||||
combiner_finally_exec(static_cast<grpc_closure*>(closure), GRPC_ERROR_REF(error));
|
||||
}
|
||||
|
||||
grpc_closure_scheduler* grpc_combiner_scheduler(grpc_combiner* combiner) {
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ grpc_error* grpc_error_ref(grpc_error* err) {
|
|||
static void unref_errs(grpc_error* err) {
|
||||
uint8_t slot = err->first_err;
|
||||
while (slot != UINT8_MAX) {
|
||||
grpc_linked_error* lerr = (grpc_linked_error*)(err->arena + slot);
|
||||
grpc_linked_error* lerr = reinterpret_cast<grpc_linked_error*>(err->arena + slot);
|
||||
GRPC_ERROR_UNREF(lerr->err);
|
||||
GPR_ASSERT(err->last_err == slot ? lerr->next == UINT8_MAX
|
||||
: lerr->next != UINT8_MAX);
|
||||
|
|
@ -162,7 +162,7 @@ static void unref_strs(grpc_error* err) {
|
|||
for (size_t which = 0; which < GRPC_ERROR_STR_MAX; ++which) {
|
||||
uint8_t slot = err->strs[which];
|
||||
if (slot != UINT8_MAX) {
|
||||
unref_slice(*(grpc_slice*)(err->arena + slot));
|
||||
unref_slice(*reinterpret_cast<grpc_slice*>(err->arena + slot));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -198,18 +198,18 @@ void grpc_error_unref(grpc_error* err) {
|
|||
|
||||
static uint8_t get_placement(grpc_error** err, size_t size) {
|
||||
GPR_ASSERT(*err);
|
||||
uint8_t slots = (uint8_t)(size / sizeof(intptr_t));
|
||||
uint8_t slots = static_cast<uint8_t>(size / sizeof(intptr_t));
|
||||
if ((*err)->arena_size + slots > (*err)->arena_capacity) {
|
||||
(*err)->arena_capacity =
|
||||
(uint8_t)GPR_MIN(UINT8_MAX - 1, (3 * (*err)->arena_capacity / 2));
|
||||
static_cast<uint8_t>GPR_MIN(UINT8_MAX - 1, (3 * (*err)->arena_capacity / 2));
|
||||
if ((*err)->arena_size + slots > (*err)->arena_capacity) {
|
||||
return UINT8_MAX;
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
grpc_error* orig = *err;
|
||||
#endif
|
||||
*err = (grpc_error*)gpr_realloc(
|
||||
*err, sizeof(grpc_error) + (*err)->arena_capacity * sizeof(intptr_t));
|
||||
*err = static_cast<grpc_error*>(gpr_realloc(
|
||||
*err, sizeof(grpc_error) + (*err)->arena_capacity * sizeof(intptr_t)));
|
||||
#ifndef NDEBUG
|
||||
if (grpc_trace_error_refcount.enabled()) {
|
||||
if (*err != orig) {
|
||||
|
|
@ -219,7 +219,7 @@ static uint8_t get_placement(grpc_error** err, size_t size) {
|
|||
#endif
|
||||
}
|
||||
uint8_t placement = (*err)->arena_size;
|
||||
(*err)->arena_size = (uint8_t)((*err)->arena_size + slots);
|
||||
(*err)->arena_size = static_cast<uint8_t>((*err)->arena_size + slots);
|
||||
return placement;
|
||||
}
|
||||
|
||||
|
|
@ -251,7 +251,7 @@ static void internal_set_str(grpc_error** err, grpc_error_strs which,
|
|||
return;
|
||||
}
|
||||
} else {
|
||||
unref_slice(*(grpc_slice*)((*err)->arena + slot));
|
||||
unref_slice(*reinterpret_cast<grpc_slice*>((*err)->arena + slot));
|
||||
}
|
||||
(*err)->strs[which] = slot;
|
||||
memcpy((*err)->arena + slot, &value, sizeof(value));
|
||||
|
|
@ -291,7 +291,7 @@ static void internal_add_error(grpc_error** err, grpc_error* new_err) {
|
|||
} else {
|
||||
GPR_ASSERT((*err)->last_err != UINT8_MAX);
|
||||
grpc_linked_error* old_last =
|
||||
(grpc_linked_error*)((*err)->arena + (*err)->last_err);
|
||||
reinterpret_cast<grpc_linked_error*>((*err)->arena + (*err)->last_err);
|
||||
old_last->next = slot;
|
||||
(*err)->last_err = slot;
|
||||
}
|
||||
|
|
@ -315,11 +315,11 @@ grpc_error* grpc_error_create(const char* file, int line, grpc_slice desc,
|
|||
grpc_error** referencing,
|
||||
size_t num_referencing) {
|
||||
GPR_TIMER_SCOPE("grpc_error_create", 0);
|
||||
uint8_t initial_arena_capacity = (uint8_t)(
|
||||
uint8_t initial_arena_capacity = static_cast<uint8_t>(
|
||||
DEFAULT_ERROR_CAPACITY +
|
||||
(uint8_t)(num_referencing * SLOTS_PER_LINKED_ERROR) + SURPLUS_CAPACITY);
|
||||
grpc_error* err = (grpc_error*)gpr_malloc(
|
||||
sizeof(*err) + initial_arena_capacity * sizeof(intptr_t));
|
||||
static_cast<uint8_t>(num_referencing * SLOTS_PER_LINKED_ERROR) + SURPLUS_CAPACITY);
|
||||
grpc_error* err = static_cast<grpc_error*>(gpr_malloc(
|
||||
sizeof(*err) + initial_arena_capacity * sizeof(intptr_t)));
|
||||
if (err == nullptr) { // TODO(ctiller): make gpr_malloc return NULL
|
||||
return GRPC_ERROR_OOM;
|
||||
}
|
||||
|
|
@ -362,7 +362,7 @@ static void ref_strs(grpc_error* err) {
|
|||
for (size_t i = 0; i < GRPC_ERROR_STR_MAX; ++i) {
|
||||
uint8_t slot = err->strs[i];
|
||||
if (slot != UINT8_MAX) {
|
||||
grpc_slice_ref_internal(*(grpc_slice*)(err->arena + slot));
|
||||
grpc_slice_ref_internal(*reinterpret_cast<grpc_slice*>(err->arena + slot));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -370,7 +370,7 @@ static void ref_strs(grpc_error* err) {
|
|||
static void ref_errs(grpc_error* err) {
|
||||
uint8_t slot = err->first_err;
|
||||
while (slot != UINT8_MAX) {
|
||||
grpc_linked_error* lerr = (grpc_linked_error*)(err->arena + slot);
|
||||
grpc_linked_error* lerr = reinterpret_cast<grpc_linked_error*>(err->arena + slot);
|
||||
GRPC_ERROR_REF(lerr->err);
|
||||
slot = lerr->next;
|
||||
}
|
||||
|
|
@ -399,11 +399,11 @@ static grpc_error* copy_error_and_unref(grpc_error* in) {
|
|||
uint8_t new_arena_capacity = in->arena_capacity;
|
||||
// the returned err will be added to, so we ensure this is room to avoid
|
||||
// unneeded allocations.
|
||||
if (in->arena_capacity - in->arena_size < (uint8_t)SLOTS_PER_STR) {
|
||||
new_arena_capacity = (uint8_t)(3 * new_arena_capacity / 2);
|
||||
if (in->arena_capacity - in->arena_size < static_cast<uint8_t>SLOTS_PER_STR) {
|
||||
new_arena_capacity = static_cast<uint8_t>(3 * new_arena_capacity / 2);
|
||||
}
|
||||
out = (grpc_error*)gpr_malloc(sizeof(*in) +
|
||||
new_arena_capacity * sizeof(intptr_t));
|
||||
out = static_cast<grpc_error*>(gpr_malloc(sizeof(*in) +
|
||||
new_arena_capacity * sizeof(intptr_t)));
|
||||
#ifndef NDEBUG
|
||||
if (grpc_trace_error_refcount.enabled()) {
|
||||
gpr_log(GPR_DEBUG, "%p create copying %p", out, in);
|
||||
|
|
@ -487,7 +487,7 @@ bool grpc_error_get_str(grpc_error* err, grpc_error_strs which,
|
|||
}
|
||||
uint8_t slot = err->strs[which];
|
||||
if (slot != UINT8_MAX) {
|
||||
*str = *(grpc_slice*)(err->arena + slot);
|
||||
*str = *reinterpret_cast<grpc_slice*>(err->arena + slot);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
|
@ -519,7 +519,7 @@ typedef struct {
|
|||
static void append_chr(char c, char** s, size_t* sz, size_t* cap) {
|
||||
if (*sz == *cap) {
|
||||
*cap = GPR_MAX(8, 3 * *cap / 2);
|
||||
*s = (char*)gpr_realloc(*s, *cap);
|
||||
*s = static_cast<char*>(gpr_realloc(*s, *cap));
|
||||
}
|
||||
(*s)[(*sz)++] = c;
|
||||
}
|
||||
|
|
@ -562,7 +562,7 @@ static void append_esc_str(const uint8_t* str, size_t len, char** s, size_t* sz,
|
|||
break;
|
||||
}
|
||||
} else {
|
||||
append_chr((char)*str, s, sz, cap);
|
||||
append_chr(static_cast<char>(*str), s, sz, cap);
|
||||
}
|
||||
}
|
||||
append_chr('"', s, sz, cap);
|
||||
|
|
@ -572,7 +572,7 @@ static void append_kv(kv_pairs* kvs, char* key, char* value) {
|
|||
if (kvs->num_kvs == kvs->cap_kvs) {
|
||||
kvs->cap_kvs = GPR_MAX(3 * kvs->cap_kvs / 2, 4);
|
||||
kvs->kvs =
|
||||
(kv_pair*)gpr_realloc(kvs->kvs, sizeof(*kvs->kvs) * kvs->cap_kvs);
|
||||
static_cast<kv_pair*>(gpr_realloc(kvs->kvs, sizeof(*kvs->kvs) * kvs->cap_kvs));
|
||||
}
|
||||
kvs->kvs[kvs->num_kvs].key = key;
|
||||
kvs->kvs[kvs->num_kvs].value = value;
|
||||
|
|
@ -593,7 +593,7 @@ static void collect_ints_kvs(grpc_error* err, kv_pairs* kvs) {
|
|||
for (size_t which = 0; which < GRPC_ERROR_INT_MAX; ++which) {
|
||||
uint8_t slot = err->ints[which];
|
||||
if (slot != UINT8_MAX) {
|
||||
append_kv(kvs, key_int((grpc_error_ints)which),
|
||||
append_kv(kvs, key_int(static_cast<grpc_error_ints>(which)),
|
||||
fmt_int(err->arena[slot]));
|
||||
}
|
||||
}
|
||||
|
|
@ -617,8 +617,8 @@ static void collect_strs_kvs(grpc_error* err, kv_pairs* kvs) {
|
|||
for (size_t which = 0; which < GRPC_ERROR_STR_MAX; ++which) {
|
||||
uint8_t slot = err->strs[which];
|
||||
if (slot != UINT8_MAX) {
|
||||
append_kv(kvs, key_str((grpc_error_strs)which),
|
||||
fmt_str(*(grpc_slice*)(err->arena + slot)));
|
||||
append_kv(kvs, key_str(static_cast<grpc_error_strs>(which)),
|
||||
fmt_str(*reinterpret_cast<grpc_slice*>(err->arena + slot)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -652,8 +652,8 @@ static void collect_times_kvs(grpc_error* err, kv_pairs* kvs) {
|
|||
for (size_t which = 0; which < GRPC_ERROR_TIME_MAX; ++which) {
|
||||
uint8_t slot = err->times[which];
|
||||
if (slot != UINT8_MAX) {
|
||||
append_kv(kvs, key_time((grpc_error_times)which),
|
||||
fmt_time(*(gpr_timespec*)(err->arena + slot)));
|
||||
append_kv(kvs, key_time(static_cast<grpc_error_times>(which)),
|
||||
fmt_time(*reinterpret_cast<gpr_timespec*>(err->arena + slot)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -662,7 +662,7 @@ static void add_errs(grpc_error* err, char** s, size_t* sz, size_t* cap) {
|
|||
uint8_t slot = err->first_err;
|
||||
bool first = true;
|
||||
while (slot != UINT8_MAX) {
|
||||
grpc_linked_error* lerr = (grpc_linked_error*)(err->arena + slot);
|
||||
grpc_linked_error* lerr = reinterpret_cast<grpc_linked_error*>(err->arena + slot);
|
||||
if (!first) append_chr(',', s, sz, cap);
|
||||
first = false;
|
||||
const char* e = grpc_error_string(lerr->err);
|
||||
|
|
@ -685,8 +685,8 @@ static char* errs_string(grpc_error* err) {
|
|||
}
|
||||
|
||||
static int cmp_kvs(const void* a, const void* b) {
|
||||
const kv_pair* ka = (const kv_pair*)a;
|
||||
const kv_pair* kb = (const kv_pair*)b;
|
||||
const kv_pair* ka = static_cast<const kv_pair*>(a);
|
||||
const kv_pair* kb = static_cast<const kv_pair*>(b);
|
||||
return strcmp(ka->key, kb->key);
|
||||
}
|
||||
|
||||
|
|
@ -698,7 +698,7 @@ static char* finish_kvs(kv_pairs* kvs) {
|
|||
append_chr('{', &s, &sz, &cap);
|
||||
for (size_t i = 0; i < kvs->num_kvs; i++) {
|
||||
if (i != 0) append_chr(',', &s, &sz, &cap);
|
||||
append_esc_str((const uint8_t*)kvs->kvs[i].key, strlen(kvs->kvs[i].key), &s,
|
||||
append_esc_str(reinterpret_cast<const uint8_t*>(kvs->kvs[i].key), strlen(kvs->kvs[i].key), &s,
|
||||
&sz, &cap);
|
||||
gpr_free(kvs->kvs[i].key);
|
||||
append_chr(':', &s, &sz, &cap);
|
||||
|
|
@ -720,7 +720,7 @@ const char* grpc_error_string(grpc_error* err) {
|
|||
|
||||
void* p = (void*)gpr_atm_acq_load(&err->atomics.error_string);
|
||||
if (p != nullptr) {
|
||||
return (const char*)p;
|
||||
return static_cast<const char*>(p);
|
||||
}
|
||||
|
||||
kv_pairs kvs;
|
||||
|
|
|
|||
|
|
@ -281,7 +281,7 @@ static grpc_fd* fd_create(int fd, const char* name) {
|
|||
gpr_mu_unlock(&fd_freelist_mu);
|
||||
|
||||
if (new_fd == nullptr) {
|
||||
new_fd = (grpc_fd*)gpr_malloc(sizeof(grpc_fd));
|
||||
new_fd = static_cast<grpc_fd*>(gpr_malloc(sizeof(grpc_fd)));
|
||||
new_fd->read_closure.Init();
|
||||
new_fd->write_closure.Init();
|
||||
}
|
||||
|
|
@ -304,7 +304,7 @@ static grpc_fd* fd_create(int fd, const char* name) {
|
|||
gpr_free(fd_name);
|
||||
|
||||
struct epoll_event ev;
|
||||
ev.events = (uint32_t)(EPOLLIN | EPOLLOUT | EPOLLET);
|
||||
ev.events = static_cast<uint32_t>(EPOLLIN | EPOLLOUT | EPOLLET);
|
||||
ev.data.ptr = new_fd;
|
||||
if (epoll_ctl(g_epoll_set.epfd, EPOLL_CTL_ADD, fd, &ev) != 0) {
|
||||
gpr_log(GPR_ERROR, "epoll_ctl failed: %s", strerror(errno));
|
||||
|
|
@ -440,7 +440,7 @@ static worker_remove_result worker_remove(grpc_pollset* pollset,
|
|||
}
|
||||
|
||||
static size_t choose_neighborhood(void) {
|
||||
return (size_t)gpr_cpu_current_cpu() % g_num_neighborhoods;
|
||||
return static_cast<size_t>(gpr_cpu_current_cpu()) % g_num_neighborhoods;
|
||||
}
|
||||
|
||||
static grpc_error* pollset_global_init(void) {
|
||||
|
|
@ -451,15 +451,15 @@ static grpc_error* pollset_global_init(void) {
|
|||
grpc_error* err = grpc_wakeup_fd_init(&global_wakeup_fd);
|
||||
if (err != GRPC_ERROR_NONE) return err;
|
||||
struct epoll_event ev;
|
||||
ev.events = (uint32_t)(EPOLLIN | EPOLLET);
|
||||
ev.events = static_cast<uint32_t>(EPOLLIN | EPOLLET);
|
||||
ev.data.ptr = &global_wakeup_fd;
|
||||
if (epoll_ctl(g_epoll_set.epfd, EPOLL_CTL_ADD, global_wakeup_fd.read_fd,
|
||||
&ev) != 0) {
|
||||
return GRPC_OS_ERROR(errno, "epoll_ctl");
|
||||
}
|
||||
g_num_neighborhoods = GPR_CLAMP(gpr_cpu_num_cores(), 1, MAX_NEIGHBORHOODS);
|
||||
g_neighborhoods = (pollset_neighborhood*)gpr_zalloc(sizeof(*g_neighborhoods) *
|
||||
g_num_neighborhoods);
|
||||
g_neighborhoods = static_cast<pollset_neighborhood*>(gpr_zalloc(sizeof(*g_neighborhoods) *
|
||||
g_num_neighborhoods));
|
||||
for (size_t i = 0; i < g_num_neighborhoods; i++) {
|
||||
gpr_mu_init(&g_neighborhoods[i].mu);
|
||||
}
|
||||
|
|
@ -579,7 +579,7 @@ static int poll_deadline_to_millis_timeout(grpc_millis millis) {
|
|||
} else if (delta < 0) {
|
||||
return 0;
|
||||
} else {
|
||||
return (int)delta;
|
||||
return static_cast<int>(delta);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -609,7 +609,7 @@ static grpc_error* process_epoll_events(grpc_pollset* pollset) {
|
|||
append_error(&error, grpc_wakeup_fd_consume_wakeup(&global_wakeup_fd),
|
||||
err_desc);
|
||||
} else {
|
||||
grpc_fd* fd = (grpc_fd*)(data_ptr);
|
||||
grpc_fd* fd = static_cast<grpc_fd*>(data_ptr);
|
||||
bool cancel = (ev->events & (EPOLLERR | EPOLLHUP)) != 0;
|
||||
bool read_ev = (ev->events & (EPOLLIN | EPOLLPRI)) != 0;
|
||||
bool write_ev = (ev->events & EPOLLOUT) != 0;
|
||||
|
|
@ -881,7 +881,7 @@ static void end_worker(grpc_pollset* pollset, grpc_pollset_worker* worker,
|
|||
} else {
|
||||
gpr_atm_no_barrier_store(&g_active_poller, 0);
|
||||
size_t poller_neighborhood_idx =
|
||||
(size_t)(pollset->neighborhood - g_neighborhoods);
|
||||
static_cast<size_t>(pollset->neighborhood - g_neighborhoods);
|
||||
gpr_mu_unlock(&pollset->mu);
|
||||
bool found_worker = false;
|
||||
bool scan_state[MAX_NEIGHBORHOODS];
|
||||
|
|
@ -1150,7 +1150,7 @@ static void pollset_add_fd(grpc_pollset* pollset, grpc_fd* fd) {}
|
|||
*/
|
||||
|
||||
static grpc_pollset_set* pollset_set_create(void) {
|
||||
return (grpc_pollset_set*)((intptr_t)0xdeafbeef);
|
||||
return (grpc_pollset_set*)(static_cast<intptr_t>(0xdeafbeef));
|
||||
}
|
||||
|
||||
static void pollset_set_destroy(grpc_pollset_set* pss) {}
|
||||
|
|
|
|||
|
|
@ -276,7 +276,7 @@ static void ref_by(grpc_fd* fd, int n) {
|
|||
}
|
||||
|
||||
static void fd_destroy(void* arg, grpc_error* error) {
|
||||
grpc_fd* fd = (grpc_fd*)arg;
|
||||
grpc_fd* fd = static_cast<grpc_fd*>(arg);
|
||||
/* Add the fd to the freelist */
|
||||
grpc_iomgr_unregister_object(&fd->iomgr_object);
|
||||
POLLABLE_UNREF(fd->pollable_obj, "fd_pollable");
|
||||
|
|
@ -338,7 +338,7 @@ static grpc_fd* fd_create(int fd, const char* name) {
|
|||
gpr_mu_unlock(&fd_freelist_mu);
|
||||
|
||||
if (new_fd == nullptr) {
|
||||
new_fd = (grpc_fd*)gpr_malloc(sizeof(grpc_fd));
|
||||
new_fd = static_cast<grpc_fd*>(gpr_malloc(sizeof(grpc_fd)));
|
||||
new_fd->read_closure.Init();
|
||||
new_fd->write_closure.Init();
|
||||
}
|
||||
|
|
@ -441,7 +441,7 @@ static grpc_error* pollable_create(pollable_type type, pollable** p) {
|
|||
if (epfd == -1) {
|
||||
return GRPC_OS_ERROR(errno, "epoll_create1");
|
||||
}
|
||||
*p = (pollable*)gpr_malloc(sizeof(**p));
|
||||
*p = static_cast<pollable*>(gpr_malloc(sizeof(**p)));
|
||||
grpc_error* err = grpc_wakeup_fd_init(&(*p)->wakeup);
|
||||
if (err != GRPC_ERROR_NONE) {
|
||||
close(epfd);
|
||||
|
|
@ -450,7 +450,7 @@ static grpc_error* pollable_create(pollable_type type, pollable** p) {
|
|||
return err;
|
||||
}
|
||||
struct epoll_event ev;
|
||||
ev.events = (uint32_t)(EPOLLIN | EPOLLET);
|
||||
ev.events = static_cast<uint32_t>(EPOLLIN | EPOLLET);
|
||||
ev.data.ptr = (void*)(1 | (intptr_t) & (*p)->wakeup);
|
||||
if (epoll_ctl(epfd, EPOLL_CTL_ADD, (*p)->wakeup.read_fd, &ev) != 0) {
|
||||
err = GRPC_OS_ERROR(errno, "epoll_ctl");
|
||||
|
|
@ -479,7 +479,7 @@ static pollable* pollable_ref(pollable* p) {
|
|||
#else
|
||||
static pollable* pollable_ref(pollable* p, int line, const char* reason) {
|
||||
if (grpc_trace_pollable_refcount.enabled()) {
|
||||
int r = (int)gpr_atm_no_barrier_load(&p->refs.count);
|
||||
int r = static_cast<int>gpr_atm_no_barrier_load(&p->refs.count);
|
||||
gpr_log(__FILE__, line, GPR_LOG_SEVERITY_DEBUG,
|
||||
"POLLABLE:%p ref %d->%d %s", p, r, r + 1, reason);
|
||||
}
|
||||
|
|
@ -494,7 +494,7 @@ static void pollable_unref(pollable* p) {
|
|||
static void pollable_unref(pollable* p, int line, const char* reason) {
|
||||
if (p == nullptr) return;
|
||||
if (grpc_trace_pollable_refcount.enabled()) {
|
||||
int r = (int)gpr_atm_no_barrier_load(&p->refs.count);
|
||||
int r = static_cast<int>gpr_atm_no_barrier_load(&p->refs.count);
|
||||
gpr_log(__FILE__, line, GPR_LOG_SEVERITY_DEBUG,
|
||||
"POLLABLE:%p unref %d->%d %s", p, r, r - 1, reason);
|
||||
}
|
||||
|
|
@ -516,7 +516,7 @@ static grpc_error* pollable_add_fd(pollable* p, grpc_fd* fd) {
|
|||
}
|
||||
|
||||
struct epoll_event ev_fd;
|
||||
ev_fd.events = (uint32_t)(EPOLLET | EPOLLIN | EPOLLOUT | EPOLLEXCLUSIVE);
|
||||
ev_fd.events = static_cast<uint32_t>(EPOLLET | EPOLLIN | EPOLLOUT | EPOLLEXCLUSIVE);
|
||||
ev_fd.data.ptr = fd;
|
||||
if (epoll_ctl(epfd, EPOLL_CTL_ADD, fd->fd, &ev_fd) != 0) {
|
||||
switch (errno) {
|
||||
|
|
@ -699,7 +699,7 @@ static int poll_deadline_to_millis_timeout(grpc_millis millis) {
|
|||
else if (delta < 0)
|
||||
return 0;
|
||||
else
|
||||
return (int)delta;
|
||||
return static_cast<int>(delta);
|
||||
}
|
||||
|
||||
static void fd_become_readable(grpc_fd* fd, grpc_pollset* notifier) {
|
||||
|
|
@ -768,10 +768,10 @@ static grpc_error* pollable_process_events(grpc_pollset* pollset,
|
|||
}
|
||||
append_error(&error,
|
||||
grpc_wakeup_fd_consume_wakeup(
|
||||
(grpc_wakeup_fd*)((~(intptr_t)1) & (intptr_t)data_ptr)),
|
||||
(grpc_wakeup_fd*)((~static_cast<intptr_t>(1)) & (intptr_t)data_ptr)),
|
||||
err_desc);
|
||||
} else {
|
||||
grpc_fd* fd = (grpc_fd*)data_ptr;
|
||||
grpc_fd* fd = static_cast<grpc_fd*>(data_ptr);
|
||||
bool cancel = (ev->events & (EPOLLERR | EPOLLHUP)) != 0;
|
||||
bool read_ev = (ev->events & (EPOLLIN | EPOLLPRI)) != 0;
|
||||
bool write_ev = (ev->events & EPOLLOUT) != 0;
|
||||
|
|
@ -1170,7 +1170,7 @@ static grpc_pollset_set* pss_lock_adam(grpc_pollset_set* pss) {
|
|||
}
|
||||
|
||||
static grpc_pollset_set* pollset_set_create(void) {
|
||||
grpc_pollset_set* pss = (grpc_pollset_set*)gpr_zalloc(sizeof(*pss));
|
||||
grpc_pollset_set* pss = static_cast<grpc_pollset_set*>(gpr_zalloc(sizeof(*pss)));
|
||||
gpr_mu_init(&pss->mu);
|
||||
gpr_ref_init(&pss->refs, 1);
|
||||
return pss;
|
||||
|
|
@ -1211,7 +1211,7 @@ static void pollset_set_add_fd(grpc_pollset_set* pss, grpc_fd* fd) {
|
|||
if (pss->fd_count == pss->fd_capacity) {
|
||||
pss->fd_capacity = GPR_MAX(pss->fd_capacity * 2, 8);
|
||||
pss->fds =
|
||||
(grpc_fd**)gpr_realloc(pss->fds, pss->fd_capacity * sizeof(*pss->fds));
|
||||
static_cast<grpc_fd**>(gpr_realloc(pss->fds, pss->fd_capacity * sizeof(*pss->fds)));
|
||||
}
|
||||
REF_BY(fd, 2, "pollset_set");
|
||||
pss->fds[pss->fd_count++] = fd;
|
||||
|
|
@ -1319,8 +1319,8 @@ static void pollset_set_add_pollset(grpc_pollset_set* pss, grpc_pollset* ps) {
|
|||
err_desc);
|
||||
if (pss->pollset_count == pss->pollset_capacity) {
|
||||
pss->pollset_capacity = GPR_MAX(pss->pollset_capacity * 2, 8);
|
||||
pss->pollsets = (grpc_pollset**)gpr_realloc(
|
||||
pss->pollsets, pss->pollset_capacity * sizeof(*pss->pollsets));
|
||||
pss->pollsets = static_cast<grpc_pollset**>(gpr_realloc(
|
||||
pss->pollsets, pss->pollset_capacity * sizeof(*pss->pollsets)));
|
||||
}
|
||||
pss->pollsets[pss->pollset_count++] = ps;
|
||||
gpr_mu_unlock(&pss->mu);
|
||||
|
|
@ -1373,7 +1373,7 @@ static void pollset_set_add_pollset_set(grpc_pollset_set* a,
|
|||
b->parent = a;
|
||||
if (a->fd_capacity < a->fd_count + b->fd_count) {
|
||||
a->fd_capacity = GPR_MAX(2 * a->fd_capacity, a->fd_count + b->fd_count);
|
||||
a->fds = (grpc_fd**)gpr_realloc(a->fds, a->fd_capacity * sizeof(*a->fds));
|
||||
a->fds = static_cast<grpc_fd**>(gpr_realloc(a->fds, a->fd_capacity * sizeof(*a->fds)));
|
||||
}
|
||||
size_t initial_a_fd_count = a->fd_count;
|
||||
a->fd_count = 0;
|
||||
|
|
@ -1390,8 +1390,8 @@ static void pollset_set_add_pollset_set(grpc_pollset_set* a,
|
|||
if (a->pollset_capacity < a->pollset_count + b->pollset_count) {
|
||||
a->pollset_capacity =
|
||||
GPR_MAX(2 * a->pollset_capacity, a->pollset_count + b->pollset_count);
|
||||
a->pollsets = (grpc_pollset**)gpr_realloc(
|
||||
a->pollsets, a->pollset_capacity * sizeof(*a->pollsets));
|
||||
a->pollsets = static_cast<grpc_pollset**>(gpr_realloc(
|
||||
a->pollsets, a->pollset_capacity * sizeof(*a->pollsets)));
|
||||
}
|
||||
if (b->pollset_count > 0) {
|
||||
memcpy(a->pollsets + a->pollset_count, b->pollsets,
|
||||
|
|
|
|||
|
|
@ -349,7 +349,7 @@ static void polling_island_add_fds_locked(polling_island* pi, grpc_fd** fds,
|
|||
#endif /* defined(GRPC_TSAN) */
|
||||
|
||||
for (i = 0; i < fd_count; i++) {
|
||||
ev.events = (uint32_t)(EPOLLIN | EPOLLOUT | EPOLLET);
|
||||
ev.events = static_cast<uint32_t>(EPOLLIN | EPOLLOUT | EPOLLET);
|
||||
ev.data.ptr = fds[i];
|
||||
err = epoll_ctl(pi->epoll_fd, EPOLL_CTL_ADD, fds[i]->fd, &ev);
|
||||
|
||||
|
|
@ -369,7 +369,7 @@ static void polling_island_add_fds_locked(polling_island* pi, grpc_fd** fds,
|
|||
if (pi->fd_cnt == pi->fd_capacity) {
|
||||
pi->fd_capacity = GPR_MAX(pi->fd_capacity + 8, pi->fd_cnt * 3 / 2);
|
||||
pi->fds =
|
||||
(grpc_fd**)gpr_realloc(pi->fds, sizeof(grpc_fd*) * pi->fd_capacity);
|
||||
static_cast<grpc_fd**>(gpr_realloc(pi->fds, sizeof(grpc_fd*) * pi->fd_capacity));
|
||||
}
|
||||
|
||||
pi->fds[pi->fd_cnt++] = fds[i];
|
||||
|
|
@ -388,7 +388,7 @@ static void polling_island_add_wakeup_fd_locked(polling_island* pi,
|
|||
char* err_msg;
|
||||
const char* err_desc = "polling_island_add_wakeup_fd";
|
||||
|
||||
ev.events = (uint32_t)(EPOLLIN | EPOLLET);
|
||||
ev.events = static_cast<uint32_t>(EPOLLIN | EPOLLET);
|
||||
ev.data.ptr = wakeup_fd;
|
||||
err = epoll_ctl(pi->epoll_fd, EPOLL_CTL_ADD,
|
||||
GRPC_WAKEUP_FD_GET_READ_FD(wakeup_fd), &ev);
|
||||
|
|
@ -471,7 +471,7 @@ static polling_island* polling_island_create(grpc_fd* initial_fd,
|
|||
|
||||
*error = GRPC_ERROR_NONE;
|
||||
|
||||
pi = (polling_island*)gpr_malloc(sizeof(*pi));
|
||||
pi = static_cast<polling_island*>(gpr_malloc(sizeof(*pi)));
|
||||
gpr_mu_init(&pi->mu);
|
||||
pi->fd_cnt = 0;
|
||||
pi->fd_capacity = 0;
|
||||
|
|
@ -815,7 +815,7 @@ static grpc_fd* fd_create(int fd, const char* name) {
|
|||
gpr_mu_unlock(&fd_freelist_mu);
|
||||
|
||||
if (new_fd == nullptr) {
|
||||
new_fd = (grpc_fd*)gpr_malloc(sizeof(grpc_fd));
|
||||
new_fd = static_cast<grpc_fd*>(gpr_malloc(sizeof(grpc_fd)));
|
||||
gpr_mu_init(&new_fd->po.mu);
|
||||
new_fd->read_closure.Init();
|
||||
new_fd->write_closure.Init();
|
||||
|
|
@ -976,7 +976,7 @@ static grpc_error* pollset_worker_kick(grpc_pollset_worker* worker) {
|
|||
grpc_error* err = GRPC_ERROR_NONE;
|
||||
|
||||
/* Kick the worker only if it was not already kicked */
|
||||
if (gpr_atm_no_barrier_cas(&worker->is_kicked, (gpr_atm)0, (gpr_atm)1)) {
|
||||
if (gpr_atm_no_barrier_cas(&worker->is_kicked, static_cast<gpr_atm>(0), static_cast<gpr_atm>(1))) {
|
||||
GRPC_POLLING_TRACE(
|
||||
"pollset_worker_kick: Kicking worker: %p (thread id: %ld)",
|
||||
(void*)worker, (long int)worker->pt_id);
|
||||
|
|
@ -1096,7 +1096,7 @@ static int poll_deadline_to_millis_timeout(grpc_millis millis) {
|
|||
else if (delta < 0)
|
||||
return 0;
|
||||
else
|
||||
return (int)delta;
|
||||
return static_cast<int>(delta);
|
||||
}
|
||||
|
||||
static void fd_become_readable(grpc_fd* fd, grpc_pollset* notifier) {
|
||||
|
|
@ -1251,7 +1251,7 @@ static void pollset_work_and_unlock(grpc_pollset* pollset,
|
|||
to the function pollset_work_and_unlock() will pick up the correct
|
||||
epoll_fd */
|
||||
} else {
|
||||
grpc_fd* fd = (grpc_fd*)data_ptr;
|
||||
grpc_fd* fd = static_cast<grpc_fd*>(data_ptr);
|
||||
int cancel = ep_ev[i].events & (EPOLLERR | EPOLLHUP);
|
||||
int read_ev = ep_ev[i].events & (EPOLLIN | EPOLLPRI);
|
||||
int write_ev = ep_ev[i].events & EPOLLOUT;
|
||||
|
|
@ -1538,7 +1538,7 @@ static void pollset_add_fd(grpc_pollset* pollset, grpc_fd* fd) {
|
|||
*/
|
||||
|
||||
static grpc_pollset_set* pollset_set_create(void) {
|
||||
grpc_pollset_set* pss = (grpc_pollset_set*)gpr_malloc(sizeof(*pss));
|
||||
grpc_pollset_set* pss = static_cast<grpc_pollset_set*>(gpr_malloc(sizeof(*pss)));
|
||||
gpr_mu_init(&pss->po.mu);
|
||||
pss->po.pi = nullptr;
|
||||
#ifndef NDEBUG
|
||||
|
|
@ -1607,8 +1607,8 @@ void* grpc_pollset_get_polling_island(grpc_pollset* ps) {
|
|||
}
|
||||
|
||||
bool grpc_are_polling_islands_equal(void* p, void* q) {
|
||||
polling_island* p1 = (polling_island*)p;
|
||||
polling_island* p2 = (polling_island*)q;
|
||||
polling_island* p1 = static_cast<polling_island*>(p);
|
||||
polling_island* p2 = static_cast<polling_island*>(q);
|
||||
|
||||
/* Note: polling_island_lock_pair() may change p1 and p2 to point to the
|
||||
latest polling islands in their respective linked lists */
|
||||
|
|
|
|||
|
|
@ -323,7 +323,7 @@ static void unref_by(grpc_fd* fd, int n) {
|
|||
}
|
||||
|
||||
static grpc_fd* fd_create(int fd, const char* name) {
|
||||
grpc_fd* r = (grpc_fd*)gpr_malloc(sizeof(*r));
|
||||
grpc_fd* r = static_cast<grpc_fd*>(gpr_malloc(sizeof(*r)));
|
||||
gpr_mu_init(&r->mu);
|
||||
gpr_atm_rel_store(&r->refst, 1);
|
||||
r->shutdown = 0;
|
||||
|
|
@ -835,8 +835,8 @@ static void pollset_add_fd(grpc_pollset* pollset, grpc_fd* fd) {
|
|||
if (pollset->fd_count == pollset->fd_capacity) {
|
||||
pollset->fd_capacity =
|
||||
GPR_MAX(pollset->fd_capacity + 8, pollset->fd_count * 3 / 2);
|
||||
pollset->fds = (grpc_fd**)gpr_realloc(
|
||||
pollset->fds, sizeof(grpc_fd*) * pollset->fd_capacity);
|
||||
pollset->fds = static_cast<grpc_fd**>(gpr_realloc(
|
||||
pollset->fds, sizeof(grpc_fd*) * pollset->fd_capacity));
|
||||
}
|
||||
pollset->fds[pollset->fd_count++] = fd;
|
||||
GRPC_FD_REF(fd, "multipoller");
|
||||
|
|
@ -890,7 +890,7 @@ static grpc_error* pollset_work(grpc_pollset* pollset,
|
|||
pollset->local_wakeup_cache = worker.wakeup_fd->next;
|
||||
} else {
|
||||
worker.wakeup_fd =
|
||||
(grpc_cached_wakeup_fd*)gpr_malloc(sizeof(*worker.wakeup_fd));
|
||||
static_cast<grpc_cached_wakeup_fd*>(gpr_malloc(sizeof(*worker.wakeup_fd)));
|
||||
error = grpc_wakeup_fd_init(&worker.wakeup_fd->fd);
|
||||
if (error != GRPC_ERROR_NONE) {
|
||||
GRPC_LOG_IF_ERROR("pollset_work", GRPC_ERROR_REF(error));
|
||||
|
|
@ -945,8 +945,8 @@ static grpc_error* pollset_work(grpc_pollset* pollset,
|
|||
const size_t pfd_size = sizeof(*pfds) * (pollset->fd_count + 2);
|
||||
const size_t watch_size = sizeof(*watchers) * (pollset->fd_count + 2);
|
||||
void* buf = gpr_malloc(pfd_size + watch_size);
|
||||
pfds = (struct pollfd*)buf;
|
||||
watchers = (grpc_fd_watcher*)(void*)((char*)buf + pfd_size);
|
||||
pfds = static_cast<struct pollfd*>(buf);
|
||||
watchers = static_cast<grpc_fd_watcher*>((void*)(static_cast<char*>(buf) + pfd_size));
|
||||
}
|
||||
|
||||
fd_count = 0;
|
||||
|
|
@ -972,8 +972,8 @@ static grpc_error* pollset_work(grpc_pollset* pollset,
|
|||
|
||||
for (i = 1; i < pfd_count; i++) {
|
||||
grpc_fd* fd = watchers[i].fd;
|
||||
pfds[i].events = (short)fd_begin_poll(fd, pollset, &worker, POLLIN,
|
||||
POLLOUT, &watchers[i]);
|
||||
pfds[i].events = static_cast<short>(fd_begin_poll(fd, pollset, &worker, POLLIN,
|
||||
POLLOUT, &watchers[i]));
|
||||
GRPC_FD_UNREF(fd, "multipoller_start");
|
||||
}
|
||||
|
||||
|
|
@ -1123,7 +1123,7 @@ static int poll_deadline_to_millis_timeout(grpc_millis deadline) {
|
|||
grpc_millis n = deadline - grpc_core::ExecCtx::Get()->Now();
|
||||
if (n < 0) return 0;
|
||||
if (n > INT_MAX) return -1;
|
||||
return (int)n;
|
||||
return static_cast<int>(n);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
|
@ -1132,7 +1132,7 @@ static int poll_deadline_to_millis_timeout(grpc_millis deadline) {
|
|||
|
||||
static grpc_pollset_set* pollset_set_create(void) {
|
||||
grpc_pollset_set* pollset_set =
|
||||
(grpc_pollset_set*)gpr_zalloc(sizeof(*pollset_set));
|
||||
static_cast<grpc_pollset_set*>(gpr_zalloc(sizeof(*pollset_set)));
|
||||
gpr_mu_init(&pollset_set->mu);
|
||||
return pollset_set;
|
||||
}
|
||||
|
|
@ -1173,9 +1173,9 @@ static void pollset_set_add_pollset(grpc_pollset_set* pollset_set,
|
|||
if (pollset_set->pollset_count == pollset_set->pollset_capacity) {
|
||||
pollset_set->pollset_capacity =
|
||||
GPR_MAX(8, 2 * pollset_set->pollset_capacity);
|
||||
pollset_set->pollsets = (grpc_pollset**)gpr_realloc(
|
||||
pollset_set->pollsets = static_cast<grpc_pollset**>(gpr_realloc(
|
||||
pollset_set->pollsets,
|
||||
pollset_set->pollset_capacity * sizeof(*pollset_set->pollsets));
|
||||
pollset_set->pollset_capacity * sizeof(*pollset_set->pollsets)));
|
||||
}
|
||||
pollset_set->pollsets[pollset_set->pollset_count++] = pollset;
|
||||
for (i = 0, j = 0; i < pollset_set->fd_count; i++) {
|
||||
|
|
@ -1222,9 +1222,9 @@ static void pollset_set_add_pollset_set(grpc_pollset_set* bag,
|
|||
gpr_mu_lock(&bag->mu);
|
||||
if (bag->pollset_set_count == bag->pollset_set_capacity) {
|
||||
bag->pollset_set_capacity = GPR_MAX(8, 2 * bag->pollset_set_capacity);
|
||||
bag->pollset_sets = (grpc_pollset_set**)gpr_realloc(
|
||||
bag->pollset_sets = static_cast<grpc_pollset_set**>(gpr_realloc(
|
||||
bag->pollset_sets,
|
||||
bag->pollset_set_capacity * sizeof(*bag->pollset_sets));
|
||||
bag->pollset_set_capacity * sizeof(*bag->pollset_sets)));
|
||||
}
|
||||
bag->pollset_sets[bag->pollset_set_count++] = item;
|
||||
for (i = 0, j = 0; i < bag->fd_count; i++) {
|
||||
|
|
@ -1259,8 +1259,8 @@ static void pollset_set_add_fd(grpc_pollset_set* pollset_set, grpc_fd* fd) {
|
|||
gpr_mu_lock(&pollset_set->mu);
|
||||
if (pollset_set->fd_count == pollset_set->fd_capacity) {
|
||||
pollset_set->fd_capacity = GPR_MAX(8, 2 * pollset_set->fd_capacity);
|
||||
pollset_set->fds = (grpc_fd**)gpr_realloc(
|
||||
pollset_set->fds, pollset_set->fd_capacity * sizeof(*pollset_set->fds));
|
||||
pollset_set->fds = static_cast<grpc_fd**>(gpr_realloc(
|
||||
pollset_set->fds, pollset_set->fd_capacity * sizeof(*pollset_set->fds)));
|
||||
}
|
||||
GRPC_FD_REF(fd, "pollset_set");
|
||||
pollset_set->fds[pollset_set->fd_count++] = fd;
|
||||
|
|
@ -1312,12 +1312,12 @@ static void cache_insert_locked(poll_args* args) {
|
|||
}
|
||||
|
||||
static void init_result(poll_args* pargs) {
|
||||
pargs->result = (poll_result*)gpr_malloc(sizeof(poll_result));
|
||||
pargs->result = static_cast<poll_result*>(gpr_malloc(sizeof(poll_result)));
|
||||
gpr_ref_init(&pargs->result->refcount, 1);
|
||||
pargs->result->watchers = nullptr;
|
||||
pargs->result->watchcount = 0;
|
||||
pargs->result->fds =
|
||||
(struct pollfd*)gpr_malloc(sizeof(struct pollfd) * pargs->nfds);
|
||||
static_cast<struct pollfd*>(gpr_malloc(sizeof(struct pollfd) * pargs->nfds));
|
||||
memcpy(pargs->result->fds, pargs->fds, sizeof(struct pollfd) * pargs->nfds);
|
||||
pargs->result->nfds = pargs->nfds;
|
||||
pargs->result->retval = 0;
|
||||
|
|
@ -1356,7 +1356,7 @@ static poll_args* get_poller_locked(struct pollfd* fds, nfds_t count) {
|
|||
return pargs;
|
||||
}
|
||||
|
||||
poll_args* pargs = (poll_args*)gpr_malloc(sizeof(struct poll_args));
|
||||
poll_args* pargs = static_cast<poll_args*>(gpr_malloc(sizeof(struct poll_args)));
|
||||
gpr_cv_init(&pargs->trigger);
|
||||
pargs->fds = fds;
|
||||
pargs->nfds = count;
|
||||
|
|
@ -1404,7 +1404,7 @@ static void cache_poller_locked(poll_args* args) {
|
|||
poll_cache.size = poll_cache.size * 2;
|
||||
poll_cache.count = 0;
|
||||
poll_cache.active_pollers =
|
||||
(poll_args**)gpr_malloc(sizeof(void*) * poll_cache.size);
|
||||
static_cast<poll_args**>(gpr_malloc(sizeof(void*) * poll_cache.size));
|
||||
for (unsigned int i = 0; i < poll_cache.size; i++) {
|
||||
poll_cache.active_pollers[i] = nullptr;
|
||||
}
|
||||
|
|
@ -1461,7 +1461,7 @@ gpr_timespec thread_grace;
|
|||
|
||||
// Poll in a background thread
|
||||
static void run_poll(void* args) {
|
||||
poll_args* pargs = (poll_args*)args;
|
||||
poll_args* pargs = static_cast<poll_args*>(args);
|
||||
while (1) {
|
||||
poll_result* result = pargs->result;
|
||||
int retval = g_cvfds.poll(result->fds, result->nfds, CV_POLL_PERIOD_MS);
|
||||
|
|
@ -1509,12 +1509,12 @@ static int cvfd_poll(struct pollfd* fds, nfds_t nfds, int timeout) {
|
|||
nfds_t nsockfds = 0;
|
||||
poll_result* result = nullptr;
|
||||
gpr_mu_lock(&g_cvfds.mu);
|
||||
pollcv = (grpc_cv_node*)gpr_malloc(sizeof(grpc_cv_node));
|
||||
pollcv = static_cast<grpc_cv_node*>(gpr_malloc(sizeof(grpc_cv_node)));
|
||||
pollcv->next = nullptr;
|
||||
gpr_cv pollcv_cv;
|
||||
gpr_cv_init(&pollcv_cv);
|
||||
pollcv->cv = &pollcv_cv;
|
||||
grpc_cv_node* fd_cvs = (grpc_cv_node*)gpr_malloc(nfds * sizeof(grpc_cv_node));
|
||||
grpc_cv_node* fd_cvs = static_cast<grpc_cv_node*>(gpr_malloc(nfds * sizeof(grpc_cv_node)));
|
||||
|
||||
for (i = 0; i < nfds; i++) {
|
||||
fds[i].revents = 0;
|
||||
|
|
@ -1547,7 +1547,7 @@ static int cvfd_poll(struct pollfd* fds, nfds_t nfds, int timeout) {
|
|||
res = 0;
|
||||
if (!skip_poll && nsockfds > 0) {
|
||||
struct pollfd* pollfds =
|
||||
(struct pollfd*)gpr_malloc(sizeof(struct pollfd) * nsockfds);
|
||||
static_cast<struct pollfd*>(gpr_malloc(sizeof(struct pollfd) * nsockfds));
|
||||
idx = 0;
|
||||
for (i = 0; i < nfds; i++) {
|
||||
if (fds[i].fd >= 0) {
|
||||
|
|
@ -1611,7 +1611,7 @@ static void global_cv_fd_table_init() {
|
|||
gpr_ref_init(&g_cvfds.pollcount, 1);
|
||||
g_cvfds.size = CV_DEFAULT_TABLE_SIZE;
|
||||
g_cvfds.cvfds =
|
||||
(grpc_fd_node*)gpr_malloc(sizeof(grpc_fd_node) * CV_DEFAULT_TABLE_SIZE);
|
||||
static_cast<grpc_fd_node*>(gpr_malloc(sizeof(grpc_fd_node) * CV_DEFAULT_TABLE_SIZE));
|
||||
g_cvfds.free_fds = nullptr;
|
||||
thread_grace = gpr_time_from_millis(POLLCV_THREAD_GRACE_MS, GPR_TIMESPAN);
|
||||
for (int i = 0; i < CV_DEFAULT_TABLE_SIZE; i++) {
|
||||
|
|
@ -1628,7 +1628,7 @@ static void global_cv_fd_table_init() {
|
|||
poll_cache.size = 32;
|
||||
poll_cache.count = 0;
|
||||
poll_cache.free_pollers = nullptr;
|
||||
poll_cache.active_pollers = (poll_args**)gpr_malloc(sizeof(void*) * 32);
|
||||
poll_cache.active_pollers = static_cast<poll_args**>(gpr_malloc(sizeof(void*) * 32));
|
||||
for (unsigned int i = 0; i < poll_cache.size; i++) {
|
||||
poll_cache.active_pollers[i] = nullptr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,11 +108,11 @@ static void add(const char* beg, const char* end, char*** ss, size_t* ns) {
|
|||
char* s;
|
||||
size_t len;
|
||||
GPR_ASSERT(end >= beg);
|
||||
len = (size_t)(end - beg);
|
||||
s = (char*)gpr_malloc(len + 1);
|
||||
len = static_cast<size_t>(end - beg);
|
||||
s = static_cast<char*>(gpr_malloc(len + 1));
|
||||
memcpy(s, beg, len);
|
||||
s[len] = 0;
|
||||
*ss = (char**)gpr_realloc(*ss, sizeof(char**) * np);
|
||||
*ss = static_cast<char**>(gpr_realloc(*ss, sizeof(char**) * np));
|
||||
(*ss)[n] = s;
|
||||
*ns = np;
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue