From 7e5d8b9487146517c881d5f93d6fae5772e3d711 Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Mon, 6 Apr 2020 09:59:45 +0000 Subject: [PATCH 1/3] tidy: fix master Signed-off-by: Lizan Zhou --- include/envoy/common/pure.h | 4 +- include/envoy/config/typed_config.h | 2 +- include/envoy/config/typed_metadata.h | 2 +- include/envoy/grpc/google_grpc_creds.h | 2 +- include/envoy/http/hash_policy.h | 2 +- include/envoy/network/resolver.h | 2 +- include/envoy/server/access_log_config.h | 2 +- .../envoy/server/active_udp_listener_config.h | 2 +- include/envoy/server/filter_config.h | 4 +- include/envoy/server/health_checker_config.h | 2 +- .../server/request_id_extension_config.h | 2 +- .../envoy/server/resource_monitor_config.h | 2 +- include/envoy/server/tracer_config.h | 2 +- .../envoy/server/transport_socket_config.h | 2 +- include/envoy/singleton/manager.h | 2 +- include/envoy/ssl/context_manager.h | 2 +- .../ssl/private_key/private_key_config.h | 2 +- include/envoy/upstream/cluster_factory.h | 2 +- include/envoy/upstream/retry.h | 4 +- .../common/access_log/access_log_formatter.cc | 3 +- source/common/access_log/access_log_impl.h | 2 +- .../buffer/zero_copy_input_stream_impl.cc | 2 +- source/common/chromium_url/url_canon.h | 31 +-- .../common/chromium_url/url_canon_internal.h | 4 +- source/common/chromium_url/url_canon_path.cc | 20 +- .../chromium_url/url_canon_stdstring.cc | 6 +- source/common/chromium_url/url_parse.h | 8 +- source/common/common/mem_block_builder.h | 2 +- source/common/config/new_grpc_mux_impl.h | 2 +- source/common/http/conn_manager_impl.h | 6 +- source/common/http/conn_pool_base.h | 4 +- source/common/http/http2/codec_impl.cc | 2 +- source/common/http/http3/quic_codec_factory.h | 4 +- source/common/http/utility.cc | 4 +- .../common/network/io_socket_handle_impl.cc | 6 +- source/common/network/utility.cc | 5 +- source/common/router/vhds.h | 2 +- source/common/stats/symbol_table_impl.h | 2 +- source/common/tcp_proxy/tcp_proxy.cc | 13 +- source/common/tcp_proxy/upstream.h | 6 +- .../common/upstream/cluster_manager_impl.cc | 4 +- source/common/upstream/health_checker_impl.cc | 4 +- source/common/upstream/logical_dns_cluster.cc | 5 +- source/common/upstream/subset_lb.cc | 4 +- .../common/wasm/null/null_vm_plugin.h | 2 +- source/extensions/common/wasm/v8/v8.cc | 2 +- .../extensions/filters/common/expr/context.cc | 8 +- .../filters/common/expr/evaluator.cc | 2 +- .../filters/http/cache/http_cache.h | 2 +- .../json_transcoder_filter.cc | 2 - .../json_transcoder_filter.h | 2 +- .../filters/http/health_check/config.cc | 6 +- .../filters/http/jwt_authn/authenticator.cc | 9 +- .../filters/http/jwt_authn/extractor.cc | 1 - .../filters/http/jwt_authn/filter_config.h | 4 +- .../filters/network/direct_response/filter.cc | 2 +- .../dubbo_proxy/filters/filter_config.h | 2 +- .../filters/network/dubbo_proxy/protocol.h | 2 +- .../network/dubbo_proxy/router/route.h | 2 +- .../filters/network/dubbo_proxy/serializer.h | 2 +- .../filters/network/kafka/serialization.h | 2 +- .../filters/network/mongo_proxy/config.cc | 6 +- .../thrift_proxy/filters/filter_config.h | 2 +- .../filters/network/thrift_proxy/protocol.h | 2 +- .../filters/network/thrift_proxy/transport.h | 2 +- .../filters/udp/udp_proxy/udp_proxy_filter.h | 2 +- .../quic_listeners/quiche/envoy_quic_alarm.h | 2 +- .../quiche/envoy_quic_fake_proof_verifier.h | 2 +- .../quiche/platform/quic_logging_impl.h | 2 +- .../opencensus/opencensus_tracer_impl.cc | 3 +- source/server/configuration_impl.h | 2 +- source/server/connection_handler_impl.h | 2 +- source/server/hot_restarting_child.cc | 2 +- source/server/http/admin.cc | 2 +- source/server/http/admin.h | 4 +- source/server/listener_manager_impl.cc | 2 +- source/server/options_impl.cc | 6 +- test/common/buffer/owned_impl_test.cc | 1 - .../config/delta_subscription_state_test.cc | 1 - test/common/config/registry_test.cc | 4 +- test/common/grpc/google_grpc_creds_test.cc | 4 +- test/common/http/conn_manager_impl_test.cc | 1 - test/common/http/header_map_impl_fuzz_test.cc | 2 +- test/common/http/http2/codec_impl_test.cc | 2 +- .../http/http2/request_header_fuzz_test.cc | 2 - .../http/http2/response_header_fuzz_test.cc | 2 - test/common/network/connection_impl_test.cc | 16 +- test/common/network/dns_impl_test.cc | 4 +- test/common/network/udp_listener_impl_test.cc | 12 +- test/common/network/utility_test.cc | 45 ++--- test/common/router/rds_impl_test.cc | 1 - test/common/router/router_test.cc | 1 - .../common/router/router_upstream_log_test.cc | 7 +- test/common/stats/stat_merger_test.cc | 4 +- test/common/stats/stat_test_utility.h | 2 +- test/common/stats/thread_local_store_test.cc | 2 +- test/common/tcp_proxy/tcp_proxy_test.cc | 11 +- test/common/tcp_proxy/upstream_test.cc | 8 +- .../upstream/cluster_factory_impl_test.cc | 5 +- test/common/upstream/eds_test.cc | 4 +- .../upstream/health_checker_impl_test.cc | 180 +++++++++--------- .../upstream/load_balancer_impl_test.cc | 10 +- .../upstream/logical_dns_cluster_test.cc | 4 +- .../upstream/original_dst_cluster_test.cc | 4 +- test/common/upstream/subset_lb_test.cc | 54 +++--- .../clusters/redis/redis_cluster_test.cc | 4 +- test/extensions/common/wasm/wasm_vm_test.cc | 4 +- .../controller/gradient_controller_test.cc | 3 - .../compressor/compressor_filter_test.cc | 29 ++- .../filters/http/common/fuzz/uber_filter.h | 6 +- .../filters/http/fault/fault_filter_test.cc | 2 +- .../grpc_json_transcoder_integration_test.cc | 1 - .../http_body_utils_test.cc | 2 +- .../json_transcoder_filter_test.cc | 2 - .../filters/http/gzip/gzip_filter_test.cc | 2 +- .../header_to_metadata_filter_test.cc | 6 +- .../http/health_check/health_check_test.cc | 3 +- .../http/ip_tagging/ip_tagging_filter_test.cc | 2 +- .../filters/http/jwt_authn/filter_test.cc | 1 - .../filters/http/lua/lua_filter_test.cc | 2 +- .../filters/http/ratelimit/ratelimit_test.cc | 4 +- .../http/router/auto_sni_integration_test.cc | 2 +- .../proxy_protocol/proxy_protocol_test.cc | 12 +- .../network/common/redis/client_impl_test.cc | 1 - .../filters/network/dubbo_proxy/mocks.cc | 4 +- .../network/dubbo_proxy/router_test.cc | 4 +- .../network/ext_authz/ext_authz_test.cc | 2 +- .../http_connection_manager/config_test.cc | 1 - .../filters/network/mongo_proxy/proxy_test.cc | 4 +- .../network/ratelimit/ratelimit_test.cc | 2 +- .../filters/network/redis_proxy/mocks.h | 2 +- .../network/redis_proxy/proxy_filter_test.cc | 3 +- .../redis_proxy_integration_test.cc | 2 - .../network/thrift_proxy/conn_manager_test.cc | 2 +- .../filters/ratelimit/ratelimit_test.cc | 4 +- .../filters/network/thrift_proxy/mocks.cc | 6 +- .../thrift_proxy/router_ratelimit_test.cc | 2 +- .../network/thrift_proxy/router_test.cc | 2 +- .../twitter_protocol_impl_test.cc | 4 +- .../udp/udp_proxy/udp_proxy_filter_test.cc | 2 +- .../udp_proxy/udp_proxy_integration_test.cc | 8 +- ...le_based_metadata_grpc_credentials_test.cc | 2 +- .../health_checkers/redis/redis_test.cc | 20 +- .../quiche/envoy_quic_client_session_test.cc | 1 - .../quiche/envoy_quic_client_stream_test.cc | 1 - .../quiche/envoy_quic_server_stream_test.cc | 1 - .../common/ot/opentracing_driver_impl_test.cc | 2 +- .../tracers/xray/xray_tracer_impl_test.cc | 2 - .../tracers/zipkin/zipkin_core_types_test.cc | 12 +- .../transport_sockets/tls/ssl_socket_test.cc | 2 +- test/integration/fake_upstream.h | 4 +- test/integration/integration.h | 2 +- .../integration/tcp_proxy_integration_test.cc | 4 +- test/mocks/grpc/mocks.h | 2 +- test/mocks/http/stream_decoder.h | 4 +- test/mocks/http/stream_encoder.h | 6 +- test/mocks/network/io_handle.h | 2 +- test/mocks/network/mocks.cc | 2 +- test/mocks/tracing/mocks.cc | 1 - test/server/connection_handler_test.cc | 2 - test/server/http/admin_test.cc | 1 - test/server/listener_manager_impl_test.h | 10 +- test/server/options_impl_test.cc | 4 +- test/test_common/utility.cc | 6 +- tools/api_boost/testdata/using_decl.cc | 1 - 165 files changed, 467 insertions(+), 452 deletions(-) diff --git a/include/envoy/common/pure.h b/include/envoy/common/pure.h index ecc74586618b0..11c7d9a0700a0 100644 --- a/include/envoy/common/pure.h +++ b/include/envoy/common/pure.h @@ -1,8 +1,8 @@ #pragma once -namespace Envoy { +// NOLINT(namespace-envoy) + /** * Friendly name for a pure virtual routine. */ #define PURE = 0 -} // namespace Envoy diff --git a/include/envoy/config/typed_config.h b/include/envoy/config/typed_config.h index 574562ff6bc01..49cc2c1f3416c 100644 --- a/include/envoy/config/typed_config.h +++ b/include/envoy/config/typed_config.h @@ -39,7 +39,7 @@ class UntypedFactory { */ class TypedFactory : public UntypedFactory { public: - virtual ~TypedFactory() = default; + ~TypedFactory() override = default; /** * @return ProtobufTypes::MessagePtr create empty config proto message for v2. The config, which diff --git a/include/envoy/config/typed_metadata.h b/include/envoy/config/typed_metadata.h index 680252e21dd3f..a05ca8235d645 100644 --- a/include/envoy/config/typed_metadata.h +++ b/include/envoy/config/typed_metadata.h @@ -53,7 +53,7 @@ class TypedMetadata { */ class TypedMetadataFactory : public UntypedFactory { public: - virtual ~TypedMetadataFactory() = default; + ~TypedMetadataFactory() override = default; /** * Convert the google.protobuf.Struct into an instance of TypedMetadata::Object. diff --git a/include/envoy/grpc/google_grpc_creds.h b/include/envoy/grpc/google_grpc_creds.h index 831cd78010b3f..32dd71efdd751 100644 --- a/include/envoy/grpc/google_grpc_creds.h +++ b/include/envoy/grpc/google_grpc_creds.h @@ -17,7 +17,7 @@ namespace Grpc { */ class GoogleGrpcCredentialsFactory : public Config::UntypedFactory { public: - virtual ~GoogleGrpcCredentialsFactory() = default; + ~GoogleGrpcCredentialsFactory() override = default; /** * Get a ChannelCredentials to be used for authentication of a gRPC channel. diff --git a/include/envoy/http/hash_policy.h b/include/envoy/http/hash_policy.h index bab03d57c2f61..2a031247d93d0 100644 --- a/include/envoy/http/hash_policy.h +++ b/include/envoy/http/hash_policy.h @@ -12,7 +12,7 @@ namespace Http { class Hashable { public: virtual absl::optional hash() const PURE; - virtual ~Hashable() {} + virtual ~Hashable() = default; }; /** diff --git a/include/envoy/network/resolver.h b/include/envoy/network/resolver.h index 457f65700c7eb..dcdcfe8a8c92f 100644 --- a/include/envoy/network/resolver.h +++ b/include/envoy/network/resolver.h @@ -19,7 +19,7 @@ namespace Address { */ class Resolver : public Config::UntypedFactory { public: - virtual ~Resolver() = default; + ~Resolver() override = default; /** * Resolve a custom address string and port to an Address::Instance. diff --git a/include/envoy/server/access_log_config.h b/include/envoy/server/access_log_config.h index 2fc07ac8d6e18..158c442acc495 100644 --- a/include/envoy/server/access_log_config.h +++ b/include/envoy/server/access_log_config.h @@ -18,7 +18,7 @@ namespace Configuration { */ class AccessLogInstanceFactory : public Config::TypedFactory { public: - virtual ~AccessLogInstanceFactory() = default; + ~AccessLogInstanceFactory() override = default; /** * Create a particular AccessLog::Instance implementation from a config proto. If the diff --git a/include/envoy/server/active_udp_listener_config.h b/include/envoy/server/active_udp_listener_config.h index 52846679a5173..2e027dc4d7472 100644 --- a/include/envoy/server/active_udp_listener_config.h +++ b/include/envoy/server/active_udp_listener_config.h @@ -14,7 +14,7 @@ namespace Server { */ class ActiveUdpListenerConfigFactory : public Config::UntypedFactory { public: - virtual ~ActiveUdpListenerConfigFactory() = default; + ~ActiveUdpListenerConfigFactory() override = default; virtual ProtobufTypes::MessagePtr createEmptyConfigProto() PURE; diff --git a/include/envoy/server/filter_config.h b/include/envoy/server/filter_config.h index 3f2b8100551f0..75d8dd24d371f 100644 --- a/include/envoy/server/filter_config.h +++ b/include/envoy/server/filter_config.h @@ -251,7 +251,7 @@ class ListenerFactoryContext : public virtual FactoryContext { */ class ListenerFilterConfigFactoryBase : public Config::TypedFactory { public: - virtual ~ListenerFilterConfigFactoryBase() = default; + ~ListenerFilterConfigFactoryBase() override = default; }; /** @@ -309,7 +309,7 @@ class NamedUdpListenerFilterConfigFactory : public ListenerFilterConfigFactoryBa */ class ProtocolOptionsFactory : public Config::TypedFactory { public: - virtual ~ProtocolOptionsFactory() = default; + ~ProtocolOptionsFactory() override = default; /** * Create a particular filter's protocol specific options implementation. If the factory diff --git a/include/envoy/server/health_checker_config.h b/include/envoy/server/health_checker_config.h index 28ed6fe27de64..5994e37f231bf 100644 --- a/include/envoy/server/health_checker_config.h +++ b/include/envoy/server/health_checker_config.h @@ -58,7 +58,7 @@ class HealthCheckerFactoryContext { */ class CustomHealthCheckerFactory : public Config::TypedFactory { public: - virtual ~CustomHealthCheckerFactory() = default; + ~CustomHealthCheckerFactory() override = default; /** * Creates a particular custom health checker factory implementation. diff --git a/include/envoy/server/request_id_extension_config.h b/include/envoy/server/request_id_extension_config.h index 58a85b7ac2748..3a52214fcc543 100644 --- a/include/envoy/server/request_id_extension_config.h +++ b/include/envoy/server/request_id_extension_config.h @@ -17,7 +17,7 @@ namespace Configuration { */ class RequestIDExtensionFactory : public Envoy::Config::TypedFactory { public: - virtual ~RequestIDExtensionFactory() = default; + ~RequestIDExtensionFactory() override = default; /** * Create a Request ID Extension instance from the provided config proto. diff --git a/include/envoy/server/resource_monitor_config.h b/include/envoy/server/resource_monitor_config.h index 2b7021a467d3a..245e9323d6b7a 100644 --- a/include/envoy/server/resource_monitor_config.h +++ b/include/envoy/server/resource_monitor_config.h @@ -41,7 +41,7 @@ class ResourceMonitorFactoryContext { */ class ResourceMonitorFactory : public Config::TypedFactory { public: - virtual ~ResourceMonitorFactory() = default; + ~ResourceMonitorFactory() override = default; /** * Create a particular resource monitor implementation. diff --git a/include/envoy/server/tracer_config.h b/include/envoy/server/tracer_config.h index 038248c4ceba6..25f8b664d9491 100644 --- a/include/envoy/server/tracer_config.h +++ b/include/envoy/server/tracer_config.h @@ -38,7 +38,7 @@ using TracerFactoryContextPtr = std::unique_ptr; */ class TracerFactory : public Config::TypedFactory { public: - virtual ~TracerFactory() = default; + ~TracerFactory() override = default; /** * Create a particular HttpTracer implementation. If the implementation is unable to produce an diff --git a/include/envoy/server/transport_socket_config.h b/include/envoy/server/transport_socket_config.h index 1dd0e4ab7b9bb..a3dd4d5dac6da 100644 --- a/include/envoy/server/transport_socket_config.h +++ b/include/envoy/server/transport_socket_config.h @@ -103,7 +103,7 @@ class TransportSocketFactoryContext { class TransportSocketConfigFactory : public Config::TypedFactory { public: - virtual ~TransportSocketConfigFactory() = default; + ~TransportSocketConfigFactory() override = default; }; /** diff --git a/include/envoy/singleton/manager.h b/include/envoy/singleton/manager.h index 212c656ecd7e4..995c333f87446 100644 --- a/include/envoy/singleton/manager.h +++ b/include/envoy/singleton/manager.h @@ -17,7 +17,7 @@ namespace Singleton { */ class Registration : public Config::UntypedFactory { public: - virtual ~Registration() = default; + ~Registration() override = default; std::string category() const override { return "envoy.singleton"; } }; diff --git a/include/envoy/ssl/context_manager.h b/include/envoy/ssl/context_manager.h index b30ef3a0edb38..77f6ead17c8c4 100644 --- a/include/envoy/ssl/context_manager.h +++ b/include/envoy/ssl/context_manager.h @@ -53,7 +53,7 @@ using ContextManagerPtr = std::unique_ptr; class ContextManagerFactory : public Config::UntypedFactory { public: - virtual ~ContextManagerFactory() = default; + ~ContextManagerFactory() override = default; virtual ContextManagerPtr createContextManager(TimeSource& time_source) PURE; // There could be only one factory thus the name is static. diff --git a/include/envoy/ssl/private_key/private_key_config.h b/include/envoy/ssl/private_key/private_key_config.h index 415584df4d42d..6a563e38b10f6 100644 --- a/include/envoy/ssl/private_key/private_key_config.h +++ b/include/envoy/ssl/private_key/private_key_config.h @@ -12,7 +12,7 @@ namespace Ssl { class PrivateKeyMethodProviderInstanceFactory : public Config::UntypedFactory { public: - virtual ~PrivateKeyMethodProviderInstanceFactory() = default; + ~PrivateKeyMethodProviderInstanceFactory() override = default; /** * Create a particular PrivateKeyMethodProvider implementation. If the implementation is diff --git a/include/envoy/upstream/cluster_factory.h b/include/envoy/upstream/cluster_factory.h index 2ec16f1c9ff9a..389a804ba0441 100644 --- a/include/envoy/upstream/cluster_factory.h +++ b/include/envoy/upstream/cluster_factory.h @@ -126,7 +126,7 @@ class ClusterFactoryContext { */ class ClusterFactory : public Config::UntypedFactory { public: - virtual ~ClusterFactory() = default; + ~ClusterFactory() override = default; /** * Create a new instance of cluster. If the implementation is unable to produce a cluster instance diff --git a/include/envoy/upstream/retry.h b/include/envoy/upstream/retry.h index 3e6ca2890a901..4a7af89201bd7 100644 --- a/include/envoy/upstream/retry.h +++ b/include/envoy/upstream/retry.h @@ -78,7 +78,7 @@ using RetryHostPredicateSharedPtr = std::shared_ptr; */ class RetryPriorityFactory : public Config::TypedFactory { public: - virtual ~RetryPriorityFactory() = default; + ~RetryPriorityFactory() override = default; virtual RetryPrioritySharedPtr createRetryPriority(const Protobuf::Message& config, @@ -93,7 +93,7 @@ class RetryPriorityFactory : public Config::TypedFactory { */ class RetryHostPredicateFactory : public Config::TypedFactory { public: - virtual ~RetryHostPredicateFactory() = default; + ~RetryHostPredicateFactory() override = default; virtual RetryHostPredicateSharedPtr createHostPredicate(const Protobuf::Message& config, uint32_t retry_count) PURE; diff --git a/source/common/access_log/access_log_formatter.cc b/source/common/access_log/access_log_formatter.cc index 66b9d353158cf..345041824b24b 100644 --- a/source/common/access_log/access_log_formatter.cc +++ b/source/common/access_log/access_log_formatter.cc @@ -1,7 +1,6 @@ #include "common/access_log/access_log_formatter.h" -#include - +#include #include #include #include diff --git a/source/common/access_log/access_log_impl.h b/source/common/access_log/access_log_impl.h index 1bdee3967d920..512a957e1dc21 100644 --- a/source/common/access_log/access_log_impl.h +++ b/source/common/access_log/access_log_impl.h @@ -233,7 +233,7 @@ class GrpcStatusFilter : public Filter { */ class ExtensionFilterFactory : public Config::TypedFactory { public: - virtual ~ExtensionFilterFactory() = default; + ~ExtensionFilterFactory() override = default; /** * Create a particular extension filter implementation from a config proto. If the diff --git a/source/common/buffer/zero_copy_input_stream_impl.cc b/source/common/buffer/zero_copy_input_stream_impl.cc index 04b70d4f95cf2..e94e36799b524 100644 --- a/source/common/buffer/zero_copy_input_stream_impl.cc +++ b/source/common/buffer/zero_copy_input_stream_impl.cc @@ -27,7 +27,7 @@ bool ZeroCopyInputStreamImpl::Next(const void** data, int* size) { Buffer::RawSliceVector slices = buffer_->getRawSlices(1); - if (slices.size() > 0 && slices[0].len_ > 0) { + if (!slices.empty() && slices[0].len_ > 0) { auto& slice = slices[0]; *data = slice.mem_; *size = slice.len_; diff --git a/source/common/chromium_url/url_canon.h b/source/common/chromium_url/url_canon.h index 0280de643ac86..f2a1ee132e7f0 100644 --- a/source/common/chromium_url/url_canon.h +++ b/source/common/chromium_url/url_canon.h @@ -8,8 +8,8 @@ #ifndef URL_URL_CANON_H_ #define URL_URL_CANON_H_ -#include -#include +#include +#include #include "common/chromium_url/envoy_shim.h" #include "common/chromium_url/url_parse.h" @@ -28,7 +28,7 @@ namespace chromium_url { // manage. template class CanonOutputT { public: - CanonOutputT() : buffer_(NULL), buffer_len_(0), cur_len_(0) {} + CanonOutputT() : buffer_(NULL) {} virtual ~CanonOutputT() = default; // Implemented to resize the buffer. This function should update the buffer @@ -83,8 +83,9 @@ template class CanonOutputT { // Grow the buffer to hold at least one more item. Hopefully we won't have // to do this very often. - if (!Grow(1)) + if (!Grow(1)) { return; + } // Actually do the insertion. buffer_[cur_len_] = ch; @@ -94,18 +95,21 @@ template class CanonOutputT { // Appends the given string to the output. void Append(const T* str, int str_len) { if (cur_len_ + str_len > buffer_len_) { - if (!Grow(cur_len_ + str_len - buffer_len_)) + if (!Grow(cur_len_ + str_len - buffer_len_)) { return; + } } - for (int i = 0; i < str_len; i++) + for (int i = 0; i < str_len; i++) { buffer_[cur_len_ + i] = str[i]; + } cur_len_ += str_len; } void ReserveSizeIfNeeded(int estimated_size) { // Reserve a bit extra to account for escaped chars. - if (estimated_size > buffer_len_) + if (estimated_size > buffer_len_) { Resize(estimated_size + 8); + } } protected: @@ -115,8 +119,9 @@ template class CanonOutputT { static const int kMinBufferLen = 16; int new_len = (buffer_len_ == 0) ? kMinBufferLen : buffer_len_; do { - if (new_len >= (1 << 30)) // Prevent overflow below. + if (new_len >= (1 << 30)) { // Prevent overflow below. return false; + } new_len *= 2; } while (new_len < buffer_len_ + min_additional); Resize(new_len); @@ -124,10 +129,10 @@ template class CanonOutputT { } T* buffer_; - int buffer_len_; + int buffer_len_{0}; // Used characters in the buffer. - int cur_len_; + int cur_len_{0}; }; // Simple implementation of the CanonOutput using new[]. This class @@ -140,15 +145,17 @@ template class RawCanonOutputT : public this->buffer_len_ = fixed_capacity; } ~RawCanonOutputT() override { - if (this->buffer_ != fixed_buffer_) + if (this->buffer_ != fixed_buffer_) { delete[] this->buffer_; + } } void Resize(int sz) override { T* new_buf = new T[sz]; memcpy(new_buf, this->buffer_, sizeof(T) * (this->cur_len_ < sz ? this->cur_len_ : sz)); - if (this->buffer_ != fixed_buffer_) + if (this->buffer_ != fixed_buffer_) { delete[] this->buffer_; + } this->buffer_ = new_buf; this->buffer_len_ = sz; } diff --git a/source/common/chromium_url/url_canon_internal.h b/source/common/chromium_url/url_canon_internal.h index 8c405b49814a0..122bc59835484 100644 --- a/source/common/chromium_url/url_canon_internal.h +++ b/source/common/chromium_url/url_canon_internal.h @@ -13,8 +13,8 @@ // template bloat because everything is inlined when anybody calls any of our // functions. -#include -#include +#include +#include #include "common/chromium_url/envoy_shim.h" #include "common/chromium_url/url_canon.h" diff --git a/source/common/chromium_url/url_canon_path.cc b/source/common/chromium_url/url_canon_path.cc index 22587c0ab8a10..3ddfae62ffe8f 100644 --- a/source/common/chromium_url/url_canon_path.cc +++ b/source/common/chromium_url/url_canon_path.cc @@ -5,7 +5,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include +#include #include "common/chromium_url/url_canon.h" #include "common/chromium_url/url_canon_internal.h" @@ -169,13 +169,15 @@ void BackUpToPreviousSlash(int path_begin_in_output, CanonOutput* output) { int i = output->length() - 1; DCHECK(output->at(i) == '/'); - if (i == path_begin_in_output) + if (i == path_begin_in_output) { return; // We're at the first slash, nothing to do. + } // Now back up (skipping the trailing slash) until we find another slash. i--; - while (output->at(i) != '/' && i > path_begin_in_output) + while (output->at(i) != '/' && i > path_begin_in_output) { i--; + } // Now shrink the output to just include that last slash we found. output->set_length(i + 1); @@ -224,8 +226,9 @@ void CheckForNestedEscapes(const CHAR* spec, int next_input_index, int input_len if (append_next_char) { // If the input doesn't contain a 7-bit character next, this case won't be a // problem. - if ((next_input_index == input_len) || (spec[next_input_index] >= 0x80)) + if ((next_input_index == input_len) || (spec[next_input_index] >= 0x80)) { return; + } output->push_back(static_cast(spec[next_input_index])); } @@ -236,8 +239,9 @@ void CheckForNestedEscapes(const CHAR* spec, int next_input_index, int input_len // New escape sequence found. Overwrite the characters following the '%' // with "25", and push_back() the one or two characters that were following // the '%' when we were called. - if (!append_next_char) + if (!append_next_char) { output->push_back(output->at(last_invalid_percent_index + 1)); + } output->set(last_invalid_percent_index + 1, '2'); output->set(last_invalid_percent_index + 2, '5'); output->push_back(last_unescaped_char); @@ -351,8 +355,9 @@ bool DoPartialPath(const CHAR* spec, const Component& path, int path_begin_in_ou output->push_back('%'); output->push_back(static_cast(spec[i - 1])); output->push_back(static_cast(spec[i])); - if (unescaped_flags & INVALID_BIT) + if (unescaped_flags & INVALID_BIT) { success = false; + } } } else { // Invalid escape sequence. IE7+ rejects any URLs with such @@ -391,8 +396,9 @@ bool DoPath(const CHAR* spec, const Component& path, CanonOutput* output, Compon // and then canonicalize it, it will of course have a slash already. This // check is for the replacement and relative URL resolving cases of file // URLs. - if (!IsURLSlash(spec[path.begin])) + if (!IsURLSlash(spec[path.begin])) { output->push_back('/'); + } success = DoPartialPath(spec, path, out_path->begin, output); } else { diff --git a/source/common/chromium_url/url_canon_stdstring.cc b/source/common/chromium_url/url_canon_stdstring.cc index 0c61831e5f1ac..6af5e26ebeec7 100644 --- a/source/common/chromium_url/url_canon_stdstring.cc +++ b/source/common/chromium_url/url_canon_stdstring.cc @@ -9,9 +9,9 @@ namespace chromium_url { -StdStringCanonOutput::StdStringCanonOutput(std::string* str) : CanonOutput(), str_(str) { +StdStringCanonOutput::StdStringCanonOutput(std::string* str) : str_(str) { cur_len_ = static_cast(str_->size()); // Append to existing data. - buffer_ = str_->empty() ? NULL : &(*str_)[0]; + buffer_ = str_->empty() ? nullptr : &(*str_)[0]; buffer_len_ = static_cast(str_->size()); } @@ -26,7 +26,7 @@ void StdStringCanonOutput::Complete() { void StdStringCanonOutput::Resize(int sz) { str_->resize(sz); - buffer_ = str_->empty() ? NULL : &(*str_)[0]; + buffer_ = str_->empty() ? nullptr : &(*str_)[0]; buffer_len_ = sz; } diff --git a/source/common/chromium_url/url_parse.h b/source/common/chromium_url/url_parse.h index b840af60438d1..8310b41f2976b 100644 --- a/source/common/chromium_url/url_parse.h +++ b/source/common/chromium_url/url_parse.h @@ -14,7 +14,7 @@ namespace chromium_url { // Represents a substring for URL parsing. struct Component { - Component() : begin(0), len(-1) {} + Component() {} // Normal constructor: takes an offset and a length. Component(int b, int l) : begin(b), len(l) {} @@ -36,13 +36,13 @@ struct Component { bool operator==(const Component& other) const { return begin == other.begin && len == other.len; } - int begin; // Byte offset in the string of this component. - int len; // Will be -1 if the component is unspecified. + int begin{0}; // Byte offset in the string of this component. + int len{-1}; // Will be -1 if the component is unspecified. }; // Helper that returns a component created with the given begin and ending // points. The ending point is non-inclusive. -inline Component MakeRange(int begin, int end) { return Component(begin, end - begin); } +inline Component MakeRange(int begin, int end) { return {begin, end - begin}; } } // namespace chromium_url diff --git a/source/common/common/mem_block_builder.h b/source/common/common/mem_block_builder.h index ce0c6827dc8b8..a43f7e885e224 100644 --- a/source/common/common/mem_block_builder.h +++ b/source/common/common/mem_block_builder.h @@ -27,7 +27,7 @@ template class MemBlockBuilder { // Constructs a MemBlockBuilder allowing for 'capacity' instances of T. explicit MemBlockBuilder(uint64_t capacity) : data_(std::make_unique(capacity)), write_span_(data_.get(), capacity) {} - MemBlockBuilder() {} + MemBlockBuilder() = default; /** * Allocates (or reallocates) memory for the MemBlockBuilder to make it the diff --git a/source/common/config/new_grpc_mux_impl.h b/source/common/config/new_grpc_mux_impl.h index fe0ff5bf1ae2e..c7d63a93d01d1 100644 --- a/source/common/config/new_grpc_mux_impl.h +++ b/source/common/config/new_grpc_mux_impl.h @@ -76,7 +76,7 @@ class NewGrpcMuxImpl WatchImpl(const std::string& type_url, Watch* watch, NewGrpcMuxImpl& parent) : type_url_(type_url), watch_(watch), parent_(parent) {} - ~WatchImpl() { remove(); } + ~WatchImpl() override { remove(); } void remove() { if (watch_) { diff --git a/source/common/http/conn_manager_impl.h b/source/common/http/conn_manager_impl.h index 426bb60a57fb6..10bcc7522bd61 100644 --- a/source/common/http/conn_manager_impl.h +++ b/source/common/http/conn_manager_impl.h @@ -614,7 +614,7 @@ class ConnectionManagerImpl : Logger::Loggable, : remote_complete_(false), local_complete_(false), codec_saw_local_complete_(false), saw_connection_close_(false), successful_upgrade_(false), created_filter_chain_(false), is_internally_created_(false), decorated_propagate_(true), has_continue_headers_(false), - is_head_request_(false), decoding_headers_only_(false), encoding_headers_only_(false) {} + is_head_request_(false) {} uint32_t filter_call_state_{0}; // The following 3 members are booleans rather than part of the space-saving bitfield as they @@ -644,10 +644,10 @@ class ConnectionManagerImpl : Logger::Loggable, bool is_head_request_ : 1; // Whether a filter has indicated that the request should be treated as a headers only // request. - bool decoding_headers_only_; + bool decoding_headers_only_{false}; // Whether a filter has indicated that the response should be treated as a headers only // response. - bool encoding_headers_only_; + bool encoding_headers_only_{false}; // Used to track which filter is the latest filter that has received data. ActiveStreamEncoderFilter* latest_data_encoding_filter_{}; diff --git a/source/common/http/conn_pool_base.h b/source/common/http/conn_pool_base.h index a0e0671e650fb..a81434cead9c2 100644 --- a/source/common/http/conn_pool_base.h +++ b/source/common/http/conn_pool_base.h @@ -30,7 +30,7 @@ class ConnPoolImplBase : public ConnectionPool::Instance, Event::Dispatcher& dispatcher, const Network::ConnectionSocket::OptionsSharedPtr& options, const Network::TransportSocketOptionsSharedPtr& transport_socket_options); - virtual ~ConnPoolImplBase(); + ~ConnPoolImplBase() override; // Closes and destroys all connections. This must be called in the destructor of // derived classes because the derived ActiveClient will downcast parent_ to a more @@ -46,7 +46,7 @@ class ConnPoolImplBase : public ConnectionPool::Instance, public: ActiveClient(ConnPoolImplBase& parent, uint64_t lifetime_request_limit, uint64_t concurrent_request_limit); - virtual ~ActiveClient(); + ~ActiveClient() override; void releaseResources(); diff --git a/source/common/http/http2/codec_impl.cc b/source/common/http/http2/codec_impl.cc index 25b09a844fcb6..714e3f8bba82d 100644 --- a/source/common/http/http2/codec_impl.cc +++ b/source/common/http/http2/codec_impl.cc @@ -927,7 +927,7 @@ void ConnectionImpl::sendSettings( {static_cast(NGHTTP2_SETTINGS_ENABLE_PUSH), disable_push ? 0U : 1U}); } - for (const auto it : http2_options.custom_settings_parameters()) { + for (const auto& it : http2_options.custom_settings_parameters()) { ASSERT(it.identifier().value() <= std::numeric_limits::max()); const bool result = insertParameter({static_cast(it.identifier().value()), it.value().value()}); diff --git a/source/common/http/http3/quic_codec_factory.h b/source/common/http/http3/quic_codec_factory.h index 8bd5dc0b4ce05..0b4a724042009 100644 --- a/source/common/http/http3/quic_codec_factory.h +++ b/source/common/http/http3/quic_codec_factory.h @@ -12,7 +12,7 @@ namespace Http { // A factory to create Http::ServerConnection instance for QUIC. class QuicHttpServerConnectionFactory : public Config::UntypedFactory { public: - virtual ~QuicHttpServerConnectionFactory() {} + ~QuicHttpServerConnectionFactory() override = default; virtual std::unique_ptr createQuicServerConnection(Network::Connection& connection, ConnectionCallbacks& callbacks) PURE; @@ -23,7 +23,7 @@ class QuicHttpServerConnectionFactory : public Config::UntypedFactory { // A factory to create Http::ClientConnection instance for QUIC. class QuicHttpClientConnectionFactory : public Config::UntypedFactory { public: - virtual ~QuicHttpClientConnectionFactory() {} + ~QuicHttpClientConnectionFactory() override = default; virtual std::unique_ptr createQuicClientConnection(Network::Connection& connection, ConnectionCallbacks& callbacks) PURE; diff --git a/source/common/http/utility.cc b/source/common/http/utility.cc index ea4aa41cd4e80..fe9393574a327 100644 --- a/source/common/http/utility.cc +++ b/source/common/http/utility.cc @@ -43,7 +43,7 @@ void validateCustomSettingsParameters( std::unordered_set custom_parameters; // User defined and named parameters with the same SETTINGS identifier can not both be set. - for (const auto it : options.custom_settings_parameters()) { + for (const auto& it : options.custom_settings_parameters()) { ASSERT(it.identifier().value() <= std::numeric_limits::max()); // Check for custom parameter inconsistencies. const auto result = custom_parameters.insert( @@ -552,7 +552,7 @@ bool Utility::sanitizeConnectionHeader(Http::RequestHeaderMap& headers) { bool keep_header = false; // Determine whether the nominated header contains invalid values - const HeaderEntry* nominated_header = NULL; + const HeaderEntry* nominated_header = nullptr; if (lcs_header_to_remove == Http::Headers::get().Connection) { // Remove the connection header from the nominated tokens if it's self nominated diff --git a/source/common/network/io_socket_handle_impl.cc b/source/common/network/io_socket_handle_impl.cc index 4e0f7db795d1f..306c0c425f64b 100644 --- a/source/common/network/io_socket_handle_impl.cc +++ b/source/common/network/io_socket_handle_impl.cc @@ -207,7 +207,7 @@ absl::optional maybeGetPacketsDroppedFromHeader( Api::IoCallUint64Result IoSocketHandleImpl::recvmsg(Buffer::RawSlice* slices, const uint64_t num_slice, uint32_t self_port, RecvMsgOutput& output) { - ASSERT(output.msg_.size() > 0); + ASSERT(!output.msg_.empty()); absl::FixedArray cbuf(cmsg_space_); memset(cbuf.begin(), 0, cmsg_space_); @@ -271,7 +271,7 @@ Api::IoCallUint64Result IoSocketHandleImpl::recvmsg(Buffer::RawSlice* slices, Api::IoCallUint64Result IoSocketHandleImpl::recvmmsg(RawSliceArrays& slices, uint32_t self_port, RecvMsgOutput& output) { ASSERT(output.msg_.size() == slices.size()); - if (slices.size() == 0) { + if (slices.empty()) { return sysCallResultToIoCallResult(Api::SysCallIntResult{0, EAGAIN}); } const uint32_t num_packets_per_mmsg_call = slices.size(); @@ -291,7 +291,7 @@ Api::IoCallUint64Result IoSocketHandleImpl::recvmmsg(RawSliceArrays& slices, uin msghdr* hdr = &mmsg_hdr[i].msg_hdr; hdr->msg_name = &raw_addresses[i]; hdr->msg_namelen = sizeof(sockaddr_storage); - ASSERT(slices[i].size() > 0); + ASSERT(!slices[i].empty()); for (size_t j = 0; j < slices[i].size(); ++j) { iovs[i][j].iov_base = slices[i][j].mem_; diff --git a/source/common/network/utility.cc b/source/common/network/utility.cc index 2d42963553a57..891e6f995ef7a 100644 --- a/source/common/network/utility.cc +++ b/source/common/network/utility.cc @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -228,9 +229,9 @@ Address::InstanceConstSharedPtr Utility::getLocalAddress(const Address::IpVersio // If the local address is not found above, then return the loopback address by default. if (ret == nullptr) { if (version == Address::IpVersion::v4) { - ret.reset(new Address::Ipv4Instance("127.0.0.1")); + ret = std::make_shared("127.0.0.1"); } else if (version == Address::IpVersion::v6) { - ret.reset(new Address::Ipv6Instance("::1")); + ret = std::make_shared("::1"); } } return ret; diff --git a/source/common/router/vhds.h b/source/common/router/vhds.h index 224e18e1a74d3..372f5a08989c7 100644 --- a/source/common/router/vhds.h +++ b/source/common/router/vhds.h @@ -53,7 +53,7 @@ class VhdsSubscription : Envoy::Config::SubscriptionBase +#include #include #include "envoy/buffer/buffer.h" @@ -438,7 +439,7 @@ Network::FilterStatus Filter::initializeUpstreamConnection() { Tcp::ConnectionPool::Cancellable* handle = conn_pool->newConnection(*this); if (handle) { ASSERT(upstream_handle_.get() == nullptr); - upstream_handle_.reset(new TcpConnectionHandle(handle)); + upstream_handle_ = std::make_shared(handle); } // Because we never return open connections to the pool, this either has a handle waiting on // connection completion, or onPoolFailure has been invoked. Either way, stop iteration. @@ -448,11 +449,11 @@ Network::FilterStatus Filter::initializeUpstreamConnection() { Http::ConnectionPool::Instance* conn_pool = cluster_manager_.httpConnPoolForCluster( cluster_name, Upstream::ResourcePriority::Default, Http::Protocol::Http2, this); if (conn_pool) { - upstream_.reset( - new HttpUpstream(*upstream_callbacks_, config_->tunnelingConfig()->hostname())); + upstream_ = std::make_unique(*upstream_callbacks_, + config_->tunnelingConfig()->hostname()); HttpUpstream* http_upstream = static_cast(upstream_.get()); - upstream_handle_.reset( - new HttpConnectionHandle(conn_pool->newStream(http_upstream->responseDecoder(), *this))); + upstream_handle_ = std::make_shared( + conn_pool->newStream(http_upstream->responseDecoder(), *this)); return Network::FilterStatus::StopIteration; } } @@ -506,7 +507,7 @@ void Filter::onPoolReady(Tcp::ConnectionPool::ConnectionDataPtr&& conn_data, Upstream::HostDescriptionConstSharedPtr host) { Tcp::ConnectionPool::ConnectionData* latched_data = conn_data.get(); - upstream_.reset(new TcpUpstream(std::move(conn_data), *upstream_callbacks_)); + upstream_ = std::make_unique(std::move(conn_data), *upstream_callbacks_); onPoolReadyBase(host, latched_data->connection().localAddress(), latched_data->connection().streamInfo().downstreamSslConnection()); read_callbacks_->connection().streamInfo().setUpstreamFilterState( diff --git a/source/common/tcp_proxy/upstream.h b/source/common/tcp_proxy/upstream.h index c83c2bd3245bd..db193b0f4bba0 100644 --- a/source/common/tcp_proxy/upstream.h +++ b/source/common/tcp_proxy/upstream.h @@ -12,7 +12,7 @@ namespace TcpProxy { // or an HttpConnectionHandle class ConnectionHandle { public: - virtual ~ConnectionHandle() {} + virtual ~ConnectionHandle() = default; // Cancel the conn pool request and close any excess pending requests. virtual void cancel() PURE; }; @@ -43,7 +43,7 @@ class HttpConnectionHandle : public ConnectionHandle { // upstream. class GenericUpstream { public: - virtual ~GenericUpstream() {} + virtual ~GenericUpstream() = default; // Calls readDisable on the upstream connection. Returns false if readDisable could not be // performed (e.g. if the connection is closed) virtual bool readDisable(bool disable) PURE; @@ -75,7 +75,7 @@ class TcpUpstream : public GenericUpstream { class HttpUpstream : public GenericUpstream, Http::StreamCallbacks { public: HttpUpstream(Tcp::ConnectionPool::UpstreamCallbacks& callbacks, const std::string& hostname); - ~HttpUpstream(); + ~HttpUpstream() override; static bool isValidBytestreamResponse(const Http::ResponseHeaderMap& headers); diff --git a/source/common/upstream/cluster_manager_impl.cc b/source/common/upstream/cluster_manager_impl.cc index a8da8b3c1d1e7..7422a82f5c277 100644 --- a/source/common/upstream/cluster_manager_impl.cc +++ b/source/common/upstream/cluster_manager_impl.cc @@ -225,8 +225,8 @@ ClusterManagerImpl::ClusterManagerImpl( if (cm_config.has_outlier_detection()) { const std::string event_log_file_path = cm_config.outlier_detection().event_log_path(); if (!event_log_file_path.empty()) { - outlier_event_logger_.reset( - new Outlier::EventLoggerImpl(log_manager, event_log_file_path, time_source_)); + outlier_event_logger_ = std::make_shared( + log_manager, event_log_file_path, time_source_); } } diff --git a/source/common/upstream/health_checker_impl.cc b/source/common/upstream/health_checker_impl.cc index 664a60c455ed2..70bb4fd9493f2 100644 --- a/source/common/upstream/health_checker_impl.cc +++ b/source/common/upstream/health_checker_impl.cc @@ -1,5 +1,7 @@ #include "common/upstream/health_checker_impl.h" +#include + #include "envoy/config/core/v3/health_check.pb.h" #include "envoy/data/core/v3/health_check_event.pb.h" #include "envoy/server/health_checker_config.h" @@ -505,7 +507,7 @@ void TcpHealthCheckerImpl::TcpActiveHealthCheckSession::onInterval() { client_ = host_->createHealthCheckConnection(parent_.dispatcher_, parent_.transportSocketOptions()) .connection_; - session_callbacks_.reset(new TcpSessionCallbacks(*this)); + session_callbacks_ = std::make_shared(*this); client_->addConnectionCallbacks(*session_callbacks_); client_->addReadFilter(session_callbacks_); diff --git a/source/common/upstream/logical_dns_cluster.cc b/source/common/upstream/logical_dns_cluster.cc index 88f3cc5aba999..709e801fb34aa 100644 --- a/source/common/upstream/logical_dns_cluster.cc +++ b/source/common/upstream/logical_dns_cluster.cc @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -120,8 +121,8 @@ void LogicalDnsCluster::startResolve() { Network::Utility::portFromTcpUrl(dns_url_)); if (!logical_host_) { - logical_host_.reset(new LogicalHost(info_, hostname_, new_address, localityLbEndpoint(), - lbEndpoint(), nullptr)); + logical_host_ = std::make_shared( + info_, hostname_, new_address, localityLbEndpoint(), lbEndpoint(), nullptr); const auto& locality_lb_endpoint = localityLbEndpoint(); PriorityStateManager priority_state_manager(*this, local_info_, nullptr); diff --git a/source/common/upstream/subset_lb.cc b/source/common/upstream/subset_lb.cc index abe6db0be5975..1cf9de7230a29 100644 --- a/source/common/upstream/subset_lb.cc +++ b/source/common/upstream/subset_lb.cc @@ -169,8 +169,8 @@ void SubsetLoadBalancer::initSelectorFallbackSubset( HostPredicate predicate = std::bind(&SubsetLoadBalancer::hostMatches, this, default_subset_metadata_, std::placeholders::_1); selector_fallback_subset_default_ = std::make_shared(); - selector_fallback_subset_default_->priority_subset_.reset( - new PrioritySubsetImpl(*this, predicate, locality_weight_aware_, scale_locality_weight_)); + selector_fallback_subset_default_->priority_subset_ = std::make_shared( + *this, predicate, locality_weight_aware_, scale_locality_weight_); } } diff --git a/source/extensions/common/wasm/null/null_vm_plugin.h b/source/extensions/common/wasm/null/null_vm_plugin.h index eef7fcebeac5e..bc89271452c6b 100644 --- a/source/extensions/common/wasm/null/null_vm_plugin.h +++ b/source/extensions/common/wasm/null/null_vm_plugin.h @@ -30,7 +30,7 @@ class NullVmPlugin { */ class NullVmPluginFactory : public Config::UntypedFactory { public: - virtual ~NullVmPluginFactory() = default; + ~NullVmPluginFactory() override = default; std::string category() const override { return "envoy.wasm.null_vms"; } diff --git a/source/extensions/common/wasm/v8/v8.cc b/source/extensions/common/wasm/v8/v8.cc index 5bd2c1f57b6f0..b9c3673315d23 100644 --- a/source/extensions/common/wasm/v8/v8.cc +++ b/source/extensions/common/wasm/v8/v8.cc @@ -415,7 +415,7 @@ void V8::link(absl::string_view debug_name) { throw WasmVmException( fmt::format("Failed to load WASM module due to a missing import: {}.{}", module, name)); } - auto func = it->second.get()->callback_.get(); + auto func = it->second->callback_.get(); if (!equalValTypes(import_type->func()->params(), func->type()->params()) || !equalValTypes(import_type->func()->results(), func->type()->results())) { throw WasmVmException(fmt::format( diff --git a/source/extensions/filters/common/expr/context.cc b/source/extensions/filters/common/expr/context.cc index 19373693901a3..6df67169d09ea 100644 --- a/source/extensions/filters/common/expr/context.cc +++ b/source/extensions/filters/common/expr/context.cc @@ -31,19 +31,19 @@ absl::optional extractSslInfo(const Ssl::ConnectionInfo& ssl_info, } else if (value == SubjectPeerCertificate) { return CelValue::CreateString(&ssl_info.subjectPeerCertificate()); } else if (value == URISanLocalCertificate) { - if (ssl_info.uriSanLocalCertificate().size() > 0) { + if (!ssl_info.uriSanLocalCertificate().empty()) { return CelValue::CreateString(&ssl_info.uriSanLocalCertificate()[0]); } } else if (value == URISanPeerCertificate) { - if (ssl_info.uriSanPeerCertificate().size() > 0) { + if (!ssl_info.uriSanPeerCertificate().empty()) { return CelValue::CreateString(&ssl_info.uriSanPeerCertificate()[0]); } } else if (value == DNSSanLocalCertificate) { - if (ssl_info.dnsSansLocalCertificate().size() > 0) { + if (!ssl_info.dnsSansLocalCertificate().empty()) { return CelValue::CreateString(&ssl_info.dnsSansLocalCertificate()[0]); } } else if (value == DNSSanPeerCertificate) { - if (ssl_info.dnsSansPeerCertificate().size() > 0) { + if (!ssl_info.dnsSansPeerCertificate().empty()) { return CelValue::CreateString(&ssl_info.dnsSansPeerCertificate()[0]); } } diff --git a/source/extensions/filters/common/expr/evaluator.cc b/source/extensions/filters/common/expr/evaluator.cc index 75c3656426e83..0bd1d3554f190 100644 --- a/source/extensions/filters/common/expr/evaluator.cc +++ b/source/extensions/filters/common/expr/evaluator.cc @@ -71,7 +71,7 @@ absl::optional evaluate(const Expression& expr, Protobuf::Arena* arena const Http::ResponseHeaderMap* response_headers, const Http::ResponseTrailerMap* response_trailers) { auto activation = createActivation(info, request_headers, response_headers, response_trailers); - auto eval_status = expr.Evaluate(*activation.get(), arena); + auto eval_status = expr.Evaluate(*activation, arena); if (!eval_status.ok()) { return {}; } diff --git a/source/extensions/filters/http/cache/http_cache.h b/source/extensions/filters/http/cache/http_cache.h index 5c82eeecf13ac..05e07a84fd7cb 100644 --- a/source/extensions/filters/http/cache/http_cache.h +++ b/source/extensions/filters/http/cache/http_cache.h @@ -311,7 +311,7 @@ class HttpCacheFactory : public Config::TypedFactory { // as the calling CacheFilter). virtual HttpCache& getCache(const envoy::extensions::filters::http::cache::v3alpha::CacheConfig& config) PURE; - virtual ~HttpCacheFactory() = default; + ~HttpCacheFactory() override = default; private: const std::string name_; diff --git a/source/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter.cc b/source/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter.cc index f194bb66ca60e..ae54456db5281 100644 --- a/source/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter.cc +++ b/source/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter.cc @@ -26,8 +26,6 @@ #include "grpc_transcoding/response_to_json_translator.h" using Envoy::Protobuf::FileDescriptorSet; -using Envoy::Protobuf::io::CodedOutputStream; -using Envoy::Protobuf::io::StringOutputStream; using Envoy::Protobuf::io::ZeroCopyInputStream; using Envoy::ProtobufUtil::Status; using Envoy::ProtobufUtil::error::Code; diff --git a/source/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter.h b/source/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter.h index 354b0b010230c..15ce110547060 100644 --- a/source/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter.h +++ b/source/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter.h @@ -47,7 +47,7 @@ struct MethodInfo { bool request_type_is_http_body_ = false; bool response_type_is_http_body_ = false; }; -typedef std::shared_ptr MethodInfoSharedPtr; +using MethodInfoSharedPtr = std::shared_ptr; void createHttpBodyEnvelope(Buffer::Instance& output, const std::vector& request_body_field_path, diff --git a/source/extensions/filters/http/health_check/config.cc b/source/extensions/filters/http/health_check/config.cc index ac388fcbdb0e4..7baa31b01daa5 100644 --- a/source/extensions/filters/http/health_check/config.cc +++ b/source/extensions/filters/http/health_check/config.cc @@ -1,5 +1,7 @@ #include "extensions/filters/http/health_check/config.h" +#include + #include "envoy/extensions/filters/http/health_check/v3/health_check.pb.h" #include "envoy/extensions/filters/http/health_check/v3/health_check.pb.validate.h" #include "envoy/registry/registry.h" @@ -31,8 +33,8 @@ Http::FilterFactoryCb HealthCheckFilterConfig::createFilterFactoryFromProtoTyped HealthCheckCacheManagerSharedPtr cache_manager; if (cache_time_ms > 0) { - cache_manager.reset(new HealthCheckCacheManager(context.dispatcher(), - std::chrono::milliseconds(cache_time_ms))); + cache_manager = std::make_shared( + context.dispatcher(), std::chrono::milliseconds(cache_time_ms)); } ClusterMinHealthyPercentagesConstSharedPtr cluster_min_healthy_percentages; diff --git a/source/extensions/filters/http/jwt_authn/authenticator.cc b/source/extensions/filters/http/jwt_authn/authenticator.cc index 140309d6fe38e..3837b2c4c0345 100644 --- a/source/extensions/filters/http/jwt_authn/authenticator.cc +++ b/source/extensions/filters/http/jwt_authn/authenticator.cc @@ -101,12 +101,15 @@ class AuthenticatorImpl : public Logger::Loggable, }; std::string AuthenticatorImpl::name() const { - if (provider_) + if (provider_) { return provider_.value() + (is_allow_missing_ ? "-OPTIONAL" : ""); - if (is_allow_failed_) + } + if (is_allow_failed_) { return "_IS_ALLOW_FALED_"; - if (is_allow_missing_) + } + if (is_allow_missing_) { return "_IS_ALLOW_MISSING_"; + } return "_UNKNOWN_"; } diff --git a/source/extensions/filters/http/jwt_authn/extractor.cc b/source/extensions/filters/http/jwt_authn/extractor.cc index 261901b1484ea..fb1ebb21a0917 100644 --- a/source/extensions/filters/http/jwt_authn/extractor.cc +++ b/source/extensions/filters/http/jwt_authn/extractor.cc @@ -11,7 +11,6 @@ #include "absl/strings/match.h" -using envoy::extensions::filters::http::jwt_authn::v3::JwtAuthentication; using envoy::extensions::filters::http::jwt_authn::v3::JwtProvider; using Envoy::Http::LowerCaseString; diff --git a/source/extensions/filters/http/jwt_authn/filter_config.h b/source/extensions/filters/http/jwt_authn/filter_config.h index c65670b859766..53c7cc965be33 100644 --- a/source/extensions/filters/http/jwt_authn/filter_config.h +++ b/source/extensions/filters/http/jwt_authn/filter_config.h @@ -104,8 +104,8 @@ class FilterConfigImpl : public Logger::Loggable, bool bypassCorsPreflightRequest() const override { return proto_config_.bypass_cors_preflight(); } - virtual const Verifier* findVerifier(const Http::RequestHeaderMap& headers, - const StreamInfo::FilterState& filter_state) const override { + const Verifier* findVerifier(const Http::RequestHeaderMap& headers, + const StreamInfo::FilterState& filter_state) const override { for (const auto& pair : rule_pairs_) { if (pair.matcher_->matches(headers)) { return pair.verifier_.get(); diff --git a/source/extensions/filters/network/direct_response/filter.cc b/source/extensions/filters/network/direct_response/filter.cc index 5c7fe7696f843..0f0cfe4d329ff 100644 --- a/source/extensions/filters/network/direct_response/filter.cc +++ b/source/extensions/filters/network/direct_response/filter.cc @@ -13,7 +13,7 @@ namespace DirectResponse { Network::FilterStatus DirectResponseFilter::onNewConnection() { auto& connection = read_callbacks_->connection(); ENVOY_CONN_LOG(trace, "direct_response: new connection", connection); - if (response_.size() > 0) { + if (!response_.empty()) { Buffer::OwnedImpl data(response_); connection.write(data, false); ASSERT(0 == data.length()); diff --git a/source/extensions/filters/network/dubbo_proxy/filters/filter_config.h b/source/extensions/filters/network/dubbo_proxy/filters/filter_config.h index 3eb49c6855f3a..2138d44bb062b 100644 --- a/source/extensions/filters/network/dubbo_proxy/filters/filter_config.h +++ b/source/extensions/filters/network/dubbo_proxy/filters/filter_config.h @@ -23,7 +23,7 @@ namespace DubboFilters { */ class NamedDubboFilterConfigFactory : public Envoy::Config::TypedFactory { public: - virtual ~NamedDubboFilterConfigFactory() = default; + ~NamedDubboFilterConfigFactory() override = default; /** * Create a particular dubbo filter factory implementation. If the implementation is unable to diff --git a/source/extensions/filters/network/dubbo_proxy/protocol.h b/source/extensions/filters/network/dubbo_proxy/protocol.h index 0c44980d57844..b496699d42c2f 100644 --- a/source/extensions/filters/network/dubbo_proxy/protocol.h +++ b/source/extensions/filters/network/dubbo_proxy/protocol.h @@ -100,7 +100,7 @@ using ProtocolPtr = std::unique_ptr; */ class NamedProtocolConfigFactory : public Config::UntypedFactory { public: - virtual ~NamedProtocolConfigFactory() = default; + ~NamedProtocolConfigFactory() override = default; /** * Create a particular Dubbo protocol. diff --git a/source/extensions/filters/network/dubbo_proxy/router/route.h b/source/extensions/filters/network/dubbo_proxy/router/route.h index fd7ece10428e8..c9814aa18f2a0 100644 --- a/source/extensions/filters/network/dubbo_proxy/router/route.h +++ b/source/extensions/filters/network/dubbo_proxy/router/route.h @@ -69,7 +69,7 @@ using RouteMatcherConstSharedPtr = std::shared_ptr; */ class NamedRouteMatcherConfigFactory : public Envoy::Config::UntypedFactory { public: - virtual ~NamedRouteMatcherConfigFactory() = default; + ~NamedRouteMatcherConfigFactory() override = default; /** * Create a particular Dubbo protocol. diff --git a/source/extensions/filters/network/dubbo_proxy/serializer.h b/source/extensions/filters/network/dubbo_proxy/serializer.h index 3b6c85dc7f188..2d3c1125cb7fe 100644 --- a/source/extensions/filters/network/dubbo_proxy/serializer.h +++ b/source/extensions/filters/network/dubbo_proxy/serializer.h @@ -81,7 +81,7 @@ using SerializerPtr = std::unique_ptr; */ class NamedSerializerConfigFactory : public Config::UntypedFactory { public: - virtual ~NamedSerializerConfigFactory() = default; + ~NamedSerializerConfigFactory() override = default; /** * Create a particular Dubbo serializer. diff --git a/source/extensions/filters/network/kafka/serialization.h b/source/extensions/filters/network/kafka/serialization.h index 7e87c268e81cc..8d157172891ac 100644 --- a/source/extensions/filters/network/kafka/serialization.h +++ b/source/extensions/filters/network/kafka/serialization.h @@ -35,7 +35,7 @@ template class Deserializer { /** * The type this deserializer is deserializing. */ - typedef T result_type; + using result_type = T; virtual ~Deserializer() = default; diff --git a/source/extensions/filters/network/mongo_proxy/config.cc b/source/extensions/filters/network/mongo_proxy/config.cc index 847ac601a9a75..13ed4139bbb4f 100644 --- a/source/extensions/filters/network/mongo_proxy/config.cc +++ b/source/extensions/filters/network/mongo_proxy/config.cc @@ -1,5 +1,7 @@ #include "extensions/filters/network/mongo_proxy/config.h" +#include + #include "envoy/extensions/filters/network/mongo_proxy/v3/mongo_proxy.pb.h" #include "envoy/extensions/filters/network/mongo_proxy/v3/mongo_proxy.pb.validate.h" #include "envoy/network/connection.h" @@ -23,8 +25,8 @@ Network::FilterFactoryCb MongoProxyFilterConfigFactory::createFilterFactoryFromP const std::string stat_prefix = fmt::format("mongo.{}", proto_config.stat_prefix()); AccessLogSharedPtr access_log; if (!proto_config.access_log().empty()) { - access_log.reset(new AccessLog(proto_config.access_log(), context.accessLogManager(), - context.dispatcher().timeSource())); + access_log = std::make_shared(proto_config.access_log(), context.accessLogManager(), + context.dispatcher().timeSource()); } Filters::Common::Fault::FaultDelayConfigSharedPtr fault_config; diff --git a/source/extensions/filters/network/thrift_proxy/filters/filter_config.h b/source/extensions/filters/network/thrift_proxy/filters/filter_config.h index a45764b15252c..62d900a8b1d6c 100644 --- a/source/extensions/filters/network/thrift_proxy/filters/filter_config.h +++ b/source/extensions/filters/network/thrift_proxy/filters/filter_config.h @@ -20,7 +20,7 @@ namespace ThriftFilters { */ class NamedThriftFilterConfigFactory : public Envoy::Config::TypedFactory { public: - virtual ~NamedThriftFilterConfigFactory() = default; + ~NamedThriftFilterConfigFactory() override = default; /** * Create a particular thrift filter factory implementation. If the implementation is unable to diff --git a/source/extensions/filters/network/thrift_proxy/protocol.h b/source/extensions/filters/network/thrift_proxy/protocol.h index eba0d7efdb7a7..3a76799229da8 100644 --- a/source/extensions/filters/network/thrift_proxy/protocol.h +++ b/source/extensions/filters/network/thrift_proxy/protocol.h @@ -501,7 +501,7 @@ class DirectResponse { */ class NamedProtocolConfigFactory : public Config::UntypedFactory { public: - virtual ~NamedProtocolConfigFactory() = default; + ~NamedProtocolConfigFactory() override = default; /** * Create a particular Thrift protocol diff --git a/source/extensions/filters/network/thrift_proxy/transport.h b/source/extensions/filters/network/thrift_proxy/transport.h index da1632c5765de..d8393cef6870d 100644 --- a/source/extensions/filters/network/thrift_proxy/transport.h +++ b/source/extensions/filters/network/thrift_proxy/transport.h @@ -85,7 +85,7 @@ using TransportPtr = std::unique_ptr; */ class NamedTransportConfigFactory : public Envoy::Config::UntypedFactory { public: - virtual ~NamedTransportConfigFactory() = default; + ~NamedTransportConfigFactory() override = default; /** * Create a particular Thrift transport. diff --git a/source/extensions/filters/udp/udp_proxy/udp_proxy_filter.h b/source/extensions/filters/udp/udp_proxy/udp_proxy_filter.h index 049125ba40546..d96eda5299953 100644 --- a/source/extensions/filters/udp/udp_proxy/udp_proxy_filter.h +++ b/source/extensions/filters/udp/udp_proxy/udp_proxy_filter.h @@ -113,7 +113,7 @@ class UdpProxyFilter : public Network::UdpListenerReadFilter, public: ActiveSession(ClusterInfo& parent, Network::UdpRecvData::LocalPeerAddresses&& addresses, const Upstream::HostConstSharedPtr& host); - ~ActiveSession(); + ~ActiveSession() override; const Network::UdpRecvData::LocalPeerAddresses& addresses() const { return addresses_; } const Upstream::Host& host() const { return *host_; } void write(const Buffer::Instance& buffer); diff --git a/source/extensions/quic_listeners/quiche/envoy_quic_alarm.h b/source/extensions/quic_listeners/quiche/envoy_quic_alarm.h index ffe4d020e09ab..ec56eafa6fff0 100644 --- a/source/extensions/quic_listeners/quiche/envoy_quic_alarm.h +++ b/source/extensions/quic_listeners/quiche/envoy_quic_alarm.h @@ -21,7 +21,7 @@ class EnvoyQuicAlarm : public quic::QuicAlarm { quic::QuicArenaScopedPtr delegate); // TimerImpl destruction deletes in-flight alarm firing event. - ~EnvoyQuicAlarm() override {} + ~EnvoyQuicAlarm() override = default; // quic::QuicAlarm void CancelImpl() override; diff --git a/source/extensions/quic_listeners/quiche/envoy_quic_fake_proof_verifier.h b/source/extensions/quic_listeners/quiche/envoy_quic_fake_proof_verifier.h index c8355717bccb8..49abe56e91226 100644 --- a/source/extensions/quic_listeners/quiche/envoy_quic_fake_proof_verifier.h +++ b/source/extensions/quic_listeners/quiche/envoy_quic_fake_proof_verifier.h @@ -49,7 +49,7 @@ class EnvoyQuicFakeProofVerifier : public quic::ProofVerifier { std::unique_ptr* /*details*/, std::unique_ptr /*callback*/) override { // Cert SCT support is not enabled for fake ProofSource. - if (cert_sct == "" && certs.size() == 1 && certs[0] == "Fake cert") { + if (cert_sct.empty() && certs.size() == 1 && certs[0] == "Fake cert") { return quic::QUIC_SUCCESS; } return quic::QUIC_FAILURE; diff --git a/source/extensions/quic_listeners/quiche/platform/quic_logging_impl.h b/source/extensions/quic_listeners/quiche/platform/quic_logging_impl.h index c61e40f8414a5..b959d7f18b879 100644 --- a/source/extensions/quic_listeners/quiche/platform/quic_logging_impl.h +++ b/source/extensions/quic_listeners/quiche/platform/quic_logging_impl.h @@ -146,7 +146,7 @@ class QuicLogEmitter { class NullLogStream : public std::ostream { public: - NullLogStream() : std::ostream(NULL) {} + NullLogStream() : std::ostream(nullptr) {} NullLogStream& stream() { return *this; } }; diff --git a/source/extensions/tracers/opencensus/opencensus_tracer_impl.cc b/source/extensions/tracers/opencensus/opencensus_tracer_impl.cc index d4b9a7daf81a4..00a13fb0e69cd 100644 --- a/source/extensions/tracers/opencensus/opencensus_tracer_impl.cc +++ b/source/extensions/tracers/opencensus/opencensus_tracer_impl.cc @@ -290,7 +290,8 @@ Driver::Driver(const envoy::config::trace::v3::OpenCensusConfig& oc_config, opts.address = oc_config.ocagent_address(); } else if (oc_config.has_ocagent_grpc_service() && oc_config.ocagent_grpc_service().has_google_grpc()) { - envoy::config::core::v3::GrpcService ocagent_service = oc_config.ocagent_grpc_service(); + const envoy::config::core::v3::GrpcService& ocagent_service = + oc_config.ocagent_grpc_service(); auto channel = Envoy::Grpc::GoogleGrpcUtils::createChannel(ocagent_service, api); opts.trace_service_stub = ::opencensus::proto::agent::trace::v1::TraceService::NewStub(channel); diff --git a/source/server/configuration_impl.h b/source/server/configuration_impl.h index 0fe8a6b12a86b..6b9f4ef51270d 100644 --- a/source/server/configuration_impl.h +++ b/source/server/configuration_impl.h @@ -33,7 +33,7 @@ namespace Configuration { */ class StatsSinkFactory : public Config::TypedFactory { public: - virtual ~StatsSinkFactory() = default; + ~StatsSinkFactory() override = default; /** * Create a particular Stats::Sink implementation. If the implementation is unable to produce a diff --git a/source/server/connection_handler_impl.h b/source/server/connection_handler_impl.h index 5680aacfc6e36..3a8812ad74b33 100644 --- a/source/server/connection_handler_impl.h +++ b/source/server/connection_handler_impl.h @@ -162,7 +162,7 @@ class ConnectionHandlerImpl : public Network::ConnectionHandler, class ActiveConnections : public Event::DeferredDeletable { public: ActiveConnections(ActiveTcpListener& listener, const Network::FilterChain& filter_chain); - ~ActiveConnections(); + ~ActiveConnections() override; // listener filter chain pair is the owner of the connections ActiveTcpListener& listener_; diff --git a/source/server/hot_restarting_child.cc b/source/server/hot_restarting_child.cc index 7240fb1e97087..f5eb8296c6634 100644 --- a/source/server/hot_restarting_child.cc +++ b/source/server/hot_restarting_child.cc @@ -98,7 +98,7 @@ void HotRestartingChild::mergeParentStats(Stats::Store& stats_store, // Convert the protobuf for serialized dynamic spans into the structure // required by StatMerger. Stats::StatMerger::DynamicsMap dynamics; - for (auto iter : stats_proto.dynamics()) { + for (const auto& iter : stats_proto.dynamics()) { Stats::DynamicSpans& spans = dynamics[iter.first]; for (int i = 0; i < iter.second.spans_size(); ++i) { const HotRestartMessage::Reply::Span& span_proto = iter.second.spans(i); diff --git a/source/server/http/admin.cc b/source/server/http/admin.cc index d7b75d6cea231..9248ab4035ab3 100644 --- a/source/server/http/admin.cc +++ b/source/server/http/admin.cc @@ -244,7 +244,7 @@ void trimResourceMessage(const Protobuf::FieldMask& field_mask, Protobuf::Messag std::string any_field_name; for (int i = 0; i < field_mask.paths().size(); ++i) { const std::string& path = field_mask.paths(i); - std::vector frags = absl::StrSplit(path, "."); + std::vector frags = absl::StrSplit(path, '.'); if (frags.empty()) { continue; } diff --git a/source/server/http/admin.h b/source/server/http/admin.h index f2a48cf1ed5de..30cd9591a6b64 100644 --- a/source/server/http/admin.h +++ b/source/server/http/admin.h @@ -414,9 +414,7 @@ class AdminImpl : public Admin, bool bindToPort() override { return true; } bool handOffRestoredDestinationConnections() const override { return false; } uint32_t perConnectionBufferLimitBytes() const override { return 0; } - std::chrono::milliseconds listenerFiltersTimeout() const override { - return std::chrono::milliseconds(); - } + std::chrono::milliseconds listenerFiltersTimeout() const override { return {}; } bool continueOnListenerFiltersTimeout() const override { return false; } Stats::Scope& listenerScope() override { return *scope_; } uint64_t listenerTag() const override { return 0; } diff --git a/source/server/listener_manager_impl.cc b/source/server/listener_manager_impl.cc index 90c6f3f19b214..cf3288004b232 100644 --- a/source/server/listener_manager_impl.cc +++ b/source/server/listener_manager_impl.cc @@ -748,7 +748,7 @@ void ListenerManagerImpl::startWorkers(GuardDog& guard_dog) { } i++; } - if (active_listeners_.size() == 0) { + if (active_listeners_.empty()) { stats_.workers_started_.set(1); } } diff --git a/source/server/options_impl.cc b/source/server/options_impl.cc index 723ef5a4b71af..f054546f11c7f 100644 --- a/source/server/options_impl.cc +++ b/source/server/options_impl.cc @@ -24,6 +24,8 @@ namespace Envoy { namespace { std::vector toArgsVector(int argc, const char* const* argv) { std::vector args; + args.reserve(argc); + for (int i = 0; i < argc; ++i) { args.emplace_back(argv[i]); } @@ -232,7 +234,7 @@ OptionsImpl::OptionsImpl(std::vector args, } if (!disable_extensions.getValue().empty()) { - disabled_extensions_ = absl::StrSplit(disable_extensions.getValue(), ","); + disabled_extensions_ = absl::StrSplit(disable_extensions.getValue(), ','); } } @@ -353,7 +355,7 @@ OptionsImpl::OptionsImpl(const std::string& service_cluster, const std::string& void OptionsImpl::disableExtensions(const std::vector& names) { for (const auto& name : names) { - const std::vector parts = absl::StrSplit(name, absl::MaxSplits("/", 1)); + const std::vector parts = absl::StrSplit(name, absl::MaxSplits('/', 1)); if (parts.size() != 2) { ENVOY_LOG_MISC(warn, "failed to disable invalid extension name '{}'", name); diff --git a/test/common/buffer/owned_impl_test.cc b/test/common/buffer/owned_impl_test.cc index d537bd6570308..6934fc63c2f4b 100644 --- a/test/common/buffer/owned_impl_test.cc +++ b/test/common/buffer/owned_impl_test.cc @@ -13,7 +13,6 @@ #include "gtest/gtest.h" using testing::_; -using testing::ContainerEq; using testing::Return; namespace Envoy { diff --git a/test/common/config/delta_subscription_state_test.cc b/test/common/config/delta_subscription_state_test.cc index c0af136225dbb..474172e3c9a41 100644 --- a/test/common/config/delta_subscription_state_test.cc +++ b/test/common/config/delta_subscription_state_test.cc @@ -12,7 +12,6 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -using testing::Eq; using testing::NiceMock; using testing::Throw; using testing::UnorderedElementsAre; diff --git a/test/common/config/registry_test.cc b/test/common/config/registry_test.cc index 2797951b0d3a4..6c7043ec59ab8 100644 --- a/test/common/config/registry_test.cc +++ b/test/common/config/registry_test.cc @@ -17,7 +17,7 @@ namespace { class InternalFactory : public Config::UntypedFactory { public: - virtual ~InternalFactory() = default; + ~InternalFactory() override = default; std::string category() const override { return ""; } }; @@ -50,7 +50,7 @@ TEST(RegistryTest, InternalFactoryNotPublished) { class PublishedFactory : public Config::UntypedFactory { public: - virtual ~PublishedFactory() = default; + ~PublishedFactory() override = default; std::string category() const override { return "testing.published"; } }; diff --git a/test/common/grpc/google_grpc_creds_test.cc b/test/common/grpc/google_grpc_creds_test.cc index 8ca5ce1d762e1..8c3b4efdefd48 100644 --- a/test/common/grpc/google_grpc_creds_test.cc +++ b/test/common/grpc/google_grpc_creds_test.cc @@ -40,10 +40,10 @@ TEST_F(CredsUtilityTest, GetChannelCredentials) { const std::string var_name = "GOOGLE_APPLICATION_CREDENTIALS"; EXPECT_EQ(nullptr, ::getenv(var_name.c_str())); const std::string creds_path = TestEnvironment::runfilesPath("test/common/grpc/service_key.json"); - TestEnvironment::setEnvVar(var_name.c_str(), creds_path.c_str(), 0); + TestEnvironment::setEnvVar(var_name, creds_path, 0); creds->mutable_google_default(); EXPECT_NE(nullptr, CredsUtility::getChannelCredentials(config, *api_)); - TestEnvironment::unsetEnvVar(var_name.c_str()); + TestEnvironment::unsetEnvVar(var_name); } TEST_F(CredsUtilityTest, DefaultSslChannelCredentials) { diff --git a/test/common/http/conn_manager_impl_test.cc b/test/common/http/conn_manager_impl_test.cc index 434721d9c3848..ed89dc6d66346 100644 --- a/test/common/http/conn_manager_impl_test.cc +++ b/test/common/http/conn_manager_impl_test.cc @@ -60,7 +60,6 @@ using testing::HasSubstr; using testing::InSequence; using testing::Invoke; using testing::InvokeWithoutArgs; -using testing::Matcher; using testing::NiceMock; using testing::Ref; using testing::Return; diff --git a/test/common/http/header_map_impl_fuzz_test.cc b/test/common/http/header_map_impl_fuzz_test.cc index d6b9d7a05a728..bfd7507e05587 100644 --- a/test/common/http/header_map_impl_fuzz_test.cc +++ b/test/common/http/header_map_impl_fuzz_test.cc @@ -103,7 +103,7 @@ DEFINE_PROTO_FUZZER(const test::common::http::HeaderMapImplFuzzTestCase& input) // Randomly (using fuzzer data) set the header_field to either be of type Reference or Inline const auto& str = lower_case_strings.back(); Http::HeaderString header_field; // By default it's Inline - if ((str->get().size() > 0) && (str->get().at(0) & 0x1)) { + if ((!str->get().empty()) && (str->get().at(0) & 0x1)) { // Keeping header_field as Inline header_field.setCopy(str->get()); // inlineTransform can only be applied to Inline type! diff --git a/test/common/http/http2/codec_impl_test.cc b/test/common/http/http2/codec_impl_test.cc index 48bcf2b070758..f0404145cdfce 100644 --- a/test/common/http/http2/codec_impl_test.cc +++ b/test/common/http/http2/codec_impl_test.cc @@ -1127,7 +1127,7 @@ class Http2CustomSettingsTestBase : public Http2CodecImplTestFixture { : Http2CodecImplTestFixture(client_settings, server_settings), validate_client_(validate_client) {} - virtual ~Http2CustomSettingsTestBase() = default; + ~Http2CustomSettingsTestBase() override = default; // Sets the custom settings parameters specified by |parameters| in the |options| proto. void setHttp2CustomSettingsParameters(envoy::config::core::v3::Http2ProtocolOptions& options, diff --git a/test/common/http/http2/request_header_fuzz_test.cc b/test/common/http/http2/request_header_fuzz_test.cc index 35bce06813b33..7f535bcd73a03 100644 --- a/test/common/http/http2/request_header_fuzz_test.cc +++ b/test/common/http/http2/request_header_fuzz_test.cc @@ -7,8 +7,6 @@ #include "test/common/http/http2/frame_replay.h" #include "test/fuzz/fuzz_runner.h" -using testing::AnyNumber; - namespace Envoy { namespace Http { namespace Http2 { diff --git a/test/common/http/http2/response_header_fuzz_test.cc b/test/common/http/http2/response_header_fuzz_test.cc index 09f0336ec8d3f..b670b49f8795d 100644 --- a/test/common/http/http2/response_header_fuzz_test.cc +++ b/test/common/http/http2/response_header_fuzz_test.cc @@ -8,8 +8,6 @@ #include "test/common/http/http2/frame_replay.h" #include "test/fuzz/fuzz_runner.h" -using testing::AnyNumber; - namespace Envoy { namespace Http { namespace Http2 { diff --git a/test/common/network/connection_impl_test.cc b/test/common/network/connection_impl_test.cc index 7b6a03428a9ae..8d9fe29f4abff 100644 --- a/test/common/network/connection_impl_test.cc +++ b/test/common/network/connection_impl_test.cc @@ -117,7 +117,7 @@ class ConnectionImplTest : public testing::TestWithParam { void connect() { int expected_callbacks = 2; client_connection_->connect(); - read_filter_.reset(new NiceMock()); + read_filter_ = std::make_shared>(); EXPECT_CALL(listener_callbacks_, onAccept_(_)) .WillOnce(Invoke([&](Network::ConnectionSocketPtr& socket) -> void { server_connection_ = dispatcher_->createServerConnection( @@ -258,7 +258,7 @@ TEST_P(ConnectionImplTest, CloseDuringConnectCallback) { })); EXPECT_CALL(client_callbacks_, onEvent(ConnectionEvent::LocalClose)); - read_filter_.reset(new NiceMock()); + read_filter_ = std::make_shared>(); EXPECT_CALL(listener_callbacks_, onAccept_(_)) .WillOnce(Invoke([&](Network::ConnectionSocketPtr& socket) -> void { @@ -283,9 +283,9 @@ TEST_P(ConnectionImplTest, ImmediateConnectError) { socket_ = std::make_shared(Network::Test::getAnyAddress(GetParam()), nullptr, true); if (socket_->localAddress()->ip()->version() == Address::IpVersion::v4) { - broadcast_address.reset(new Address::Ipv4Instance("224.0.0.1", 0)); + broadcast_address = std::make_shared("224.0.0.1", 0); } else { - broadcast_address.reset(new Address::Ipv6Instance("ff02::1", 0)); + broadcast_address = std::make_shared("ff02::1", 0); } client_connection_ = dispatcher_->createClientConnection( @@ -315,7 +315,7 @@ TEST_P(ConnectionImplTest, SocketOptions) { })); EXPECT_CALL(client_callbacks_, onEvent(ConnectionEvent::LocalClose)); - read_filter_.reset(new NiceMock()); + read_filter_ = std::make_shared>(); auto option = std::make_shared(); @@ -364,7 +364,7 @@ TEST_P(ConnectionImplTest, SocketOptionsFailureTest) { })); EXPECT_CALL(client_callbacks_, onEvent(ConnectionEvent::LocalClose)); - read_filter_.reset(new NiceMock()); + read_filter_ = std::make_shared>(); auto option = std::make_shared(); @@ -444,7 +444,7 @@ TEST_P(ConnectionImplTest, ConnectionStats) { EXPECT_CALL(client_callbacks_, onEvent(ConnectionEvent::Connected)).InSequence(s1); EXPECT_CALL(client_connection_stats.tx_total_, add(4)).InSequence(s1); - read_filter_.reset(new NiceMock()); + read_filter_ = std::make_shared>(); MockConnectionStats server_connection_stats; EXPECT_CALL(listener_callbacks_, onAccept_(_)) .WillOnce(Invoke([&](Network::ConnectionSocketPtr& socket) -> void { @@ -2003,7 +2003,7 @@ class ReadBufferLimitTest : public ConnectionImplTest { client_connection_->addConnectionCallbacks(client_callbacks_); client_connection_->connect(); - read_filter_.reset(new NiceMock()); + read_filter_ = std::make_shared>(); EXPECT_CALL(listener_callbacks_, onAccept_(_)) .WillOnce(Invoke([&](Network::ConnectionSocketPtr& socket) -> void { server_connection_ = dispatcher_->createServerConnection( diff --git a/test/common/network/dns_impl_test.cc b/test/common/network/dns_impl_test.cc index c40716cac8575..e759e862304d5 100644 --- a/test/common/network/dns_impl_test.cc +++ b/test/common/network/dns_impl_test.cc @@ -482,13 +482,13 @@ class DnsImplTest : public testing::TestWithParam { EXPECT_EQ(expected_results, address_as_string_list); } - for (auto expected_absent_result : expected_absent_results) { + for (const auto& expected_absent_result : expected_absent_results) { EXPECT_THAT(address_as_string_list, Not(Contains(expected_absent_result))); } if (expected_ttl) { std::list address_list = getAddressList(results); - for (auto address : results) { + for (const auto& address : results) { EXPECT_EQ(address.ttl_, expected_ttl.value()); } } diff --git a/test/common/network/udp_listener_impl_test.cc b/test/common/network/udp_listener_impl_test.cc index cf3821bab4299..96c8f235df607 100644 --- a/test/common/network/udp_listener_impl_test.cc +++ b/test/common/network/udp_listener_impl_test.cc @@ -174,8 +174,8 @@ TEST_P(UdpListenerImplTest, UdpEcho) { "seventh", "eighth", "ninth", "tenth", "eleventh", "twelveth", "thirteenth", "fourteenth", "fifteenth", "sixteenth", "seventeenth"}); - for (size_t i = 0; i < client_data.size(); ++i) { - client_.write(client_data[i], *send_to_addr_); + for (const auto& i : client_data) { + client_.write(i, *send_to_addr_); } // For unit test purposes, we assume that the data was received in order. @@ -337,25 +337,25 @@ TEST_P(UdpListenerImplTest, SendData) { Address::InstanceConstSharedPtr send_from_addr; if (version_ == Address::IpVersion::v4) { // Linux kernel regards any 127.x.x.x as local address. But Mac OS doesn't. - send_from_addr.reset(new Address::Ipv4Instance( + send_from_addr = std::make_shared( #ifndef __APPLE__ "127.1.2.3", #else "127.0.0.1", #endif - server_socket_->localAddress()->ip()->port())); + server_socket_->localAddress()->ip()->port()); } else { // Only use non-local v6 address if IP_FREEBIND is supported. Otherwise use // ::1 to avoid EINVAL error. Unfortunately this can't verify that sendmsg with // customized source address is doing the work because kernel also picks ::1 // if it's not specified in cmsghdr. - send_from_addr.reset(new Address::Ipv6Instance( + send_from_addr = std::make_shared( #ifdef IP_FREEBIND "::9", #else "::1", #endif - server_socket_->localAddress()->ip()->port())); + server_socket_->localAddress()->ip()->port()); } UdpSendData send_data{send_from_addr->ip(), *client_.localAddress(), *buffer}; diff --git a/test/common/network/utility_test.cc b/test/common/network/utility_test.cc index 05f768ede2f18..120f13615c82b 100644 --- a/test/common/network/utility_test.cc +++ b/test/common/network/utility_test.cc @@ -1,5 +1,6 @@ #include #include +#include #include #include "envoy/common/exception.h" @@ -179,52 +180,52 @@ TEST(NetworkUtility, LocalConnection) { EXPECT_CALL(socket, localAddress()).WillRepeatedly(testing::ReturnRef(local_addr)); EXPECT_CALL(socket, remoteAddress()).WillRepeatedly(testing::ReturnRef(remote_addr)); - local_addr.reset(new Network::Address::Ipv4Instance("127.0.0.1")); - remote_addr.reset(new Network::Address::PipeInstance("/pipe/path")); + local_addr = std::make_shared("127.0.0.1"); + remote_addr = std::make_shared("/pipe/path"); EXPECT_TRUE(Utility::isSameIpOrLoopback(socket)); - local_addr.reset(new Network::Address::PipeInstance("/pipe/path")); - remote_addr.reset(new Network::Address::PipeInstance("/pipe/path")); + local_addr = std::make_shared("/pipe/path"); + remote_addr = std::make_shared("/pipe/path"); EXPECT_TRUE(Utility::isSameIpOrLoopback(socket)); - local_addr.reset(new Network::Address::Ipv4Instance("127.0.0.1")); - remote_addr.reset(new Network::Address::Ipv4Instance("127.0.0.1")); + local_addr = std::make_shared("127.0.0.1"); + remote_addr = std::make_shared("127.0.0.1"); EXPECT_TRUE(Utility::isSameIpOrLoopback(socket)); - local_addr.reset(new Network::Address::Ipv4Instance("127.0.0.2")); + local_addr = std::make_shared("127.0.0.2"); EXPECT_TRUE(Utility::isSameIpOrLoopback(socket)); - local_addr.reset(new Network::Address::Ipv4Instance("4.4.4.4")); - remote_addr.reset(new Network::Address::Ipv4Instance("8.8.8.8")); + local_addr = std::make_shared("4.4.4.4"); + remote_addr = std::make_shared("8.8.8.8"); EXPECT_FALSE(Utility::isSameIpOrLoopback(socket)); - local_addr.reset(new Network::Address::Ipv4Instance("4.4.4.4")); - remote_addr.reset(new Network::Address::Ipv4Instance("4.4.4.4")); + local_addr = std::make_shared("4.4.4.4"); + remote_addr = std::make_shared("4.4.4.4"); EXPECT_TRUE(Utility::isSameIpOrLoopback(socket)); - local_addr.reset(new Network::Address::Ipv4Instance("4.4.4.4", 1234)); - remote_addr.reset(new Network::Address::Ipv4Instance("4.4.4.4", 4321)); + local_addr = std::make_shared("4.4.4.4", 1234); + remote_addr = std::make_shared("4.4.4.4", 4321); EXPECT_TRUE(Utility::isSameIpOrLoopback(socket)); - local_addr.reset(new Network::Address::Ipv6Instance("::1")); - remote_addr.reset(new Network::Address::Ipv6Instance("::1")); + local_addr = std::make_shared("::1"); + remote_addr = std::make_shared("::1"); EXPECT_TRUE(Utility::isSameIpOrLoopback(socket)); - local_addr.reset(new Network::Address::Ipv6Instance("::2")); - remote_addr.reset(new Network::Address::Ipv6Instance("::1")); + local_addr = std::make_shared("::2"); + remote_addr = std::make_shared("::1"); EXPECT_TRUE(Utility::isSameIpOrLoopback(socket)); - remote_addr.reset(new Network::Address::Ipv6Instance("::3")); + remote_addr = std::make_shared("::3"); EXPECT_FALSE(Utility::isSameIpOrLoopback(socket)); - remote_addr.reset(new Network::Address::Ipv6Instance("::2")); + remote_addr = std::make_shared("::2"); EXPECT_TRUE(Utility::isSameIpOrLoopback(socket)); - remote_addr.reset(new Network::Address::Ipv6Instance("::2", 4321)); - local_addr.reset(new Network::Address::Ipv6Instance("::2", 1234)); + remote_addr = std::make_shared("::2", 4321); + local_addr = std::make_shared("::2", 1234); EXPECT_TRUE(Utility::isSameIpOrLoopback(socket)); - remote_addr.reset(new Network::Address::Ipv6Instance("fd00::")); + remote_addr = std::make_shared("fd00::"); EXPECT_FALSE(Utility::isSameIpOrLoopback(socket)); } diff --git a/test/common/router/rds_impl_test.cc b/test/common/router/rds_impl_test.cc index 0c0b5a0828ed2..ad211cedc787b 100644 --- a/test/common/router/rds_impl_test.cc +++ b/test/common/router/rds_impl_test.cc @@ -32,7 +32,6 @@ using testing::_; using testing::Eq; using testing::InSequence; using testing::Invoke; -using testing::Return; using testing::ReturnRef; namespace Envoy { diff --git a/test/common/router/router_test.cc b/test/common/router/router_test.cc index 2f84b043f5626..b2d35aeb3ad16 100644 --- a/test/common/router/router_test.cc +++ b/test/common/router/router_test.cc @@ -55,7 +55,6 @@ using testing::MockFunction; using testing::NiceMock; using testing::Property; using testing::Return; -using testing::ReturnPointee; using testing::ReturnRef; using testing::StartsWith; diff --git a/test/common/router/router_upstream_log_test.cc b/test/common/router/router_upstream_log_test.cc index 7d8267b096ffd..d62043effadb3 100644 --- a/test/common/router/router_upstream_log_test.cc +++ b/test/common/router/router_upstream_log_test.cc @@ -1,4 +1,5 @@ #include +#include #include #include "envoy/config/accesslog/v3/accesslog.pb.h" @@ -92,9 +93,9 @@ class RouterUpstreamLogTest : public testing::Test { current_upstream_log->CopyFrom(upstream_log.value()); } - config_.reset(new FilterConfig("prefix.", context_, ShadowWriterPtr(new MockShadowWriter()), - router_proto)); - router_.reset(new TestFilter(*config_)); + config_ = std::make_shared("prefix.", context_, + ShadowWriterPtr(new MockShadowWriter()), router_proto); + router_ = std::make_shared(*config_); router_->setDecoderFilterCallbacks(callbacks_); EXPECT_CALL(callbacks_.dispatcher_, setTrackedObject(_)).Times(testing::AnyNumber()); diff --git a/test/common/stats/stat_merger_test.cc b/test/common/stats/stat_merger_test.cc index ba75e1777fbc3..bb47651bcdc93 100644 --- a/test/common/stats/stat_merger_test.cc +++ b/test/common/stats/stat_merger_test.cc @@ -38,7 +38,7 @@ class StatMergerTest : public testing::Test { StatNamePool symbolic_pool(symbol_table); StatNameDynamicPool dynamic_pool(symbol_table); - for (absl::string_view segment : absl::StrSplit(input_name, ".")) { + for (absl::string_view segment : absl::StrSplit(input_name, '.')) { if (absl::StartsWith(segment, "D:")) { std::string hacked = absl::StrReplaceAll(segment.substr(2), {{",", "."}}); components.push_back(dynamic_pool.add(hacked)); @@ -237,7 +237,7 @@ class StatMergerDynamicTest : public testing::Test { StatNamePool symbolic_pool(*symbol_table_); StatNameDynamicPool dynamic_pool(*symbol_table_); - for (absl::string_view segment : absl::StrSplit(input_descriptor, ".")) { + for (absl::string_view segment : absl::StrSplit(input_descriptor, '.')) { if (absl::StartsWith(segment, "D:")) { std::string hacked = absl::StrReplaceAll(segment.substr(2), {{",", "."}}); components.push_back(dynamic_pool.add(hacked)); diff --git a/test/common/stats/stat_test_utility.h b/test/common/stats/stat_test_utility.h index a3ecd0b657a20..b0ccd31763b5e 100644 --- a/test/common/stats/stat_test_utility.h +++ b/test/common/stats/stat_test_utility.h @@ -90,7 +90,7 @@ class MemoryTest { // and symbol strings as production. class TestStore : public IsolatedStoreImpl { public: - TestStore() {} + TestStore() = default; // Constructs a store using a symbol table, allowing for explicit sharing. explicit TestStore(SymbolTable& symbol_table) : IsolatedStoreImpl(symbol_table) {} diff --git a/test/common/stats/thread_local_store_test.cc b/test/common/stats/thread_local_store_test.cc index 35d5a45d22d28..8473222d2cfd6 100644 --- a/test/common/stats/thread_local_store_test.cc +++ b/test/common/stats/thread_local_store_test.cc @@ -1300,7 +1300,7 @@ class ClusterShutdownCleanupStarvationTest : public ThreadLocalStoreNoMocksTestB } } - ~ClusterShutdownCleanupStarvationTest() { + ~ClusterShutdownCleanupStarvationTest() override { { BlockingBarrier blocking_barrier(1); main_dispatcher_->post(blocking_barrier.run([this]() { diff --git a/test/common/tcp_proxy/tcp_proxy_test.cc b/test/common/tcp_proxy/tcp_proxy_test.cc index 792cb66541012..34a92a7798cbf 100644 --- a/test/common/tcp_proxy/tcp_proxy_test.cc +++ b/test/common/tcp_proxy/tcp_proxy_test.cc @@ -39,7 +39,6 @@ using testing::_; using testing::Invoke; using testing::InvokeWithoutArgs; -using testing::MatchesRegex; using testing::NiceMock; using testing::Return; using testing::ReturnPointee; @@ -841,7 +840,7 @@ class TcpProxyTest : public testing::Test { } void configure(const envoy::extensions::filters::network::tcp_proxy::v3::TcpProxy& config) { - config_.reset(new Config(config, factory_context_)); + config_ = std::make_shared(config, factory_context_); } envoy::extensions::filters::network::tcp_proxy::v3::TcpProxy defaultConfig() { @@ -1305,7 +1304,7 @@ TEST_F(TcpProxyTest, WeightedClusterWithMetadataMatch) { k0: v0 )EOF"; - config_.reset(new Config(constructConfigFromYaml(yaml, factory_context_))); + config_ = std::make_shared(constructConfigFromYaml(yaml, factory_context_)); ProtobufWkt::Value v0, v1, v2; v0.set_string_value("v0"); @@ -1761,7 +1760,7 @@ class TcpProxyRoutingTest : public testing::Test { cluster: fake_cluster )EOF"; - config_.reset(new Config(constructConfigFromYaml(yaml, factory_context_))); + config_ = std::make_shared(constructConfigFromYaml(yaml, factory_context_)); } void initializeFilter() { @@ -1915,7 +1914,7 @@ class TcpProxyNonDeprecatedConfigRoutingTest : public TcpProxyRoutingTest { cluster: fake_cluster )EOF"; - config_.reset(new Config(constructConfigFromYaml(yaml, factory_context_))); + config_ = std::make_shared(constructConfigFromYaml(yaml, factory_context_)); } }; @@ -1956,7 +1955,7 @@ class TcpProxyHashingTest : public testing::Test { - source_ip: {} )EOF"; - config_.reset(new Config(constructConfigFromYaml(yaml, factory_context_))); + config_ = std::make_shared(constructConfigFromYaml(yaml, factory_context_)); } void initializeFilter() { diff --git a/test/common/tcp_proxy/upstream_test.cc b/test/common/tcp_proxy/upstream_test.cc index 6435c687410bf..9464d5d259705 100644 --- a/test/common/tcp_proxy/upstream_test.cc +++ b/test/common/tcp_proxy/upstream_test.cc @@ -1,3 +1,5 @@ +#include + #include "common/tcp_proxy/upstream.h" #include "test/mocks/buffer/mocks.h" @@ -19,7 +21,7 @@ class HttpUpstreamTest : public testing::Test { HttpUpstreamTest() { EXPECT_CALL(encoder_, getStream()).Times(AnyNumber()); EXPECT_CALL(encoder_, encodeHeaders(_, false)); - upstream_.reset(new HttpUpstream(callbacks_, hostname_)); + upstream_ = std::make_unique(callbacks_, hostname_); upstream_->setRequestEncoder(encoder_, true); } @@ -39,7 +41,7 @@ TEST_F(HttpUpstreamTest, WriteUpstream) { upstream_->encodeData(buffer2, true); // New upstream with no encoder - upstream_.reset(new HttpUpstream(callbacks_, hostname_)); + upstream_ = std::make_unique(callbacks_, hostname_); upstream_->encodeData(buffer2, true); } @@ -73,7 +75,7 @@ TEST_F(HttpUpstreamTest, ReadDisable) { EXPECT_TRUE(upstream_->readDisable(false)); // New upstream with no encoder - upstream_.reset(new HttpUpstream(callbacks_, hostname_)); + upstream_ = std::make_unique(callbacks_, hostname_); EXPECT_FALSE(upstream_->readDisable(true)); } diff --git a/test/common/upstream/cluster_factory_impl_test.cc b/test/common/upstream/cluster_factory_impl_test.cc index 3fba09d7c070d..dbeac5c6c75ba 100644 --- a/test/common/upstream/cluster_factory_impl_test.cc +++ b/test/common/upstream/cluster_factory_impl_test.cc @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -50,8 +51,8 @@ class TestStaticClusterFactory : public ClusterFactoryImplBase { class ClusterFactoryTestBase { protected: ClusterFactoryTestBase() : api_(Api::createApiForTest(stats_)) { - outlier_event_logger_.reset(new Outlier::MockEventLogger()); - dns_resolver_.reset(new Network::MockDnsResolver()); + outlier_event_logger_ = std::make_shared(); + dns_resolver_ = std::make_shared(); } NiceMock admin_; diff --git a/test/common/upstream/eds_test.cc b/test/common/upstream/eds_test.cc index 2f43b6b830b2e..23600bbfe0e5f 100644 --- a/test/common/upstream/eds_test.cc +++ b/test/common/upstream/eds_test.cc @@ -95,8 +95,8 @@ class EdsTest : public testing::Test { Envoy::Server::Configuration::TransportSocketFactoryContextImpl factory_context( admin_, ssl_context_manager_, *scope, cm_, local_info_, dispatcher_, random_, stats_, singleton_manager_, tls_, validation_visitor_, *api_); - cluster_.reset( - new EdsClusterImpl(eds_cluster_, runtime_, factory_context, std::move(scope), false)); + cluster_ = std::make_shared(eds_cluster_, runtime_, factory_context, + std::move(scope), false); EXPECT_EQ(initialize_phase, cluster_->initializePhase()); eds_callbacks_ = cm_.subscription_factory_.callbacks_; } diff --git a/test/common/upstream/health_checker_impl_test.cc b/test/common/upstream/health_checker_impl_test.cc index 489954dc0c883..c19007c768462 100644 --- a/test/common/upstream/health_checker_impl_test.cc +++ b/test/common/upstream/health_checker_impl_test.cc @@ -145,9 +145,9 @@ class HttpHealthCheckerImplTest : public testing::Test { codec_client_type: Http2 )EOF"; - health_checker_.reset(new TestHttpHealthCheckerImpl(*cluster_, parseHealthCheckFromV2Yaml(yaml), - dispatcher_, runtime_, random_, - HealthCheckEventLoggerPtr(event_logger_))); + health_checker_ = std::make_shared( + *cluster_, parseHealthCheckFromV2Yaml(yaml), dispatcher_, runtime_, random_, + HealthCheckEventLoggerPtr(event_logger_)); health_checker_->addHostCheckCompleteCb( [this](HostSharedPtr host, HealthTransition changed_state) -> void { onHostStatus(host, changed_state); @@ -169,9 +169,9 @@ class HttpHealthCheckerImplTest : public testing::Test { path: /healthcheck )EOF"; - health_checker_.reset(new TestHttpHealthCheckerImpl(*cluster_, parseHealthCheckFromV2Yaml(yaml), - dispatcher_, runtime_, random_, - HealthCheckEventLoggerPtr(event_logger_))); + health_checker_ = std::make_shared( + *cluster_, parseHealthCheckFromV2Yaml(yaml), dispatcher_, runtime_, random_, + HealthCheckEventLoggerPtr(event_logger_)); health_checker_->addHostCheckCompleteCb( [this](HostSharedPtr host, HealthTransition changed_state) -> void { onHostStatus(host, changed_state); @@ -192,9 +192,9 @@ class HttpHealthCheckerImplTest : public testing::Test { path: /healthcheck )EOF"; - health_checker_.reset(new TestHttpHealthCheckerImpl(*cluster_, parseHealthCheckFromV2Yaml(yaml), - dispatcher_, runtime_, random_, - HealthCheckEventLoggerPtr(event_logger_))); + health_checker_ = std::make_shared( + *cluster_, parseHealthCheckFromV2Yaml(yaml), dispatcher_, runtime_, random_, + HealthCheckEventLoggerPtr(event_logger_)); health_checker_->addHostCheckCompleteCb( [this](HostSharedPtr host, HealthTransition changed_state) -> void { onHostStatus(host, changed_state); @@ -215,9 +215,9 @@ class HttpHealthCheckerImplTest : public testing::Test { path: /healthcheck )EOF"; - health_checker_.reset(new TestHttpHealthCheckerImpl(*cluster_, parseHealthCheckFromV2Yaml(yaml), - dispatcher_, runtime_, random_, - HealthCheckEventLoggerPtr(event_logger_))); + health_checker_ = std::make_shared( + *cluster_, parseHealthCheckFromV2Yaml(yaml), dispatcher_, runtime_, random_, + HealthCheckEventLoggerPtr(event_logger_)); health_checker_->addHostCheckCompleteCb( [this](HostSharedPtr host, HealthTransition changed_state) -> void { onHostStatus(host, changed_state); @@ -238,9 +238,9 @@ class HttpHealthCheckerImplTest : public testing::Test { path: /healthcheck )EOF"; - health_checker_.reset(new TestHttpHealthCheckerImpl(*cluster_, parseHealthCheckFromV2Yaml(yaml), - dispatcher_, runtime_, random_, - HealthCheckEventLoggerPtr(event_logger_))); + health_checker_ = std::make_shared( + *cluster_, parseHealthCheckFromV2Yaml(yaml), dispatcher_, runtime_, random_, + HealthCheckEventLoggerPtr(event_logger_)); health_checker_->addHostCheckCompleteCb( [this](HostSharedPtr host, HealthTransition changed_state) -> void { onHostStatus(host, changed_state); @@ -262,9 +262,9 @@ class HttpHealthCheckerImplTest : public testing::Test { always_log_health_check_failures: true )EOF"; - health_checker_.reset(new TestHttpHealthCheckerImpl(*cluster_, parseHealthCheckFromV2Yaml(yaml), - dispatcher_, runtime_, random_, - HealthCheckEventLoggerPtr(event_logger_))); + health_checker_ = std::make_shared( + *cluster_, parseHealthCheckFromV2Yaml(yaml), dispatcher_, runtime_, random_, + HealthCheckEventLoggerPtr(event_logger_)); health_checker_->addHostCheckCompleteCb( [this](HostSharedPtr host, HealthTransition changed_state) -> void { onHostStatus(host, changed_state); @@ -283,9 +283,9 @@ class HttpHealthCheckerImplTest : public testing::Test { path: /healthcheck )EOF"; - health_checker_.reset(new TestHttpHealthCheckerImpl(*cluster_, parseHealthCheckFromV2Yaml(yaml), - dispatcher_, runtime_, random_, - HealthCheckEventLoggerPtr(event_logger_))); + health_checker_ = std::make_shared( + *cluster_, parseHealthCheckFromV2Yaml(yaml), dispatcher_, runtime_, random_, + HealthCheckEventLoggerPtr(event_logger_)); health_checker_->addHostCheckCompleteCb( [this](HostSharedPtr host, HealthTransition changed_state) -> void { onHostStatus(host, changed_state); @@ -309,9 +309,9 @@ class HttpHealthCheckerImplTest : public testing::Test { path: /healthcheck )EOF"; - health_checker_.reset(new TestHttpHealthCheckerImpl(*cluster_, parseHealthCheckFromV2Yaml(yaml), - dispatcher_, runtime_, random_, - HealthCheckEventLoggerPtr(event_logger_))); + health_checker_ = std::make_shared( + *cluster_, parseHealthCheckFromV2Yaml(yaml), dispatcher_, runtime_, random_, + HealthCheckEventLoggerPtr(event_logger_)); health_checker_->addHostCheckCompleteCb( [this](HostSharedPtr host, HealthTransition changed_state) -> void { onHostStatus(host, changed_state); @@ -331,9 +331,9 @@ class HttpHealthCheckerImplTest : public testing::Test { path: /healthcheck )EOF"; - health_checker_.reset(new TestHttpHealthCheckerImpl(*cluster_, parseHealthCheckFromV2Yaml(yaml), - dispatcher_, runtime_, random_, - HealthCheckEventLoggerPtr(event_logger_))); + health_checker_ = std::make_shared( + *cluster_, parseHealthCheckFromV2Yaml(yaml), dispatcher_, runtime_, random_, + HealthCheckEventLoggerPtr(event_logger_)); health_checker_->addHostCheckCompleteCb( [this](HostSharedPtr host, HealthTransition changed_state) -> void { onHostStatus(host, changed_state); @@ -354,9 +354,9 @@ class HttpHealthCheckerImplTest : public testing::Test { )EOF", prefix); - health_checker_.reset(new TestHttpHealthCheckerImpl(*cluster_, parseHealthCheckFromV2Yaml(yaml), - dispatcher_, runtime_, random_, - HealthCheckEventLoggerPtr(event_logger_))); + health_checker_ = std::make_shared( + *cluster_, parseHealthCheckFromV2Yaml(yaml), dispatcher_, runtime_, random_, + HealthCheckEventLoggerPtr(event_logger_)); health_checker_->addHostCheckCompleteCb( [this](HostSharedPtr host, HealthTransition changed_state) -> void { onHostStatus(host, changed_state); @@ -376,9 +376,9 @@ class HttpHealthCheckerImplTest : public testing::Test { path: /healthcheck )EOF"; - health_checker_.reset(new TestHttpHealthCheckerImpl(*cluster_, parseHealthCheckFromV2Yaml(yaml), - dispatcher_, runtime_, random_, - HealthCheckEventLoggerPtr(event_logger_))); + health_checker_ = std::make_shared( + *cluster_, parseHealthCheckFromV2Yaml(yaml), dispatcher_, runtime_, random_, + HealthCheckEventLoggerPtr(event_logger_)); health_checker_->addHostCheckCompleteCb( [this](HostSharedPtr host, HealthTransition changed_state) -> void { onHostStatus(host, changed_state); @@ -398,9 +398,9 @@ class HttpHealthCheckerImplTest : public testing::Test { path: /healthcheck )EOF"; - health_checker_.reset(new TestHttpHealthCheckerImpl(*cluster_, parseHealthCheckFromV2Yaml(yaml), - dispatcher_, runtime_, random_, - HealthCheckEventLoggerPtr(event_logger_))); + health_checker_ = std::make_shared( + *cluster_, parseHealthCheckFromV2Yaml(yaml), dispatcher_, runtime_, random_, + HealthCheckEventLoggerPtr(event_logger_)); health_checker_->addHostCheckCompleteCb( [this](HostSharedPtr host, HealthTransition changed_state) -> void { onHostStatus(host, changed_state); @@ -422,9 +422,9 @@ class HttpHealthCheckerImplTest : public testing::Test { path: /healthcheck )EOF"; - health_checker_.reset(new TestHttpHealthCheckerImpl(*cluster_, parseHealthCheckFromV2Yaml(yaml), - dispatcher_, runtime_, random_, - HealthCheckEventLoggerPtr(event_logger_))); + health_checker_ = std::make_shared( + *cluster_, parseHealthCheckFromV2Yaml(yaml), dispatcher_, runtime_, random_, + HealthCheckEventLoggerPtr(event_logger_)); health_checker_->addHostCheckCompleteCb( [this](HostSharedPtr host, HealthTransition changed_state) -> void { onHostStatus(host, changed_state); @@ -446,9 +446,9 @@ class HttpHealthCheckerImplTest : public testing::Test { )EOF", host); - health_checker_.reset(new TestHttpHealthCheckerImpl(*cluster_, parseHealthCheckFromV2Yaml(yaml), - dispatcher_, runtime_, random_, - HealthCheckEventLoggerPtr(event_logger_))); + health_checker_ = std::make_shared( + *cluster_, parseHealthCheckFromV2Yaml(yaml), dispatcher_, runtime_, random_, + HealthCheckEventLoggerPtr(event_logger_)); health_checker_->addHostCheckCompleteCb( [this](HostSharedPtr host, HealthTransition changed_state) -> void { onHostStatus(host, changed_state); @@ -521,9 +521,9 @@ class HttpHealthCheckerImplTest : public testing::Test { value: "%START_TIME(%s.%9f)%" )EOF"; - health_checker_.reset(new TestHttpHealthCheckerImpl(*cluster_, parseHealthCheckFromV2Yaml(yaml), - dispatcher_, runtime_, random_, - HealthCheckEventLoggerPtr(event_logger_))); + health_checker_ = std::make_shared( + *cluster_, parseHealthCheckFromV2Yaml(yaml), dispatcher_, runtime_, random_, + HealthCheckEventLoggerPtr(event_logger_)); health_checker_->addHostCheckCompleteCb( [this](HostSharedPtr host, HealthTransition changed_state) -> void { onHostStatus(host, changed_state); @@ -546,9 +546,9 @@ class HttpHealthCheckerImplTest : public testing::Test { request_headers_to_remove: ["user-agent"] )EOF"; - health_checker_.reset(new TestHttpHealthCheckerImpl(*cluster_, parseHealthCheckFromV2Yaml(yaml), - dispatcher_, runtime_, random_, - HealthCheckEventLoggerPtr(event_logger_))); + health_checker_ = std::make_shared( + *cluster_, parseHealthCheckFromV2Yaml(yaml), dispatcher_, runtime_, random_, + HealthCheckEventLoggerPtr(event_logger_)); health_checker_->addHostCheckCompleteCb( [this](HostSharedPtr host, HealthTransition changed_state) -> void { onHostStatus(host, changed_state); @@ -1026,9 +1026,9 @@ TEST_F(HttpHealthCheckerImplTest, ZeroRetryInterval) { path: /healthcheck )EOF"; - health_checker_.reset(new TestHttpHealthCheckerImpl(*cluster_, parseHealthCheckFromV2Yaml(yaml), - dispatcher_, runtime_, random_, - HealthCheckEventLoggerPtr(event_logger_))); + health_checker_ = std::make_shared( + *cluster_, parseHealthCheckFromV2Yaml(yaml), dispatcher_, runtime_, random_, + HealthCheckEventLoggerPtr(event_logger_)); health_checker_->addHostCheckCompleteCb( [this](HostSharedPtr host, HealthTransition changed_state) -> void { onHostStatus(host, changed_state); @@ -1096,9 +1096,9 @@ TEST_F(HttpHealthCheckerImplTest, TlsOptions) { EXPECT_CALL(*socket_factory, createTransportSocket(ApplicationProtocolListEq("http1"))); - health_checker_.reset(new TestHttpHealthCheckerImpl(*cluster_, parseHealthCheckFromV2Yaml(yaml), - dispatcher_, runtime_, random_, - HealthCheckEventLoggerPtr(event_logger_))); + health_checker_ = std::make_shared( + *cluster_, parseHealthCheckFromV2Yaml(yaml), dispatcher_, runtime_, random_, + HealthCheckEventLoggerPtr(event_logger_)); cluster_->prioritySet().getMockHostSet(0)->hosts_ = { makeTestHost(cluster_->info_, "tcp://127.0.0.1:80")}; @@ -2497,9 +2497,9 @@ class ProdHttpHealthCheckerTest : public HttpHealthCheckerImplTest { codec_client_type: Http2 )EOF"; - health_checker_.reset(new TestProdHttpHealthChecker(*cluster_, parseHealthCheckFromV2Yaml(yaml), - dispatcher_, runtime_, random_, - HealthCheckEventLoggerPtr(event_logger_))); + health_checker_ = std::make_shared( + *cluster_, parseHealthCheckFromV2Yaml(yaml), dispatcher_, runtime_, random_, + HealthCheckEventLoggerPtr(event_logger_)); health_checker_->addHostCheckCompleteCb( [this](HostSharedPtr host, HealthTransition changed_state) -> void { onHostStatus(host, changed_state); @@ -2520,9 +2520,9 @@ class ProdHttpHealthCheckerTest : public HttpHealthCheckerImplTest { path: /healthcheck )EOF"; - health_checker_.reset(new TestProdHttpHealthChecker(*cluster_, parseHealthCheckFromV2Yaml(yaml), - dispatcher_, runtime_, random_, - HealthCheckEventLoggerPtr(event_logger_))); + health_checker_ = std::make_shared( + *cluster_, parseHealthCheckFromV2Yaml(yaml), dispatcher_, runtime_, random_, + HealthCheckEventLoggerPtr(event_logger_)); health_checker_->addHostCheckCompleteCb( [this](HostSharedPtr host, HealthTransition changed_state) -> void { onHostStatus(host, changed_state); @@ -2555,9 +2555,9 @@ TEST_F(HttpHealthCheckerImplTest, DEPRECATED_FEATURE_TEST(Http1CodecClient)) { use_http2: false )EOF"; - health_checker_.reset(new TestHttpHealthCheckerImpl(*cluster_, parseHealthCheckFromV2Yaml(yaml), - dispatcher_, runtime_, random_, - HealthCheckEventLoggerPtr(event_logger_))); + health_checker_ = std::make_shared( + *cluster_, parseHealthCheckFromV2Yaml(yaml), dispatcher_, runtime_, random_, + HealthCheckEventLoggerPtr(event_logger_)); health_checker_->addHostCheckCompleteCb( [this](HostSharedPtr host, HealthTransition changed_state) -> void { onHostStatus(host, changed_state); @@ -2580,9 +2580,9 @@ TEST_F(HttpHealthCheckerImplTest, DEPRECATED_FEATURE_TEST(Http2CodecClient)) { use_http2: true )EOF"; - health_checker_.reset(new TestHttpHealthCheckerImpl(*cluster_, parseHealthCheckFromV2Yaml(yaml), - dispatcher_, runtime_, random_, - HealthCheckEventLoggerPtr(event_logger_))); + health_checker_ = std::make_shared( + *cluster_, parseHealthCheckFromV2Yaml(yaml), dispatcher_, runtime_, random_, + HealthCheckEventLoggerPtr(event_logger_)); health_checker_->addHostCheckCompleteCb( [this](HostSharedPtr host, HealthTransition changed_state) -> void { onHostStatus(host, changed_state); @@ -2927,9 +2927,9 @@ class TcpHealthCheckerImplTest : public testing::Test { - text: "02" )EOF"; - health_checker_.reset( - new TcpHealthCheckerImpl(*cluster_, parseHealthCheckFromV2Yaml(yaml.str()), dispatcher_, - runtime_, random_, HealthCheckEventLoggerPtr(event_logger_))); + health_checker_ = std::make_shared( + *cluster_, parseHealthCheckFromV2Yaml(yaml.str()), dispatcher_, runtime_, random_, + HealthCheckEventLoggerPtr(event_logger_)); } void setupNoData() { @@ -2941,9 +2941,9 @@ class TcpHealthCheckerImplTest : public testing::Test { tcp_health_check: {} )EOF"; - health_checker_.reset(new TcpHealthCheckerImpl(*cluster_, parseHealthCheckFromV2Yaml(yaml), - dispatcher_, runtime_, random_, - HealthCheckEventLoggerPtr(event_logger_))); + health_checker_ = std::make_shared( + *cluster_, parseHealthCheckFromV2Yaml(yaml), dispatcher_, runtime_, random_, + HealthCheckEventLoggerPtr(event_logger_)); } void setupDataDontReuseConnection() { @@ -2960,9 +2960,9 @@ class TcpHealthCheckerImplTest : public testing::Test { - text: "02" )EOF"; - health_checker_.reset(new TcpHealthCheckerImpl(*cluster_, parseHealthCheckFromV2Yaml(yaml), - dispatcher_, runtime_, random_, - HealthCheckEventLoggerPtr(event_logger_))); + health_checker_ = std::make_shared( + *cluster_, parseHealthCheckFromV2Yaml(yaml), dispatcher_, runtime_, random_, + HealthCheckEventLoggerPtr(event_logger_)); } void expectSessionCreate() { @@ -3532,9 +3532,9 @@ class GrpcHealthCheckerImplTestBase { void setupHC() { const auto config = createGrpcHealthCheckConfig(); - health_checker_.reset(new TestGrpcHealthCheckerImpl(*cluster_, config, dispatcher_, runtime_, - random_, - HealthCheckEventLoggerPtr(event_logger_))); + health_checker_ = std::make_shared( + *cluster_, config, dispatcher_, runtime_, random_, + HealthCheckEventLoggerPtr(event_logger_)); health_checker_->addHostCheckCompleteCb( [this](HostSharedPtr host, HealthTransition changed_state) -> void { onHostStatus(host, changed_state); @@ -3544,9 +3544,9 @@ class GrpcHealthCheckerImplTestBase { void setupHCWithUnhealthyThreshold(int value) { auto config = createGrpcHealthCheckConfig(); config.mutable_unhealthy_threshold()->set_value(value); - health_checker_.reset(new TestGrpcHealthCheckerImpl(*cluster_, config, dispatcher_, runtime_, - random_, - HealthCheckEventLoggerPtr(event_logger_))); + health_checker_ = std::make_shared( + *cluster_, config, dispatcher_, runtime_, random_, + HealthCheckEventLoggerPtr(event_logger_)); health_checker_->addHostCheckCompleteCb( [this](HostSharedPtr host, HealthTransition changed_state) -> void { onHostStatus(host, changed_state); @@ -3559,9 +3559,9 @@ class GrpcHealthCheckerImplTestBase { if (authority.has_value()) { config.mutable_grpc_health_check()->set_authority(authority.value()); } - health_checker_.reset(new TestGrpcHealthCheckerImpl(*cluster_, config, dispatcher_, runtime_, - random_, - HealthCheckEventLoggerPtr(event_logger_))); + health_checker_ = std::make_shared( + *cluster_, config, dispatcher_, runtime_, random_, + HealthCheckEventLoggerPtr(event_logger_)); health_checker_->addHostCheckCompleteCb( [this](HostSharedPtr host, HealthTransition changed_state) -> void { onHostStatus(host, changed_state); @@ -3571,9 +3571,9 @@ class GrpcHealthCheckerImplTestBase { void setupNoReuseConnectionHC() { auto config = createGrpcHealthCheckConfig(); config.mutable_reuse_connection()->set_value(false); - health_checker_.reset(new TestGrpcHealthCheckerImpl(*cluster_, config, dispatcher_, runtime_, - random_, - HealthCheckEventLoggerPtr(event_logger_))); + health_checker_ = std::make_shared( + *cluster_, config, dispatcher_, runtime_, random_, + HealthCheckEventLoggerPtr(event_logger_)); health_checker_->addHostCheckCompleteCb( [this](HostSharedPtr host, HealthTransition changed_state) -> void { onHostStatus(host, changed_state); @@ -3590,9 +3590,9 @@ class GrpcHealthCheckerImplTestBase { config.mutable_interval_jitter()->set_seconds(0); config.mutable_unhealthy_threshold()->set_value(3); config.mutable_healthy_threshold()->set_value(3); - health_checker_.reset(new TestGrpcHealthCheckerImpl(*cluster_, config, dispatcher_, runtime_, - random_, - HealthCheckEventLoggerPtr(event_logger_))); + health_checker_ = std::make_shared( + *cluster_, config, dispatcher_, runtime_, random_, + HealthCheckEventLoggerPtr(event_logger_)); health_checker_->addHostCheckCompleteCb( [this](HostSharedPtr host, HealthTransition changed_state) -> void { onHostStatus(host, changed_state); diff --git a/test/common/upstream/load_balancer_impl_test.cc b/test/common/upstream/load_balancer_impl_test.cc index 406cecd31f4b5..3ad095de9bc4b 100644 --- a/test/common/upstream/load_balancer_impl_test.cc +++ b/test/common/upstream/load_balancer_impl_test.cc @@ -531,11 +531,11 @@ class RoundRobinLoadBalancerTest : public LoadBalancerTestBase { public: void init(bool need_local_cluster) { if (need_local_cluster) { - local_priority_set_.reset(new PrioritySetImpl()); + local_priority_set_ = std::make_shared(); local_priority_set_->getOrCreateHostSet(0); } - lb_.reset(new RoundRobinLoadBalancer(priority_set_, local_priority_set_.get(), stats_, runtime_, - random_, common_config_)); + lb_ = std::make_shared(priority_set_, local_priority_set_.get(), stats_, + runtime_, random_, common_config_); } // Updates priority 0 with the given hosts and hosts_per_locality. @@ -1562,8 +1562,8 @@ INSTANTIATE_TEST_SUITE_P(PrimaryOrFailover, LeastRequestLoadBalancerTest, class RandomLoadBalancerTest : public LoadBalancerTestBase { public: void init() { - lb_.reset( - new RandomLoadBalancer(priority_set_, nullptr, stats_, runtime_, random_, common_config_)); + lb_ = std::make_shared(priority_set_, nullptr, stats_, runtime_, random_, + common_config_); } std::shared_ptr lb_; }; diff --git a/test/common/upstream/logical_dns_cluster_test.cc b/test/common/upstream/logical_dns_cluster_test.cc index 6a04fe274764e..74154fd825105 100644 --- a/test/common/upstream/logical_dns_cluster_test.cc +++ b/test/common/upstream/logical_dns_cluster_test.cc @@ -52,8 +52,8 @@ class LogicalDnsClusterTest : public testing::Test { Envoy::Server::Configuration::TransportSocketFactoryContextImpl factory_context( admin_, ssl_context_manager_, *scope, cm, local_info_, dispatcher_, random_, stats_store_, singleton_manager_, tls_, validation_visitor_, *api_); - cluster_.reset(new LogicalDnsCluster(cluster_config, runtime_, dns_resolver_, factory_context, - std::move(scope), false)); + cluster_ = std::make_shared(cluster_config, runtime_, dns_resolver_, + factory_context, std::move(scope), false); cluster_->prioritySet().addPriorityUpdateCb( [&](uint32_t, const HostVector&, const HostVector&) -> void { membership_updated_.ready(); diff --git a/test/common/upstream/original_dst_cluster_test.cc b/test/common/upstream/original_dst_cluster_test.cc index 608f4c31992c7..72fb82425b029 100644 --- a/test/common/upstream/original_dst_cluster_test.cc +++ b/test/common/upstream/original_dst_cluster_test.cc @@ -79,8 +79,8 @@ class OriginalDstClusterTest : public testing::Test { Envoy::Server::Configuration::TransportSocketFactoryContextImpl factory_context( admin_, ssl_context_manager_, *scope, cm, local_info_, dispatcher_, random_, stats_store_, singleton_manager_, tls_, validation_visitor_, *api_); - cluster_.reset( - new OriginalDstCluster(cluster_config, runtime_, factory_context, std::move(scope), false)); + cluster_ = std::make_shared(cluster_config, runtime_, factory_context, + std::move(scope), false); cluster_->prioritySet().addPriorityUpdateCb( [&](uint32_t, const HostVector&, const HostVector&) -> void { membership_updated_.ready(); diff --git a/test/common/upstream/subset_lb_test.cc b/test/common/upstream/subset_lb_test.cc index 39df196afb9ae..5c4cf7c5faf5b 100644 --- a/test/common/upstream/subset_lb_test.cc +++ b/test/common/upstream/subset_lb_test.cc @@ -187,9 +187,9 @@ class SubsetLoadBalancerTest : public testing::TestWithParam { configureHostSet(failover_host_metadata, *priority_set_.getMockHostSet(1)); } - lb_.reset(new SubsetLoadBalancer(lb_type_, priority_set_, nullptr, stats_, stats_store_, - runtime_, random_, subset_info_, ring_hash_lb_config_, - least_request_lb_config_, common_config_)); + lb_ = std::make_shared( + lb_type_, priority_set_, nullptr, stats_, stats_store_, runtime_, random_, subset_info_, + ring_hash_lb_config_, least_request_lb_config_, common_config_); } void zoneAwareInit(const std::vector& host_metadata_per_locality, @@ -214,7 +214,7 @@ class SubsetLoadBalancerTest : public testing::TestWithParam { host_set_.healthy_hosts_ = host_set_.hosts_; host_set_.healthy_hosts_per_locality_ = host_set_.hosts_per_locality_; - local_hosts_.reset(new HostVector()); + local_hosts_ = std::make_shared(); std::vector local_hosts_per_locality_vector; for (const auto& local_host_metadata : local_host_metadata_per_locality) { HostVector local_locality_hosts; @@ -236,9 +236,9 @@ class SubsetLoadBalancerTest : public testing::TestWithParam { std::make_shared(), HostsPerLocalityImpl::empty()), {}, {}, {}, absl::nullopt); - lb_.reset(new SubsetLoadBalancer( + lb_ = std::make_shared( lb_type_, priority_set_, &local_priority_set_, stats_, stats_store_, runtime_, random_, - subset_info_, ring_hash_lb_config_, least_request_lb_config_, common_config_)); + subset_info_, ring_hash_lb_config_, least_request_lb_config_, common_config_); } HostSharedPtr makeHost(const std::string& url, const HostMetadata& metadata) { @@ -1291,9 +1291,9 @@ TEST_F(SubsetLoadBalancerTest, IgnoresHostsWithoutMetadata) { host_set_.healthy_hosts_ = host_set_.hosts_; host_set_.healthy_hosts_per_locality_ = host_set_.hosts_per_locality_; - lb_.reset(new SubsetLoadBalancer(lb_type_, priority_set_, nullptr, stats_, stats_store_, runtime_, - random_, subset_info_, ring_hash_lb_config_, - least_request_lb_config_, common_config_)); + lb_ = std::make_shared(lb_type_, priority_set_, nullptr, stats_, stats_store_, + runtime_, random_, subset_info_, ring_hash_lb_config_, + least_request_lb_config_, common_config_); TestLoadBalancerContext context_version({{"version", "1.0"}}); @@ -1710,9 +1710,9 @@ TEST_F(SubsetLoadBalancerTest, DisabledLocalityWeightAwareness) { }, host_set_, {1, 100}); - lb_.reset(new SubsetLoadBalancer(lb_type_, priority_set_, nullptr, stats_, stats_store_, runtime_, - random_, subset_info_, ring_hash_lb_config_, - least_request_lb_config_, common_config_)); + lb_ = std::make_shared(lb_type_, priority_set_, nullptr, stats_, stats_store_, + runtime_, random_, subset_info_, ring_hash_lb_config_, + least_request_lb_config_, common_config_); TestLoadBalancerContext context({{"version", "1.1"}}); @@ -1733,9 +1733,9 @@ TEST_F(SubsetLoadBalancerTest, DoesNotCheckHostHealth) { EXPECT_CALL(*mock_host, weight()).WillRepeatedly(Return(1)); - lb_.reset(new SubsetLoadBalancer(lb_type_, priority_set_, nullptr, stats_, stats_store_, runtime_, - random_, subset_info_, ring_hash_lb_config_, - least_request_lb_config_, common_config_)); + lb_ = std::make_shared(lb_type_, priority_set_, nullptr, stats_, stats_store_, + runtime_, random_, subset_info_, ring_hash_lb_config_, + least_request_lb_config_, common_config_); } TEST_F(SubsetLoadBalancerTest, EnabledLocalityWeightAwareness) { @@ -1756,9 +1756,9 @@ TEST_F(SubsetLoadBalancerTest, EnabledLocalityWeightAwareness) { }, host_set_, {1, 100}); - lb_.reset(new SubsetLoadBalancer(lb_type_, priority_set_, nullptr, stats_, stats_store_, runtime_, - random_, subset_info_, ring_hash_lb_config_, - least_request_lb_config_, common_config_)); + lb_ = std::make_shared(lb_type_, priority_set_, nullptr, stats_, stats_store_, + runtime_, random_, subset_info_, ring_hash_lb_config_, + least_request_lb_config_, common_config_); TestLoadBalancerContext context({{"version", "1.1"}}); @@ -1791,9 +1791,9 @@ TEST_F(SubsetLoadBalancerTest, EnabledScaleLocalityWeights) { }, host_set_, {50, 50}); - lb_.reset(new SubsetLoadBalancer(lb_type_, priority_set_, nullptr, stats_, stats_store_, runtime_, - random_, subset_info_, ring_hash_lb_config_, - least_request_lb_config_, common_config_)); + lb_ = std::make_shared(lb_type_, priority_set_, nullptr, stats_, stats_store_, + runtime_, random_, subset_info_, ring_hash_lb_config_, + least_request_lb_config_, common_config_); TestLoadBalancerContext context({{"version", "1.1"}}); // Since we scale the locality weights by number of hosts removed, we expect to see the second @@ -1836,9 +1836,9 @@ TEST_F(SubsetLoadBalancerTest, EnabledScaleLocalityWeightsRounding) { }, host_set_, {2, 2}); - lb_.reset(new SubsetLoadBalancer(lb_type_, priority_set_, nullptr, stats_, stats_store_, runtime_, - random_, subset_info_, ring_hash_lb_config_, - least_request_lb_config_, common_config_)); + lb_ = std::make_shared(lb_type_, priority_set_, nullptr, stats_, stats_store_, + runtime_, random_, subset_info_, ring_hash_lb_config_, + least_request_lb_config_, common_config_); TestLoadBalancerContext context({{"version", "1.0"}}); // We expect to see a 33/66 split because 2 * 1 / 2 = 1 and 2 * 3 / 4 = 1.5 -> 2 @@ -1868,9 +1868,9 @@ TEST_F(SubsetLoadBalancerTest, ScaleLocalityWeightsWithNoLocalityWeights) { }, host_set_); - lb_.reset(new SubsetLoadBalancer(lb_type_, priority_set_, nullptr, stats_, stats_store_, runtime_, - random_, subset_info_, ring_hash_lb_config_, - least_request_lb_config_, common_config_)); + lb_ = std::make_shared(lb_type_, priority_set_, nullptr, stats_, stats_store_, + runtime_, random_, subset_info_, ring_hash_lb_config_, + least_request_lb_config_, common_config_); } TEST_P(SubsetLoadBalancerTest, GaugesUpdatedOnDestroy) { diff --git a/test/extensions/clusters/redis/redis_cluster_test.cc b/test/extensions/clusters/redis/redis_cluster_test.cc index e01bc47bb62e4..27fabee1128ce 100644 --- a/test/extensions/clusters/redis/redis_cluster_test.cc +++ b/test/extensions/clusters/redis/redis_cluster_test.cc @@ -101,12 +101,12 @@ class RedisClusterTest : public testing::Test, ProtobufWkt::Struct::default_instance(), ProtobufMessage::getStrictValidationVisitor(), config); cluster_callback_ = std::make_shared>(); - cluster_.reset(new RedisCluster( + cluster_ = std::make_shared( cluster_config, TestUtility::downcastAndValidate( config), *this, cm, runtime_, *api_, dns_resolver_, factory_context, std::move(scope), false, - cluster_callback_)); + cluster_callback_); // This allows us to create expectation on cluster slot response without waiting for // makeRequest. pool_callbacks_ = &cluster_->redis_discovery_session_; diff --git a/test/extensions/common/wasm/wasm_vm_test.cc b/test/extensions/common/wasm/wasm_vm_test.cc index c206994ef6e1d..1cc49f42b2d8a 100644 --- a/test/extensions/common/wasm/wasm_vm_test.cc +++ b/test/extensions/common/wasm/wasm_vm_test.cc @@ -114,10 +114,10 @@ MockHostFunctions* g_host_functions; void pong(void*, Word value) { g_host_functions->pong(convertWordToUint32(value)); } -Word random(void*) { return Word(g_host_functions->random()); } +Word random(void*) { return {g_host_functions->random()}; } // pong() with wrong number of arguments. -void bad_pong1(void*) { return; } +void bad_pong1(void*) {} // pong() with wrong return type. Word bad_pong2(void*, Word) { return 2; } diff --git a/test/extensions/filters/http/adaptive_concurrency/controller/gradient_controller_test.cc b/test/extensions/filters/http/adaptive_concurrency/controller/gradient_controller_test.cc index a087cf223d5f8..a6e5777dbbc7c 100644 --- a/test/extensions/filters/http/adaptive_concurrency/controller/gradient_controller_test.cc +++ b/test/extensions/filters/http/adaptive_concurrency/controller/gradient_controller_test.cc @@ -19,9 +19,6 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -using testing::AllOf; -using testing::Ge; -using testing::Le; using testing::NiceMock; using testing::Return; diff --git a/test/extensions/filters/http/common/compressor/compressor_filter_test.cc b/test/extensions/filters/http/common/compressor/compressor_filter_test.cc index 2d04b8d22bf7e..a82c86444d0a2 100644 --- a/test/extensions/filters/http/common/compressor/compressor_filter_test.cc +++ b/test/extensions/filters/http/common/compressor/compressor_filter_test.cc @@ -1,3 +1,5 @@ +#include + #include "envoy/extensions/filters/http/compressor/v3/compressor.pb.h" #include "common/protobuf/utility.h" @@ -90,7 +92,8 @@ class CompressorFilterTest : public testing::Test { void setUpFilter(std::string&& json) { envoy::extensions::filters::http::compressor::v3::Compressor compressor; TestUtility::loadFromJson(json, compressor); - config_.reset(new MockCompressorFilterConfig(compressor, "test.", stats_, runtime_, "test")); + config_ = + std::make_shared(compressor, "test.", stats_, runtime_, "test"); filter_ = std::make_unique(config_); filter_->setEncoderFilterCallbacks(encoder_callbacks_); } @@ -350,7 +353,8 @@ TEST_F(CompressorFilterTest, IsAcceptEncodingAllowed) { envoy::extensions::filters::http::compressor::v3::Compressor compressor; TestUtility::loadFromJson("{}", compressor); CompressorFilterConfigSharedPtr config2; - config2.reset(new MockCompressorFilterConfig(compressor, "test2.", stats, runtime, "test2")); + config2 = + std::make_shared(compressor, "test2.", stats, runtime, "test2"); std::unique_ptr filter2 = std::make_unique(config2); NiceMock decoder_callbacks; filter2->setDecoderFilterCallbacks(decoder_callbacks); @@ -373,7 +377,8 @@ TEST_F(CompressorFilterTest, IsAcceptEncodingAllowed) { envoy::extensions::filters::http::compressor::v3::Compressor compressor; TestUtility::loadFromJson("{}", compressor); CompressorFilterConfigSharedPtr config2; - config2.reset(new MockCompressorFilterConfig(compressor, "test2.", stats, runtime, "gzip")); + config2 = + std::make_shared(compressor, "test2.", stats, runtime, "gzip"); std::unique_ptr gzip_filter = std::make_unique(config2); NiceMock decoder_callbacks; gzip_filter->setDecoderFilterCallbacks(decoder_callbacks); @@ -392,7 +397,8 @@ TEST_F(CompressorFilterTest, IsAcceptEncodingAllowed) { envoy::extensions::filters::http::compressor::v3::Compressor compressor; TestUtility::loadFromJson("{}", compressor); CompressorFilterConfigSharedPtr config2; - config2.reset(new MockCompressorFilterConfig(compressor, "test2.", stats, runtime, "test")); + config2 = + std::make_shared(compressor, "test2.", stats, runtime, "test"); std::unique_ptr filter2 = std::make_unique(config2); NiceMock decoder_callbacks; filter2->setDecoderFilterCallbacks(decoder_callbacks); @@ -411,7 +417,8 @@ TEST_F(CompressorFilterTest, IsAcceptEncodingAllowed) { envoy::extensions::filters::http::compressor::v3::Compressor compressor; TestUtility::loadFromJson("{}", compressor); CompressorFilterConfigSharedPtr config2; - config2.reset(new MockCompressorFilterConfig(compressor, "test2.", stats, runtime, "test")); + config2 = + std::make_shared(compressor, "test2.", stats, runtime, "test"); std::unique_ptr filter2 = std::make_unique(config2); NiceMock decoder_callbacks; filter2->setDecoderFilterCallbacks(decoder_callbacks); @@ -430,10 +437,12 @@ TEST_F(CompressorFilterTest, IsAcceptEncodingAllowed) { envoy::extensions::filters::http::compressor::v3::Compressor compressor; TestUtility::loadFromJson("{}", compressor); CompressorFilterConfigSharedPtr config1; - config1.reset(new MockCompressorFilterConfig(compressor, "test1.", stats, runtime, "test1")); + config1 = + std::make_shared(compressor, "test1.", stats, runtime, "test1"); std::unique_ptr filter1 = std::make_unique(config1); CompressorFilterConfigSharedPtr config2; - config2.reset(new MockCompressorFilterConfig(compressor, "test2.", stats, runtime, "test2")); + config2 = + std::make_shared(compressor, "test2.", stats, runtime, "test2"); std::unique_ptr filter2 = std::make_unique(config2); NiceMock decoder_callbacks; filter1->setDecoderFilterCallbacks(decoder_callbacks); @@ -458,10 +467,12 @@ TEST_F(CompressorFilterTest, IsAcceptEncodingAllowed) { envoy::extensions::filters::http::compressor::v3::Compressor compressor; TestUtility::loadFromJson("{}", compressor); CompressorFilterConfigSharedPtr config1; - config1.reset(new MockCompressorFilterConfig(compressor, "test1.", stats, runtime, "test1")); + config1 = + std::make_shared(compressor, "test1.", stats, runtime, "test1"); std::unique_ptr filter1 = std::make_unique(config1); CompressorFilterConfigSharedPtr config2; - config2.reset(new MockCompressorFilterConfig(compressor, "test2.", stats, runtime, "test2")); + config2 = + std::make_shared(compressor, "test2.", stats, runtime, "test2"); std::unique_ptr filter2 = std::make_unique(config2); NiceMock decoder_callbacks; filter1->setDecoderFilterCallbacks(decoder_callbacks); diff --git a/test/extensions/filters/http/common/fuzz/uber_filter.h b/test/extensions/filters/http/common/fuzz/uber_filter.h index 260e4476cb014..2f97166f60a7c 100644 --- a/test/extensions/filters/http/common/fuzz/uber_filter.h +++ b/test/extensions/filters/http/common/fuzz/uber_filter.h @@ -75,7 +75,7 @@ class UberFilterFuzzer { headers.setHost("foo.com"); } - if (data.data().size() == 0 && !data.has_trailers()) { + if (data.data().empty() && !data.has_trailers()) { end_stream = true; } ENVOY_LOG_MISC(debug, "Decoding headers: {} ", data.headers().DebugString()); @@ -126,8 +126,8 @@ class UberFilterFuzzer { } void reset() { - if (filter_.get() != nullptr) { - filter_.get()->onDestroy(); + if (filter_ != nullptr) { + filter_->onDestroy(); } filter_.reset(); } diff --git a/test/extensions/filters/http/fault/fault_filter_test.cc b/test/extensions/filters/http/fault/fault_filter_test.cc index eb83202d83c85..0de6912992aa6 100644 --- a/test/extensions/filters/http/fault/fault_filter_test.cc +++ b/test/extensions/filters/http/fault/fault_filter_test.cc @@ -128,7 +128,7 @@ class FaultFilterTest : public testing::Test { const std::string v2_empty_fault_config_yaml = "{}"; void SetUpTest(const envoy::extensions::filters::http::fault::v3::HTTPFault fault) { - config_.reset(new FaultFilterConfig(fault, runtime_, "prefix.", stats_, time_system_)); + config_ = std::make_shared(fault, runtime_, "prefix.", stats_, time_system_); filter_ = std::make_unique(config_); filter_->setDecoderFilterCallbacks(decoder_filter_callbacks_); filter_->setEncoderFilterCallbacks(encoder_filter_callbacks_); diff --git a/test/extensions/filters/http/grpc_json_transcoder/grpc_json_transcoder_integration_test.cc b/test/extensions/filters/http/grpc_json_transcoder/grpc_json_transcoder_integration_test.cc index 4b6cd69535df9..f396b6704584b 100644 --- a/test/extensions/filters/http/grpc_json_transcoder/grpc_json_transcoder_integration_test.cc +++ b/test/extensions/filters/http/grpc_json_transcoder/grpc_json_transcoder_integration_test.cc @@ -12,7 +12,6 @@ #include "gtest/gtest.h" using Envoy::Protobuf::TextFormat; -using Envoy::Protobuf::util::MessageDifferencer; using Envoy::ProtobufUtil::Status; using Envoy::ProtobufUtil::error::Code; using Envoy::ProtobufWkt::Empty; diff --git a/test/extensions/filters/http/grpc_json_transcoder/http_body_utils_test.cc b/test/extensions/filters/http/grpc_json_transcoder/http_body_utils_test.cc index f89d0f66936f4..1446c4d8874d0 100644 --- a/test/extensions/filters/http/grpc_json_transcoder/http_body_utils_test.cc +++ b/test/extensions/filters/http/grpc_json_transcoder/http_body_utils_test.cc @@ -16,7 +16,7 @@ namespace { class HttpBodyUtilsTest : public testing::Test { public: - HttpBodyUtilsTest() {} + HttpBodyUtilsTest() = default; template void basicTest(const std::string& content, const std::string& content_type, diff --git a/test/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter_test.cc b/test/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter_test.cc index 613b9acaa7a26..74513d9c0c7d8 100644 --- a/test/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter_test.cc +++ b/test/extensions/filters/http/grpc_json_transcoder/json_transcoder_filter_test.cc @@ -25,8 +25,6 @@ using testing::_; using testing::Invoke; using testing::NiceMock; -using Envoy::Protobuf::MethodDescriptor; - using Envoy::Protobuf::FileDescriptorProto; using Envoy::Protobuf::FileDescriptorSet; using Envoy::Protobuf::util::MessageDifferencer; diff --git a/test/extensions/filters/http/gzip/gzip_filter_test.cc b/test/extensions/filters/http/gzip/gzip_filter_test.cc index cb4c451a01935..24f715b569e7f 100644 --- a/test/extensions/filters/http/gzip/gzip_filter_test.cc +++ b/test/extensions/filters/http/gzip/gzip_filter_test.cc @@ -41,7 +41,7 @@ class GzipFilterTest : public testing::Test { Json::ObjectSharedPtr config = Json::Factory::loadFromString(json); envoy::extensions::filters::http::gzip::v3::Gzip gzip; TestUtility::loadFromJson(json, gzip); - config_.reset(new GzipFilterConfig(gzip, "test.", stats_, runtime_)); + config_ = std::make_shared(gzip, "test.", stats_, runtime_); filter_ = std::make_unique(config_); filter_->setEncoderFilterCallbacks(encoder_callbacks_); filter_->setDecoderFilterCallbacks(decoder_callbacks_); diff --git a/test/extensions/filters/http/header_to_metadata/header_to_metadata_filter_test.cc b/test/extensions/filters/http/header_to_metadata/header_to_metadata_filter_test.cc index 3ac11b3e98268..2dc2c3ec845eb 100644 --- a/test/extensions/filters/http/header_to_metadata/header_to_metadata_filter_test.cc +++ b/test/extensions/filters/http/header_to_metadata/header_to_metadata_filter_test.cc @@ -1,3 +1,5 @@ +#include + #include "envoy/extensions/filters/http/header_to_metadata/v3/header_to_metadata.pb.h" #include "common/common/base64.h" @@ -41,8 +43,8 @@ class HeaderToMetadataTest : public testing::Test { void initializeFilter(const std::string& yaml) { envoy::extensions::filters::http::header_to_metadata::v3::Config config; TestUtility::loadFromYaml(yaml, config); - config_.reset(new Config(config)); - filter_.reset(new HeaderToMetadataFilter(config_)); + config_ = std::make_shared(config); + filter_ = std::make_shared(config_); filter_->setDecoderFilterCallbacks(decoder_callbacks_); filter_->setEncoderFilterCallbacks(encoder_callbacks_); } diff --git a/test/extensions/filters/http/health_check/health_check_test.cc b/test/extensions/filters/http/health_check/health_check_test.cc index c24e3a418c417..54f5306cdb477 100644 --- a/test/extensions/filters/http/health_check/health_check_test.cc +++ b/test/extensions/filters/http/health_check/health_check_test.cc @@ -37,7 +37,8 @@ class HealthCheckFilterTest : public testing::Test { if (caching) { cache_timer_ = new Event::MockTimer(&dispatcher_); EXPECT_CALL(*cache_timer_, enableTimer(_, _)); - cache_manager_.reset(new HealthCheckCacheManager(dispatcher_, std::chrono::milliseconds(1))); + cache_manager_ = + std::make_shared(dispatcher_, std::chrono::milliseconds(1)); } prepareFilter(pass_through); diff --git a/test/extensions/filters/http/ip_tagging/ip_tagging_filter_test.cc b/test/extensions/filters/http/ip_tagging/ip_tagging_filter_test.cc index dc1a01f110152..e99f427275a8b 100644 --- a/test/extensions/filters/http/ip_tagging/ip_tagging_filter_test.cc +++ b/test/extensions/filters/http/ip_tagging/ip_tagging_filter_test.cc @@ -45,7 +45,7 @@ request_type: internal void initializeFilter(const std::string& yaml) { envoy::extensions::filters::http::ip_tagging::v3::IPTagging config; TestUtility::loadFromYaml(yaml, config); - config_.reset(new IpTaggingFilterConfig(config, "prefix.", stats_, runtime_)); + config_ = std::make_shared(config, "prefix.", stats_, runtime_); filter_ = std::make_unique(config_); filter_->setDecoderFilterCallbacks(filter_callbacks_); } diff --git a/test/extensions/filters/http/jwt_authn/filter_test.cc b/test/extensions/filters/http/jwt_authn/filter_test.cc index b920bb2ef77f6..9881cd25bab20 100644 --- a/test/extensions/filters/http/jwt_authn/filter_test.cc +++ b/test/extensions/filters/http/jwt_authn/filter_test.cc @@ -10,7 +10,6 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -using envoy::extensions::filters::http::jwt_authn::v3::JwtAuthentication; using ::google::jwt_verify::Status; using testing::_; diff --git a/test/extensions/filters/http/lua/lua_filter_test.cc b/test/extensions/filters/http/lua/lua_filter_test.cc index 8de472b120ab0..3d2e35eb3d0ee 100644 --- a/test/extensions/filters/http/lua/lua_filter_test.cc +++ b/test/extensions/filters/http/lua/lua_filter_test.cc @@ -71,7 +71,7 @@ class LuaHttpFilterTest : public testing::Test { ~LuaHttpFilterTest() override { filter_->onDestroy(); } void setup(const std::string& lua_code) { - config_.reset(new FilterConfig(lua_code, tls_, cluster_manager_)); + config_ = std::make_shared(lua_code, tls_, cluster_manager_); setupFilter(); } diff --git a/test/extensions/filters/http/ratelimit/ratelimit_test.cc b/test/extensions/filters/http/ratelimit/ratelimit_test.cc index 2bfd0e1cc0ee3..625801433f743 100644 --- a/test/extensions/filters/http/ratelimit/ratelimit_test.cc +++ b/test/extensions/filters/http/ratelimit/ratelimit_test.cc @@ -54,8 +54,8 @@ class HttpRateLimitFilterTest : public testing::Test { envoy::extensions::filters::http::ratelimit::v3::RateLimit proto_config{}; TestUtility::loadFromYaml(yaml, proto_config); - config_.reset( - new FilterConfig(proto_config, local_info_, stats_store_, runtime_, http_context_)); + config_ = std::make_shared(proto_config, local_info_, stats_store_, runtime_, + http_context_); client_ = new Filters::Common::RateLimit::MockClient(); filter_ = std::make_unique(config_, Filters::Common::RateLimit::ClientPtr{client_}); diff --git a/test/extensions/filters/http/router/auto_sni_integration_test.cc b/test/extensions/filters/http/router/auto_sni_integration_test.cc index 95724d818be1b..9a7770c353c31 100644 --- a/test/extensions/filters/http/router/auto_sni_integration_test.cc +++ b/test/extensions/filters/http/router/auto_sni_integration_test.cc @@ -97,7 +97,7 @@ TEST_P(AutoSniIntegrationTest, PassingNotDNS) { const Extensions::TransportSockets::Tls::SslSocketInfo* ssl_socket = dynamic_cast( fake_upstream_connection_->connection().ssl().get()); - EXPECT_STREQ(NULL, SSL_get_servername(ssl_socket->rawSslForTest(), TLSEXT_NAMETYPE_host_name)); + EXPECT_STREQ(nullptr, SSL_get_servername(ssl_socket->rawSslForTest(), TLSEXT_NAMETYPE_host_name)); } TEST_P(AutoSniIntegrationTest, PassingHostWithoutPort) { diff --git a/test/extensions/filters/listener/proxy_protocol/proxy_protocol_test.cc b/test/extensions/filters/listener/proxy_protocol/proxy_protocol_test.cc index 81c03672637bd..6efd2b9639a6f 100644 --- a/test/extensions/filters/listener/proxy_protocol/proxy_protocol_test.cc +++ b/test/extensions/filters/listener/proxy_protocol/proxy_protocol_test.cc @@ -77,9 +77,7 @@ class ProxyProtocolTest : public testing::TestWithParamconnect(); if (read) { - read_filter_.reset(new NiceMock()); + read_filter_ = std::make_shared>(); EXPECT_CALL(factory_, createNetworkFilterChain(_, _)) .WillOnce(Invoke([&](Network::Connection& connection, const std::vector&) -> bool { @@ -1026,9 +1024,7 @@ class WildcardProxyProtocolTest : public testing::TestWithParamconnect(); - read_filter_.reset(new NiceMock()); + read_filter_ = std::make_shared>(); EXPECT_CALL(factory_, createNetworkFilterChain(_, _)) .WillOnce(Invoke([&](Network::Connection& connection, const std::vector&) -> bool { diff --git a/test/extensions/filters/network/common/redis/client_impl_test.cc b/test/extensions/filters/network/common/redis/client_impl_test.cc index 044e003a12215..c9028a1da42ac 100644 --- a/test/extensions/filters/network/common/redis/client_impl_test.cc +++ b/test/extensions/filters/network/common/redis/client_impl_test.cc @@ -25,7 +25,6 @@ using testing::Invoke; using testing::Property; using testing::Ref; using testing::Return; -using testing::ReturnRef; using testing::SaveArg; namespace Envoy { diff --git a/test/extensions/filters/network/dubbo_proxy/mocks.cc b/test/extensions/filters/network/dubbo_proxy/mocks.cc index 13565441e6430..4cd21e654dc9f 100644 --- a/test/extensions/filters/network/dubbo_proxy/mocks.cc +++ b/test/extensions/filters/network/dubbo_proxy/mocks.cc @@ -62,7 +62,7 @@ MockDecoderFilter::MockDecoderFilter() { MockDecoderFilter::~MockDecoderFilter() = default; MockDecoderFilterCallbacks::MockDecoderFilterCallbacks() { - route_.reset(new NiceMock()); + route_ = std::make_shared>(); ON_CALL(*this, streamId()).WillByDefault(Return(stream_id_)); ON_CALL(*this, connection()).WillByDefault(Return(&connection_)); @@ -80,7 +80,7 @@ MockEncoderFilter::MockEncoderFilter() { MockEncoderFilter::~MockEncoderFilter() = default; MockEncoderFilterCallbacks::MockEncoderFilterCallbacks() { - route_.reset(new NiceMock()); + route_ = std::make_shared>(); ON_CALL(*this, streamId()).WillByDefault(Return(stream_id_)); ON_CALL(*this, connection()).WillByDefault(Return(&connection_)); diff --git a/test/extensions/filters/network/dubbo_proxy/router_test.cc b/test/extensions/filters/network/dubbo_proxy/router_test.cc index 13796ab9fead3..e21148d3d7436 100644 --- a/test/extensions/filters/network/dubbo_proxy/router_test.cc +++ b/test/extensions/filters/network/dubbo_proxy/router_test.cc @@ -1,3 +1,5 @@ +#include + #include "extensions/filters/network/dubbo_proxy/app_exception.h" #include "extensions/filters/network/dubbo_proxy/dubbo_hessian2_serializer_impl.h" #include "extensions/filters/network/dubbo_proxy/message_impl.h" @@ -93,7 +95,7 @@ class DubboRouterTestBase { void initializeMetadata(MessageType msg_type) { msg_type_ = msg_type; - metadata_.reset(new MessageMetadata()); + metadata_ = std::make_shared(); metadata_->setMessageType(msg_type_); metadata_->setRequestId(1); diff --git a/test/extensions/filters/network/ext_authz/ext_authz_test.cc b/test/extensions/filters/network/ext_authz/ext_authz_test.cc index 6f9f6b356a711..47a208dc8c3bd 100644 --- a/test/extensions/filters/network/ext_authz/ext_authz_test.cc +++ b/test/extensions/filters/network/ext_authz/ext_authz_test.cc @@ -50,7 +50,7 @@ class ExtAuthzFilterTest : public testing::Test { envoy::extensions::filters::network::ext_authz::v3::ExtAuthz proto_config{}; TestUtility::loadFromJson(json, proto_config); - config_.reset(new Config(proto_config, stats_store_)); + config_ = std::make_shared(proto_config, stats_store_); client_ = new Filters::Common::ExtAuthz::MockClient(); filter_ = std::make_unique(config_, Filters::Common::ExtAuthz::ClientPtr{client_}); filter_->initializeReadFilterCallbacks(filter_callbacks_); diff --git a/test/extensions/filters/network/http_connection_manager/config_test.cc b/test/extensions/filters/network/http_connection_manager/config_test.cc index f0e727d08433d..5e9d06d239166 100644 --- a/test/extensions/filters/network/http_connection_manager/config_test.cc +++ b/test/extensions/filters/network/http_connection_manager/config_test.cc @@ -28,7 +28,6 @@ using testing::Eq; using testing::NotNull; using testing::Pointee; using testing::Return; -using testing::ReturnRef; using testing::WhenDynamicCastTo; namespace Envoy { diff --git a/test/extensions/filters/network/mongo_proxy/proxy_test.cc b/test/extensions/filters/network/mongo_proxy/proxy_test.cc index 52f048d592756..71df3fb3d7d7e 100644 --- a/test/extensions/filters/network/mongo_proxy/proxy_test.cc +++ b/test/extensions/filters/network/mongo_proxy/proxy_test.cc @@ -75,7 +75,7 @@ class MongoProxyFilterTest : public testing::Test { .WillRepeatedly(ReturnRef(stream_info_)); EXPECT_CALL(log_manager_, createAccessLog(_)).WillOnce(Return(file_)); - access_log_.reset(new AccessLog("test", log_manager_, dispatcher_.timeSource())); + access_log_ = std::make_shared("test", log_manager_, dispatcher_.timeSource()); } void initializeFilter(bool emit_dynamic_metadata = false) { @@ -96,7 +96,7 @@ class MongoProxyFilterTest : public testing::Test { fault.mutable_percentage()->set_denominator(envoy::type::v3::FractionalPercent::HUNDRED); fault.mutable_fixed_delay()->CopyFrom(Protobuf::util::TimeUtil::MillisecondsToDuration(10)); - fault_config_.reset(new Filters::Common::Fault::FaultDelayConfig(fault)); + fault_config_ = std::make_shared(fault); EXPECT_CALL(runtime_.snapshot_, featureEnabled("mongo.fault.fixed_delay.percent", diff --git a/test/extensions/filters/network/ratelimit/ratelimit_test.cc b/test/extensions/filters/network/ratelimit/ratelimit_test.cc index 200154dcf473b..e77f6080cba8d 100644 --- a/test/extensions/filters/network/ratelimit/ratelimit_test.cc +++ b/test/extensions/filters/network/ratelimit/ratelimit_test.cc @@ -41,7 +41,7 @@ class RateLimitFilterTest : public testing::Test { envoy::extensions::filters::network::ratelimit::v3::RateLimit proto_config{}; TestUtility::loadFromYaml(yaml, proto_config); - config_.reset(new Config(proto_config, stats_store_, runtime_)); + config_ = std::make_shared(proto_config, stats_store_, runtime_); client_ = new Filters::Common::RateLimit::MockClient(); filter_ = std::make_unique(config_, Filters::Common::RateLimit::ClientPtr{client_}); filter_->initializeReadFilterCallbacks(filter_callbacks_); diff --git a/test/extensions/filters/network/redis_proxy/mocks.h b/test/extensions/filters/network/redis_proxy/mocks.h index 3ef0fc22f3ced..5bb208bfa9019 100644 --- a/test/extensions/filters/network/redis_proxy/mocks.h +++ b/test/extensions/filters/network/redis_proxy/mocks.h @@ -43,7 +43,7 @@ class MockRoute : public Route { class MockMirrorPolicy : public MirrorPolicy { public: MockMirrorPolicy(ConnPool::InstanceSharedPtr); - ~MockMirrorPolicy() = default; + ~MockMirrorPolicy() override = default; MOCK_METHOD(ConnPool::InstanceSharedPtr, upstream, (), (const)); MOCK_METHOD(bool, shouldMirror, (const std::string&), (const)); diff --git a/test/extensions/filters/network/redis_proxy/proxy_filter_test.cc b/test/extensions/filters/network/redis_proxy/proxy_filter_test.cc index d80ec24da6859..72cebf97fcd28 100644 --- a/test/extensions/filters/network/redis_proxy/proxy_filter_test.cc +++ b/test/extensions/filters/network/redis_proxy/proxy_filter_test.cc @@ -107,7 +107,8 @@ class RedisProxyFilterTest : public testing::Test, public Common::Redis::Decoder RedisProxyFilterTest(const std::string& yaml_string) { envoy::extensions::filters::network::redis_proxy::v3::RedisProxy proto_config = parseProtoFromYaml(yaml_string); - config_.reset(new ProxyFilterConfig(proto_config, store_, drain_decision_, runtime_, api_)); + config_ = + std::make_shared(proto_config, store_, drain_decision_, runtime_, api_); filter_ = std::make_unique(*this, Common::Redis::EncoderPtr{encoder_}, splitter_, config_); filter_->initializeReadFilterCallbacks(filter_callbacks_); diff --git a/test/extensions/filters/network/redis_proxy/redis_proxy_integration_test.cc b/test/extensions/filters/network/redis_proxy/redis_proxy_integration_test.cc index 3f74f71aaaf7b..b1e33acfe8203 100644 --- a/test/extensions/filters/network/redis_proxy/redis_proxy_integration_test.cc +++ b/test/extensions/filters/network/redis_proxy/redis_proxy_integration_test.cc @@ -7,8 +7,6 @@ #include "gtest/gtest.h" -using testing::Return; - namespace RedisCmdSplitter = Envoy::Extensions::NetworkFilters::RedisProxy::CommandSplitter; namespace Envoy { diff --git a/test/extensions/filters/network/thrift_proxy/conn_manager_test.cc b/test/extensions/filters/network/thrift_proxy/conn_manager_test.cc index ce4f784305e53..5de6de271950b 100644 --- a/test/extensions/filters/network/thrift_proxy/conn_manager_test.cc +++ b/test/extensions/filters/network/thrift_proxy/conn_manager_test.cc @@ -97,7 +97,7 @@ class ThriftConnectionManagerTest : public testing::Test { proto_config_.set_stat_prefix("test"); - decoder_filter_.reset(new NiceMock()); + decoder_filter_ = std::make_shared>(); config_ = std::make_unique(proto_config_, context_, decoder_filter_, stats_); if (custom_transport_) { diff --git a/test/extensions/filters/network/thrift_proxy/filters/ratelimit/ratelimit_test.cc b/test/extensions/filters/network/thrift_proxy/filters/ratelimit/ratelimit_test.cc index 9ea412d0362a4..df6fabc70d9a3 100644 --- a/test/extensions/filters/network/thrift_proxy/filters/ratelimit/ratelimit_test.cc +++ b/test/extensions/filters/network/thrift_proxy/filters/ratelimit/ratelimit_test.cc @@ -55,9 +55,9 @@ class ThriftRateLimitFilterTest : public testing::Test { proto_config{}; TestUtility::loadFromYaml(yaml, proto_config); - config_.reset(new Config(proto_config, local_info_, stats_store_, runtime_, cm_)); + config_ = std::make_shared(proto_config, local_info_, stats_store_, runtime_, cm_); - request_metadata_.reset(new ThriftProxy::MessageMetadata()); + request_metadata_ = std::make_shared(); client_ = new Filters::Common::RateLimit::MockClient(); filter_ = std::make_unique(config_, Filters::Common::RateLimit::ClientPtr{client_}); diff --git a/test/extensions/filters/network/thrift_proxy/mocks.cc b/test/extensions/filters/network/thrift_proxy/mocks.cc index 8b68296e786d5..ee57deef2893a 100644 --- a/test/extensions/filters/network/thrift_proxy/mocks.cc +++ b/test/extensions/filters/network/thrift_proxy/mocks.cc @@ -1,5 +1,7 @@ #include "test/extensions/filters/network/thrift_proxy/mocks.h" +#include + #include "common/protobuf/protobuf.h" #include "gtest/gtest.h" @@ -81,7 +83,7 @@ MockDecoderFilter::MockDecoderFilter() { MockDecoderFilter::~MockDecoderFilter() = default; MockDecoderFilterCallbacks::MockDecoderFilterCallbacks() { - route_.reset(new NiceMock()); + route_ = std::make_shared>(); ON_CALL(*this, streamId()).WillByDefault(Return(stream_id_)); ON_CALL(*this, connection()).WillByDefault(Return(&connection_)); @@ -92,7 +94,7 @@ MockDecoderFilterCallbacks::~MockDecoderFilterCallbacks() = default; MockFilterConfigFactory::MockFilterConfigFactory() : FactoryBase("envoy.filters.thrift.mock_filter") { - mock_filter_.reset(new NiceMock()); + mock_filter_ = std::make_shared>(); } MockFilterConfigFactory::~MockFilterConfigFactory() = default; diff --git a/test/extensions/filters/network/thrift_proxy/router_ratelimit_test.cc b/test/extensions/filters/network/thrift_proxy/router_ratelimit_test.cc index 70a5c61740010..458412b7d0e05 100644 --- a/test/extensions/filters/network/thrift_proxy/router_ratelimit_test.cc +++ b/test/extensions/filters/network/thrift_proxy/router_ratelimit_test.cc @@ -38,7 +38,7 @@ class ThriftRateLimitConfigurationTest : public testing::Test { } MessageMetadata& genMetadata(const std::string& method_name) { - metadata_.reset(new MessageMetadata()); + metadata_ = std::make_shared(); metadata_->setMethodName(method_name); return *metadata_; } diff --git a/test/extensions/filters/network/thrift_proxy/router_test.cc b/test/extensions/filters/network/thrift_proxy/router_test.cc index 44398d7e8b984..ca3d8198a5bd2 100644 --- a/test/extensions/filters/network/thrift_proxy/router_test.cc +++ b/test/extensions/filters/network/thrift_proxy/router_test.cc @@ -95,7 +95,7 @@ class ThriftRouterTestBase { void initializeMetadata(MessageType msg_type, std::string method = "method") { msg_type_ = msg_type; - metadata_.reset(new MessageMetadata()); + metadata_ = std::make_shared(); metadata_->setMethodName(method); metadata_->setMessageType(msg_type_); metadata_->setSequenceId(1); diff --git a/test/extensions/filters/network/thrift_proxy/twitter_protocol_impl_test.cc b/test/extensions/filters/network/thrift_proxy/twitter_protocol_impl_test.cc index 5b1b77b9ae78e..3d08c0eb95e23 100644 --- a/test/extensions/filters/network/thrift_proxy/twitter_protocol_impl_test.cc +++ b/test/extensions/filters/network/thrift_proxy/twitter_protocol_impl_test.cc @@ -1,3 +1,5 @@ +#include + #include "envoy/common/exception.h" #include "common/buffer/buffer_impl.h" @@ -38,7 +40,7 @@ class TestTwitterProtocolImpl : public TwitterProtocolImpl { class TwitterProtocolTest : public testing::Test { public: - void clearMetadata() { metadata_.reset(new MessageMetadata()); } + void clearMetadata() { metadata_ = std::make_shared(); } void resetMetadata() { clearMetadata(); diff --git a/test/extensions/filters/udp/udp_proxy/udp_proxy_filter_test.cc b/test/extensions/filters/udp/udp_proxy/udp_proxy_filter_test.cc index cc9d41f351e35..3e773189bcc9e 100644 --- a/test/extensions/filters/udp/udp_proxy/udp_proxy_filter_test.cc +++ b/test/extensions/filters/udp/udp_proxy/udp_proxy_filter_test.cc @@ -125,7 +125,7 @@ class UdpProxyFilterTest : public testing::Test { .WillRepeatedly(Return(Upstream::Host::Health::Healthy)); } - ~UdpProxyFilterTest() { EXPECT_CALL(callbacks_.udp_listener_, onDestroy()); } + ~UdpProxyFilterTest() override { EXPECT_CALL(callbacks_.udp_listener_, onDestroy()); } void setup(const std::string& yaml, bool has_cluster = true) { envoy::config::filter::udp::udp_proxy::v2alpha::UdpProxyConfig config; diff --git a/test/extensions/filters/udp/udp_proxy/udp_proxy_integration_test.cc b/test/extensions/filters/udp/udp_proxy/udp_proxy_integration_test.cc index 21fc2b2ee1a3f..88b51986362b5 100644 --- a/test/extensions/filters/udp/udp_proxy/udp_proxy_integration_test.cc +++ b/test/extensions/filters/udp/udp_proxy/udp_proxy_integration_test.cc @@ -1,3 +1,5 @@ +#include + #include "envoy/config/bootstrap/v3/bootstrap.pb.h" #include "test/integration/integration.h" @@ -107,20 +109,20 @@ TEST_P(UdpProxyIntegrationTest, HelloWorldOnNonLocalAddress) { Network::Address::InstanceConstSharedPtr listener_address; if (version_ == Network::Address::IpVersion::v4) { // Kernel regards any 127.x.x.x as local address. - listener_address.reset(new Network::Address::Ipv4Instance( + listener_address = std::make_shared( #ifndef __APPLE__ "127.0.0.3", #else "127.0.0.1", #endif - port)); + port); } else { // IPv6 doesn't allow any non-local source address for sendmsg. And the only // local address guaranteed in tests in loopback. Unfortunately, even if it's not // specified, kernel will pick this address as source address. So this test // only checks if IoSocketHandle::sendmsg() sets up CMSG_DATA correctly, // i.e. cmsg_len is big enough when that code path is executed. - listener_address.reset(new Network::Address::Ipv6Instance("::1", port)); + listener_address = std::make_shared("::1", port); } requestResponseWithListenerAddress(*listener_address); diff --git a/test/extensions/grpc_credentials/file_based_metadata/file_based_metadata_grpc_credentials_test.cc b/test/extensions/grpc_credentials/file_based_metadata/file_based_metadata_grpc_credentials_test.cc index 41db5c69403e9..f567b3d3e258b 100644 --- a/test/extensions/grpc_credentials/file_based_metadata/file_based_metadata_grpc_credentials_test.cc +++ b/test/extensions/grpc_credentials/file_based_metadata/file_based_metadata_grpc_credentials_test.cc @@ -141,7 +141,7 @@ TEST_P(GrpcFileBasedMetadataClientIntegrationTest, ExtraConfigFileBasedMetadataG class MockAuthContext : public ::grpc::AuthContext { public: - ~MockAuthContext() override {} + ~MockAuthContext() override = default; MOCK_METHOD(bool, IsPeerAuthenticated, (), (const, override)); MOCK_METHOD(std::vector, GetPeerIdentity, (), (const, override)); MOCK_METHOD(std::string, GetPeerIdentityPropertyName, (), (const, override)); diff --git a/test/extensions/health_checkers/redis/redis_test.cc b/test/extensions/health_checkers/redis/redis_test.cc index 3e6e96f069a58..9d413879998ca 100644 --- a/test/extensions/health_checkers/redis/redis_test.cc +++ b/test/extensions/health_checkers/redis/redis_test.cc @@ -53,9 +53,9 @@ class RedisHealthCheckerTest const auto& redis_config = getRedisHealthCheckConfig( health_check_config, ProtobufMessage::getStrictValidationVisitor()); - health_checker_.reset(new RedisHealthChecker( + health_checker_ = std::make_shared( *cluster_, health_check_config, redis_config, dispatcher_, runtime_, random_, - Upstream::HealthCheckEventLoggerPtr(event_logger_), *api_, *this)); + Upstream::HealthCheckEventLoggerPtr(event_logger_), *api_, *this); } void setupAlwaysLogHealthCheckFailures() { @@ -77,9 +77,9 @@ class RedisHealthCheckerTest const auto& redis_config = getRedisHealthCheckConfig( health_check_config, ProtobufMessage::getStrictValidationVisitor()); - health_checker_.reset(new RedisHealthChecker( + health_checker_ = std::make_shared( *cluster_, health_check_config, redis_config, dispatcher_, runtime_, random_, - Upstream::HealthCheckEventLoggerPtr(event_logger_), *api_, *this)); + Upstream::HealthCheckEventLoggerPtr(event_logger_), *api_, *this); } void setupExistsHealthcheck() { @@ -101,9 +101,9 @@ class RedisHealthCheckerTest const auto& redis_config = getRedisHealthCheckConfig( health_check_config, ProtobufMessage::getStrictValidationVisitor()); - health_checker_.reset(new RedisHealthChecker( + health_checker_ = std::make_shared( *cluster_, health_check_config, redis_config, dispatcher_, runtime_, random_, - Upstream::HealthCheckEventLoggerPtr(event_logger_), *api_, *this)); + Upstream::HealthCheckEventLoggerPtr(event_logger_), *api_, *this); } void setupExistsHealthcheckDeprecated() { @@ -124,9 +124,9 @@ class RedisHealthCheckerTest const auto& redis_config = getRedisHealthCheckConfig( health_check_config, ProtobufMessage::getStrictValidationVisitor()); - health_checker_.reset(new RedisHealthChecker( + health_checker_ = std::make_shared( *cluster_, health_check_config, redis_config, dispatcher_, runtime_, random_, - Upstream::HealthCheckEventLoggerPtr(event_logger_), *api_, *this)); + Upstream::HealthCheckEventLoggerPtr(event_logger_), *api_, *this); } void setupDontReuseConnection() { @@ -148,9 +148,9 @@ class RedisHealthCheckerTest const auto& redis_config = getRedisHealthCheckConfig( health_check_config, ProtobufMessage::getStrictValidationVisitor()); - health_checker_.reset(new RedisHealthChecker( + health_checker_ = std::make_shared( *cluster_, health_check_config, redis_config, dispatcher_, runtime_, random_, - Upstream::HealthCheckEventLoggerPtr(event_logger_), *api_, *this)); + Upstream::HealthCheckEventLoggerPtr(event_logger_), *api_, *this); } Extensions::NetworkFilters::Common::Redis::Client::ClientPtr diff --git a/test/extensions/quic_listeners/quiche/envoy_quic_client_session_test.cc b/test/extensions/quic_listeners/quiche/envoy_quic_client_session_test.cc index dcca8f3f244e7..86c7ea98284a1 100644 --- a/test/extensions/quic_listeners/quiche/envoy_quic_client_session_test.cc +++ b/test/extensions/quic_listeners/quiche/envoy_quic_client_session_test.cc @@ -31,7 +31,6 @@ using testing::_; using testing::Invoke; using testing::Return; -using testing::ReturnRef; namespace Envoy { namespace Quic { diff --git a/test/extensions/quic_listeners/quiche/envoy_quic_client_stream_test.cc b/test/extensions/quic_listeners/quiche/envoy_quic_client_stream_test.cc index aa69e6dc87020..6b42b24f854e5 100644 --- a/test/extensions/quic_listeners/quiche/envoy_quic_client_stream_test.cc +++ b/test/extensions/quic_listeners/quiche/envoy_quic_client_stream_test.cc @@ -18,7 +18,6 @@ namespace Quic { using testing::_; using testing::Invoke; -using testing::Return; class EnvoyQuicClientStreamTest : public testing::TestWithParam { public: diff --git a/test/extensions/quic_listeners/quiche/envoy_quic_server_stream_test.cc b/test/extensions/quic_listeners/quiche/envoy_quic_server_stream_test.cc index 9877676774dda..748554d8182f9 100644 --- a/test/extensions/quic_listeners/quiche/envoy_quic_server_stream_test.cc +++ b/test/extensions/quic_listeners/quiche/envoy_quic_server_stream_test.cc @@ -20,7 +20,6 @@ using testing::_; using testing::Invoke; -using testing::Return; namespace Envoy { namespace Quic { diff --git a/test/extensions/tracers/common/ot/opentracing_driver_impl_test.cc b/test/extensions/tracers/common/ot/opentracing_driver_impl_test.cc index 122efa3b5ef67..d159f0de0a58e 100644 --- a/test/extensions/tracers/common/ot/opentracing_driver_impl_test.cc +++ b/test/extensions/tracers/common/ot/opentracing_driver_impl_test.cc @@ -29,7 +29,7 @@ class TestDriver : public OpenTracingDriver { recorder_ = recorder; options.recorder.reset(recorder); options.propagation_options = propagation_options; - tracer_.reset(new opentracing::mocktracer::MockTracer{std::move(options)}); + tracer_ = std::make_shared(std::move(options)); } const opentracing::mocktracer::InMemoryRecorder& recorder() const { return *recorder_; } diff --git a/test/extensions/tracers/xray/xray_tracer_impl_test.cc b/test/extensions/tracers/xray/xray_tracer_impl_test.cc index f553a6f8b16cc..81f9532cb4a8a 100644 --- a/test/extensions/tracers/xray/xray_tracer_impl_test.cc +++ b/test/extensions/tracers/xray/xray_tracer_impl_test.cc @@ -13,8 +13,6 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -using ::testing::ReturnRef; - namespace Envoy { namespace Extensions { namespace Tracers { diff --git a/test/extensions/tracers/zipkin/zipkin_core_types_test.cc b/test/extensions/tracers/zipkin/zipkin_core_types_test.cc index 1b7d66ebb1eea..97ef5254db056 100644 --- a/test/extensions/tracers/zipkin/zipkin_core_types_test.cc +++ b/test/extensions/tracers/zipkin/zipkin_core_types_test.cc @@ -71,7 +71,7 @@ TEST(ZipkinCoreTypesEndpointTest, copyOperator) { Network::Address::InstanceConstSharedPtr addr = Network::Utility::parseInternetAddressAndPort("127.0.0.1:3306"); Endpoint ep1(std::string("my_service"), addr); - Endpoint ep2(ep1); + const Endpoint& ep2(ep1); EXPECT_EQ("my_service", ep1.serviceName()); EXPECT_TRUE(TestUtility::protoEqual( @@ -86,7 +86,7 @@ TEST(ZipkinCoreTypesEndpointTest, assignmentOperator) { Network::Address::InstanceConstSharedPtr addr = Network::Utility::parseInternetAddressAndPort("127.0.0.1:3306"); Endpoint ep1(std::string("my_service"), addr); - Endpoint ep2 = ep1; + const Endpoint& ep2 = ep1; EXPECT_EQ("my_service", ep1.serviceName()); EXPECT_TRUE(TestUtility::protoEqual( @@ -194,7 +194,7 @@ TEST(ZipkinCoreTypesAnnotationTest, copyConstructor) { test_time.timeSystem().systemTime().time_since_epoch()) .count(); Annotation ann(timestamp, CLIENT_SEND, ep); - Annotation ann2(ann); + const Annotation& ann2(ann); EXPECT_EQ(ann.value(), ann2.value()); EXPECT_EQ(ann.timestamp(), ann2.timestamp()); @@ -212,7 +212,7 @@ TEST(ZipkinCoreTypesAnnotationTest, assignmentOperator) { test_time.timeSystem().systemTime().time_since_epoch()) .count(); Annotation ann(timestamp, CLIENT_SEND, ep); - Annotation ann2 = ann; + const Annotation& ann2 = ann; EXPECT_EQ(ann.value(), ann2.value()); EXPECT_EQ(ann.timestamp(), ann2.timestamp()); @@ -288,7 +288,7 @@ TEST(ZipkinCoreTypesBinaryAnnotationTest, customConstructor) { TEST(ZipkinCoreTypesBinaryAnnotationTest, copyConstructor) { BinaryAnnotation ann("key", "value"); - BinaryAnnotation ann2(ann); + const BinaryAnnotation& ann2(ann); EXPECT_EQ(ann.value(), ann2.value()); EXPECT_EQ(ann.key(), ann2.key()); @@ -299,7 +299,7 @@ TEST(ZipkinCoreTypesBinaryAnnotationTest, copyConstructor) { TEST(ZipkinCoreTypesBinaryAnnotationTest, assignmentOperator) { BinaryAnnotation ann("key", "value"); - BinaryAnnotation ann2 = ann; + const BinaryAnnotation& ann2 = ann; EXPECT_EQ(ann.value(), ann2.value()); EXPECT_EQ(ann.key(), ann2.key()); diff --git a/test/extensions/transport_sockets/tls/ssl_socket_test.cc b/test/extensions/transport_sockets/tls/ssl_socket_test.cc index d646a65eefbad..7009310a53de9 100644 --- a/test/extensions/transport_sockets/tls/ssl_socket_test.cc +++ b/test/extensions/transport_sockets/tls/ssl_socket_test.cc @@ -4297,7 +4297,7 @@ class SslReadBufferLimitTest : public SslSocketTest { socket_->localAddress(), source_address_, std::move(transport_socket), nullptr); client_connection_->addConnectionCallbacks(client_callbacks_); client_connection_->connect(); - read_filter_.reset(new Network::MockReadFilter()); + read_filter_ = std::make_shared(); } void readBufferLimitTest(uint32_t read_buffer_limit, uint32_t expected_chunk_size, diff --git a/test/integration/fake_upstream.h b/test/integration/fake_upstream.h index 4b4a588cf05d0..d898711ed33e8 100644 --- a/test/integration/fake_upstream.h +++ b/test/integration/fake_upstream.h @@ -669,9 +669,7 @@ class FakeUpstream : Logger::Loggable, bool bindToPort() override { return true; } bool handOffRestoredDestinationConnections() const override { return false; } uint32_t perConnectionBufferLimitBytes() const override { return 0; } - std::chrono::milliseconds listenerFiltersTimeout() const override { - return std::chrono::milliseconds(); - } + std::chrono::milliseconds listenerFiltersTimeout() const override { return {}; } bool continueOnListenerFiltersTimeout() const override { return false; } Stats::Scope& listenerScope() override { return parent_.stats_store_; } uint64_t listenerTag() const override { return 0; } diff --git a/test/integration/integration.h b/test/integration/integration.h index fa45953d85a06..8c388b46314fa 100644 --- a/test/integration/integration.h +++ b/test/integration/integration.h @@ -328,7 +328,7 @@ class BaseIntegrationTest : protected Logger::Loggable { resource->set_name(TestUtility::xdsResourceName(temp_any)); resource->set_version(version); resource->mutable_resource()->PackFrom(API_DOWNGRADE(message)); - for (const auto alias : aliases) { + for (const auto& alias : aliases) { resource->add_aliases(alias); } } diff --git a/test/integration/tcp_proxy_integration_test.cc b/test/integration/tcp_proxy_integration_test.cc index 240525e6a9b6f..93f5040fc4383 100644 --- a/test/integration/tcp_proxy_integration_test.cc +++ b/test/integration/tcp_proxy_integration_test.cc @@ -386,7 +386,7 @@ TEST_P(TcpProxyIntegrationTest, TestIdletimeoutWithLargeOutstandingData) { class TcpProxyMetadataMatchIntegrationTest : public TcpProxyIntegrationTest { public: - void initialize(); + void initialize() override; void expectEndpointToMatchRoute(); void expectEndpointNotToMatchRoute(); @@ -677,7 +677,7 @@ void TcpProxySslIntegrationTest::initialize() { context_manager_ = std::make_unique(timeSystem()); - payload_reader_.reset(new WaitForPayloadReader(*dispatcher_)); + payload_reader_ = std::make_shared(*dispatcher_); } void TcpProxySslIntegrationTest::setupConnections() { diff --git a/test/mocks/grpc/mocks.h b/test/mocks/grpc/mocks.h index d71bac5694c72..bbf8f6d1b60d1 100644 --- a/test/mocks/grpc/mocks.h +++ b/test/mocks/grpc/mocks.h @@ -74,7 +74,7 @@ class MockAsyncStreamCallbacks : public AsyncStreamCallbacks { class MockAsyncClient : public RawAsyncClient { public: MockAsyncClient(); - ~MockAsyncClient(); + ~MockAsyncClient() override; MOCK_METHOD(AsyncRequest*, sendRaw, (absl::string_view service_full_name, absl::string_view method_name, diff --git a/test/mocks/http/stream_decoder.h b/test/mocks/http/stream_decoder.h index 689ccfa9fcf32..2abbe175aaa44 100644 --- a/test/mocks/http/stream_decoder.h +++ b/test/mocks/http/stream_decoder.h @@ -21,7 +21,7 @@ class MockStreamDecoder : public virtual StreamDecoder { class MockRequestDecoder : public MockStreamDecoder, public RequestDecoder { public: MockRequestDecoder(); - ~MockRequestDecoder(); + ~MockRequestDecoder() override; void decodeHeaders(RequestHeaderMapPtr&& headers, bool end_stream) override { decodeHeaders_(headers, end_stream); @@ -36,7 +36,7 @@ class MockRequestDecoder : public MockStreamDecoder, public RequestDecoder { class MockResponseDecoder : public MockStreamDecoder, public ResponseDecoder { public: MockResponseDecoder(); - ~MockResponseDecoder(); + ~MockResponseDecoder() override; void decode100ContinueHeaders(ResponseHeaderMapPtr&& headers) override { decode100ContinueHeaders_(headers); diff --git a/test/mocks/http/stream_encoder.h b/test/mocks/http/stream_encoder.h index f89f12c6654d5..768951a411b4c 100644 --- a/test/mocks/http/stream_encoder.h +++ b/test/mocks/http/stream_encoder.h @@ -12,7 +12,7 @@ namespace Http { class MockHttp1StreamEncoderOptions : public Http1StreamEncoderOptions { public: MockHttp1StreamEncoderOptions(); - ~MockHttp1StreamEncoderOptions(); + ~MockHttp1StreamEncoderOptions() override; MOCK_METHOD(void, disableChunkEncoding, ()); }; @@ -34,7 +34,7 @@ class MockStreamEncoder : public virtual StreamEncoder { class MockRequestEncoder : public MockStreamEncoder, public RequestEncoder { public: MockRequestEncoder(); - ~MockRequestEncoder(); + ~MockRequestEncoder() override; // Http::RequestEncoder MOCK_METHOD(void, encodeHeaders, (const RequestHeaderMap& headers, bool end_stream)); @@ -44,7 +44,7 @@ class MockRequestEncoder : public MockStreamEncoder, public RequestEncoder { class MockResponseEncoder : public MockStreamEncoder, public ResponseEncoder { public: MockResponseEncoder(); - ~MockResponseEncoder(); + ~MockResponseEncoder() override; // Http::ResponseEncoder MOCK_METHOD(void, encode100ContinueHeaders, (const ResponseHeaderMap& headers)); diff --git a/test/mocks/network/io_handle.h b/test/mocks/network/io_handle.h index 5a5691adda641..787ea202f464d 100644 --- a/test/mocks/network/io_handle.h +++ b/test/mocks/network/io_handle.h @@ -11,7 +11,7 @@ namespace Network { class MockIoHandle : public IoHandle { public: MockIoHandle(); - ~MockIoHandle(); + ~MockIoHandle() override; MOCK_METHOD(int, fd, (), (const)); MOCK_METHOD(Api::IoCallUint64Result, close, ()); diff --git a/test/mocks/network/mocks.cc b/test/mocks/network/mocks.cc index a601612e42c28..81f9d03721c20 100644 --- a/test/mocks/network/mocks.cc +++ b/test/mocks/network/mocks.cc @@ -156,7 +156,7 @@ MockConnectionSocket::MockConnectionSocket() MockConnectionSocket::~MockConnectionSocket() = default; -MockListener::MockListener() {} +MockListener::MockListener() = default; MockListener::~MockListener() { onDestroy(); } diff --git a/test/mocks/tracing/mocks.cc b/test/mocks/tracing/mocks.cc index 6b75d70431f75..22c42b78d21d2 100644 --- a/test/mocks/tracing/mocks.cc +++ b/test/mocks/tracing/mocks.cc @@ -4,7 +4,6 @@ #include "gtest/gtest.h" using testing::Return; -using testing::ReturnRef; namespace Envoy { namespace Tracing { diff --git a/test/server/connection_handler_test.cc b/test/server/connection_handler_test.cc index 09c329e20e19a..06676a01e987a 100644 --- a/test/server/connection_handler_test.cc +++ b/test/server/connection_handler_test.cc @@ -22,12 +22,10 @@ #include "gtest/gtest.h" using testing::_; -using testing::ByRef; using testing::HasSubstr; using testing::InSequence; using testing::Invoke; using testing::NiceMock; -using testing::Ref; using testing::Return; using testing::ReturnRef; using testing::SaveArg; diff --git a/test/server/http/admin_test.cc b/test/server/http/admin_test.cc index c671ee0f71acd..3099de1ebf935 100644 --- a/test/server/http/admin_test.cc +++ b/test/server/http/admin_test.cc @@ -40,7 +40,6 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -using testing::_; using testing::AllOf; using testing::EndsWith; using testing::Ge; diff --git a/test/server/listener_manager_impl_test.h b/test/server/listener_manager_impl_test.h index a1357d39c6f0c..2ab79f6f487b0 100644 --- a/test/server/listener_manager_impl_test.h +++ b/test/server/listener_manager_impl_test.h @@ -1,3 +1,5 @@ +#include + #include "envoy/admin/v3/config_dump.pb.h" #include "envoy/config/core/v3/base.pb.h" #include "envoy/config/listener/v3/listener.pb.h" @@ -84,8 +86,8 @@ class ListenerManagerImplTest : public testing::Test { return listener_tag_++; })); - local_address_.reset(new Network::Address::Ipv4Instance("127.0.0.1", 1234)); - remote_address_.reset(new Network::Address::Ipv4Instance("127.0.0.1", 1234)); + local_address_ = std::make_shared("127.0.0.1", 1234); + remote_address_ = std::make_shared("127.0.0.1", 1234); EXPECT_CALL(os_sys_calls_, close(_)).WillRepeatedly(Return(Api::SysCallIntResult{0, errno})); EXPECT_CALL(os_sys_calls_, getsockname) .WillRepeatedly(Invoke([this](os_fd_t sockfd, sockaddr* addr, socklen_t* addrlen) { @@ -137,7 +139,7 @@ class ListenerManagerImplTest : public testing::Test { const std::vector& application_protocols, const std::string& source_address, uint16_t source_port) { if (absl::StartsWith(destination_address, "/")) { - local_address_.reset(new Network::Address::PipeInstance(destination_address)); + local_address_ = std::make_shared(destination_address); } else { local_address_ = Network::Utility::parseInternetAddress(destination_address, destination_port); @@ -151,7 +153,7 @@ class ListenerManagerImplTest : public testing::Test { .WillByDefault(ReturnRef(application_protocols)); if (absl::StartsWith(source_address, "/")) { - remote_address_.reset(new Network::Address::PipeInstance(source_address)); + remote_address_ = std::make_shared(source_address); } else { remote_address_ = Network::Utility::parseInternetAddress(source_address, source_port); } diff --git a/test/server/options_impl_test.cc b/test/server/options_impl_test.cc index df8ab29102615..6e6219ec35a46 100644 --- a/test/server/options_impl_test.cc +++ b/test/server/options_impl_test.cc @@ -486,7 +486,7 @@ TEST_F(OptionsImplPlatformLinuxTest, AffinityTest4) { class TestFactory : public Config::TypedFactory { public: - virtual ~TestFactory() = default; + ~TestFactory() override = default; std::string category() const override { return "test"; } std::string configType() override { return "google.protobuf.StringValue"; } ProtobufTypes::MessagePtr createEmptyConfigProto() override { @@ -501,7 +501,7 @@ class TestTestFactory : public TestFactory { class TestingFactory : public Config::TypedFactory { public: - virtual ~TestingFactory() = default; + ~TestingFactory() override = default; std::string category() const override { return "testing"; } std::string configType() override { return "google.protobuf.StringValue"; } ProtobufTypes::MessagePtr createEmptyConfigProto() override { diff --git a/test/test_common/utility.cc b/test/test_common/utility.cc index 34c7deeaa5731..f7be0dee94096 100644 --- a/test/test_common/utility.cc +++ b/test/test_common/utility.cc @@ -102,14 +102,14 @@ bool TestUtility::buffersEqual(const Buffer::Instance& lhs, const Buffer::Instan size_t rhs_slice = 0; size_t rhs_offset = 0; - for (size_t lhs_slice = 0; lhs_slice < lhs_slices.size(); lhs_slice++) { - for (size_t lhs_offset = 0; lhs_offset < lhs_slices[lhs_slice].len_; lhs_offset++) { + for (auto& lhs_slice : lhs_slices) { + for (size_t lhs_offset = 0; lhs_offset < lhs_slice.len_; lhs_offset++) { while (rhs_offset >= rhs_slices[rhs_slice].len_) { rhs_slice++; ASSERT(rhs_slice < rhs_slices.size()); rhs_offset = 0; } - auto lhs_str = static_cast(lhs_slices[lhs_slice].mem_); + auto lhs_str = static_cast(lhs_slice.mem_); auto rhs_str = static_cast(rhs_slices[rhs_slice].mem_); if (lhs_str[lhs_offset] != rhs_str[rhs_offset]) { return false; diff --git a/tools/api_boost/testdata/using_decl.cc b/tools/api_boost/testdata/using_decl.cc index 88b3f2ef44035..97335b2bc2ed1 100644 --- a/tools/api_boost/testdata/using_decl.cc +++ b/tools/api_boost/testdata/using_decl.cc @@ -1,7 +1,6 @@ #include "envoy/config/overload/v2alpha/overload.pb.h" using envoy::config::overload::v2alpha::ThresholdTrigger; -using ::envoy::config::overload::v2alpha::Trigger; using SomePtrAlias = std::unique_ptr; class ThresholdTriggerImpl { From 65d286dcf41bd4bf2a9f93cab5334988205fbae4 Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Mon, 6 Apr 2020 18:54:08 +0000 Subject: [PATCH 2/3] revert chromium Signed-off-by: Lizan Zhou --- source/common/chromium_url/url_canon.h | 31 +++++++------------ .../common/chromium_url/url_canon_internal.h | 4 +-- source/common/chromium_url/url_canon_path.cc | 20 +++++------- .../chromium_url/url_canon_stdstring.cc | 6 ++-- source/common/chromium_url/url_parse.h | 8 ++--- tools/api_boost/testdata/using_decl.cc | 1 + 6 files changed, 29 insertions(+), 41 deletions(-) diff --git a/source/common/chromium_url/url_canon.h b/source/common/chromium_url/url_canon.h index f2a1ee132e7f0..0280de643ac86 100644 --- a/source/common/chromium_url/url_canon.h +++ b/source/common/chromium_url/url_canon.h @@ -8,8 +8,8 @@ #ifndef URL_URL_CANON_H_ #define URL_URL_CANON_H_ -#include -#include +#include +#include #include "common/chromium_url/envoy_shim.h" #include "common/chromium_url/url_parse.h" @@ -28,7 +28,7 @@ namespace chromium_url { // manage. template class CanonOutputT { public: - CanonOutputT() : buffer_(NULL) {} + CanonOutputT() : buffer_(NULL), buffer_len_(0), cur_len_(0) {} virtual ~CanonOutputT() = default; // Implemented to resize the buffer. This function should update the buffer @@ -83,9 +83,8 @@ template class CanonOutputT { // Grow the buffer to hold at least one more item. Hopefully we won't have // to do this very often. - if (!Grow(1)) { + if (!Grow(1)) return; - } // Actually do the insertion. buffer_[cur_len_] = ch; @@ -95,21 +94,18 @@ template class CanonOutputT { // Appends the given string to the output. void Append(const T* str, int str_len) { if (cur_len_ + str_len > buffer_len_) { - if (!Grow(cur_len_ + str_len - buffer_len_)) { + if (!Grow(cur_len_ + str_len - buffer_len_)) return; - } } - for (int i = 0; i < str_len; i++) { + for (int i = 0; i < str_len; i++) buffer_[cur_len_ + i] = str[i]; - } cur_len_ += str_len; } void ReserveSizeIfNeeded(int estimated_size) { // Reserve a bit extra to account for escaped chars. - if (estimated_size > buffer_len_) { + if (estimated_size > buffer_len_) Resize(estimated_size + 8); - } } protected: @@ -119,9 +115,8 @@ template class CanonOutputT { static const int kMinBufferLen = 16; int new_len = (buffer_len_ == 0) ? kMinBufferLen : buffer_len_; do { - if (new_len >= (1 << 30)) { // Prevent overflow below. + if (new_len >= (1 << 30)) // Prevent overflow below. return false; - } new_len *= 2; } while (new_len < buffer_len_ + min_additional); Resize(new_len); @@ -129,10 +124,10 @@ template class CanonOutputT { } T* buffer_; - int buffer_len_{0}; + int buffer_len_; // Used characters in the buffer. - int cur_len_{0}; + int cur_len_; }; // Simple implementation of the CanonOutput using new[]. This class @@ -145,17 +140,15 @@ template class RawCanonOutputT : public this->buffer_len_ = fixed_capacity; } ~RawCanonOutputT() override { - if (this->buffer_ != fixed_buffer_) { + if (this->buffer_ != fixed_buffer_) delete[] this->buffer_; - } } void Resize(int sz) override { T* new_buf = new T[sz]; memcpy(new_buf, this->buffer_, sizeof(T) * (this->cur_len_ < sz ? this->cur_len_ : sz)); - if (this->buffer_ != fixed_buffer_) { + if (this->buffer_ != fixed_buffer_) delete[] this->buffer_; - } this->buffer_ = new_buf; this->buffer_len_ = sz; } diff --git a/source/common/chromium_url/url_canon_internal.h b/source/common/chromium_url/url_canon_internal.h index 122bc59835484..8c405b49814a0 100644 --- a/source/common/chromium_url/url_canon_internal.h +++ b/source/common/chromium_url/url_canon_internal.h @@ -13,8 +13,8 @@ // template bloat because everything is inlined when anybody calls any of our // functions. -#include -#include +#include +#include #include "common/chromium_url/envoy_shim.h" #include "common/chromium_url/url_canon.h" diff --git a/source/common/chromium_url/url_canon_path.cc b/source/common/chromium_url/url_canon_path.cc index 3ddfae62ffe8f..22587c0ab8a10 100644 --- a/source/common/chromium_url/url_canon_path.cc +++ b/source/common/chromium_url/url_canon_path.cc @@ -5,7 +5,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include +#include #include "common/chromium_url/url_canon.h" #include "common/chromium_url/url_canon_internal.h" @@ -169,15 +169,13 @@ void BackUpToPreviousSlash(int path_begin_in_output, CanonOutput* output) { int i = output->length() - 1; DCHECK(output->at(i) == '/'); - if (i == path_begin_in_output) { + if (i == path_begin_in_output) return; // We're at the first slash, nothing to do. - } // Now back up (skipping the trailing slash) until we find another slash. i--; - while (output->at(i) != '/' && i > path_begin_in_output) { + while (output->at(i) != '/' && i > path_begin_in_output) i--; - } // Now shrink the output to just include that last slash we found. output->set_length(i + 1); @@ -226,9 +224,8 @@ void CheckForNestedEscapes(const CHAR* spec, int next_input_index, int input_len if (append_next_char) { // If the input doesn't contain a 7-bit character next, this case won't be a // problem. - if ((next_input_index == input_len) || (spec[next_input_index] >= 0x80)) { + if ((next_input_index == input_len) || (spec[next_input_index] >= 0x80)) return; - } output->push_back(static_cast(spec[next_input_index])); } @@ -239,9 +236,8 @@ void CheckForNestedEscapes(const CHAR* spec, int next_input_index, int input_len // New escape sequence found. Overwrite the characters following the '%' // with "25", and push_back() the one or two characters that were following // the '%' when we were called. - if (!append_next_char) { + if (!append_next_char) output->push_back(output->at(last_invalid_percent_index + 1)); - } output->set(last_invalid_percent_index + 1, '2'); output->set(last_invalid_percent_index + 2, '5'); output->push_back(last_unescaped_char); @@ -355,9 +351,8 @@ bool DoPartialPath(const CHAR* spec, const Component& path, int path_begin_in_ou output->push_back('%'); output->push_back(static_cast(spec[i - 1])); output->push_back(static_cast(spec[i])); - if (unescaped_flags & INVALID_BIT) { + if (unescaped_flags & INVALID_BIT) success = false; - } } } else { // Invalid escape sequence. IE7+ rejects any URLs with such @@ -396,9 +391,8 @@ bool DoPath(const CHAR* spec, const Component& path, CanonOutput* output, Compon // and then canonicalize it, it will of course have a slash already. This // check is for the replacement and relative URL resolving cases of file // URLs. - if (!IsURLSlash(spec[path.begin])) { + if (!IsURLSlash(spec[path.begin])) output->push_back('/'); - } success = DoPartialPath(spec, path, out_path->begin, output); } else { diff --git a/source/common/chromium_url/url_canon_stdstring.cc b/source/common/chromium_url/url_canon_stdstring.cc index 6af5e26ebeec7..0c61831e5f1ac 100644 --- a/source/common/chromium_url/url_canon_stdstring.cc +++ b/source/common/chromium_url/url_canon_stdstring.cc @@ -9,9 +9,9 @@ namespace chromium_url { -StdStringCanonOutput::StdStringCanonOutput(std::string* str) : str_(str) { +StdStringCanonOutput::StdStringCanonOutput(std::string* str) : CanonOutput(), str_(str) { cur_len_ = static_cast(str_->size()); // Append to existing data. - buffer_ = str_->empty() ? nullptr : &(*str_)[0]; + buffer_ = str_->empty() ? NULL : &(*str_)[0]; buffer_len_ = static_cast(str_->size()); } @@ -26,7 +26,7 @@ void StdStringCanonOutput::Complete() { void StdStringCanonOutput::Resize(int sz) { str_->resize(sz); - buffer_ = str_->empty() ? nullptr : &(*str_)[0]; + buffer_ = str_->empty() ? NULL : &(*str_)[0]; buffer_len_ = sz; } diff --git a/source/common/chromium_url/url_parse.h b/source/common/chromium_url/url_parse.h index 8310b41f2976b..b840af60438d1 100644 --- a/source/common/chromium_url/url_parse.h +++ b/source/common/chromium_url/url_parse.h @@ -14,7 +14,7 @@ namespace chromium_url { // Represents a substring for URL parsing. struct Component { - Component() {} + Component() : begin(0), len(-1) {} // Normal constructor: takes an offset and a length. Component(int b, int l) : begin(b), len(l) {} @@ -36,13 +36,13 @@ struct Component { bool operator==(const Component& other) const { return begin == other.begin && len == other.len; } - int begin{0}; // Byte offset in the string of this component. - int len{-1}; // Will be -1 if the component is unspecified. + int begin; // Byte offset in the string of this component. + int len; // Will be -1 if the component is unspecified. }; // Helper that returns a component created with the given begin and ending // points. The ending point is non-inclusive. -inline Component MakeRange(int begin, int end) { return {begin, end - begin}; } +inline Component MakeRange(int begin, int end) { return Component(begin, end - begin); } } // namespace chromium_url diff --git a/tools/api_boost/testdata/using_decl.cc b/tools/api_boost/testdata/using_decl.cc index 97335b2bc2ed1..88b3f2ef44035 100644 --- a/tools/api_boost/testdata/using_decl.cc +++ b/tools/api_boost/testdata/using_decl.cc @@ -1,6 +1,7 @@ #include "envoy/config/overload/v2alpha/overload.pb.h" using envoy::config::overload::v2alpha::ThresholdTrigger; +using ::envoy::config::overload::v2alpha::Trigger; using SomePtrAlias = std::unique_ptr; class ThresholdTriggerImpl { From 4d7b342264460508c9b1a30ae7e52546214a233b Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Tue, 7 Apr 2020 09:49:16 +0000 Subject: [PATCH 3/3] update memory values Signed-off-by: Lizan Zhou --- test/integration/stats_integration_test.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/integration/stats_integration_test.cc b/test/integration/stats_integration_test.cc index fb345932f32cd..c08092a4b47de 100644 --- a/test/integration/stats_integration_test.cc +++ b/test/integration/stats_integration_test.cc @@ -270,6 +270,7 @@ TEST_P(ClusterMemoryTestRunner, MemoryLargeClusterSizeWithFakeSymbolTable) { // 2020/03/16 9964 44085 44600 http2: support custom SETTINGS parameters. // 2020/03/24 10501 44261 44600 upstream: upstream_rq_retry_limit_exceeded. // 2020/04/02 10624 43356 44000 Use 100 clusters rather than 1000 to avoid timeouts + // 2020/04/07 10661 43349 44000 fix clang tidy on master // Note: when adjusting this value: EXPECT_MEMORY_EQ is active only in CI // 'release' builds, where we control the platform and tool-chain. So you @@ -283,7 +284,7 @@ TEST_P(ClusterMemoryTestRunner, MemoryLargeClusterSizeWithFakeSymbolTable) { // If you encounter a failure here, please see // https://github.com/envoyproxy/envoy/blob/master/source/docs/stats.md#stats-memory-tests // for details on how to fix. - EXPECT_MEMORY_EQ(m_per_cluster, 43356); + EXPECT_MEMORY_EQ(m_per_cluster, 43349); EXPECT_MEMORY_LE(m_per_cluster, 44000); } @@ -327,6 +328,7 @@ TEST_P(ClusterMemoryTestRunner, MemoryLargeClusterSizeWithRealSymbolTable) { // 2020/03/16 9964 36220 36800 http2: support custom SETTINGS parameters. // 2020/03/24 10501 36300 36800 upstream: upstream_rq_retry_limit_exceeded. // 2020/04/02 10624 35564 36000 Use 100 clusters rather than 1000 to avoid timeouts + // 2020/04/07 10661 35557 36000 fix clang tidy on master // Note: when adjusting this value: EXPECT_MEMORY_EQ is active only in CI // 'release' builds, where we control the platform and tool-chain. So you @@ -340,7 +342,7 @@ TEST_P(ClusterMemoryTestRunner, MemoryLargeClusterSizeWithRealSymbolTable) { // If you encounter a failure here, please see // https://github.com/envoyproxy/envoy/blob/master/source/docs/stats.md#stats-memory-tests // for details on how to fix. - EXPECT_MEMORY_EQ(m_per_cluster, 35564); + EXPECT_MEMORY_EQ(m_per_cluster, 35557); EXPECT_MEMORY_LE(m_per_cluster, 36000); }