diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc index 1ff42e5653b..4d76b39d44c 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc @@ -55,7 +55,7 @@ class XdsClusterManagerLbConfig : public LoadBalancingPolicy::Config { using ClusterMap = std::map>; - XdsClusterManagerLbConfig(ClusterMap cluster_map) + explicit XdsClusterManagerLbConfig(ClusterMap cluster_map) : cluster_map_(std::move(cluster_map)) {} const char* name() const override { return kXdsClusterManager; } diff --git a/src/core/ext/transport/chttp2/transport/flow_control.h b/src/core/ext/transport/chttp2/transport/flow_control.h index 42c5986fd93..7e053585b18 100644 --- a/src/core/ext/transport/chttp2/transport/flow_control.h +++ b/src/core/ext/transport/chttp2/transport/flow_control.h @@ -201,7 +201,7 @@ class TransportFlowControlBase { class TransportFlowControlDisabled final : public TransportFlowControlBase { public: // Maxes out all values - TransportFlowControlDisabled(grpc_chttp2_transport* t); + explicit TransportFlowControlDisabled(grpc_chttp2_transport* t); bool flow_control_enabled() const override { return false; } diff --git a/src/core/ext/transport/chttp2/transport/writing.cc b/src/core/ext/transport/chttp2/transport/writing.cc index 2ce55d08505..317afcc5103 100644 --- a/src/core/ext/transport/chttp2/transport/writing.cc +++ b/src/core/ext/transport/chttp2/transport/writing.cc @@ -198,7 +198,7 @@ class StreamWriteContext; class WriteContext { public: - WriteContext(grpc_chttp2_transport* t) : t_(t) { + explicit WriteContext(grpc_chttp2_transport* t) : t_(t) { GRPC_STATS_INC_HTTP2_WRITES_BEGUN(); GPR_TIMER_SCOPE("grpc_chttp2_begin_write", 0); } diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.cc b/src/core/ext/transport/cronet/transport/cronet_transport.cc index 4b5a3ff29a3..b98b6a173f3 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.cc +++ b/src/core/ext/transport/cronet/transport/cronet_transport.cc @@ -117,7 +117,7 @@ typedef struct grpc_cronet_transport grpc_cronet_transport; /* TODO (makdharma): reorder structure for memory efficiency per http://www.catb.org/esr/structure-packing/#_structure_reordering: */ struct read_state { - read_state(grpc_core::Arena* arena) + explicit read_state(grpc_core::Arena* arena) : trailing_metadata(arena), initial_metadata(arena) { grpc_slice_buffer_init(&read_slice_buffer); } @@ -151,7 +151,7 @@ struct write_state { /* track state of one stream op */ struct op_state { - op_state(grpc_core::Arena* arena) : rs(arena) {} + explicit op_state(grpc_core::Arena* arena) : rs(arena) {} bool state_op_done[OP_NUM_OPS] = {}; bool state_callback_received[OP_NUM_OPS] = {}; diff --git a/src/core/lib/channel/channel_trace.h b/src/core/lib/channel/channel_trace.h index c26e3016da7..126abc7eb9d 100644 --- a/src/core/lib/channel/channel_trace.h +++ b/src/core/lib/channel/channel_trace.h @@ -41,7 +41,7 @@ class BaseNode; // https://github.com/grpc/proposal/blob/master/A14-channelz.md class ChannelTrace { public: - ChannelTrace(size_t max_event_memory); + explicit ChannelTrace(size_t max_event_memory); ~ChannelTrace(); enum Severity { diff --git a/src/core/lib/gprpp/ref_counted.h b/src/core/lib/gprpp/ref_counted.h index bb5e18020c7..64f3f8fc9cf 100644 --- a/src/core/lib/gprpp/ref_counted.h +++ b/src/core/lib/gprpp/ref_counted.h @@ -221,12 +221,12 @@ class Delete; template class Delete { public: - Delete(T* t) { delete t; } + explicit Delete(T* t) { delete t; } }; template class Delete { public: - Delete(T* t) {} + explicit Delete(T* t) {} }; } // namespace internal diff --git a/src/core/lib/gprpp/ref_counted_ptr.h b/src/core/lib/gprpp/ref_counted_ptr.h index 62fb39fa019..fd3bfbda87c 100644 --- a/src/core/lib/gprpp/ref_counted_ptr.h +++ b/src/core/lib/gprpp/ref_counted_ptr.h @@ -35,10 +35,12 @@ template class RefCountedPtr { public: RefCountedPtr() {} + // NOLINTNEXTLINE(google-explicit-constructor) RefCountedPtr(std::nullptr_t) {} // If value is non-null, we take ownership of a ref to it. template + // NOLINTNEXTLINE(google-explicit-constructor) RefCountedPtr(Y* value) : value_(value) {} // Move ctors. @@ -47,6 +49,7 @@ class RefCountedPtr { other.value_ = nullptr; } template + // NOLINTNEXTLINE(google-explicit-constructor) RefCountedPtr(RefCountedPtr&& other) noexcept { value_ = static_cast(other.value_); other.value_ = nullptr; @@ -71,6 +74,7 @@ class RefCountedPtr { value_ = other.value_; } template + // NOLINTNEXTLINE(google-explicit-constructor) RefCountedPtr(const RefCountedPtr& other) { static_assert(std::has_virtual_destructor::value, "T does not have a virtual dtor"); @@ -181,11 +185,13 @@ template class WeakRefCountedPtr { public: WeakRefCountedPtr() {} + // NOLINTNEXTLINE(google-explicit-constructor) WeakRefCountedPtr(std::nullptr_t) {} // If value is non-null, we take ownership of a ref to it. template - explicit WeakRefCountedPtr(Y* value) { + // NOLINTNEXTLINE(google-explicit-constructor) + WeakRefCountedPtr(Y* value) { value_ = value; } @@ -195,6 +201,7 @@ class WeakRefCountedPtr { other.value_ = nullptr; } template + // NOLINTNEXTLINE(google-explicit-constructor) WeakRefCountedPtr(WeakRefCountedPtr&& other) noexcept { value_ = static_cast(other.value_); other.value_ = nullptr; @@ -219,6 +226,7 @@ class WeakRefCountedPtr { value_ = other.value_; } template + // NOLINTNEXTLINE(google-explicit-constructor) WeakRefCountedPtr(const WeakRefCountedPtr& other) { static_assert(std::has_virtual_destructor::value, "T does not have a virtual dtor"); diff --git a/src/core/lib/http/httpcli_security_connector.cc b/src/core/lib/http/httpcli_security_connector.cc index 966a8fb6415..15aea333c77 100644 --- a/src/core/lib/http/httpcli_security_connector.cc +++ b/src/core/lib/http/httpcli_security_connector.cc @@ -43,7 +43,7 @@ class grpc_httpcli_ssl_channel_security_connector final : public grpc_channel_security_connector { public: - grpc_httpcli_ssl_channel_security_connector(char* secure_peer_name) + explicit grpc_httpcli_ssl_channel_security_connector(char* secure_peer_name) : grpc_channel_security_connector( /*url_scheme=*/nullptr, /*channel_creds=*/nullptr, diff --git a/src/core/lib/iomgr/exec_ctx.h b/src/core/lib/iomgr/exec_ctx.h index 7340e36e560..c993133ef1c 100644 --- a/src/core/lib/iomgr/exec_ctx.h +++ b/src/core/lib/iomgr/exec_ctx.h @@ -113,7 +113,7 @@ class ExecCtx { } /** Parameterised Constructor */ - ExecCtx(uintptr_t fl) : flags_(fl) { + explicit ExecCtx(uintptr_t fl) : flags_(fl) { if (!(GRPC_EXEC_CTX_FLAG_IS_INTERNAL_THREAD & flags_)) { grpc_core::Fork::IncExecCtxCount(); } @@ -308,7 +308,9 @@ class ApplicationCallbackExecCtx { ApplicationCallbackExecCtx() { Set(this, flags_); } /** Parameterised Constructor */ - ApplicationCallbackExecCtx(uintptr_t fl) : flags_(fl) { Set(this, flags_); } + explicit ApplicationCallbackExecCtx(uintptr_t fl) : flags_(fl) { + Set(this, flags_); + } ~ApplicationCallbackExecCtx() { if (reinterpret_cast( diff --git a/src/core/lib/iomgr/executor.h b/src/core/lib/iomgr/executor.h index 71337004841..7a5d16b9fc5 100644 --- a/src/core/lib/iomgr/executor.h +++ b/src/core/lib/iomgr/executor.h @@ -54,7 +54,7 @@ enum class ExecutorJobType { class Executor { public: - Executor(const char* executor_name); + explicit Executor(const char* executor_name); void Init(); diff --git a/src/core/lib/iomgr/executor/threadpool.h b/src/core/lib/iomgr/executor/threadpool.h index 5f8a9680aa3..66218b52b62 100644 --- a/src/core/lib/iomgr/executor/threadpool.h +++ b/src/core/lib/iomgr/executor/threadpool.h @@ -99,7 +99,7 @@ class ThreadPool : public ThreadPoolInterface { // Creates a thread pool with size of "num_threads", with default thread name // "ThreadPoolWorker" and all thread options set to default. If the given size // is 0 or less, there will be 1 worker thread created inside pool. - ThreadPool(int num_threads); + explicit ThreadPool(int num_threads); // Same as ThreadPool(int num_threads) constructor, except // that it also sets "thd_name" as the name of all threads in the thread pool. diff --git a/src/core/lib/iomgr/poller/eventmanager_libuv.h b/src/core/lib/iomgr/poller/eventmanager_libuv.h index 3c0e05d394e..0bd0ecc4161 100644 --- a/src/core/lib/iomgr/poller/eventmanager_libuv.h +++ b/src/core/lib/iomgr/poller/eventmanager_libuv.h @@ -36,7 +36,7 @@ class LibuvEventManager { class Options { public: Options(); - Options(int num_workers); + explicit Options(int num_workers); int num_workers() const { return num_workers_; } void set_num_workers(int num) { num_workers_ = num; } diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc index d33e9ef12c0..7813e044c50 100644 --- a/src/core/lib/iomgr/tcp_posix.cc +++ b/src/core/lib/iomgr/tcp_posix.cc @@ -181,8 +181,9 @@ class TcpZerocopySendCtx { static constexpr int kDefaultMaxSends = 4; static constexpr size_t kDefaultSendBytesThreshold = 16 * 1024; // 16KB - TcpZerocopySendCtx(int max_sends = kDefaultMaxSends, - size_t send_bytes_threshold = kDefaultSendBytesThreshold) + explicit TcpZerocopySendCtx( + int max_sends = kDefaultMaxSends, + size_t send_bytes_threshold = kDefaultSendBytesThreshold) : max_sends_(max_sends), free_send_records_size_(max_sends), threshold_bytes_(send_bytes_threshold) { diff --git a/src/core/lib/json/json.h b/src/core/lib/json/json.h index 4916fe2a849..9b3e0be7bfd 100644 --- a/src/core/lib/json/json.h +++ b/src/core/lib/json/json.h @@ -76,6 +76,7 @@ class Json { // Construct from copying a string. // If is_number is true, the type will be NUMBER instead of STRING. + // NOLINTNEXTLINE(google-explicit-constructor) Json(const std::string& string, bool is_number = false) : type_(is_number ? Type::NUMBER : Type::STRING), string_value_(string) {} Json& operator=(const std::string& string) { @@ -85,12 +86,14 @@ class Json { } // Same thing for C-style strings, both const and mutable. + // NOLINTNEXTLINE(google-explicit-constructor) Json(const char* string, bool is_number = false) : Json(std::string(string), is_number) {} Json& operator=(const char* string) { *this = std::string(string); return *this; } + // NOLINTNEXTLINE(google-explicit-constructor) Json(char* string, bool is_number = false) : Json(std::string(string), is_number) {} Json& operator=(char* string) { @@ -99,6 +102,7 @@ class Json { } // Construct by moving a string. + // NOLINTNEXTLINE(google-explicit-constructor) Json(std::string&& string) : type_(Type::STRING), string_value_(std::move(string)) {} Json& operator=(std::string&& string) { @@ -108,6 +112,7 @@ class Json { } // Construct from bool. + // NOLINTNEXTLINE(google-explicit-constructor) Json(bool b) : type_(b ? Type::JSON_TRUE : Type::JSON_FALSE) {} Json& operator=(bool b) { type_ = b ? Type::JSON_TRUE : Type::JSON_FALSE; @@ -116,6 +121,7 @@ class Json { // Construct from any numeric type. template + // NOLINTNEXTLINE(google-explicit-constructor) Json(NumericType number) : type_(Type::NUMBER), string_value_(std::to_string(number)) {} template @@ -126,6 +132,7 @@ class Json { } // Construct by copying object. + // NOLINTNEXTLINE(google-explicit-constructor) Json(const Object& object) : type_(Type::OBJECT), object_value_(object) {} Json& operator=(const Object& object) { type_ = Type::OBJECT; @@ -134,6 +141,7 @@ class Json { } // Construct by moving object. + // NOLINTNEXTLINE(google-explicit-constructor) Json(Object&& object) : type_(Type::OBJECT), object_value_(std::move(object)) {} Json& operator=(Object&& object) { @@ -143,6 +151,7 @@ class Json { } // Construct by copying array. + // NOLINTNEXTLINE(google-explicit-constructor) Json(const Array& array) : type_(Type::ARRAY), array_value_(array) {} Json& operator=(const Array& array) { type_ = Type::ARRAY; @@ -151,6 +160,7 @@ class Json { } // Construct by moving array. + // NOLINTNEXTLINE(google-explicit-constructor) Json(Array&& array) : type_(Type::ARRAY), array_value_(std::move(array)) {} Json& operator=(Array&& array) { type_ = Type::ARRAY; diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.h b/src/core/lib/security/credentials/oauth2/oauth2_credentials.h index 2a9b37e1fec..6111d9adcaa 100644 --- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.h @@ -107,7 +107,8 @@ class grpc_oauth2_token_fetcher_credentials : public grpc_call_credentials { class grpc_google_refresh_token_credentials final : public grpc_oauth2_token_fetcher_credentials { public: - grpc_google_refresh_token_credentials(grpc_auth_refresh_token refresh_token); + explicit grpc_google_refresh_token_credentials( + grpc_auth_refresh_token refresh_token); ~grpc_google_refresh_token_credentials() override; const grpc_auth_refresh_token& refresh_token() const { @@ -130,7 +131,7 @@ class grpc_google_refresh_token_credentials final // Access token credentials. class grpc_access_token_credentials final : public grpc_call_credentials { public: - grpc_access_token_credentials(const char* access_token); + explicit grpc_access_token_credentials(const char* access_token); ~grpc_access_token_credentials() override; bool get_request_metadata(grpc_polling_entity* pollent, diff --git a/src/core/lib/security/credentials/ssl/ssl_credentials.h b/src/core/lib/security/credentials/ssl/ssl_credentials.h index 4c90813f8d2..0c5af81c7d8 100644 --- a/src/core/lib/security/credentials/ssl/ssl_credentials.h +++ b/src/core/lib/security/credentials/ssl/ssl_credentials.h @@ -64,7 +64,7 @@ struct grpc_ssl_server_certificate_config_fetcher { class grpc_ssl_server_credentials final : public grpc_server_credentials { public: - grpc_ssl_server_credentials( + explicit grpc_ssl_server_credentials( const grpc_ssl_server_credentials_options& options); ~grpc_ssl_server_credentials() override; diff --git a/src/core/lib/security/security_connector/alts/alts_security_connector.cc b/src/core/lib/security/security_connector/alts/alts_security_connector.cc index 47c357f8fab..64c39e6d5e3 100644 --- a/src/core/lib/security/security_connector/alts/alts_security_connector.cc +++ b/src/core/lib/security/security_connector/alts/alts_security_connector.cc @@ -134,7 +134,7 @@ class grpc_alts_channel_security_connector final class grpc_alts_server_security_connector final : public grpc_server_security_connector { public: - grpc_alts_server_security_connector( + explicit grpc_alts_server_security_connector( grpc_core::RefCountedPtr server_creds) : grpc_server_security_connector(GRPC_ALTS_URL_SCHEME, std::move(server_creds)) {} diff --git a/src/core/lib/security/security_connector/fake/fake_security_connector.cc b/src/core/lib/security/security_connector/fake/fake_security_connector.cc index 0e3b1e8b973..fdf750f4ede 100644 --- a/src/core/lib/security/security_connector/fake/fake_security_connector.cc +++ b/src/core/lib/security/security_connector/fake/fake_security_connector.cc @@ -275,7 +275,7 @@ void grpc_fake_channel_security_connector::check_peer( class grpc_fake_server_security_connector : public grpc_server_security_connector { public: - grpc_fake_server_security_connector( + explicit grpc_fake_server_security_connector( grpc_core::RefCountedPtr server_creds) : grpc_server_security_connector(GRPC_FAKE_SECURITY_URL_SCHEME, std::move(server_creds)) {} diff --git a/src/core/lib/security/security_connector/insecure/insecure_security_connector.h b/src/core/lib/security/security_connector/insecure/insecure_security_connector.h index f55ae02bd67..7d0f79e90f1 100644 --- a/src/core/lib/security/security_connector/insecure/insecure_security_connector.h +++ b/src/core/lib/security/security_connector/insecure/insecure_security_connector.h @@ -65,7 +65,7 @@ class InsecureChannelSecurityConnector class InsecureServerSecurityConnector : public grpc_server_security_connector { public: - InsecureServerSecurityConnector( + explicit InsecureServerSecurityConnector( grpc_core::RefCountedPtr server_creds) : grpc_server_security_connector(nullptr /* url_scheme */, std::move(server_creds)) {} diff --git a/src/core/lib/security/security_connector/local/local_security_connector.cc b/src/core/lib/security/security_connector/local/local_security_connector.cc index 3313fd01247..2cec0dbb9a5 100644 --- a/src/core/lib/security/security_connector/local/local_security_connector.cc +++ b/src/core/lib/security/security_connector/local/local_security_connector.cc @@ -206,7 +206,7 @@ class grpc_local_channel_security_connector final class grpc_local_server_security_connector final : public grpc_server_security_connector { public: - grpc_local_server_security_connector( + explicit grpc_local_server_security_connector( grpc_core::RefCountedPtr server_creds) : grpc_server_security_connector(nullptr, std::move(server_creds)) {} ~grpc_local_server_security_connector() override = default; 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 41a2252435c..ee5672b955a 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 @@ -206,7 +206,7 @@ class grpc_ssl_channel_security_connector final class grpc_ssl_server_security_connector : public grpc_server_security_connector { public: - grpc_ssl_server_security_connector( + explicit grpc_ssl_server_security_connector( grpc_core::RefCountedPtr server_creds) : grpc_server_security_connector(GRPC_SSL_URL_SCHEME, std::move(server_creds)) {} diff --git a/src/core/lib/slice/slice_internal.h b/src/core/lib/slice/slice_internal.h index 6ada6b0f945..1cbe32baf6b 100644 --- a/src/core/lib/slice/slice_internal.h +++ b/src/core/lib/slice/slice_internal.h @@ -176,7 +176,7 @@ namespace grpc_core { struct StaticSliceRefcount { static grpc_slice_refcount kStaticSubRefcount; - StaticSliceRefcount(uint32_t index) + explicit StaticSliceRefcount(uint32_t index) : base(&kStaticSubRefcount, grpc_slice_refcount::Type::STATIC), index(index) {} diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index 3e9db709ada..d749d396eda 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -124,7 +124,7 @@ struct parent_call { }; struct child_call { - child_call(grpc_call* parent) : parent(parent) {} + explicit child_call(grpc_call* parent) : parent(parent) {} grpc_call* parent; /** siblings: children of the same parent form a list, and this list is protected under diff --git a/src/core/lib/surface/completion_queue.cc b/src/core/lib/surface/completion_queue.cc index c262cc95978..02ac5067a31 100644 --- a/src/core/lib/surface/completion_queue.cc +++ b/src/core/lib/surface/completion_queue.cc @@ -310,7 +310,7 @@ struct cq_pluck_data { }; struct cq_callback_data { - cq_callback_data( + explicit cq_callback_data( grpc_experimental_completion_queue_functor* shutdown_callback) : shutdown_callback(shutdown_callback) {} @@ -913,7 +913,8 @@ struct cq_is_finished_arg { }; class ExecCtxNext : public grpc_core::ExecCtx { public: - ExecCtxNext(void* arg) : ExecCtx(0), check_ready_to_finish_arg_(arg) {} + explicit ExecCtxNext(void* arg) + : ExecCtx(0), check_ready_to_finish_arg_(arg) {} bool CheckReadyToFinish() override { cq_is_finished_arg* a = @@ -1161,7 +1162,8 @@ static void del_plucker(grpc_completion_queue* cq, void* tag, class ExecCtxPluck : public grpc_core::ExecCtx { public: - ExecCtxPluck(void* arg) : ExecCtx(0), check_ready_to_finish_arg_(arg) {} + explicit ExecCtxPluck(void* arg) + : ExecCtx(0), check_ready_to_finish_arg_(arg) {} bool CheckReadyToFinish() override { cq_is_finished_arg* a = diff --git a/src/core/lib/transport/connectivity_state.h b/src/core/lib/transport/connectivity_state.h index cad34c27003..e5fee88e3b7 100644 --- a/src/core/lib/transport/connectivity_state.h +++ b/src/core/lib/transport/connectivity_state.h @@ -95,9 +95,9 @@ class AsyncConnectivityStateWatcherInterface // to be called). class ConnectivityStateTracker { public: - ConnectivityStateTracker(const char* name, - grpc_connectivity_state state = GRPC_CHANNEL_IDLE, - const absl::Status& status = absl::Status()) + explicit ConnectivityStateTracker( + const char* name, grpc_connectivity_state state = GRPC_CHANNEL_IDLE, + const absl::Status& status = absl::Status()) : name_(name), state_(state), status_(status) {} ~ConnectivityStateTracker(); diff --git a/src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc b/src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc index 612ecfffd46..dcfff00cb9a 100644 --- a/src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc +++ b/src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc @@ -32,7 +32,7 @@ namespace { class BoringSslCachedSession : public SslCachedSession { public: - BoringSslCachedSession(SslSessionPtr session) + explicit BoringSslCachedSession(SslSessionPtr session) : session_(std::move(session)) {} SslSessionPtr CopySession() const override { diff --git a/src/cpp/server/dynamic_thread_pool.h b/src/cpp/server/dynamic_thread_pool.h index 3bc7b677bad..954aaff35da 100644 --- a/src/cpp/server/dynamic_thread_pool.h +++ b/src/cpp/server/dynamic_thread_pool.h @@ -41,7 +41,7 @@ class DynamicThreadPool final : public ThreadPoolInterface { private: class DynamicThread { public: - DynamicThread(DynamicThreadPool* pool); + explicit DynamicThread(DynamicThreadPool* pool); ~DynamicThread(); private: diff --git a/src/cpp/server/secure_server_credentials.h b/src/cpp/server/secure_server_credentials.h index 4e24b2534da..730abdb83cd 100644 --- a/src/cpp/server/secure_server_credentials.h +++ b/src/cpp/server/secure_server_credentials.h @@ -40,7 +40,7 @@ class AuthMetadataProcessorAyncWrapper final { const grpc_metadata* md, size_t num_md, grpc_process_auth_metadata_done_cb cb, void* user_data); - AuthMetadataProcessorAyncWrapper( + explicit AuthMetadataProcessorAyncWrapper( const std::shared_ptr& processor) : processor_(processor) { if (processor && processor->IsBlocking()) { diff --git a/src/cpp/server/server_cc.cc b/src/cpp/server/server_cc.cc index 933ef938efa..13357ae4919 100644 --- a/src/cpp/server/server_cc.cc +++ b/src/cpp/server/server_cc.cc @@ -315,7 +315,7 @@ class Server::UnimplementedAsyncResponse final grpc::internal::CallOpSendInitialMetadata, grpc::internal::CallOpServerSendStatus> { public: - UnimplementedAsyncResponse(UnimplementedAsyncRequest* request); + explicit UnimplementedAsyncResponse(UnimplementedAsyncRequest* request); ~UnimplementedAsyncResponse() override { delete request_; } bool FinalizeResult(void** tag, bool* status) override { @@ -592,7 +592,7 @@ class Server::CallbackRequest final class CallbackCallTag : public grpc_experimental_completion_queue_functor { public: - CallbackCallTag(Server::CallbackRequest* req) + explicit CallbackCallTag(Server::CallbackRequest* req) : req_(req) { functor_run = &CallbackCallTag::StaticRun; // Set inlineable to true since this callback is internally-controlled diff --git a/src/cpp/thread_manager/thread_manager.h b/src/cpp/thread_manager/thread_manager.h index 43f1fd5585f..aae24177873 100644 --- a/src/cpp/thread_manager/thread_manager.h +++ b/src/cpp/thread_manager/thread_manager.h @@ -119,7 +119,7 @@ class ThreadManager { // not be called (and the need for this WorkerThread class is eliminated) class WorkerThread { public: - WorkerThread(ThreadManager* thd_mgr); + explicit WorkerThread(ThreadManager* thd_mgr); ~WorkerThread(); bool created() const { return created_; } diff --git a/test/core/channel/channel_trace_test.cc b/test/core/channel/channel_trace_test.cc index f0917fa67fa..0ecefede9c3 100644 --- a/test/core/channel/channel_trace_test.cc +++ b/test/core/channel/channel_trace_test.cc @@ -102,7 +102,7 @@ void ValidateChannelTrace(ChannelTrace* tracer, size_t num_events_logged) { class ChannelFixture { public: - ChannelFixture(int max_tracer_event_memory) { + explicit ChannelFixture(int max_tracer_event_memory) { grpc_arg client_a = grpc_channel_arg_integer_create( const_cast(GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE), max_tracer_event_memory); diff --git a/test/core/channel/channelz_test.cc b/test/core/channel/channelz_test.cc index 3c7c89848e0..0da9f6f9339 100644 --- a/test/core/channel/channelz_test.cc +++ b/test/core/channel/channelz_test.cc @@ -143,7 +143,7 @@ void ValidateGetServers(size_t expected_servers) { class ChannelFixture { public: - ChannelFixture(int max_tracer_event_memory = 0) { + explicit ChannelFixture(int max_tracer_event_memory = 0) { grpc_arg client_a[] = { grpc_channel_arg_integer_create( const_cast(GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE), diff --git a/test/core/client_channel/service_config_test.cc b/test/core/client_channel/service_config_test.cc index 97749cfb15f..6df340f5b47 100644 --- a/test/core/client_channel/service_config_test.cc +++ b/test/core/client_channel/service_config_test.cc @@ -38,7 +38,7 @@ namespace testing { class TestParsedConfig1 : public ServiceConfigParser::ParsedConfig { public: - TestParsedConfig1(int value) : value_(value) {} + explicit TestParsedConfig1(int value) : value_(value) {} int value() const { return value_; } diff --git a/test/core/iomgr/mpmcqueue_test.cc b/test/core/iomgr/mpmcqueue_test.cc index 93beb663b01..d63ae7893c2 100644 --- a/test/core/iomgr/mpmcqueue_test.cc +++ b/test/core/iomgr/mpmcqueue_test.cc @@ -30,7 +30,7 @@ struct WorkItem { int index; bool done; - WorkItem(int i) : index(i) { done = false; } + explicit WorkItem(int i) : index(i) { done = false; } }; // Thread to "produce" items and put items into queue @@ -77,7 +77,7 @@ class ProducerThread { // Thread to pull out items from queue class ConsumerThread { public: - ConsumerThread(grpc_core::InfLenFIFOQueue* queue) : queue_(queue) { + explicit ConsumerThread(grpc_core::InfLenFIFOQueue* queue) : queue_(queue) { thd_ = grpc_core::Thread( "mpmcq_test_consumer_thd", [](void* th) { static_cast(th)->Run(); }, this); diff --git a/test/core/iomgr/poller/eventmanager_libuv_test.cc b/test/core/iomgr/poller/eventmanager_libuv_test.cc index 8443e9f4c02..82b6de1b913 100644 --- a/test/core/iomgr/poller/eventmanager_libuv_test.cc +++ b/test/core/iomgr/poller/eventmanager_libuv_test.cc @@ -32,7 +32,8 @@ namespace { TEST(LibuvEventManager, Allocation) { for (int i = 0; i < 10; i++) { - LibuvEventManager* em = new LibuvEventManager(i); + LibuvEventManager* em = + new LibuvEventManager(LibuvEventManager::Options(i)); gpr_sleep_until(grpc_timeout_milliseconds_to_deadline(1)); delete em; } @@ -40,7 +41,8 @@ TEST(LibuvEventManager, Allocation) { TEST(LibuvEventManager, ShutdownRef) { for (int i = 0; i < 10; i++) { - LibuvEventManager* em = new LibuvEventManager(i); + LibuvEventManager* em = + new LibuvEventManager(LibuvEventManager::Options(i)); for (int j = 0; j < i; j++) { em->ShutdownRef(); } @@ -54,7 +56,8 @@ TEST(LibuvEventManager, ShutdownRef) { TEST(LibuvEventManager, ShutdownRefAsync) { for (int i = 0; i < 10; i++) { - LibuvEventManager* em = new LibuvEventManager(i); + LibuvEventManager* em = + new LibuvEventManager(LibuvEventManager::Options(i)); for (int j = 0; j < i; j++) { em->ShutdownRef(); } diff --git a/test/core/surface/completion_queue_test.cc b/test/core/surface/completion_queue_test.cc index 22079f88ae8..cbf536fa16c 100644 --- a/test/core/surface/completion_queue_test.cc +++ b/test/core/surface/completion_queue_test.cc @@ -380,7 +380,7 @@ static void test_callback(void) { bool got_shutdown = false; class ShutdownCallback : public grpc_experimental_completion_queue_functor { public: - ShutdownCallback(bool* done) : done_(done) { + explicit ShutdownCallback(bool* done) : done_(done) { functor_run = &ShutdownCallback::Run; inlineable = false; } diff --git a/test/core/tsi/alts/handshaker/alts_concurrent_connectivity_test.cc b/test/core/tsi/alts/handshaker/alts_concurrent_connectivity_test.cc index c96a6141f43..bc2eca1a61b 100644 --- a/test/core/tsi/alts/handshaker/alts_concurrent_connectivity_test.cc +++ b/test/core/tsi/alts/handshaker/alts_concurrent_connectivity_test.cc @@ -104,7 +104,7 @@ grpc_channel* create_secure_channel_for_test( class FakeHandshakeServer { public: - FakeHandshakeServer(bool check_num_concurrent_rpcs) { + explicit FakeHandshakeServer(bool check_num_concurrent_rpcs) { int port = grpc_pick_unused_port_or_die(); address_ = grpc_core::JoinHostPort("localhost", port); if (check_num_concurrent_rpcs) { diff --git a/test/core/xds/xds_bootstrap_test.cc b/test/core/xds/xds_bootstrap_test.cc index 7a7545dca1d..d74bbf035a6 100644 --- a/test/core/xds/xds_bootstrap_test.cc +++ b/test/core/xds/xds_bootstrap_test.cc @@ -36,7 +36,7 @@ namespace testing { class TestType { public: - TestType(bool parse_xds_certificate_providers) + explicit TestType(bool parse_xds_certificate_providers) : parse_xds_certificate_providers_(parse_xds_certificate_providers) {} bool parse_xds_certificate_providers() const { diff --git a/test/cpp/end2end/client_callback_end2end_test.cc b/test/cpp/end2end/client_callback_end2end_test.cc index bc093534944..e38bd7115cc 100644 --- a/test/cpp/end2end/client_callback_end2end_test.cc +++ b/test/cpp/end2end/client_callback_end2end_test.cc @@ -806,7 +806,7 @@ TEST_P(ClientCallbackEnd2endTest, UnaryReactor) { ResetStub(); class UnaryClient : public grpc::experimental::ClientUnaryReactor { public: - UnaryClient(grpc::testing::EchoTestService::Stub* stub) { + explicit UnaryClient(grpc::testing::EchoTestService::Stub* stub) { cli_ctx_.AddMetadata("key1", "val1"); cli_ctx_.AddMetadata("key2", "val2"); request_.mutable_param()->set_echo_metadata_initially(true); @@ -1351,7 +1351,7 @@ TEST_P(ClientCallbackEnd2endTest, SimultaneousReadAndWritesDone) { class Client : public grpc::experimental::ClientBidiReactor { public: - Client(grpc::testing::EchoTestService::Stub* stub) { + explicit Client(grpc::testing::EchoTestService::Stub* stub) { request_.set_message("Hello bidi "); stub->experimental_async()->BidiStream(&context_, this); StartWrite(&request_); @@ -1434,7 +1434,8 @@ TEST_P(ClientCallbackEnd2endTest, class ReadAllIncomingDataClient : public grpc::experimental::ClientReadReactor { public: - ReadAllIncomingDataClient(grpc::testing::EchoTestService::Stub* stub) { + explicit ReadAllIncomingDataClient( + grpc::testing::EchoTestService::Stub* stub) { request_.set_message("Hello client "); stub->experimental_async()->ResponseStream(&context_, &request_, this); } diff --git a/test/cpp/end2end/client_interceptors_end2end_test.cc b/test/cpp/end2end/client_interceptors_end2end_test.cc index 8bc81bfb361..af454198eb2 100644 --- a/test/cpp/end2end/client_interceptors_end2end_test.cc +++ b/test/cpp/end2end/client_interceptors_end2end_test.cc @@ -72,7 +72,7 @@ enum class ChannelType { /* Hijacks Echo RPC and fills in the expected values */ class HijackingInterceptor : public experimental::Interceptor { public: - HijackingInterceptor(experimental::ClientRpcInfo* info) { + explicit HijackingInterceptor(experimental::ClientRpcInfo* info) { info_ = info; // Make sure it is the right method EXPECT_EQ(strcmp("/grpc.testing.EchoTestService/Echo", info->method()), 0); @@ -178,7 +178,8 @@ class HijackingInterceptorFactory class HijackingInterceptorMakesAnotherCall : public experimental::Interceptor { public: - HijackingInterceptorMakesAnotherCall(experimental::ClientRpcInfo* info) { + explicit HijackingInterceptorMakesAnotherCall( + experimental::ClientRpcInfo* info) { info_ = info; // Make sure it is the right method EXPECT_EQ(strcmp("/grpc.testing.EchoTestService/Echo", info->method()), 0); @@ -300,7 +301,8 @@ class HijackingInterceptorMakesAnotherCallFactory class BidiStreamingRpcHijackingInterceptor : public experimental::Interceptor { public: - BidiStreamingRpcHijackingInterceptor(experimental::ClientRpcInfo* info) { + explicit BidiStreamingRpcHijackingInterceptor( + experimental::ClientRpcInfo* info) { info_ = info; } @@ -370,7 +372,8 @@ class BidiStreamingRpcHijackingInterceptor : public experimental::Interceptor { class ClientStreamingRpcHijackingInterceptor : public experimental::Interceptor { public: - ClientStreamingRpcHijackingInterceptor(experimental::ClientRpcInfo* info) { + explicit ClientStreamingRpcHijackingInterceptor( + experimental::ClientRpcInfo* info) { info_ = info; } void Intercept(experimental::InterceptorBatchMethods* methods) override { @@ -424,7 +427,8 @@ class ClientStreamingRpcHijackingInterceptorFactory class ServerStreamingRpcHijackingInterceptor : public experimental::Interceptor { public: - ServerStreamingRpcHijackingInterceptor(experimental::ClientRpcInfo* info) { + explicit ServerStreamingRpcHijackingInterceptor( + experimental::ClientRpcInfo* info) { info_ = info; got_failed_message_ = false; } @@ -534,7 +538,7 @@ class BidiStreamingRpcHijackingInterceptorFactory // single RPC should be made on the channel before calling the Verify methods. class LoggingInterceptor : public experimental::Interceptor { public: - LoggingInterceptor(experimental::ClientRpcInfo* /*info*/) { + explicit LoggingInterceptor(experimental::ClientRpcInfo* /*info*/) { pre_send_initial_metadata_ = false; pre_send_message_count_ = 0; pre_send_close_ = false; diff --git a/test/cpp/end2end/delegating_channel_test.cc b/test/cpp/end2end/delegating_channel_test.cc index 9b371e29a29..5ff66d8ffd1 100644 --- a/test/cpp/end2end/delegating_channel_test.cc +++ b/test/cpp/end2end/delegating_channel_test.cc @@ -45,7 +45,8 @@ namespace { class TestChannel : public experimental::DelegatingChannel { public: - TestChannel(const std::shared_ptr& delegate_channel) + explicit TestChannel( + const std::shared_ptr& delegate_channel) : experimental::DelegatingChannel(delegate_channel) {} // Always returns GRPC_CHANNEL_READY grpc_connectivity_state GetState(bool /*try_to_connect*/) override { diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index 08e75eff61f..906d0fa5160 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -204,7 +204,8 @@ class TestAuthMetadataProcessor : public AuthMetadataProcessor { public: static const char kGoodGuy[]; - TestAuthMetadataProcessor(bool is_blocking) : is_blocking_(is_blocking) {} + explicit TestAuthMetadataProcessor(bool is_blocking) + : is_blocking_(is_blocking) {} std::shared_ptr GetCompatibleClientCreds() { return grpc::MetadataCredentialsFromPlugin( @@ -259,7 +260,7 @@ const char TestAuthMetadataProcessor::kIdentityPropName[] = "novel identity"; class Proxy : public ::grpc::testing::EchoTestService::Service { public: - Proxy(const std::shared_ptr& channel) + explicit Proxy(const std::shared_ptr& channel) : stub_(grpc::testing::EchoTestService::NewStub(channel)) {} Status Echo(ServerContext* server_context, const EchoRequest* request, @@ -1857,7 +1858,8 @@ TEST_P(SecureEnd2endTest, SetPerCallCredentials) { class CredentialsInterceptor : public experimental::Interceptor { public: - CredentialsInterceptor(experimental::ClientRpcInfo* info) : info_(info) {} + explicit CredentialsInterceptor(experimental::ClientRpcInfo* info) + : info_(info) {} void Intercept(experimental::InterceptorBatchMethods* methods) override { if (methods->QueryInterceptionHookPoint( diff --git a/test/cpp/end2end/server_interceptors_end2end_test.cc b/test/cpp/end2end/server_interceptors_end2end_test.cc index 4c90514c532..43457343c65 100644 --- a/test/cpp/end2end/server_interceptors_end2end_test.cc +++ b/test/cpp/end2end/server_interceptors_end2end_test.cc @@ -47,7 +47,7 @@ namespace { class LoggingInterceptor : public experimental::Interceptor { public: - LoggingInterceptor(experimental::ServerRpcInfo* info) { + explicit LoggingInterceptor(experimental::ServerRpcInfo* info) { info_ = info; // Check the method name and compare to the type @@ -150,7 +150,7 @@ class LoggingInterceptorFactory // Test if SendMessage function family works as expected for sync/callback apis class SyncSendMessageTester : public experimental::Interceptor { public: - SyncSendMessageTester(experimental::ServerRpcInfo* /*info*/) {} + explicit SyncSendMessageTester(experimental::ServerRpcInfo* /*info*/) {} void Intercept(experimental::InterceptorBatchMethods* methods) override { if (methods->QueryInterceptionHookPoint( @@ -180,7 +180,7 @@ class SyncSendMessageTesterFactory // Test if SendMessage function family works as expected for sync/callback apis class SyncSendMessageVerifier : public experimental::Interceptor { public: - SyncSendMessageVerifier(experimental::ServerRpcInfo* /*info*/) {} + explicit SyncSendMessageVerifier(experimental::ServerRpcInfo* /*info*/) {} void Intercept(experimental::InterceptorBatchMethods* methods) override { if (methods->QueryInterceptionHookPoint( diff --git a/test/cpp/end2end/xds_end2end_test.cc b/test/cpp/end2end/xds_end2end_test.cc index 514b8852b0c..70c2891d195 100644 --- a/test/cpp/end2end/xds_end2end_test.cc +++ b/test/cpp/end2end/xds_end2end_test.cc @@ -358,7 +358,7 @@ class ClientStats { // Converts from proto message class. template - LocalityStats(const UpstreamLocalityStats& upstream_locality_stats) + explicit LocalityStats(const UpstreamLocalityStats& upstream_locality_stats) : total_successful_requests( upstream_locality_stats.total_successful_requests()), total_requests_in_progress( diff --git a/test/cpp/interop/client_helper.h b/test/cpp/interop/client_helper.h index adb9d72af56..2902ab7913f 100644 --- a/test/cpp/interop/client_helper.h +++ b/test/cpp/interop/client_helper.h @@ -47,7 +47,7 @@ std::shared_ptr CreateChannelForTestCase( class InteropClientContextInspector { public: - InteropClientContextInspector(const ::grpc::ClientContext& context) + explicit InteropClientContextInspector(const ::grpc::ClientContext& context) : context_(context) {} // Inspector methods, able to peek inside ClientContext, follow. @@ -68,7 +68,7 @@ class InteropClientContextInspector { class AdditionalMetadataInterceptor : public experimental::Interceptor { public: - AdditionalMetadataInterceptor( + explicit AdditionalMetadataInterceptor( std::multimap additional_metadata) : additional_metadata_(std::move(additional_metadata)) {} @@ -91,7 +91,7 @@ class AdditionalMetadataInterceptor : public experimental::Interceptor { class AdditionalMetadataInterceptorFactory : public experimental::ClientInterceptorFactoryInterface { public: - AdditionalMetadataInterceptorFactory( + explicit AdditionalMetadataInterceptorFactory( std::multimap additional_metadata) : additional_metadata_(std::move(additional_metadata)) {} diff --git a/test/cpp/interop/http2_client.h b/test/cpp/interop/http2_client.h index 269d3b32e27..42728fc52e0 100644 --- a/test/cpp/interop/http2_client.h +++ b/test/cpp/interop/http2_client.h @@ -44,7 +44,7 @@ class Http2Client { private: class ServiceStub { public: - ServiceStub(const std::shared_ptr& channel); + explicit ServiceStub(const std::shared_ptr& channel); TestService::Stub* Get(); diff --git a/test/cpp/interop/server_helper.h b/test/cpp/interop/server_helper.h index 237c33cd0cd..ee72697b5e9 100644 --- a/test/cpp/interop/server_helper.h +++ b/test/cpp/interop/server_helper.h @@ -37,7 +37,7 @@ std::shared_ptr CreateInteropServerCredentials(); class InteropServerContextInspector { public: - InteropServerContextInspector(const ::grpc::ServerContext& context); + explicit InteropServerContextInspector(const ::grpc::ServerContext& context); // Inspector methods, able to peek inside ServerContext, follow. std::shared_ptr GetAuthContext() const; diff --git a/test/cpp/interop/stress_interop_client.h b/test/cpp/interop/stress_interop_client.h index eb2ec415af6..653df916542 100644 --- a/test/cpp/interop/stress_interop_client.h +++ b/test/cpp/interop/stress_interop_client.h @@ -77,7 +77,8 @@ const vector> kTestCaseList = { class WeightedRandomTestSelector { public: // Takes a vector of pairs as the input - WeightedRandomTestSelector(const vector>& tests); + explicit WeightedRandomTestSelector( + const vector>& tests); // Returns a weighted-randomly chosen test case based on the test cases and // weights passed in the constructor diff --git a/test/cpp/interop/xds_interop_server.cc b/test/cpp/interop/xds_interop_server.cc index fa8f3a780e0..99551737d9c 100644 --- a/test/cpp/interop/xds_interop_server.cc +++ b/test/cpp/interop/xds_interop_server.cc @@ -50,7 +50,7 @@ using grpc::testing::TestService; class TestServiceImpl : public TestService::Service { public: - TestServiceImpl(const std::string& i) : hostname_(i) {} + explicit TestServiceImpl(const std::string& i) : hostname_(i) {} Status UnaryCall(ServerContext* context, const SimpleRequest* request, SimpleResponse* response) override { diff --git a/test/cpp/microbenchmarks/bm_call_create.cc b/test/cpp/microbenchmarks/bm_call_create.cc index 4b114167c43..e167f40bbe4 100644 --- a/test/cpp/microbenchmarks/bm_call_create.cc +++ b/test/cpp/microbenchmarks/bm_call_create.cc @@ -76,7 +76,7 @@ BENCHMARK(BM_Zalloc) class BaseChannelFixture { public: - BaseChannelFixture(grpc_channel* channel) : channel_(channel) {} + explicit BaseChannelFixture(grpc_channel* channel) : channel_(channel) {} ~BaseChannelFixture() { grpc_channel_destroy(channel_); } grpc_channel* channel() const { return channel_; } diff --git a/test/cpp/microbenchmarks/bm_chttp2_transport.cc b/test/cpp/microbenchmarks/bm_chttp2_transport.cc index 220504b3de8..3c8822a4d65 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_transport.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_transport.cc @@ -181,7 +181,7 @@ std::unique_ptr MakeTestClosure(F f) { template grpc_closure* MakeOnceClosure(F f) { struct C : public grpc_closure { - C(const F& f) : f_(f) {} + explicit C(const F& f) : f_(f) {} F f_; static void Execute(void* arg, grpc_error* error) { static_cast(arg)->f_(error); @@ -194,7 +194,7 @@ grpc_closure* MakeOnceClosure(F f) { class Stream { public: - Stream(Fixture* f) : f_(f) { + explicit Stream(Fixture* f) : f_(f) { stream_size_ = grpc_transport_stream_size(f->transport()); stream_ = gpr_malloc(stream_size_); arena_ = grpc_core::Arena::Create(4096); diff --git a/test/cpp/microbenchmarks/bm_threadpool.cc b/test/cpp/microbenchmarks/bm_threadpool.cc index d403f8f0918..cb6110a8187 100644 --- a/test/cpp/microbenchmarks/bm_threadpool.cc +++ b/test/cpp/microbenchmarks/bm_threadpool.cc @@ -37,7 +37,7 @@ namespace testing { // the count reaches 0. class BlockingCounter { public: - BlockingCounter(int count) : count_(count) {} + explicit BlockingCounter(int count) : count_(count) {} void DecrementCount() { std::lock_guard l(mu_); count_--; @@ -130,7 +130,7 @@ BENCHMARK_TEMPLATE(ThreadPoolAddAnother, 2048) // A functor class that will delete self on end of running. class SuicideFunctorForAdd : public grpc_experimental_completion_queue_functor { public: - SuicideFunctorForAdd(BlockingCounter* counter) : counter_(counter) { + explicit SuicideFunctorForAdd(BlockingCounter* counter) : counter_(counter) { functor_run = &SuicideFunctorForAdd::Run; inlineable = false; internal_next = this; diff --git a/test/cpp/microbenchmarks/fullstack_context_mutators.h b/test/cpp/microbenchmarks/fullstack_context_mutators.h index 06a1d78f153..82e05e8dc28 100644 --- a/test/cpp/microbenchmarks/fullstack_context_mutators.h +++ b/test/cpp/microbenchmarks/fullstack_context_mutators.h @@ -52,7 +52,7 @@ auto MakeVector(size_t length, F f) -> std::vector { class NoOpMutator { public: template - NoOpMutator(ContextType* /*context*/) {} + explicit NoOpMutator(ContextType* /*context*/) {} }; template @@ -100,7 +100,7 @@ class RandomAsciiMetadata { template class Client_AddMetadata : public NoOpMutator { public: - Client_AddMetadata(ClientContext* context) : NoOpMutator(context) { + explicit Client_AddMetadata(ClientContext* context) : NoOpMutator(context) { for (int i = 0; i < kNumKeys; i++) { context->AddMetadata(Generator::Key(), Generator::Value()); } @@ -110,7 +110,8 @@ class Client_AddMetadata : public NoOpMutator { template class Server_AddInitialMetadata : public NoOpMutator { public: - Server_AddInitialMetadata(ServerContext* context) : NoOpMutator(context) { + explicit Server_AddInitialMetadata(ServerContext* context) + : NoOpMutator(context) { for (int i = 0; i < kNumKeys; i++) { context->AddInitialMetadata(Generator::Key(), Generator::Value()); } diff --git a/test/cpp/microbenchmarks/fullstack_fixtures.h b/test/cpp/microbenchmarks/fullstack_fixtures.h index 9ba190b691f..b5e8028173d 100644 --- a/test/cpp/microbenchmarks/fullstack_fixtures.h +++ b/test/cpp/microbenchmarks/fullstack_fixtures.h @@ -111,8 +111,9 @@ class FullstackFixture : public BaseFixture { class TCP : public FullstackFixture { public: - TCP(Service* service, const FixtureConfiguration& fixture_configuration = - FixtureConfiguration()) + explicit TCP(Service* service, + const FixtureConfiguration& fixture_configuration = + FixtureConfiguration()) : FullstackFixture(service, fixture_configuration, MakeAddress(&port_)) {} ~TCP() override { grpc_recycle_unused_port(port_); } @@ -130,8 +131,9 @@ class TCP : public FullstackFixture { class UDS : public FullstackFixture { public: - UDS(Service* service, const FixtureConfiguration& fixture_configuration = - FixtureConfiguration()) + explicit UDS(Service* service, + const FixtureConfiguration& fixture_configuration = + FixtureConfiguration()) : FullstackFixture(service, fixture_configuration, MakeAddress(&port_)) {} ~UDS() override { grpc_recycle_unused_port(port_); } @@ -150,9 +152,9 @@ class UDS : public FullstackFixture { class InProcess : public FullstackFixture { public: - InProcess(Service* service, - const FixtureConfiguration& fixture_configuration = - FixtureConfiguration()) + explicit InProcess(Service* service, + const FixtureConfiguration& fixture_configuration = + FixtureConfiguration()) : FullstackFixture(service, fixture_configuration, "") {} ~InProcess() override {} }; @@ -241,8 +243,9 @@ class EndpointPairFixture : public BaseFixture { class SockPair : public EndpointPairFixture { public: - SockPair(Service* service, const FixtureConfiguration& fixture_configuration = - FixtureConfiguration()) + explicit SockPair(Service* service, + const FixtureConfiguration& fixture_configuration = + FixtureConfiguration()) : EndpointPairFixture(service, grpc_iomgr_create_endpoint_pair("test", nullptr), fixture_configuration) {} @@ -287,9 +290,9 @@ class InProcessCHTTP2WithExplicitStats : public EndpointPairFixture { class InProcessCHTTP2 : public InProcessCHTTP2WithExplicitStats { public: - InProcessCHTTP2(Service* service, - const FixtureConfiguration& fixture_configuration = - FixtureConfiguration()) + explicit InProcessCHTTP2(Service* service, + const FixtureConfiguration& fixture_configuration = + FixtureConfiguration()) : InProcessCHTTP2WithExplicitStats(service, grpc_passthru_endpoint_stats_create(), fixture_configuration) {} @@ -313,7 +316,8 @@ class MinStackConfiguration : public FixtureConfiguration { template class MinStackize : public Base { public: - MinStackize(Service* service) : Base(service, MinStackConfiguration()) {} + explicit MinStackize(Service* service) + : Base(service, MinStackConfiguration()) {} }; typedef MinStackize MinTCP; diff --git a/test/cpp/qps/client_callback.cc b/test/cpp/qps/client_callback.cc index bc8fdb52175..d0d3d4c30e1 100644 --- a/test/cpp/qps/client_callback.cc +++ b/test/cpp/qps/client_callback.cc @@ -45,7 +45,7 @@ namespace testing { * Maintains context info per RPC */ struct CallbackClientRpcContext { - CallbackClientRpcContext(BenchmarkService::Stub* stub) + explicit CallbackClientRpcContext(BenchmarkService::Stub* stub) : alarm_(nullptr), stub_(stub) {} ~CallbackClientRpcContext() {} @@ -64,7 +64,7 @@ static std::unique_ptr BenchmarkStubCreator( class CallbackClient : public ClientImpl { public: - CallbackClient(const ClientConfig& config) + explicit CallbackClient(const ClientConfig& config) : ClientImpl( config, BenchmarkStubCreator) { num_threads_ = NumThreads(config); @@ -144,7 +144,8 @@ class CallbackClient class CallbackUnaryClient final : public CallbackClient { public: - CallbackUnaryClient(const ClientConfig& config) : CallbackClient(config) { + explicit CallbackUnaryClient(const ClientConfig& config) + : CallbackClient(config) { for (int ch = 0; ch < config.client_channels(); ch++) { for (int i = 0; i < config.outstanding_rpcs_per_channel(); i++) { ctx_.emplace_back( @@ -214,7 +215,7 @@ class CallbackUnaryClient final : public CallbackClient { class CallbackStreamingClient : public CallbackClient { public: - CallbackStreamingClient(const ClientConfig& config) + explicit CallbackStreamingClient(const ClientConfig& config) : CallbackClient(config), messages_per_stream_(config.messages_per_stream()) { for (int ch = 0; ch < config.client_channels(); ch++) { @@ -244,7 +245,7 @@ class CallbackStreamingClient : public CallbackClient { class CallbackStreamingPingPongClient : public CallbackStreamingClient { public: - CallbackStreamingPingPongClient(const ClientConfig& config) + explicit CallbackStreamingPingPongClient(const ClientConfig& config) : CallbackStreamingClient(config) {} ~CallbackStreamingPingPongClient() override {} }; @@ -342,7 +343,7 @@ class CallbackStreamingPingPongReactor final class CallbackStreamingPingPongClientImpl final : public CallbackStreamingPingPongClient { public: - CallbackStreamingPingPongClientImpl(const ClientConfig& config) + explicit CallbackStreamingPingPongClientImpl(const ClientConfig& config) : CallbackStreamingPingPongClient(config) { for (size_t i = 0; i < total_outstanding_rpcs_; i++) { reactor_.emplace_back( diff --git a/test/cpp/qps/client_sync.cc b/test/cpp/qps/client_sync.cc index f042a035825..72fff1a8533 100644 --- a/test/cpp/qps/client_sync.cc +++ b/test/cpp/qps/client_sync.cc @@ -50,7 +50,7 @@ static std::unique_ptr BenchmarkStubCreator( class SynchronousClient : public ClientImpl { public: - SynchronousClient(const ClientConfig& config) + explicit SynchronousClient(const ClientConfig& config) : ClientImpl( config, BenchmarkStubCreator) { num_threads_ = @@ -111,7 +111,7 @@ class SynchronousClient class SynchronousUnaryClient final : public SynchronousClient { public: - SynchronousUnaryClient(const ClientConfig& config) + explicit SynchronousUnaryClient(const ClientConfig& config) : SynchronousClient(config) { StartThreads(num_threads_); } @@ -143,7 +143,7 @@ class SynchronousUnaryClient final : public SynchronousClient { template class SynchronousStreamingClient : public SynchronousClient { public: - SynchronousStreamingClient(const ClientConfig& config) + explicit SynchronousStreamingClient(const ClientConfig& config) : SynchronousClient(config), context_(num_threads_), stream_(num_threads_), @@ -219,7 +219,7 @@ class SynchronousStreamingPingPongClient final : public SynchronousStreamingClient< grpc::ClientReaderWriter> { public: - SynchronousStreamingPingPongClient(const ClientConfig& config) + explicit SynchronousStreamingPingPongClient(const ClientConfig& config) : SynchronousStreamingClient(config) {} ~SynchronousStreamingPingPongClient() override { CleanupAllStreams( @@ -276,7 +276,7 @@ class SynchronousStreamingPingPongClient final class SynchronousStreamingFromClientClient final : public SynchronousStreamingClient> { public: - SynchronousStreamingFromClientClient(const ClientConfig& config) + explicit SynchronousStreamingFromClientClient(const ClientConfig& config) : SynchronousStreamingClient(config), last_issue_(num_threads_) {} ~SynchronousStreamingFromClientClient() override { CleanupAllStreams( @@ -329,7 +329,7 @@ class SynchronousStreamingFromClientClient final class SynchronousStreamingFromServerClient final : public SynchronousStreamingClient> { public: - SynchronousStreamingFromServerClient(const ClientConfig& config) + explicit SynchronousStreamingFromServerClient(const ClientConfig& config) : SynchronousStreamingClient(config), last_recv_(num_threads_) {} ~SynchronousStreamingFromServerClient() override {} @@ -375,7 +375,7 @@ class SynchronousStreamingBothWaysClient final : public SynchronousStreamingClient< grpc::ClientReaderWriter> { public: - SynchronousStreamingBothWaysClient(const ClientConfig& config) + explicit SynchronousStreamingBothWaysClient(const ClientConfig& config) : SynchronousStreamingClient(config) {} ~SynchronousStreamingBothWaysClient() override { CleanupAllStreams( diff --git a/test/cpp/qps/qps_worker.cc b/test/cpp/qps/qps_worker.cc index 54a1b20baee..99c0e34b3ad 100644 --- a/test/cpp/qps/qps_worker.cc +++ b/test/cpp/qps/qps_worker.cc @@ -157,7 +157,7 @@ class WorkerServiceImpl final : public WorkerService::Service { // Protect against multiple clients using this worker at once. class InstanceGuard { public: - InstanceGuard(WorkerServiceImpl* impl) + explicit InstanceGuard(WorkerServiceImpl* impl) : impl_(impl), acquired_(impl->TryAcquireInstance()) {} ~InstanceGuard() { if (acquired_) { diff --git a/test/cpp/qps/report.h b/test/cpp/qps/report.h index b00b0a311ff..d85dea4349b 100644 --- a/test/cpp/qps/report.h +++ b/test/cpp/qps/report.h @@ -37,7 +37,7 @@ namespace testing { class Reporter { public: /** Construct a reporter with the given \a name. */ - Reporter(const string& name) : name_(name) {} + explicit Reporter(const string& name) : name_(name) {} virtual ~Reporter() {} @@ -94,7 +94,7 @@ class CompositeReporter : public Reporter { /** Reporter to gpr_log(GPR_INFO). */ class GprLogReporter : public Reporter { public: - GprLogReporter(const string& name) : Reporter(name) {} + explicit GprLogReporter(const string& name) : Reporter(name) {} private: void ReportQPS(const ScenarioResult& result) override; diff --git a/test/cpp/server/server_builder_with_socket_mutator_test.cc b/test/cpp/server/server_builder_with_socket_mutator_test.cc index ab4308007ce..b0bedeb3882 100644 --- a/test/cpp/server/server_builder_with_socket_mutator_test.cc +++ b/test/cpp/server/server_builder_with_socket_mutator_test.cc @@ -74,7 +74,8 @@ void mock_socket_mutator_destroy(grpc_socket_mutator* m) { class MockSocketMutatorServerBuilderOption : public grpc::ServerBuilderOption { public: - MockSocketMutatorServerBuilderOption(MockSocketMutator* mock_socket_mutator) + explicit MockSocketMutatorServerBuilderOption( + MockSocketMutator* mock_socket_mutator) : mock_socket_mutator_(mock_socket_mutator) {} void UpdateArguments(ChannelArguments* args) override { diff --git a/test/cpp/util/grpc_tool_test.cc b/test/cpp/util/grpc_tool_test.cc index bf4eeaf6608..7cd2751417c 100644 --- a/test/cpp/util/grpc_tool_test.cc +++ b/test/cpp/util/grpc_tool_test.cc @@ -133,7 +133,7 @@ const int kServerDefaultResponseStreamsToSend = 3; class TestCliCredentials final : public grpc::testing::CliCredentials { public: - TestCliCredentials(bool secure = false) : secure_(secure) {} + explicit TestCliCredentials(bool secure = false) : secure_(secure) {} std::shared_ptr GetChannelCredentials() const override { if (!secure_) { diff --git a/test/cpp/util/subprocess.h b/test/cpp/util/subprocess.h index 0fe56d40e98..d75de16b872 100644 --- a/test/cpp/util/subprocess.h +++ b/test/cpp/util/subprocess.h @@ -29,7 +29,7 @@ namespace grpc { class SubProcess { public: - SubProcess(const std::vector& args); + explicit SubProcess(const std::vector& args); ~SubProcess(); int Join();