diff options
Diffstat (limited to 'src/core/ext/filters')
29 files changed, 237 insertions, 160 deletions
diff --git a/src/core/ext/filters/client_channel/backup_poller.cc b/src/core/ext/filters/client_channel/backup_poller.cc index 35f1b97b77..ee90b499eb 100644 --- a/src/core/ext/filters/client_channel/backup_poller.cc +++ b/src/core/ext/filters/client_channel/backup_poller.cc @@ -134,7 +134,8 @@ void grpc_client_channel_start_backup_polling( gpr_mu_lock(&g_poller_mu); if (g_poller == nullptr) { 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->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); diff --git a/src/core/ext/filters/client_channel/channel_connectivity.cc b/src/core/ext/filters/client_channel/channel_connectivity.cc index 74c6cfe93c..31a5c31124 100644 --- a/src/core/ext/filters/client_channel/channel_connectivity.cc +++ b/src/core/ext/filters/client_channel/channel_connectivity.cc @@ -227,8 +227,8 @@ void grpc_channel_watch_connectivity_state( w->channel = channel; w->error = nullptr; - watcher_timer_init_arg* wa = - static_cast<watcher_timer_init_arg*>(gpr_malloc(sizeof(watcher_timer_init_arg))); + watcher_timer_init_arg* wa = 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, diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index ee2f21a064..50d562f946 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -260,7 +260,8 @@ 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 = static_cast<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()) { @@ -353,7 +354,8 @@ static void parse_retry_throttle_params(const grpc_json* field, void* arg) { &whole_value)) { return; } - milli_token_ratio = static_cast<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 +366,8 @@ 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 = static_cast<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. @@ -458,7 +461,8 @@ static void on_resolver_result_changed_locked(void* arg, grpc_error* error) { lb_policy_name); } else { reresolution_request_args* args = - static_cast<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, @@ -973,8 +977,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 = static_cast<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 @@ -1161,7 +1165,8 @@ 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 = static_cast<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; @@ -1195,7 +1200,8 @@ 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 = static_cast<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()) { @@ -1595,7 +1601,8 @@ int grpc_client_channel_num_external_connectivity_watchers( } static void on_external_watch_complete_locked(void* arg, grpc_error* error) { - external_connectivity_watcher* w = static_cast<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 +1615,8 @@ 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 = static_cast<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); diff --git a/src/core/ext/filters/client_channel/client_channel_factory.cc b/src/core/ext/filters/client_channel/client_channel_factory.cc index a21db1ff69..3baf5b31ab 100644 --- a/src/core/ext/filters/client_channel/client_channel_factory.cc +++ b/src/core/ext/filters/client_channel/client_channel_factory.cc @@ -39,12 +39,14 @@ grpc_channel* grpc_client_channel_factory_create_channel( } static void* factory_arg_copy(void* factory) { - grpc_client_channel_factory_ref(static_cast<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(static_cast<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) { diff --git a/src/core/ext/filters/client_channel/http_connect_handshaker.cc b/src/core/ext/filters/client_channel/http_connect_handshaker.cc index b4684a81dc..6bb4cefe73 100644 --- a/src/core/ext/filters/client_channel/http_connect_handshaker.cc +++ b/src/core/ext/filters/client_channel/http_connect_handshaker.cc @@ -119,7 +119,8 @@ 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 = static_cast<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 +140,8 @@ 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 = static_cast<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 +226,15 @@ done: // static void http_connect_handshaker_destroy(grpc_handshaker* handshaker_in) { - http_connect_handshaker* handshaker = reinterpret_cast<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 = reinterpret_cast<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 +248,8 @@ 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 = reinterpret_cast<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 +275,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 = static_cast<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) { diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc index b048989d4e..1a3a1f029c 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc @@ -70,9 +70,9 @@ static grpc_error* init_call_elem(grpc_call_element* elem, // 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( - static_cast<grpc_grpclb_client_stats*>(args->context[GRPC_GRPCLB_CLIENT_STATS] - .value)); + calld->client_stats = + grpc_grpclb_client_stats_ref(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); } diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index 9ebc15d985..04bf798267 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -320,7 +320,8 @@ 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, - static_cast<unsigned long>(count - 1), static_cast<unsigned long>(count), reason); + static_cast<unsigned long>(count - 1), + static_cast<unsigned long>(count), reason); } } @@ -331,7 +332,8 @@ 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, - static_cast<unsigned long>(count + 1), static_cast<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); @@ -493,13 +495,15 @@ static void parse_server(const grpc_grpclb_server* server, const grpc_grpclb_ip_address* ip = &server->ip_address; if (ip->size == 4) { addr->len = sizeof(struct sockaddr_in); - struct sockaddr_in* addr4 = reinterpret_cast<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 = reinterpret_cast<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; @@ -716,7 +720,8 @@ 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 = static_cast<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 @@ -887,8 +892,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 = - static_cast<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) { @@ -1257,7 +1262,8 @@ 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 = - static_cast<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 == @@ -1338,7 +1344,8 @@ 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 = static_cast<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, @@ -1809,14 +1816,16 @@ 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 = static_cast<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 = static_cast<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); @@ -1920,7 +1929,8 @@ 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, static_cast<const grpc_channel_filter*>(arg), nullptr, nullptr); + builder, static_cast<const grpc_channel_filter*>(arg), nullptr, + nullptr); } return true; } diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc index f9ffea6c39..3929ed0843 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc @@ -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 = - static_cast<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 = static_cast<grpc_grpclb_drop_token_count*>(gpr_realloc( - drop_token_counts->token_counts, - new_num_entries * sizeof(grpc_grpclb_drop_token_count))); + 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))); 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 = static_cast<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)); } diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc index ee6dd27eb5..c388b6ba77 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc @@ -60,8 +60,8 @@ 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 = - static_cast<grpc_grpclb_request*>(gpr_malloc(sizeof(grpc_grpclb_request))); + grpc_grpclb_request* req = 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; @@ -107,8 +107,8 @@ 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 = - static_cast<grpc_grpclb_request*>(gpr_zalloc(sizeof(grpc_grpclb_request))); + grpc_grpclb_request* req = 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, - reinterpret_cast<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,7 +148,8 @@ 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 = - static_cast<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); @@ -170,8 +171,8 @@ grpc_grpclb_initial_response* grpc_grpclb_initial_response_parse( if (!res.has_initial_response) return nullptr; grpc_grpclb_initial_response* initial_res = - static_cast<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)); @@ -184,8 +185,8 @@ grpc_grpclb_serverlist* grpc_grpclb_response_parse_serverlist( pb_istream_from_buffer(GRPC_SLICE_START_PTR(encoded_grpc_grpclb_response), GRPC_SLICE_LENGTH(encoded_grpc_grpclb_response)); pb_istream_t stream_at_start = stream; - grpc_grpclb_serverlist* sl = - static_cast<grpc_grpclb_serverlist*>(gpr_zalloc(sizeof(grpc_grpclb_serverlist))); + grpc_grpclb_serverlist* sl = 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. @@ -199,8 +200,8 @@ grpc_grpclb_serverlist* grpc_grpclb_response_parse_serverlist( } // Second pass: populate servers. if (sl->num_servers > 0) { - sl->servers = static_cast<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; @@ -230,14 +231,14 @@ 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 = - static_cast<grpc_grpclb_serverlist*>(gpr_zalloc(sizeof(grpc_grpclb_serverlist))); + grpc_grpclb_serverlist* copy = static_cast<grpc_grpclb_serverlist*>( + gpr_zalloc(sizeof(grpc_grpclb_serverlist))); copy->num_servers = sl->num_servers; - copy->servers = static_cast<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] = - static_cast<grpc_grpclb_server*>(gpr_malloc(sizeof(grpc_grpclb_server))); + copy->servers[i] = static_cast<grpc_grpclb_server*>( + gpr_malloc(sizeof(grpc_grpclb_server))); memcpy(copy->servers[i], sl->servers[i], sizeof(grpc_grpclb_server)); } return copy; diff --git a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc index 7e957e082c..1485f7caf5 100644 --- a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +++ b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc @@ -348,7 +348,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 = static_cast<grpc_lb_subchannel_data*>(arg); - pick_first_lb_policy* p = reinterpret_cast<pick_first_lb_policy*>(sd->subchannel_list->policy); + 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 @@ -547,7 +548,8 @@ 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 = static_cast<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); } diff --git a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc index b0e1c79500..f657a2af10 100644 --- a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +++ b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc @@ -82,7 +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, static_cast<unsigned long>(p->subchannel_list->num_subchannels), + (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) { @@ -334,7 +335,8 @@ 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 = reinterpret_cast<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 */ @@ -426,7 +428,8 @@ 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 - ? static_cast<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 +470,8 @@ 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, static_cast<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); } @@ -537,7 +541,8 @@ static void rr_update_locked(grpc_lb_policy* policy, } return; } - grpc_lb_addresses* addresses = static_cast<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); @@ -643,7 +648,8 @@ 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 = static_cast<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, diff --git a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc index b671b2ae39..e35c5e8db3 100644 --- a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc +++ b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc @@ -60,7 +60,8 @@ 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, static_cast<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)); } @@ -91,7 +92,8 @@ 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 = - static_cast<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 +102,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 = static_cast<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,8 +192,8 @@ 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, static_cast<unsigned long>(count - 1), static_cast<unsigned long>(count), - reason); + subchannel_list, static_cast<unsigned long>(count - 1), + static_cast<unsigned long>(count), reason); } } @@ -202,8 +204,8 @@ 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, static_cast<unsigned long>(count + 1), static_cast<unsigned long>(count), - reason); + subchannel_list, static_cast<unsigned long>(count + 1), + static_cast<unsigned long>(count), reason); } if (done) { subchannel_list_destroy(subchannel_list); diff --git a/src/core/ext/filters/client_channel/lb_policy_factory.cc b/src/core/ext/filters/client_channel/lb_policy_factory.cc index b9b9e298a5..f2a800b221 100644 --- a/src/core/ext/filters/client_channel/lb_policy_factory.cc +++ b/src/core/ext/filters/client_channel/lb_policy_factory.cc @@ -33,7 +33,8 @@ grpc_lb_addresses* grpc_lb_addresses_create( 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 = static_cast<grpc_lb_address*>(gpr_zalloc(addresses_size)); + addresses->addresses = + static_cast<grpc_lb_address*>(gpr_zalloc(addresses_size)); return addresses; } diff --git a/src/core/ext/filters/client_channel/parse_address.cc b/src/core/ext/filters/client_channel/parse_address.cc index c95560dd82..473c7542df 100644 --- a/src/core/ext/filters/client_channel/parse_address.cc +++ b/src/core/ext/filters/client_channel/parse_address.cc @@ -40,7 +40,8 @@ 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 = reinterpret_cast<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; diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc index 9e3a8c891e..0442b1e496 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc @@ -312,7 +312,8 @@ 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, const_cast<char*>(lb_policy_name)); + (char*)GRPC_ARG_LB_POLICY_NAME, + const_cast<char*>(lb_policy_name)); } } } diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc index 3b23b53e60..10bc8f6074 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc @@ -124,7 +124,8 @@ 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 = static_cast<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) { diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc index 93f5f44fa6..82b5545601 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc @@ -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 = static_cast<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,8 @@ 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 = static_cast<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 +145,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 = static_cast<grpc_lb_address*>(gpr_realloc( - (*lb_addresses)->addresses, - sizeof(grpc_lb_address) * (*lb_addresses)->num_addresses)); + (*lb_addresses)->addresses = static_cast<grpc_lb_address*>( + gpr_realloc((*lb_addresses)->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: { @@ -279,13 +280,15 @@ 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 = static_cast<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 = static_cast<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; @@ -372,7 +375,8 @@ 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 = reinterpret_cast<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); @@ -492,11 +496,12 @@ static void on_dns_lookup_done_cb(void* arg, grpc_error* error) { if (r->lb_addrs == nullptr || r->lb_addrs->num_addresses == 0) { *resolved_addresses = nullptr; } else { - *resolved_addresses = - static_cast<grpc_resolved_addresses*>(gpr_zalloc(sizeof(grpc_resolved_addresses))); + *resolved_addresses = static_cast<grpc_resolved_addresses*>( + gpr_zalloc(sizeof(grpc_resolved_addresses))); (*resolved_addresses)->naddrs = r->lb_addrs->num_addresses; - (*resolved_addresses)->addrs = static_cast<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 +519,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 = - static_cast<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, diff --git a/src/core/ext/filters/client_channel/retry_throttle.cc b/src/core/ext/filters/client_channel/retry_throttle.cc index d1e0820560..dd33b69102 100644 --- a/src/core/ext/filters/client_channel/retry_throttle.cc +++ b/src/core/ext/filters/client_channel/retry_throttle.cc @@ -60,7 +60,8 @@ bool grpc_server_retry_throttle_data_record_failure( get_replacement_throttle_data_if_needed(&throttle_data); // We decrement milli_tokens by 1000 (1 token) for each failure. 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), + &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). @@ -73,8 +74,10 @@ 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, static_cast<gpr_atm>(throttle_data->milli_token_ratio), - static_cast<gpr_atm>(0), static_cast<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 +103,8 @@ 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 = - static_cast<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,7 +116,7 @@ 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 = - static_cast<int>gpr_atm_acq_load(&old_throttle_data->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); } @@ -178,13 +182,14 @@ 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 = - static_cast<grpc_server_retry_throttle_data*>(grpc_avl_get(g_avl, const_cast<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, const_cast<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 +197,8 @@ 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, const_cast<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); diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index 55b11b89d9..179e3f27ac 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -241,8 +241,9 @@ 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, static_cast<gpr_atm>(1) - static_cast<gpr_atm>(1 << INTERNAL_REF_BITS), - 1 REF_MUTATE_PURPOSE("STRONG_UNREF")); + 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 +253,8 @@ 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, -static_cast<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), @@ -325,8 +327,8 @@ grpc_subchannel* grpc_subchannel_create(grpc_connector* connector, grpc_connector_ref(c->connector); c->num_filters = args->filter_count; if (c->num_filters > 0) { - c->filters = static_cast<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 { @@ -570,7 +572,8 @@ 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, reinterpret_cast<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", @@ -581,8 +584,8 @@ static bool publish_transport_locked(grpc_subchannel* c) { memset(&c->connecting_result, 0, sizeof(c->connecting_result)); /* initialize state watcher */ - state_watcher* connected_subchannel_watcher = - static_cast<state_watcher*>(gpr_zalloc(sizeof(*connected_subchannel_watcher))); + state_watcher* 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, diff --git a/src/core/ext/filters/client_channel/subchannel_index.cc b/src/core/ext/filters/client_channel/subchannel_index.cc index 2deafb380b..d1dc5ee970 100644 --- a/src/core/ext/filters/client_channel/subchannel_index.cc +++ b/src/core/ext/filters/client_channel/subchannel_index.cc @@ -45,13 +45,14 @@ 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 = static_cast<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 = 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); + 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; } @@ -170,7 +171,8 @@ grpc_subchannel* grpc_subchannel_index_register(grpc_subchannel_key* key, gpr_mu_unlock(&g_mu); // - Check to see if a subchannel already exists - c = static_cast<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"); } @@ -220,8 +222,8 @@ 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 = - static_cast<grpc_subchannel*>(grpc_avl_get(index, key, grpc_core::ExecCtx::Get())); + grpc_subchannel* c = 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; diff --git a/src/core/ext/filters/deadline/deadline_filter.cc b/src/core/ext/filters/deadline/deadline_filter.cc index a936d17e8d..76c1204090 100644 --- a/src/core/ext/filters/deadline/deadline_filter.cc +++ b/src/core/ext/filters/deadline/deadline_filter.cc @@ -47,7 +47,8 @@ static void yield_call_combiner(void* arg, grpc_error* ignored) { // synchronized. static void send_cancel_op_in_call_combiner(void* arg, grpc_error* error) { grpc_call_element* elem = static_cast<grpc_call_element*>(arg); - grpc_deadline_state* deadline_state = static_cast<grpc_deadline_state*>(elem->call_data); + 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)); @@ -59,7 +60,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 = static_cast<grpc_call_element*>(arg); - grpc_deadline_state* deadline_state = static_cast<grpc_deadline_state*>(elem->call_data); + 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 +87,8 @@ static void start_timer_if_needed(grpc_call_element* elem, if (deadline == GRPC_MILLIS_INF_FUTURE) { return; } - grpc_deadline_state* deadline_state = static_cast<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: @@ -173,7 +176,8 @@ 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 = static_cast<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 +191,8 @@ 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 = - static_cast<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 +202,23 @@ void grpc_deadline_state_init(grpc_call_element* elem, } void grpc_deadline_state_destroy(grpc_call_element* elem) { - grpc_deadline_state* deadline_state = static_cast<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 = static_cast<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 = static_cast<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 { @@ -360,7 +368,8 @@ 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, static_cast<const grpc_channel_filter*>(arg), nullptr, nullptr) + builder, static_cast<const grpc_channel_filter*>(arg), + nullptr, nullptr) : true; } diff --git a/src/core/ext/filters/http/client/http_client_filter.cc b/src/core/ext/filters/http/client/http_client_filter.cc index aabc405bec..80643f8584 100644 --- a/src/core/ext/filters/http/client/http_client_filter.cc +++ b/src/core/ext/filters/http/client/http_client_filter.cc @@ -189,7 +189,8 @@ 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, - ~static_cast<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 == @@ -224,7 +225,8 @@ 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 = static_cast<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, @@ -253,8 +255,10 @@ 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 = reinterpret_cast<char*>GRPC_SLICE_START_PTR(path_with_query_slice); - char* original_path = reinterpret_cast<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++ = '?'; @@ -265,7 +269,7 @@ static grpc_error* update_path_for_get(grpc_call_element* elem, true /* url_safe */, false /* multi_line */); gpr_free(payload_bytes); /* remove trailing unused memory and add trailing 0 to terminate string */ - char* t = reinterpret_cast<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)); diff --git a/src/core/ext/filters/http/http_filters_plugin.cc b/src/core/ext/filters/http/http_filters_plugin.cc index b89cb028ea..56fe1e5c24 100644 --- a/src/core/ext/filters/http/http_filters_plugin.cc +++ b/src/core/ext/filters/http/http_filters_plugin.cc @@ -58,7 +58,8 @@ 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, static_cast<const grpc_channel_filter*>(arg), nullptr, nullptr) + builder, static_cast<const grpc_channel_filter*>(arg), + nullptr, nullptr) : true; } diff --git a/src/core/ext/filters/http/message_compress/message_compress_filter.cc b/src/core/ext/filters/http/message_compress/message_compress_filter.cc index 223548d3bf..73220a0ea1 100644 --- a/src/core/ext/filters/http/message_compress/message_compress_filter.cc +++ b/src/core/ext/filters/http/message_compress/message_compress_filter.cc @@ -226,7 +226,8 @@ 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 - static_cast<float>(after_size) / static_cast<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, @@ -291,8 +292,8 @@ static grpc_error* pull_slice_from_send_message(call_data* calld) { static void continue_reading_send_message(grpc_call_element* elem) { call_data* calld = static_cast<call_data*>(elem->call_data); while (grpc_byte_stream_next( - calld->send_message_batch->payload->send_message.send_message, ~static_cast<size_t>(0), - &calld->on_send_message_next_done)) { + 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) { // Closure callback; does not take ownership of error. diff --git a/src/core/ext/filters/http/server/http_server_filter.cc b/src/core/ext/filters/http/server/http_server_filter.cc index 560b5795e3..63bc2bd59f 100644 --- a/src/core/ext/filters/http/server/http_server_filter.cc +++ b/src/core/ext/filters/http/server/http_server_filter.cc @@ -224,10 +224,11 @@ static grpc_error* server_filter_incoming_metadata(grpc_call_element* elem, /* decode payload from query and add to the slice buffer to be returned */ const int k_url_safe = 1; - grpc_slice_buffer_add(&calld->read_slice_buffer, - grpc_base64_decode_with_len( - reinterpret_cast<const char*>GRPC_SLICE_START_PTR(query_slice), - GRPC_SLICE_LENGTH(query_slice), k_url_safe)); + grpc_slice_buffer_add( + &calld->read_slice_buffer, + grpc_base64_decode_with_len( + 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); calld->seen_path_with_query = true; @@ -277,9 +278,10 @@ static void hs_on_complete(void* user_data, grpc_error* err) { 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 - : reinterpret_cast<grpc_byte_stream*>(&calld->read_stream); + *calld->pp_recv_message = + calld->payload_bin_delivered + ? nullptr + : 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, diff --git a/src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc b/src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc index 4255a77ea0..667c0c56ef 100644 --- a/src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc +++ b/src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc @@ -41,7 +41,8 @@ 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 = static_cast<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 = diff --git a/src/core/ext/filters/max_age/max_age_filter.cc b/src/core/ext/filters/max_age/max_age_filter.cc index ba41e4674b..415a90959d 100644 --- a/src/core/ext/filters/max_age/max_age_filter.cc +++ b/src/core/ext/filters/max_age/max_age_filter.cc @@ -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, - static_cast<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); @@ -384,7 +384,7 @@ 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 > (static_cast<double>GRPC_MILLIS_INF_FUTURE) - 0.5 + return result > (static_cast<double> GRPC_MILLIS_INF_FUTURE) - 0.5 ? GRPC_MILLIS_INF_FUTURE : static_cast<grpc_millis>(result); } diff --git a/src/core/ext/filters/message_size/message_size_filter.cc b/src/core/ext/filters/message_size/message_size_filter.cc index a2406a24dd..49d9ae60ae 100644 --- a/src/core/ext/filters/message_size/message_size_filter.cc +++ b/src/core/ext/filters/message_size/message_size_filter.cc @@ -78,8 +78,8 @@ static void* refcounted_message_size_limits_create_from_json( } } refcounted_message_size_limits* value = - static_cast<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; @@ -113,7 +113,8 @@ static void recv_message_ready(void* user_data, grpc_error* error) { 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 > static_cast<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)", @@ -183,8 +184,9 @@ 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 = - static_cast<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 || diff --git a/src/core/ext/filters/workarounds/workaround_utils.cc b/src/core/ext/filters/workarounds/workaround_utils.cc index b94c7536d0..850ed75ec9 100644 --- a/src/core/ext/filters/workarounds/workaround_utils.cc +++ b/src/core/ext/filters/workarounds/workaround_utils.cc @@ -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 = - static_cast<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 = static_cast<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); |