enable clang-tidy readability-static-definition-in-anonymous-namespace check (#28033)

pull/28117/head
Mark D. Roth 3 years ago committed by GitHub
parent 2ea8e50c3a
commit 1050eedb87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .clang-tidy
  2. 2
      src/core/ext/filters/client_channel/resolver_registry.cc
  3. 8
      src/core/ext/transport/chttp2/transport/flow_control.cc
  4. 4
      src/core/ext/transport/chttp2/transport/hpack_parser.cc
  5. 2
      src/core/ext/xds/certificate_provider_registry.cc
  6. 2
      src/core/lib/iomgr/buffer_list.cc
  7. 2
      src/core/lib/iomgr/call_combiner.cc
  8. 2
      src/core/lib/iomgr/executor.cc
  9. 7
      src/core/lib/security/security_connector/fake/fake_security_connector.cc
  10. 4
      src/core/lib/slice/percent_encoding.cc
  11. 4
      src/core/lib/surface/completion_queue.cc
  12. 28
      src/core/lib/surface/lame_client.cc
  13. 4
      src/core/lib/surface/validate_metadata.cc
  14. 30
      src/core/tsi/local_transport_security.cc
  15. 4
      src/cpp/server/admin/admin_services.cc
  16. 2
      test/core/channel/channel_stack_builder_test.cc
  17. 25
      test/core/util/stack_tracer.cc
  18. 3
      test/cpp/end2end/async_end2end_test.cc
  19. 2
      test/cpp/end2end/channelz_service_test.cc
  20. 3
      test/cpp/end2end/client_callback_end2end_test.cc
  21. 3
      test/cpp/end2end/context_allocator_end2end_test.cc
  22. 7
      test/cpp/end2end/end2end_test.cc
  23. 3
      test/cpp/end2end/message_allocator_end2end_test.cc
  24. 5
      test/cpp/end2end/port_sharing_end2end_test.cc
  25. 4
      test/cpp/ext/filters/census/stats_plugin_end2end_test.cc
  26. 2
      test/cpp/naming/address_sorting_test.cc

@ -47,7 +47,6 @@
# - readability-else-after-return
# - readability-implicit-bool-conversion
# - readability-redundant-declaration
# - readability-static-definition-in-anonymous-namespace
#
Checks: '-*,
abseil-*,
@ -115,6 +114,7 @@ Checks: '-*,
readability-redundant-function-ptr-dereference,
readability-redundant-smartptr-get,
readability-simplify-boolean-expr,
readability-static-definition-in-anonymous-namespace,
readability-string-compare,
readability-uniqueptr-delete-release'
WarningsAsErrors: '*'

@ -107,7 +107,7 @@ class RegistryState {
UniquePtr<char> default_prefix_;
};
static RegistryState* g_state = nullptr;
RegistryState* g_state = nullptr;
} // namespace

