From 8a8348b2ca16ed5d3fb677aed1d09dcb49dc3913 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Mon, 21 Oct 2019 09:16:33 -0700 Subject: [PATCH] Remove unused-parameter warnings, round 2 (11 of 19) --- .../filters/http/client/http_client_filter.cc | 2 +- .../ssl/ssl_security_connector.cc | 12 +++++----- .../security/security_connector/ssl_utils.cc | 2 +- .../tls/spiffe_security_connector.cc | 10 ++++---- .../security/transport/client_auth_filter.cc | 4 ++-- .../security/transport/security_handshaker.cc | 6 ++--- .../security/transport/server_auth_filter.cc | 4 ++-- src/core/lib/slice/b64.cc | 7 +++--- src/core/lib/slice/b64.h | 3 +-- src/core/lib/surface/call.cc | 23 ++++++++++--------- src/core/lib/surface/call.h | 13 +++++------ src/core/lib/surface/call_log_batch.cc | 3 +-- src/core/lib/surface/channel.cc | 10 +------- src/core/lib/surface/channel.h | 19 --------------- src/core/lib/transport/status_metadata.cc | 7 ++++++ src/core/lib/transport/status_metadata.h | 18 +++++++++++++++ 16 files changed, 69 insertions(+), 74 deletions(-) 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 1687f7ead09..d21fb83939a 100644 --- a/src/core/ext/filters/http/client/http_client_filter.cc +++ b/src/core/ext/filters/http/client/http_client_filter.cc @@ -302,7 +302,7 @@ static grpc_error* update_path_for_get(grpc_call_element* elem, size_t estimated_len = GRPC_SLICE_LENGTH(path_slice); estimated_len++; /* for the '?' */ estimated_len += grpc_base64_estimate_encoded_size( - batch->payload->send_message.send_message->length(), true /* url_safe */, + batch->payload->send_message.send_message->length(), false /* multi_line */); grpc_core::UnmanagedMemorySlice path_with_query_slice(estimated_len); /* memcopy individual pieces into this slice */ diff --git a/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc b/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc index 87ebd7ad171..8e3558f102a 100644 --- a/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +++ b/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc @@ -118,7 +118,7 @@ class grpc_ssl_channel_security_connector final } void add_handshakers(const grpc_channel_args* args, - grpc_pollset_set* interested_parties, + grpc_pollset_set* /*interested_parties*/, grpc_core::HandshakeManager* handshake_mgr) override { // Instantiate TSI handshaker. tsi_handshaker* tsi_hs = nullptr; @@ -136,7 +136,7 @@ class grpc_ssl_channel_security_connector final handshake_mgr->Add(grpc_core::SecurityHandshakerCreate(tsi_hs, this, args)); } - void check_peer(tsi_peer peer, grpc_endpoint* ep, + void check_peer(tsi_peer peer, grpc_endpoint* /*ep*/, grpc_core::RefCountedPtr* auth_context, grpc_closure* on_peer_checked) override { const char* target_name = overridden_target_name_ != nullptr @@ -188,7 +188,7 @@ class grpc_ssl_channel_security_connector final bool check_call_host(grpc_core::StringView host, grpc_auth_context* auth_context, - grpc_closure* on_call_host_checked, + grpc_closure* /*on_call_host_checked*/, grpc_error** error) override { grpc_security_status status = GRPC_SECURITY_ERROR; tsi_peer peer = grpc_shallow_peer_from_ssl_auth_context(auth_context); @@ -207,7 +207,7 @@ class grpc_ssl_channel_security_connector final return true; } - void cancel_check_call_host(grpc_closure* on_call_host_checked, + void cancel_check_call_host(grpc_closure* /*on_call_host_checked*/, grpc_error* error) override { GRPC_ERROR_UNREF(error); } @@ -281,7 +281,7 @@ class grpc_ssl_server_security_connector } void add_handshakers(const grpc_channel_args* args, - grpc_pollset_set* interested_parties, + grpc_pollset_set* /*interested_parties*/, grpc_core::HandshakeManager* handshake_mgr) override { // Instantiate TSI handshaker. try_fetch_ssl_server_credentials(); @@ -297,7 +297,7 @@ class grpc_ssl_server_security_connector handshake_mgr->Add(grpc_core::SecurityHandshakerCreate(tsi_hs, this, args)); } - void check_peer(tsi_peer peer, grpc_endpoint* ep, + void check_peer(tsi_peer peer, grpc_endpoint* /*ep*/, grpc_core::RefCountedPtr* auth_context, grpc_closure* on_peer_checked) override { grpc_error* error = ssl_check_peer(nullptr, &peer, auth_context); diff --git a/src/core/lib/security/security_connector/ssl_utils.cc b/src/core/lib/security/security_connector/ssl_utils.cc index 9686426074e..66fe80c3c54 100644 --- a/src/core/lib/security/security_connector/ssl_utils.cc +++ b/src/core/lib/security/security_connector/ssl_utils.cc @@ -143,7 +143,7 @@ bool grpc_ssl_check_call_host(grpc_core::StringView host, grpc_core::StringView target_name, grpc_core::StringView overridden_target_name, grpc_auth_context* auth_context, - grpc_closure* on_call_host_checked, + grpc_closure* /*on_call_host_checked*/, grpc_error** error) { grpc_security_status status = GRPC_SECURITY_ERROR; tsi_peer peer = grpc_shallow_peer_from_ssl_auth_context(auth_context); diff --git a/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc b/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc index de3bbace1b0..8fedff78266 100644 --- a/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc +++ b/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc @@ -141,7 +141,7 @@ SpiffeChannelSecurityConnector::~SpiffeChannelSecurityConnector() { } void SpiffeChannelSecurityConnector::add_handshakers( - const grpc_channel_args* args, grpc_pollset_set* interested_parties, + const grpc_channel_args* args, grpc_pollset_set* /*interested_parties*/, grpc_core::HandshakeManager* handshake_mgr) { if (RefreshHandshakerFactory() != GRPC_SECURITY_OK) { gpr_log(GPR_ERROR, "Handshaker factory refresh failed."); @@ -164,7 +164,7 @@ void SpiffeChannelSecurityConnector::add_handshakers( } void SpiffeChannelSecurityConnector::check_peer( - tsi_peer peer, grpc_endpoint* ep, + tsi_peer peer, grpc_endpoint* /*ep*/, grpc_core::RefCountedPtr* auth_context, grpc_closure* on_peer_checked) { const char* target_name = overridden_target_name_ != nullptr @@ -239,7 +239,7 @@ bool SpiffeChannelSecurityConnector::check_call_host( } void SpiffeChannelSecurityConnector::cancel_check_call_host( - grpc_closure* on_call_host_checked, grpc_error* error) { + grpc_closure* /*on_call_host_checked*/, grpc_error* error) { GRPC_ERROR_UNREF(error); } @@ -419,7 +419,7 @@ SpiffeServerSecurityConnector::~SpiffeServerSecurityConnector() { } void SpiffeServerSecurityConnector::add_handshakers( - const grpc_channel_args* args, grpc_pollset_set* interested_parties, + const grpc_channel_args* args, grpc_pollset_set* /*interested_parties*/, grpc_core::HandshakeManager* handshake_mgr) { /* Refresh handshaker factory if needed. */ if (RefreshHandshakerFactory() != GRPC_SECURITY_OK) { @@ -439,7 +439,7 @@ void SpiffeServerSecurityConnector::add_handshakers( } void SpiffeServerSecurityConnector::check_peer( - tsi_peer peer, grpc_endpoint* ep, + tsi_peer peer, grpc_endpoint* /*ep*/, grpc_core::RefCountedPtr* auth_context, grpc_closure* on_peer_checked) { grpc_error* error = grpc_ssl_check_alpn(&peer); diff --git a/src/core/lib/security/transport/client_auth_filter.cc b/src/core/lib/security/transport/client_auth_filter.cc index 282ec5c97a9..191f38cac75 100644 --- a/src/core/lib/security/transport/client_auth_filter.cc +++ b/src/core/lib/security/transport/client_auth_filter.cc @@ -383,8 +383,8 @@ static void client_auth_set_pollset_or_pollset_set( /* Destructor for call_data */ static void client_auth_destroy_call_elem( - grpc_call_element* elem, const grpc_call_final_info* final_info, - grpc_closure* ignored) { + grpc_call_element* elem, const grpc_call_final_info* /*final_info*/, + grpc_closure* /*ignored*/) { call_data* calld = static_cast(elem->call_data); calld->destroy(); } diff --git a/src/core/lib/security/transport/security_handshaker.cc b/src/core/lib/security/transport/security_handshaker.cc index 0128a344e1f..74062be682f 100644 --- a/src/core/lib/security/transport/security_handshaker.cc +++ b/src/core/lib/security/transport/security_handshaker.cc @@ -421,7 +421,7 @@ void SecurityHandshaker::Shutdown(grpc_error* why) { GRPC_ERROR_UNREF(why); } -void SecurityHandshaker::DoHandshake(grpc_tcp_server_acceptor* acceptor, +void SecurityHandshaker::DoHandshake(grpc_tcp_server_acceptor* /*acceptor*/, grpc_closure* on_handshake_done, HandshakerArgs* args) { auto ref = Ref(); @@ -446,9 +446,9 @@ class FailHandshaker : public Handshaker { public: const char* name() const override { return "security_fail"; } void Shutdown(grpc_error* why) override { GRPC_ERROR_UNREF(why); } - void DoHandshake(grpc_tcp_server_acceptor* acceptor, + void DoHandshake(grpc_tcp_server_acceptor* /*acceptor*/, grpc_closure* on_handshake_done, - HandshakerArgs* args) override { + HandshakerArgs* /*args*/) override { GRPC_CLOSURE_SCHED(on_handshake_done, GRPC_ERROR_CREATE_FROM_STATIC_STRING( "Failed to create security handshaker")); diff --git a/src/core/lib/security/transport/server_auth_filter.cc b/src/core/lib/security/transport/server_auth_filter.cc index 341e0e4a86a..d7b33f99509 100644 --- a/src/core/lib/security/transport/server_auth_filter.cc +++ b/src/core/lib/security/transport/server_auth_filter.cc @@ -286,8 +286,8 @@ static grpc_error* server_auth_init_call_elem( /* Destructor for call_data */ static void server_auth_destroy_call_elem( - grpc_call_element* elem, const grpc_call_final_info* final_info, - grpc_closure* ignored) { + grpc_call_element* elem, const grpc_call_final_info* /*final_info*/, + grpc_closure* /*ignored*/) { call_data* calld = static_cast(elem->call_data); calld->~call_data(); } diff --git a/src/core/lib/slice/b64.cc b/src/core/lib/slice/b64.cc index 27f2724002e..0a06a05c934 100644 --- a/src/core/lib/slice/b64.cc +++ b/src/core/lib/slice/b64.cc @@ -59,14 +59,13 @@ static const char base64_url_safe_chars[] = char* grpc_base64_encode(const void* vdata, size_t data_size, int url_safe, int multiline) { size_t result_projected_size = - grpc_base64_estimate_encoded_size(data_size, url_safe, multiline); + grpc_base64_estimate_encoded_size(data_size, multiline); char* result = static_cast(gpr_malloc(result_projected_size)); grpc_base64_encode_core(result, vdata, data_size, url_safe, multiline); return result; } -size_t grpc_base64_estimate_encoded_size(size_t data_size, int url_safe, - int multiline) { +size_t grpc_base64_estimate_encoded_size(size_t data_size, int multiline) { size_t result_projected_size = 4 * ((data_size + 3) / 3) + 2 * (multiline ? (data_size / (3 * GRPC_BASE64_MULTILINE_NUM_BLOCKS)) @@ -81,7 +80,7 @@ void grpc_base64_encode_core(char* result, const void* vdata, size_t data_size, const char* base64_chars = url_safe ? base64_url_safe_chars : base64_url_unsafe_chars; const size_t result_projected_size = - grpc_base64_estimate_encoded_size(data_size, url_safe, multiline); + grpc_base64_estimate_encoded_size(data_size, multiline); char* current = result; size_t num_blocks = 0; diff --git a/src/core/lib/slice/b64.h b/src/core/lib/slice/b64.h index 88b880a4542..65ba6622b20 100644 --- a/src/core/lib/slice/b64.h +++ b/src/core/lib/slice/b64.h @@ -31,8 +31,7 @@ char* grpc_base64_encode(const void* data, size_t data_size, int url_safe, /* estimate the upper bound on size of base64 encoded data. The actual size * is guaranteed to be less than or equal to the size returned here. */ -size_t grpc_base64_estimate_encoded_size(size_t data_size, int url_safe, - int multiline); +size_t grpc_base64_estimate_encoded_size(size_t data_size, int multiline); /* Encodes data using base64 and write it to memory pointed to by result. It is * the caller's responsibility to allocate enough memory in |result| to fit the diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index 99ea9a453ef..605d69a2ebf 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -511,7 +511,7 @@ void grpc_call_internal_unref(grpc_call* c REF_ARG) { GRPC_CALL_STACK_UNREF(CALL_STACK_FROM_CALL(c), REF_REASON); } -static void release_call(void* call, grpc_error* error) { +static void release_call(void* call, grpc_error* /*error*/) { grpc_call* c = static_cast(call); grpc_channel* channel = c->channel; grpc_core::Arena* arena = c->arena; @@ -520,7 +520,7 @@ static void release_call(void* call, grpc_error* error) { GRPC_CHANNEL_INTERNAL_UNREF(channel, "call"); } -static void destroy_call(void* call, grpc_error* error) { +static void destroy_call(void* call, grpc_error* /*error*/) { GPR_TIMER_SCOPE("destroy_call", 0); size_t i; int ii; @@ -617,7 +617,7 @@ grpc_call_error grpc_call_cancel(grpc_call* call, void* reserved) { // This is called via the call combiner to start sending a batch down // the filter stack. -static void execute_batch_in_call_combiner(void* arg, grpc_error* ignored) { +static void execute_batch_in_call_combiner(void* arg, grpc_error* /*ignored*/) { GPR_TIMER_SCOPE("execute_batch_in_call_combiner", 0); grpc_transport_stream_op_batch* batch = static_cast(arg); @@ -678,7 +678,7 @@ typedef struct { // The on_complete callback used when sending a cancel_stream batch down // the filter stack. Yields the call combiner when the batch is done. -static void done_termination(void* arg, grpc_error* error) { +static void done_termination(void* arg, grpc_error* /*error*/) { cancel_state* state = static_cast(arg); GRPC_CALL_COMBINER_STOP(&state->call->call_combiner, "on_complete for cancel_stream op"); @@ -805,9 +805,10 @@ uint32_t grpc_call_test_only_get_message_flags(grpc_call* call) { return flags; } -static void destroy_encodings_accepted_by_peer(void* p) { return; } +static void destroy_encodings_accepted_by_peer(void* /*p*/) { return; } -static void set_encodings_accepted_by_peer(grpc_call* call, grpc_mdelem mdel, +static void set_encodings_accepted_by_peer(grpc_call* /*call*/, + grpc_mdelem mdel, uint32_t* encodings_accepted_by_peer, bool stream_encoding) { size_t i; @@ -1152,7 +1153,7 @@ static batch_control* reuse_or_allocate_batch_control(grpc_call* call, } static void finish_batch_completion(void* user_data, - grpc_cq_completion* storage) { + grpc_cq_completion* /*storage*/) { batch_control* bctl = static_cast(user_data); grpc_call* call = bctl->call; bctl->call = nullptr; @@ -1545,7 +1546,7 @@ static void finish_batch(void* bctlp, grpc_error* error) { finish_batch_step(bctl); } -static void free_no_op_completion(void* p, grpc_cq_completion* completion) { +static void free_no_op_completion(void* /*p*/, grpc_cq_completion* completion) { gpr_free(completion); } @@ -1563,7 +1564,7 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops, grpc_transport_stream_op_batch* stream_op; grpc_transport_stream_op_batch_payload* stream_op_payload; - GRPC_CALL_LOG_BATCH(GPR_INFO, call, ops, nops, notify_tag); + GRPC_CALL_LOG_BATCH(GPR_INFO, ops, nops); if (nops == 0) { if (!is_notify_tag_closure) { @@ -1748,8 +1749,8 @@ static grpc_call_error call_start_batch(grpc_call* call, const grpc_op* ops, call->sent_final_op = true; GPR_ASSERT(call->send_extra_metadata_count == 0); call->send_extra_metadata_count = 1; - call->send_extra_metadata[0].md = grpc_channel_get_reffed_status_elem( - call->channel, op->data.send_status_from_server.status); + call->send_extra_metadata[0].md = grpc_get_reffed_status_elem( + op->data.send_status_from_server.status); grpc_error* status_error = op->data.send_status_from_server.status == GRPC_STATUS_OK ? GRPC_ERROR_NONE diff --git a/src/core/lib/surface/call.h b/src/core/lib/surface/call.h index 15392fea6dc..a33664af6a9 100644 --- a/src/core/lib/surface/call.h +++ b/src/core/lib/surface/call.h @@ -90,8 +90,7 @@ void grpc_call_cancel_internal(grpc_call* call); grpc_call* grpc_call_from_top_element(grpc_call_element* surface_element); void grpc_call_log_batch(const char* file, int line, gpr_log_severity severity, - grpc_call* call, const grpc_op* ops, size_t nops, - void* tag); + const grpc_op* ops, size_t nops); /* Set a context pointer. No thread safety guarantees are made wrt this value. */ @@ -101,11 +100,11 @@ void grpc_call_context_set(grpc_call* call, grpc_context_index elem, /* Get a context pointer. */ void* grpc_call_context_get(grpc_call* call, grpc_context_index elem); -#define GRPC_CALL_LOG_BATCH(sev, call, ops, nops, tag) \ - do { \ - if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace)) { \ - grpc_call_log_batch(sev, call, ops, nops, tag); \ - } \ +#define GRPC_CALL_LOG_BATCH(sev, ops, nops) \ + do { \ + if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace)) { \ + grpc_call_log_batch(sev, ops, nops); \ + } \ } while (0) uint8_t grpc_call_is_client(grpc_call* call); diff --git a/src/core/lib/surface/call_log_batch.cc b/src/core/lib/surface/call_log_batch.cc index f0c82c03570..23c344a2c0e 100644 --- a/src/core/lib/surface/call_log_batch.cc +++ b/src/core/lib/surface/call_log_batch.cc @@ -108,8 +108,7 @@ char* grpc_op_string(const grpc_op* op) { } void grpc_call_log_batch(const char* file, int line, gpr_log_severity severity, - grpc_call* call, const grpc_op* ops, size_t nops, - void* tag) { + const grpc_op* ops, size_t nops) { char* tmp; size_t i; for (i = 0; i < nops; i++) { diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 7f48f258318..c6bebf715b2 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -463,7 +463,7 @@ grpc_call* grpc_channel_create_registered_call( return call; } -static void destroy_channel(void* arg, grpc_error* error) { +static void destroy_channel(void* arg, grpc_error* /*error*/) { grpc_channel* channel = static_cast(arg); if (channel->channelz_node != nullptr) { if (channel->channelz_node->parent_uuid() > 0) { @@ -512,11 +512,3 @@ void grpc_channel_destroy(grpc_channel* channel) { GRPC_CHANNEL_INTERNAL_UNREF(channel, "channel"); } - -grpc_mdelem grpc_channel_get_reffed_status_elem_slowpath(grpc_channel* channel, - int i) { - char tmp[GPR_LTOA_MIN_BUFSIZE]; - gpr_ltoa(i, tmp); - return grpc_mdelem_from_slices(GRPC_MDSTR_GRPC_STATUS, - grpc_core::UnmanagedMemorySlice(tmp)); -} diff --git a/src/core/lib/surface/channel.h b/src/core/lib/surface/channel.h index a4cac748f2d..5136e93bcd5 100644 --- a/src/core/lib/surface/channel.h +++ b/src/core/lib/surface/channel.h @@ -55,25 +55,6 @@ grpc_channel_stack* grpc_channel_get_channel_stack(grpc_channel* channel); grpc_core::channelz::ChannelNode* grpc_channel_get_channelz_node( grpc_channel* channel); -/** Get a grpc_mdelem of grpc-status: X where X is the numeric value of - status_code. - - The returned elem is owned by the caller. */ -grpc_mdelem grpc_channel_get_reffed_status_elem_slowpath(grpc_channel* channel, - int status_code); -inline grpc_mdelem grpc_channel_get_reffed_status_elem(grpc_channel* channel, - int status_code) { - switch (status_code) { - case 0: - return GRPC_MDELEM_GRPC_STATUS_0; - case 1: - return GRPC_MDELEM_GRPC_STATUS_1; - case 2: - return GRPC_MDELEM_GRPC_STATUS_2; - } - return grpc_channel_get_reffed_status_elem_slowpath(channel, status_code); -} - size_t grpc_channel_get_call_size_estimate(grpc_channel* channel); void grpc_channel_update_call_size_estimate(grpc_channel* channel, size_t size); diff --git a/src/core/lib/transport/status_metadata.cc b/src/core/lib/transport/status_metadata.cc index 8ef96821c3d..d4381f5b0a1 100644 --- a/src/core/lib/transport/status_metadata.cc +++ b/src/core/lib/transport/status_metadata.cc @@ -52,3 +52,10 @@ grpc_status_code grpc_get_status_code_from_metadata(grpc_mdelem md) { md, destroy_status, (void*)static_cast(status + STATUS_OFFSET)); return static_cast(status); } + +grpc_mdelem grpc_get_reffed_status_elem_slowpath(int status_code) { + char tmp[GPR_LTOA_MIN_BUFSIZE]; + gpr_ltoa(status_code, tmp); + return grpc_mdelem_from_slices(GRPC_MDSTR_GRPC_STATUS, + grpc_core::UnmanagedMemorySlice(tmp)); +} diff --git a/src/core/lib/transport/status_metadata.h b/src/core/lib/transport/status_metadata.h index aed9c7ac201..24022c0cf55 100644 --- a/src/core/lib/transport/status_metadata.h +++ b/src/core/lib/transport/status_metadata.h @@ -24,7 +24,25 @@ #include #include "src/core/lib/transport/metadata.h" +#include "src/core/lib/transport/static_metadata.h" grpc_status_code grpc_get_status_code_from_metadata(grpc_mdelem md); +/** Get a grpc_mdelem of grpc-status: X where X is the numeric value of + status_code. + + The returned elem is owned by the caller. */ +grpc_mdelem grpc_get_reffed_status_elem_slowpath(int status_code); +inline grpc_mdelem grpc_get_reffed_status_elem(int status_code) { + switch (status_code) { + case 0: + return GRPC_MDELEM_GRPC_STATUS_0; + case 1: + return GRPC_MDELEM_GRPC_STATUS_1; + case 2: + return GRPC_MDELEM_GRPC_STATUS_2; + } + return grpc_get_reffed_status_elem_slowpath(status_code); +} + #endif /* GRPC_CORE_LIB_TRANSPORT_STATUS_METADATA_H */