@ -47,10 +47,10 @@ bool g_test_only_transport_flow_control_window_check;
namespace {
static constexpr const int kTracePadding = 30;
static constexpr const int64_t kMaxWindowUpdateSize = (1u << 31) - 1;
constexpr const int kTracePadding = 30;
constexpr const int64_t kMaxWindowUpdateSize = (1u << 31) - 1;
static char* fmt_int64_diff_str(int64_t old_val, int64_t new_val) {
char* fmt_int64_diff_str(int64_t old_val, int64_t new_val) {
std::string str;
if (old_val != new_val) {
str = absl::StrFormat("%" PRId64 " -> %" PRId64 "", old_val, new_val);
@ -60,7 +60,7 @@ static char* fmt_int64_diff_str(int64_t old_val, int64_t new_val) {
return gpr_leftpad(str.c_str(), ' ', kTracePadding);
}
static char* fmt_uint32_diff_str(uint32_t old_val, uint32_t new_val) {
char* fmt_uint32_diff_str(uint32_t old_val, uint32_t new_val) {
std::string str;
if (old_val != new_val) {
str = absl::StrFormat("%" PRIu32 " -> %" PRIu32 "", old_val, new_val);

@ -428,7 +428,7 @@ static const int16_t emit_sub_tbl[249 * 16] = {
namespace {
// The alphabet used for base64 encoding binary metadata.
static constexpr char kBase64Alphabet[] =
constexpr char kBase64Alphabet[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
// An inverted table: for each value in kBase64Alphabet, table contains the
@ -448,7 +448,7 @@ struct Base64InverseTable {
}
};
static GRPC_HPACK_CONSTEXPR_VALUE Base64InverseTable kBase64InverseTable;
GRPC_HPACK_CONSTEXPR_VALUE Base64InverseTable kBase64InverseTable;
} // namespace
// Input tracks the current byte through the input data and provides it

@ -58,7 +58,7 @@ class RegistryState {
factories_;
};
static RegistryState* g_state = nullptr;
RegistryState* g_state = nullptr;
} // namespace

@ -189,7 +189,7 @@ void extract_opt_stats_from_cmsg(ConnectionMetrics* metrics,
}
}
static int get_socket_tcp_info(tcp_info* info, int fd) {
int get_socket_tcp_info(tcp_info* info, int fd) {
memset(info, 0, sizeof(*info));
info->length = offsetof(tcp_info, length);
return getsockopt(fd, IPPROTO_TCP, TCP_INFO, info, &(info->length));

@ -34,7 +34,7 @@ DebugOnlyTraceFlag grpc_call_combiner_trace(false, "call_combiner");
namespace {
// grpc_error LSB can be used
constexpr static intptr_t kErrorBit = 1;
constexpr intptr_t kErrorBit = 1;
grpc_error_handle DecodeCancelStateError(gpr_atm cancel_state) {
if (cancel_state & kErrorBit) {

@ -52,7 +52,7 @@
namespace grpc_core {
namespace {
static GPR_THREAD_LOCAL(ThreadState*) g_this_thread_state;
GPR_THREAD_LOCAL(ThreadState*) g_this_thread_state;
Executor* executors[static_cast<size_t>(ExecutorType::NUM_EXECUTORS)];

@ -214,10 +214,9 @@ class grpc_fake_channel_security_connector final
char* target_name_override_;
};
static void fake_check_peer(
grpc_security_connector* /*sc*/, tsi_peer peer,
grpc_core::RefCountedPtr<grpc_auth_context>* auth_context,
grpc_closure* on_peer_checked) {
void fake_check_peer(grpc_security_connector* /*sc*/, tsi_peer peer,
grpc_core::RefCountedPtr<grpc_auth_context>* auth_context,
grpc_closure* on_peer_checked) {
const char* prop_name;
grpc_error_handle error = GRPC_ERROR_NONE;
*auth_context = nullptr;

@ -51,7 +51,7 @@ class UrlTable : public BitSet<256> {
}
};
static GRPC_PCTENCODE_CONSTEXPR_VALUE UrlTable g_url_table;
GRPC_PCTENCODE_CONSTEXPR_VALUE UrlTable g_url_table;
class CompatibleTable : public BitSet<256> {
public:
@ -63,7 +63,7 @@ class CompatibleTable : public BitSet<256> {
}
};
static GRPC_PCTENCODE_CONSTEXPR_VALUE CompatibleTable g_compatible_table;
GRPC_PCTENCODE_CONSTEXPR_VALUE CompatibleTable g_compatible_table;
// Map PercentEncodingType to a lookup table of legal symbols for that encoding.
const BitSet<256>& LookupTableForPercentEncodingType(PercentEncodingType type) {

@ -58,8 +58,8 @@ namespace {
// with a cq cache will go into that cache, and
// will only be returned on the thread that initialized the cache.
// NOTE: Only one event will ever be cached.
static GPR_THREAD_LOCAL(grpc_cq_completion*) g_cached_event;
static GPR_THREAD_LOCAL(grpc_completion_queue*) g_cached_cq;
GPR_THREAD_LOCAL(grpc_cq_completion*) g_cached_event;
GPR_THREAD_LOCAL(grpc_completion_queue*) g_cached_cq;
struct plucker {
grpc_pollset_worker** worker;

@ -62,19 +62,19 @@ struct CallData {
CallCombiner* call_combiner;
};
static void lame_start_transport_stream_op_batch(
grpc_call_element* elem, grpc_transport_stream_op_batch* op) {
void lame_start_transport_stream_op_batch(grpc_call_element* elem,
grpc_transport_stream_op_batch* op) {
CallData* calld = static_cast<CallData*>(elem->call_data);
ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
grpc_transport_stream_op_batch_finish_with_failure(
op, GRPC_ERROR_REF(chand->error), calld->call_combiner);
}
static void lame_get_channel_info(grpc_channel_element* /*elem*/,
const grpc_channel_info* /*channel_info*/) {}
void lame_get_channel_info(grpc_channel_element* /*elem*/,
const grpc_channel_info* /*channel_info*/) {}
static void lame_start_transport_op(grpc_channel_element* elem,
grpc_transport_op* op) {
void lame_start_transport_op(grpc_channel_element* elem,
grpc_transport_op* op) {
ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
{
MutexLock lock(&chand->mu);
@ -100,26 +100,26 @@ static void lame_start_transport_op(grpc_channel_element* elem,
}
}
static grpc_error_handle lame_init_call_elem(
grpc_call_element* elem, const grpc_call_element_args* args) {
grpc_error_handle lame_init_call_elem(grpc_call_element* elem,
const grpc_call_element_args* args) {
CallData* calld = static_cast<CallData*>(elem->call_data);
calld->call_combiner = args->call_combiner;
return GRPC_ERROR_NONE;
}
static void lame_destroy_call_elem(grpc_call_element* /*elem*/,
const grpc_call_final_info* /*final_info*/,
grpc_closure* then_schedule_closure) {
void lame_destroy_call_elem(grpc_call_element* /*elem*/,
const grpc_call_final_info* /*final_info*/,
grpc_closure* then_schedule_closure) {
ExecCtx::Run(DEBUG_LOCATION, then_schedule_closure, GRPC_ERROR_NONE);
}
static grpc_error_handle lame_init_channel_elem(
grpc_channel_element* elem, grpc_channel_element_args* args) {
grpc_error_handle lame_init_channel_elem(grpc_channel_element* elem,
grpc_channel_element_args* args) {
new (elem->channel_data) ChannelData(args);
return GRPC_ERROR_NONE;
}
static void lame_destroy_channel_elem(grpc_channel_element* elem) {
void lame_destroy_channel_elem(grpc_channel_element* elem) {
ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
chand->~ChannelData();
}

@ -79,7 +79,7 @@ class LegalHeaderKeyBits : public grpc_core::BitSet<256> {
set('.');
}
};
static GRPC_VALIDATE_METADATA_CONSTEXPR_VALUE LegalHeaderKeyBits
GRPC_VALIDATE_METADATA_CONSTEXPR_VALUE LegalHeaderKeyBits
g_legal_header_key_bits;
} // namespace
@ -112,7 +112,7 @@ class LegalHeaderNonBinValueBits : public grpc_core::BitSet<256> {
}
}
};
static GRPC_VALIDATE_METADATA_CONSTEXPR_VALUE LegalHeaderNonBinValueBits
GRPC_VALIDATE_METADATA_CONSTEXPR_VALUE LegalHeaderNonBinValueBits
g_legal_header_non_bin_value_bits;
} // namespace

@ -54,21 +54,21 @@ typedef struct local_tsi_handshaker {
/* --- tsi_handshaker_result methods implementation. --- */
static tsi_result handshaker_result_extract_peer(
const tsi_handshaker_result* /*self*/, tsi_peer* /*peer*/) {
tsi_result handshaker_result_extract_peer(const tsi_handshaker_result* /*self*/,
tsi_peer* /*peer*/) {
return TSI_OK;
}
static tsi_result handshaker_result_get_frame_protector_type(
tsi_result handshaker_result_get_frame_protector_type(
const tsi_handshaker_result* /*self*/,
tsi_frame_protector_type* frame_protector_type) {
*frame_protector_type = TSI_FRAME_PROTECTOR_NONE;
return TSI_OK;
}
static tsi_result handshaker_result_get_unused_bytes(
const tsi_handshaker_result* self, const unsigned char** bytes,
size_t* bytes_size) {
tsi_result handshaker_result_get_unused_bytes(const tsi_handshaker_result* self,
const unsigned char** bytes,
size_t* bytes_size) {
if (self == nullptr || bytes == nullptr || bytes_size == nullptr) {
gpr_log(GPR_ERROR, "Invalid arguments to get_unused_bytes()");
return TSI_INVALID_ARGUMENT;
@ -80,7 +80,7 @@ static tsi_result handshaker_result_get_unused_bytes(
return TSI_OK;
}
static void handshaker_result_destroy(tsi_handshaker_result* self) {
void handshaker_result_destroy(tsi_handshaker_result* self) {
if (self == nullptr) {
return;
}
@ -91,7 +91,7 @@ static void handshaker_result_destroy(tsi_handshaker_result* self) {
gpr_free(result);
}
static const tsi_handshaker_result_vtable result_vtable = {
const tsi_handshaker_result_vtable result_vtable = {
handshaker_result_extract_peer,
handshaker_result_get_frame_protector_type,
nullptr, /* handshaker_result_create_zero_copy_grpc_protector */
@ -99,10 +99,10 @@ static const tsi_handshaker_result_vtable result_vtable = {
handshaker_result_get_unused_bytes,
handshaker_result_destroy};
static tsi_result create_handshaker_result(bool is_client,
const unsigned char* received_bytes,
size_t received_bytes_size,
tsi_handshaker_result** self) {
tsi_result create_handshaker_result(bool is_client,
const unsigned char* received_bytes,
size_t received_bytes_size,
tsi_handshaker_result** self) {
if (self == nullptr) {
gpr_log(GPR_ERROR, "Invalid arguments to create_handshaker_result()");
return TSI_INVALID_ARGUMENT;
@ -123,7 +123,7 @@ static tsi_result create_handshaker_result(bool is_client,
/* --- tsi_handshaker methods implementation. --- */
static tsi_result handshaker_next(
tsi_result handshaker_next(
tsi_handshaker* self, const unsigned char* received_bytes,
size_t received_bytes_size, const unsigned char** /*bytes_to_send*/,
size_t* bytes_to_send_size, tsi_handshaker_result** result,
@ -143,7 +143,7 @@ static tsi_result handshaker_next(
return TSI_OK;
}
static void handshaker_destroy(tsi_handshaker* self) {
void handshaker_destroy(tsi_handshaker* self) {
if (self == nullptr) {
return;
}
@ -152,7 +152,7 @@ static void handshaker_destroy(tsi_handshaker* self) {
gpr_free(handshaker);
}
static const tsi_handshaker_vtable handshaker_vtable = {
const tsi_handshaker_vtable handshaker_vtable = {
nullptr, /* get_bytes_to_send_to_peer -- deprecated */
nullptr, /* process_bytes_from_peer -- deprecated */
nullptr, /* get_result -- deprecated */

@ -34,9 +34,9 @@ namespace grpc {
namespace {
static auto* g_channelz_service = new ChannelzService();
auto* g_channelz_service = new ChannelzService();
#if !defined(GRPC_NO_XDS) && !defined(DISABLED_XDS_PROTO_IN_CC)
static auto* g_csds = new xds::experimental::ClientStatusDiscoveryService();
auto* g_csds = new xds::experimental::ClientStatusDiscoveryService();
#endif // GRPC_NO_XDS or DISABLED_XDS_PROTO_IN_CC
} // namespace

@ -99,7 +99,7 @@ const grpc_channel_filter original_filter = {
grpc_channel_next_get_info,
"filter_name"};
static bool AddReplacementFilter(grpc_channel_stack_builder* builder) {
bool AddReplacementFilter(grpc_channel_stack_builder* builder) {
// Get rid of any other version of the filter, as determined by having the
// same name.
GPR_ASSERT(grpc_channel_stack_builder_remove_filter(builder,

@ -30,12 +30,12 @@
namespace {
static constexpr int kPrintfPointerFieldWidth = 2 + 2 * sizeof(void*);
constexpr int kPrintfPointerFieldWidth = 2 + 2 * sizeof(void*);
static void DumpPCAndFrameSizeAndSymbol(void (*writerfn)(const char*, void*),
void* writerfn_arg, void* pc,
void* symbolize_pc, int framesize,
const char* const prefix) {
void DumpPCAndFrameSizeAndSymbol(void (*writerfn)(const char*, void*),
void* writerfn_arg, void* pc,
void* symbolize_pc, int framesize,
const char* const prefix) {
char tmp[1024];
const char* symbol = "(unknown)";
if (absl::Symbolize(symbolize_pc, tmp, sizeof(tmp))) {
@ -52,9 +52,9 @@ static void DumpPCAndFrameSizeAndSymbol(void (*writerfn)(const char*, void*),
writerfn(buf, writerfn_arg);
}
static void DumpPCAndFrameSize(void (*writerfn)(const char*, void*),
void* writerfn_arg, void* pc, int framesize,
const char* const prefix) {
void DumpPCAndFrameSize(void (*writerfn)(const char*, void*),
void* writerfn_arg, void* pc, int framesize,
const char* const prefix) {
char buf[100];
if (framesize <= 0) {
snprintf(buf, sizeof(buf), "%s@ %*p (unknown)\n", prefix,
@ -66,10 +66,9 @@ static void DumpPCAndFrameSize(void (*writerfn)(const char*, void*),
writerfn(buf, writerfn_arg);
}
static void DumpStackTrace(void* const stack[], int frame_sizes[], int depth,
bool symbolize_stacktrace,
void (*writerfn)(const char*, void*),
void* writerfn_arg) {
void DumpStackTrace(void* const stack[], int frame_sizes[], int depth,
bool symbolize_stacktrace,
void (*writerfn)(const char*, void*), void* writerfn_arg) {
for (int i = 0; i < depth; i++) {
if (symbolize_stacktrace) {
DumpPCAndFrameSizeAndSymbol(writerfn, writerfn_arg, stack[i],
@ -82,7 +81,7 @@ static void DumpStackTrace(void* const stack[], int frame_sizes[], int depth,
}
}
static void DebugWriteToString(const char* data, void* str) {
void DebugWriteToString(const char* data, void* str) {
reinterpret_cast<std::string*>(str)->append(data);
}

@ -238,8 +238,7 @@ class TestScenario {
const std::string message_content;
};
static std::ostream& operator<<(std::ostream& out,
const TestScenario& scenario) {
std::ostream& operator<<(std::ostream& out, const TestScenario& scenario) {
return out << "TestScenario{inproc=" << (scenario.inproc ? "true" : "false")
<< ", credentials='" << scenario.credentials_type
<< ", health_check_service="

@ -67,7 +67,7 @@ namespace grpc {
namespace testing {
namespace {
static bool ValidateAddress(const Address& address) {
bool ValidateAddress(const Address& address) {
if (address.address_case() != Address::kTcpipAddress) {
return true;
}

@ -69,8 +69,7 @@ class TestScenario {
const std::string credentials_type;
};
static std::ostream& operator<<(std::ostream& out,
const TestScenario& scenario) {
std::ostream& operator<<(std::ostream& out, const TestScenario& scenario) {
return out << "TestScenario{callback_server="
<< (scenario.callback_server ? "true" : "false") << ",protocol="
<< (scenario.protocol == Protocol::INPROC ? "INPROC" : "TCP")

@ -59,8 +59,7 @@ class TestScenario {
const std::string credentials_type;
};
static std::ostream& operator<<(std::ostream& out,
const TestScenario& scenario) {
std::ostream& operator<<(std::ostream& out, const TestScenario& scenario) {
return out << "TestScenario{protocol="
<< (scenario.protocol == Protocol::INPROC ? "INPROC" : "TCP")
<< "," << scenario.credentials_type << "}";

@ -290,8 +290,7 @@ class TestScenario {
bool callback_server;
};
static std::ostream& operator<<(std::ostream& out,
const TestScenario& scenario) {
std::ostream& operator<<(std::ostream& out, const TestScenario& scenario) {
return out << "TestScenario{use_interceptors="
<< (scenario.use_interceptors ? "true" : "false")
<< ", use_proxy=" << (scenario.use_proxy ? "true" : "false")
@ -468,8 +467,8 @@ class End2endTest : public ::testing::TestWithParam<TestScenario> {
int first_picked_port_;
};
static void SendRpc(grpc::testing::EchoTestService::Stub* stub, int num_rpcs,
bool with_binary_metadata) {
void SendRpc(grpc::testing::EchoTestService::Stub* stub, int num_rpcs,
bool with_binary_metadata) {
EchoRequest request;
EchoResponse response;
request.set_message("Hello hello hello hello");

@ -88,8 +88,7 @@ class TestScenario {
const std::string credentials_type;
};
static std::ostream& operator<<(std::ostream& out,
const TestScenario& scenario) {
std::ostream& operator<<(std::ostream& out, const TestScenario& scenario) {
return out << "TestScenario{protocol="
<< (scenario.protocol == Protocol::INPROC ? "INPROC" : "TCP")
<< "," << scenario.credentials_type << "}";

@ -71,8 +71,7 @@ class TestScenario {
const std::string credentials_type;
};
static std::ostream& operator<<(std::ostream& out,
const TestScenario& scenario) {
std::ostream& operator<<(std::ostream& out, const TestScenario& scenario) {
return out << "TestScenario{server_has_port="
<< (scenario.server_has_port ? "true" : "false")
<< ", queue_pending_data="
@ -295,7 +294,7 @@ class PortSharingEnd2endTest : public ::testing::TestWithParam<TestScenario> {
int first_picked_port_;
};
static void SendRpc(EchoTestService::Stub* stub, int num_rpcs) {
void SendRpc(EchoTestService::Stub* stub, int num_rpcs) {
EchoRequest request;
EchoResponse response;
request.set_message("Hello hello hello hello");

@ -50,8 +50,8 @@ using ::opencensus::stats::testing::TestUtils;
using ::opencensus::tags::TagKey;
using ::opencensus::tags::WithTagMap;
static const auto TEST_TAG_KEY = TagKey::Register("my_key");
static const auto TEST_TAG_VALUE = "my_value";
const auto TEST_TAG_KEY = TagKey::Register("my_key");
const auto TEST_TAG_VALUE = "my_value";
const char* kExpectedTraceIdKey = "expected_trace_id";
class EchoServer final : public EchoTestService::Service {

@ -134,7 +134,7 @@ class MockSourceAddrFactory : public address_sorting_source_addr_factory {
std::map<std::string, TestAddress> dest_addr_to_src_addr_;
};
static bool mock_source_addr_factory_wrapper_get_source_addr(
bool mock_source_addr_factory_wrapper_get_source_addr(
address_sorting_source_addr_factory* factory,
const address_sorting_address* dest_addr,
address_sorting_address* source_addr) {

Loading…
Cancel
Save