diff --git a/bazel/envoy_internal.bzl b/bazel/envoy_internal.bzl index 06ab0d4787d1..8a8a88ad2d0b 100644 --- a/bazel/envoy_internal.bzl +++ b/bazel/envoy_internal.bzl @@ -15,16 +15,22 @@ def envoy_copts(repository, test = False): "-std=c++14", ] + # Windows options for cleanest service compilation; + # General MSVC C++ options + # Streamline windows.h behavior for Win8+ API (for ntohll, see; + # https://msdn.microsoft.com/en-us/library/windows/desktop/aa383745(v=vs.85).aspx ) + # Minimize Win32 API, dropping GUI-oriented features msvc_options = [ "-WX", "-Zc:__cplusplus", "-std:c++14", "-DWIN32", - "-DWIN32_LEAN_AND_MEAN", - # need win8 for ntohll - # https://msdn.microsoft.com/en-us/library/windows/desktop/aa383745(v=vs.85).aspx "-D_WIN32_WINNT=0x0602", "-DNTDDI_VERSION=0x06020000", + "-DWIN32_LEAN_AND_MEAN", + "-DNOUSER", + "-DNOMCX", + "-DNOIME", ] return select({ diff --git a/bazel/foreign_cc/nghttp2.patch b/bazel/foreign_cc/nghttp2.patch index e7b001673a56..55768dca2003 100644 --- a/bazel/foreign_cc/nghttp2.patch +++ b/bazel/foreign_cc/nghttp2.patch @@ -8,7 +8,7 @@ index 35c77d1d..47bd63f5 100644 # Set it to "int" to match the behavior of AC_TYPE_SSIZE_T (autotools). - set(ssize_t int) + if(WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 8) -+ set(ssize_t int64_t) ++ set(ssize_t ptrdiff_t) + else() + set(ssize_t int) + endif() diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index d07a5497e93c..d07b6833fda6 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -237,6 +237,12 @@ def _com_github_eile_tclap(): _repository_impl( name = "com_github_eile_tclap", build_file = "@envoy//bazel/external:tclap.BUILD", + patch_args = ["-p1"], + # If and when we pick up tclap 1.4 or later release, + # this entire issue was refactored away 6 years ago; + # https://sourceforge.net/p/tclap/code/ci/5d4ffbf2db794af799b8c5727fb6c65c079195ac/ + # https://github.com/envoyproxy/envoy/pull/8572#discussion_r337554195 + patches = ["@envoy//bazel:tclap-win64-ull-sizet.patch"], ) native.bind( name = "tclap", @@ -334,6 +340,10 @@ def _com_github_nghttp2_nghttp2(): name = "com_github_nghttp2_nghttp2", build_file_content = BUILD_ALL_CONTENT, patch_args = ["-p1"], + # This patch cannot be picked up due to ABI rules. Better + # solve is likely at the next version-major. Discussion at; + # https://github.com/nghttp2/nghttp2/pull/1395 + # https://github.com/envoyproxy/envoy/pull/8572#discussion_r334067786 patches = ["@envoy//bazel/foreign_cc:nghttp2.patch"], **location ) diff --git a/bazel/tclap-win64-ull-sizet.patch b/bazel/tclap-win64-ull-sizet.patch new file mode 100644 index 000000000000..b393d8572813 --- /dev/null +++ b/bazel/tclap-win64-ull-sizet.patch @@ -0,0 +1,16 @@ +diff --git a/include/tclap/StandardTraits.h b/include/tclap/StandardTraits.h +index 46d7f6f..117057b 100644 +--- a/include/tclap/StandardTraits.h ++++ b/include/tclap/StandardTraits.h +@@ -123,8 +123,9 @@ struct ArgTraits { + typedef ValueLike ValueCategory; + }; + +-// Microsoft implements size_t awkwardly. +-#if defined(_MSC_VER) && defined(_M_X64) ++// Microsoft implements size_t awkwardly. ++// Studio 2005 introduces unsigned long long, which conflicts with the size_t template ++#if defined(_MSC_VER) && (_MSC_VER < 1400) && defined(_M_X64) + /** + * size_ts have value-like semantics. + */ diff --git a/include/envoy/api/os_sys_calls.h b/include/envoy/api/os_sys_calls.h index e2213a0db0a1..e14fa20e90b9 100644 --- a/include/envoy/api/os_sys_calls.h +++ b/include/envoy/api/os_sys_calls.h @@ -1,20 +1,13 @@ #pragma once -#ifndef WIN32 -#include -#include // for mode_t -#include // for sockaddr #include -#include // for iovec - -#endif #include #include #include "envoy/api/os_sys_calls_common.h" -#include "envoy/common/pure.h" #include "envoy/common/platform.h" +#include "envoy/common/pure.h" namespace Envoy { namespace Api { diff --git a/include/envoy/api/os_sys_calls_common.h b/include/envoy/api/os_sys_calls_common.h index d85aed3407b2..4689e298977f 100644 --- a/include/envoy/api/os_sys_calls_common.h +++ b/include/envoy/api/os_sys_calls_common.h @@ -3,6 +3,8 @@ #include #include +#include "envoy/common/platform.h" + namespace Envoy { namespace Api { /** diff --git a/include/envoy/buffer/buffer.h b/include/envoy/buffer/buffer.h index 1e29bf5cd953..937d0a30faea 100644 --- a/include/envoy/buffer/buffer.h +++ b/include/envoy/buffer/buffer.h @@ -7,6 +7,7 @@ #include "envoy/api/os_sys_calls.h" #include "envoy/common/exception.h" +#include "envoy/common/platform.h" #include "envoy/common/pure.h" #include "envoy/network/io_handle.h" diff --git a/include/envoy/common/platform.h b/include/envoy/common/platform.h index 12e8f4bca33c..7656d3feb161 100644 --- a/include/envoy/common/platform.h +++ b/include/envoy/common/platform.h @@ -1,20 +1,64 @@ #pragma once - // NOLINT(namespace-envoy) + +// This common "platform.h" header exists to simplify the most common references +// to non-ANSI C/C++ headers, required on Windows, Posix, Linux, BSD etc, +// and to provide substitute definitions when absolutely required. +// +// The goal is to eventually not require this file of envoy header declarations, +// but limit the use of these architecture-specific types and declarations +// to the corresponding .cc implementation files. + #ifdef _MSC_VER + +#include +#include + +// These must follow afterwards +#include +#include + +// defines some frequently used symbols, so we need to undef these interfering symbols. +#undef DELETE +#undef ERROR +#undef GetMessage +#undef interface +#undef TRUE + +#include #include #define PACKED_STRUCT(definition, ...) \ __pragma(pack(push, 1)) definition, ##__VA_ARGS__; \ __pragma(pack(pop)) -#ifdef _M_X64 -using ssize_t = int64_t; -#else -#error Envoy is not supported on 32-bit Windows +using ssize_t = ptrdiff_t; + +typedef unsigned int sa_family_t; + +#else // POSIX + +#include +#include +#include +#include +#include +#include +#include // for mode_t +#include +#include // for iovec +#include +#include + +#if defined(__linux__) +#include #endif -#else #define PACKED_STRUCT(definition, ...) definition, ##__VA_ARGS__ __attribute__((packed)) +#ifndef IP6T_SO_ORIGINAL_DST +// From linux/netfilter_ipv6/ip6_tables.h +#define IP6T_SO_ORIGINAL_DST 80 +#endif + #endif diff --git a/include/envoy/network/address.h b/include/envoy/network/address.h index 7c42b8ad772d..5117b4bc1786 100644 --- a/include/envoy/network/address.h +++ b/include/envoy/network/address.h @@ -1,6 +1,5 @@ #pragma once -#include #include #include @@ -9,6 +8,7 @@ #include #include "envoy/api/os_sys_calls.h" +#include "envoy/common/platform.h" #include "envoy/common/pure.h" #include "envoy/network/io_handle.h" diff --git a/include/envoy/network/io_handle.h b/include/envoy/network/io_handle.h index 5062fae0c317..1260fb411d12 100644 --- a/include/envoy/network/io_handle.h +++ b/include/envoy/network/io_handle.h @@ -1,6 +1,7 @@ #pragma once #include "envoy/api/io_error.h" +#include "envoy/common/platform.h" #include "envoy/common/pure.h" namespace Envoy { diff --git a/source/common/common/byte_order.h b/source/common/common/byte_order.h index 2728220e7393..1ca0286399b6 100644 --- a/source/common/common/byte_order.h +++ b/source/common/common/byte_order.h @@ -25,10 +25,7 @@ #elif WIN32 -#include -// includes , so undef some interfering symbols -#undef DELETE -#undef GetMessage +#include "envoy/common/platform.h" #define htole16(x) (x) #define htole32(x) (x) diff --git a/source/common/common/fmt.h b/source/common/common/fmt.h index ba019fabe46a..1c37d0cf32b6 100644 --- a/source/common/common/fmt.h +++ b/source/common/common/fmt.h @@ -1,5 +1,7 @@ #pragma once +#include "envoy/common/platform.h" // Avert format.h including windows.h + #include "absl/strings/string_view.h" #include "fmt/format.h" #include "fmt/ostream.h" diff --git a/source/common/common/perf_annotation.cc b/source/common/common/perf_annotation.cc index b31eb76a5548..f2c8afeb3ff2 100644 --- a/source/common/common/perf_annotation.cc +++ b/source/common/common/perf_annotation.cc @@ -4,12 +4,12 @@ #include "common/common/perf_annotation.h" -#include - #include #include #include +#include "envoy/common/platform.h" + #include "common/common/lock_guard.h" #include "common/common/utility.h" diff --git a/source/common/common/utility.cc b/source/common/common/utility.cc index e67ae4ebb607..2166e2b54614 100644 --- a/source/common/common/utility.cc +++ b/source/common/common/utility.cc @@ -168,7 +168,7 @@ DateFormatter::fromTimeAndPrepareSpecifierOffsets(time_t time, SpecifierOffsets& const std::string& seconds_str) const { std::string formatted_time; - size_t previous = 0; + int32_t previous = 0; specifier_offsets.reserve(specifiers_.size()); for (const auto& specifier : specifiers_) { std::string current_format = @@ -353,7 +353,7 @@ uint32_t StringUtil::itoa(char* out, size_t buffer_size, uint64_t i) { } *current = 0; - return current - out; + return static_cast(current - out); } size_t StringUtil::strlcpy(char* dst, const char* src, size_t size) { diff --git a/source/common/common/version.cc b/source/common/common/version.cc index d7c2f2075a19..d01cf6d90657 100644 --- a/source/common/common/version.cc +++ b/source/common/common/version.cc @@ -6,6 +6,8 @@ #include "common/common/macros.h" #include "common/common/version_linkstamp.h" +#include "absl/strings/string_view.h" + extern const char build_scm_revision[]; extern const char build_scm_status[]; @@ -19,18 +21,18 @@ const std::string& VersionInfo::revisionStatus() { } const std::string& VersionInfo::version() { - CONSTRUCT_ON_FIRST_USE(std::string, fmt::format("{}/{}/{}/{}/{}", revision(), - BUILD_VERSION_NUMBER, revisionStatus(), #ifdef NDEBUG - "RELEASE", + static const absl::string_view release_type = "RELEASE"; #else - "DEBUG", + static const absl::string_view release_type = "DEBUG"; #endif #ifdef ENVOY_SSL_VERSION - ENVOY_SSL_VERSION + static const absl::string_view ssl_version = ENVOY_SSL_VERSION; #else - "no-ssl" + static const absl::string_view ssl_version = "no-ssl"; #endif - )); + CONSTRUCT_ON_FIRST_USE(std::string, + fmt::format("{}/{}/{}/{}/{}", revision(), BUILD_VERSION_NUMBER, + revisionStatus(), release_type, ssl_version)); } } // namespace Envoy diff --git a/source/common/common/win32/thread_impl.h b/source/common/common/win32/thread_impl.h index a8c74eb5d21a..76d61a459943 100644 --- a/source/common/common/win32/thread_impl.h +++ b/source/common/common/win32/thread_impl.h @@ -1,13 +1,8 @@ #pragma once -#include - -// defines some macros that interfere with our code, so undef them -#undef DELETE -#undef GetMessage - #include +#include "envoy/common/platform.h" #include "envoy/thread/thread.h" namespace Envoy { diff --git a/source/common/filesystem/win32/directory_iterator_impl.h b/source/common/filesystem/win32/directory_iterator_impl.h index 6a9713f87b51..bfeed6dde6cc 100644 --- a/source/common/filesystem/win32/directory_iterator_impl.h +++ b/source/common/filesystem/win32/directory_iterator_impl.h @@ -1,15 +1,5 @@ #pragma once -#include - -// uses macros to #define a ton of symbols, two of which (DELETE and GetMessage) -// interfere with our code. DELETE shows up in the base.pb.h header generated from -// api/envoy/api/core/base.proto. Since it's a generated header, we can't #undef DELETE at -// the top of that header to avoid the collision. Similarly, GetMessage shows up in generated -// protobuf code so we can't #undef the symbol there. -#undef DELETE -#undef GetMessage - #include "envoy/filesystem/filesystem.h" namespace Envoy { diff --git a/source/common/filesystem/win32/filesystem_impl.cc b/source/common/filesystem/win32/filesystem_impl.cc index cc08abbc924c..e25fef1d708e 100644 --- a/source/common/filesystem/win32/filesystem_impl.cc +++ b/source/common/filesystem/win32/filesystem_impl.cc @@ -1,18 +1,6 @@ #include #include #include -#include - -// uses macros to #define a ton of symbols, two of which (DELETE and GetMessage) -// interfere with our code. DELETE shows up in the base.pb.h header generated from -// api/envoy/api/core/base.proto. Since it's a generated header, we can't #undef DELETE at -// the top of that header to avoid the collision. Similarly, GetMessage shows up in generated -// protobuf code so we can't #undef the symbol there. -#undef DELETE -#undef GetMessage - -#include "common/common/assert.h" -#include "common/filesystem/filesystem_impl.h" #include #include @@ -21,7 +9,9 @@ #include "envoy/common/exception.h" +#include "common/common/assert.h" #include "common/common/fmt.h" +#include "common/filesystem/filesystem_impl.h" namespace Envoy { namespace Filesystem { diff --git a/source/common/grpc/common.cc b/source/common/grpc/common.cc index 4299fddd6f3e..54c4b3b9639c 100644 --- a/source/common/grpc/common.cc +++ b/source/common/grpc/common.cc @@ -1,7 +1,5 @@ #include "common/grpc/common.h" -#include - #include #include #include diff --git a/source/common/grpc/common.h b/source/common/grpc/common.h index 32f4fd02ee36..e5939eaee45f 100644 --- a/source/common/grpc/common.h +++ b/source/common/grpc/common.h @@ -4,6 +4,7 @@ #include #include "envoy/common/exception.h" +#include "envoy/common/platform.h" #include "envoy/grpc/status.h" #include "envoy/http/filter.h" #include "envoy/http/header_map.h" diff --git a/source/common/grpc/google_async_client_impl.h b/source/common/grpc/google_async_client_impl.h index 09ef09b951bc..edc633a08d4d 100644 --- a/source/common/grpc/google_async_client_impl.h +++ b/source/common/grpc/google_async_client_impl.h @@ -3,6 +3,7 @@ #include #include "envoy/api/api.h" +#include "envoy/common/platform.h" #include "envoy/grpc/async_client.h" #include "envoy/stats/scope.h" #include "envoy/thread/thread.h" diff --git a/source/common/grpc/google_grpc_creds_impl.h b/source/common/grpc/google_grpc_creds_impl.h index c7104f6a32d0..485a6ba75ad8 100644 --- a/source/common/grpc/google_grpc_creds_impl.h +++ b/source/common/grpc/google_grpc_creds_impl.h @@ -2,6 +2,7 @@ #include "envoy/api/api.h" #include "envoy/api/v2/core/grpc_service.pb.h" +#include "envoy/common/platform.h" #include "grpcpp/grpcpp.h" diff --git a/source/common/grpc/google_grpc_utils.h b/source/common/grpc/google_grpc_utils.h index 9500ce0589b3..476aeaa3ee22 100644 --- a/source/common/grpc/google_grpc_utils.h +++ b/source/common/grpc/google_grpc_utils.h @@ -4,6 +4,7 @@ #include #include "envoy/buffer/buffer.h" +#include "envoy/common/platform.h" #include "grpcpp/grpcpp.h" diff --git a/source/common/http/http2/nghttp2.cc b/source/common/http/http2/nghttp2.cc index 5781cfa262ad..448ea9bb2404 100644 --- a/source/common/http/http2/nghttp2.cc +++ b/source/common/http/http2/nghttp2.cc @@ -2,6 +2,11 @@ #include "common/common/logger.h" +// nghttp2 fails to convey the POSIX ssize_t declaration +// that Microsoft declines to implement. Pick up a valid +// ssize_t declaration for win32 in our platform.h +#include "envoy/common/platform.h" + #include "nghttp2/nghttp2.h" namespace Envoy { diff --git a/source/common/network/addr_family_aware_socket_option_impl.cc b/source/common/network/addr_family_aware_socket_option_impl.cc index 2e06974f5aa3..ffa31a96f565 100644 --- a/source/common/network/addr_family_aware_socket_option_impl.cc +++ b/source/common/network/addr_family_aware_socket_option_impl.cc @@ -1,6 +1,7 @@ #include "common/network/addr_family_aware_socket_option_impl.h" #include "envoy/common/exception.h" +#include "envoy/common/platform.h" #include "common/api/os_sys_calls_impl.h" #include "common/common/assert.h" diff --git a/source/common/network/addr_family_aware_socket_option_impl.h b/source/common/network/addr_family_aware_socket_option_impl.h index b54eb244f187..1e8b463dbd4a 100644 --- a/source/common/network/addr_family_aware_socket_option_impl.h +++ b/source/common/network/addr_family_aware_socket_option_impl.h @@ -1,8 +1,6 @@ #pragma once -#include -#include - +#include "envoy/common/platform.h" #include "envoy/network/listen_socket.h" #include "common/common/logger.h" diff --git a/source/common/network/address_impl.cc b/source/common/network/address_impl.cc index ed84671094f1..a690e85c8cfd 100644 --- a/source/common/network/address_impl.cc +++ b/source/common/network/address_impl.cc @@ -1,15 +1,11 @@ #include "common/network/address_impl.h" -#include -#include -#include -#include - #include #include #include #include "envoy/common/exception.h" +#include "envoy/common/platform.h" #include "common/api/os_sys_calls_impl.h" #include "common/common/assert.h" diff --git a/source/common/network/address_impl.h b/source/common/network/address_impl.h index 63e0566ffaaa..d35ca44842a8 100644 --- a/source/common/network/address_impl.h +++ b/source/common/network/address_impl.h @@ -1,14 +1,12 @@ #pragma once -#include -#include #include -#include #include #include #include +#include "envoy/common/platform.h" #include "envoy/network/address.h" #include "envoy/network/io_handle.h" diff --git a/source/common/network/base_listener_impl.cc b/source/common/network/base_listener_impl.cc index 7340dd693bc5..2377c48b4595 100644 --- a/source/common/network/base_listener_impl.cc +++ b/source/common/network/base_listener_impl.cc @@ -1,7 +1,5 @@ #include "common/network/base_listener_impl.h" -#include - #include "envoy/common/exception.h" #include "common/common/assert.h" diff --git a/source/common/network/cidr_range.cc b/source/common/network/cidr_range.cc index 50b33dccbd64..f59686389a88 100644 --- a/source/common/network/cidr_range.cc +++ b/source/common/network/cidr_range.cc @@ -1,15 +1,12 @@ #include "common/network/cidr_range.h" -#include -#include -#include - #include #include #include #include #include "envoy/common/exception.h" +#include "envoy/common/platform.h" #include "common/common/assert.h" #include "common/common/fmt.h" diff --git a/source/common/network/connection_impl.cc b/source/common/network/connection_impl.cc index 44b073083c1c..933d2940b440 100644 --- a/source/common/network/connection_impl.cc +++ b/source/common/network/connection_impl.cc @@ -1,15 +1,11 @@ #include "common/network/connection_impl.h" -#include -#include -#include -#include - #include #include #include #include "envoy/common/exception.h" +#include "envoy/common/platform.h" #include "envoy/event/timer.h" #include "envoy/network/filter.h" diff --git a/source/common/network/dns_impl.cc b/source/common/network/dns_impl.cc index fbde214f9aab..17be12924d9f 100644 --- a/source/common/network/dns_impl.cc +++ b/source/common/network/dns_impl.cc @@ -1,15 +1,13 @@ #include "common/network/dns_impl.h" -#include -#include -#include - #include #include #include #include #include +#include "envoy/common/platform.h" + #include "common/common/assert.h" #include "common/common/fmt.h" #include "common/network/address_impl.h" diff --git a/source/common/network/dns_impl.h b/source/common/network/dns_impl.h index 096c2c71178f..8f73c8922504 100644 --- a/source/common/network/dns_impl.h +++ b/source/common/network/dns_impl.h @@ -1,11 +1,10 @@ #pragma once -#include - #include #include #include +#include "envoy/common/platform.h" #include "envoy/event/dispatcher.h" #include "envoy/event/file_event.h" #include "envoy/network/dns.h" diff --git a/source/common/network/io_socket_handle_impl.h b/source/common/network/io_socket_handle_impl.h index 78e6211d35da..cce287eab60b 100644 --- a/source/common/network/io_socket_handle_impl.h +++ b/source/common/network/io_socket_handle_impl.h @@ -2,6 +2,7 @@ #include "envoy/api/io_error.h" #include "envoy/api/os_sys_calls.h" +#include "envoy/common/platform.h" #include "envoy/network/io_handle.h" #include "common/common/logger.h" diff --git a/source/common/network/lc_trie.h b/source/common/network/lc_trie.h index cf6dfdb0d65a..7039642b17ab 100644 --- a/source/common/network/lc_trie.h +++ b/source/common/network/lc_trie.h @@ -1,12 +1,11 @@ #pragma once -#include - #include #include #include #include "envoy/common/exception.h" +#include "envoy/common/platform.h" #include "envoy/network/address.h" #include "common/common/assert.h" diff --git a/source/common/network/listen_socket_impl.cc b/source/common/network/listen_socket_impl.cc index dc9e8991805c..aac2196dc98d 100644 --- a/source/common/network/listen_socket_impl.cc +++ b/source/common/network/listen_socket_impl.cc @@ -1,11 +1,11 @@ #include "common/network/listen_socket_impl.h" -#include #include #include #include "envoy/common/exception.h" +#include "envoy/common/platform.h" #include "common/api/os_sys_calls_impl.h" #include "common/common/assert.h" diff --git a/source/common/network/listen_socket_impl.h b/source/common/network/listen_socket_impl.h index a5247e68f192..2cd7c6b32d67 100644 --- a/source/common/network/listen_socket_impl.h +++ b/source/common/network/listen_socket_impl.h @@ -1,11 +1,10 @@ #pragma once -#include - #include #include #include +#include "envoy/common/platform.h" #include "envoy/network/connection.h" #include "envoy/network/listen_socket.h" diff --git a/source/common/network/listener_impl.cc b/source/common/network/listener_impl.cc index bd0679464cc3..84498125d511 100644 --- a/source/common/network/listener_impl.cc +++ b/source/common/network/listener_impl.cc @@ -1,8 +1,7 @@ #include "common/network/listener_impl.h" -#include - #include "envoy/common/exception.h" +#include "envoy/common/platform.h" #include "common/common/assert.h" #include "common/common/empty_string.h" diff --git a/source/common/network/socket_option_factory.h b/source/common/network/socket_option_factory.h index 6fb2f2f5abad..f9b02f04864e 100644 --- a/source/common/network/socket_option_factory.h +++ b/source/common/network/socket_option_factory.h @@ -1,9 +1,7 @@ #pragma once -#include -#include - #include "envoy/api/v2/core/address.pb.h" +#include "envoy/common/platform.h" #include "envoy/network/listen_socket.h" #include "common/common/logger.h" diff --git a/source/common/network/socket_option_impl.h b/source/common/network/socket_option_impl.h index 1a13a67010cb..577608f1a778 100644 --- a/source/common/network/socket_option_impl.h +++ b/source/common/network/socket_option_impl.h @@ -1,10 +1,7 @@ #pragma once -#include -#include -#include - #include "envoy/api/os_sys_calls.h" +#include "envoy/common/platform.h" #include "envoy/network/listen_socket.h" #include "common/common/assert.h" diff --git a/source/common/network/udp_listener_impl.cc b/source/common/network/udp_listener_impl.cc index a3c5237e60f1..a89bc20f5930 100644 --- a/source/common/network/udp_listener_impl.cc +++ b/source/common/network/udp_listener_impl.cc @@ -1,13 +1,12 @@ #include "common/network/udp_listener_impl.h" -#include - #include #include #include #include "envoy/buffer/buffer.h" #include "envoy/common/exception.h" +#include "envoy/common/platform.h" #include "common/api/os_sys_calls_impl.h" #include "common/common/assert.h" diff --git a/source/common/network/utility.cc b/source/common/network/utility.cc index 667d0ccc997f..4c9034cbfb0c 100644 --- a/source/common/network/utility.cc +++ b/source/common/network/utility.cc @@ -1,20 +1,5 @@ #include "common/network/utility.h" -#include -#include - -#if defined(__linux__) -#include -#endif - -#ifndef IP6T_SO_ORIGINAL_DST -// From linux/netfilter_ipv6/ip6_tables.h -#define IP6T_SO_ORIGINAL_DST 80 -#endif - -#include -#include - #include #include #include @@ -22,18 +7,18 @@ #include #include "envoy/common/exception.h" +#include "envoy/common/platform.h" #include "envoy/network/connection.h" #include "common/api/os_sys_calls_impl.h" +#include "common/buffer/buffer_impl.h" #include "common/common/assert.h" #include "common/common/cleanup.h" +#include "common/common/fmt.h" #include "common/common/utility.h" -#include "common/buffer/buffer_impl.h" #include "common/network/address_impl.h" -#include "common/protobuf/protobuf.h" #include "common/network/io_socket_error_impl.h" - -#include "common/common/fmt.h" +#include "common/protobuf/protobuf.h" #include "absl/strings/match.h" diff --git a/source/common/network/utility.h b/source/common/network/utility.h index 53d3db2c75e6..34443c219f1b 100644 --- a/source/common/network/utility.h +++ b/source/common/network/utility.h @@ -5,6 +5,7 @@ #include #include "envoy/api/v2/core/address.pb.h" +#include "envoy/common/platform.h" #include "envoy/network/connection.h" #include "absl/strings/string_view.h" diff --git a/source/common/protobuf/protobuf.h b/source/common/protobuf/protobuf.h index aa3b78ce4902..4cf6fe865fc5 100644 --- a/source/common/protobuf/protobuf.h +++ b/source/common/protobuf/protobuf.h @@ -4,6 +4,8 @@ #include #include +#include "envoy/common/platform.h" + #include "google/protobuf/any.pb.h" #include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.pb.h" diff --git a/source/common/router/retry_state_impl.cc b/source/common/router/retry_state_impl.cc index 0f3c7060765a..63e879e333e5 100644 --- a/source/common/router/retry_state_impl.cc +++ b/source/common/router/retry_state_impl.cc @@ -92,10 +92,10 @@ RetryStateImpl::RetryStateImpl(const RetryPolicy& route_policy, Http::HeaderMap& if (!retriable_request_headers_.empty()) { // If this route limits retries by request headers, make sure there is a match. - bool request_header_match = false; + uint32_t request_header_match = 0; for (const auto& retriable_header : retriable_request_headers_) { if (retriable_header->matchesHeaders(request_headers)) { - request_header_match = true; + request_header_match = 1; break; } } @@ -112,7 +112,7 @@ RetryStateImpl::RetryStateImpl(const RetryPolicy& route_policy, Http::HeaderMap& if (request_headers.EnvoyRetriableStatusCodes()) { for (const auto code : StringUtil::splitToken( request_headers.EnvoyRetriableStatusCodes()->value().getStringView(), ",")) { - uint64_t out; + unsigned int out; if (absl::SimpleAtoi(code, &out)) { retriable_status_codes_.emplace_back(out); } diff --git a/source/common/singleton/threadsafe_singleton.h b/source/common/singleton/threadsafe_singleton.h index 39f3df7fd7fe..5b55dc0af517 100644 --- a/source/common/singleton/threadsafe_singleton.h +++ b/source/common/singleton/threadsafe_singleton.h @@ -25,6 +25,7 @@ namespace Envoy { * where state "leaks" across tests. * * */ +template class TestThreadsafeSingletonInjector; template class ThreadSafeSingleton { public: static T& get() { diff --git a/source/common/tracing/http_tracer_impl.h b/source/common/tracing/http_tracer_impl.h index bb99d7934e77..4d0cc4ec05c2 100644 --- a/source/common/tracing/http_tracer_impl.h +++ b/source/common/tracing/http_tracer_impl.h @@ -2,6 +2,7 @@ #include +#include "envoy/common/platform.h" #include "envoy/local_info/local_info.h" #include "envoy/runtime/runtime.h" #include "envoy/thread_local/thread_local.h" diff --git a/source/common/upstream/edf_scheduler.h b/source/common/upstream/edf_scheduler.h index 192eb7d39161..fc135dfc1490 100644 --- a/source/common/upstream/edf_scheduler.h +++ b/source/common/upstream/edf_scheduler.h @@ -13,9 +13,9 @@ namespace Upstream { #define EDF_DEBUG 0 #if EDF_DEBUG -#define EDF_TRACE(fmt...) ENVOY_LOG_MISC(trace, fmt) +#define EDF_TRACE(...) ENVOY_LOG_MISC(trace, __VA_ARGS__) #else -#define EDF_TRACE(fmt...) +#define EDF_TRACE(...) #endif // Earliest Deadline First (EDF) scheduler diff --git a/source/common/upstream/load_balancer_impl.cc b/source/common/upstream/load_balancer_impl.cc index b3172d9c9a27..742978bf4f2f 100644 --- a/source/common/upstream/load_balancer_impl.cc +++ b/source/common/upstream/load_balancer_impl.cc @@ -79,7 +79,7 @@ LoadBalancerBase::choosePriority(uint64_t hash, const HealthyLoad& healthy_per_p for (size_t priority = 0; priority < healthy_per_priority_load.get().size(); ++priority) { aggregate_percentage_load += healthy_per_priority_load.get()[priority]; if (hash <= aggregate_percentage_load) { - return {priority, HostAvailability::Healthy}; + return {static_cast(priority), HostAvailability::Healthy}; } } @@ -88,7 +88,7 @@ LoadBalancerBase::choosePriority(uint64_t hash, const HealthyLoad& healthy_per_p for (size_t priority = 0; priority < degraded_per_priority_load.get().size(); ++priority) { aggregate_percentage_load += degraded_per_priority_load.get()[priority]; if (hash <= aggregate_percentage_load) { - return {priority, HostAvailability::Degraded}; + return {static_cast(priority), HostAvailability::Degraded}; } } diff --git a/source/common/upstream/upstream_impl.h b/source/common/upstream/upstream_impl.h index 6a32adbb0262..4a438594b529 100644 --- a/source/common/upstream/upstream_impl.h +++ b/source/common/upstream/upstream_impl.h @@ -237,7 +237,7 @@ class HostImpl : public HostDescriptionImpl, private: void setEdsHealthFlag(envoy::api::v2::core::HealthStatus health_status); - std::atomic health_flags_{}; + std::atomic health_flags_{}; ActiveHealthFailureType active_health_failure_type_{}; std::atomic weight_; std::atomic used_; diff --git a/source/exe/win32/platform_impl.cc b/source/exe/win32/platform_impl.cc index 674ad0db0b1f..5db56c722521 100644 --- a/source/exe/win32/platform_impl.cc +++ b/source/exe/win32/platform_impl.cc @@ -4,10 +4,6 @@ #include "exe/platform_impl.h" -// clang-format off -#include -// clang-format on - namespace Envoy { PlatformImpl::PlatformImpl() diff --git a/source/extensions/common/tap/tap_config_base.cc b/source/extensions/common/tap/tap_config_base.cc index 5db293de3a84..f99dc4f6009a 100644 --- a/source/extensions/common/tap/tap_config_base.cc +++ b/source/extensions/common/tap/tap_config_base.cc @@ -167,7 +167,9 @@ void FilePerTapSink::FilePerTapSinkHandle::submitTrace( } ENVOY_LOG_MISC(debug, "Opening tap file for [id={}] to {}", trace_id_, path); - output_file_.open(path); + // When reading and writing binary files, we need to be sure std::ios_base::binary + // is set, otherwise we will not get the expected results on Windows + output_file_.open(path, std::ios_base::binary); } ENVOY_LOG_MISC(trace, "Tap for [id={}]: {}", trace_id_, trace->DebugString()); diff --git a/source/extensions/filters/http/grpc_web/grpc_web_filter.cc b/source/extensions/filters/http/grpc_web/grpc_web_filter.cc index 67113d6d73b5..718ae11bffbc 100644 --- a/source/extensions/filters/http/grpc_web/grpc_web_filter.cc +++ b/source/extensions/filters/http/grpc_web/grpc_web_filter.cc @@ -1,6 +1,8 @@ #include "extensions/filters/http/grpc_web/grpc_web_filter.h" +#ifndef WIN32 #include +#endif #include "common/common/assert.h" #include "common/common/base64.h" diff --git a/source/extensions/filters/listener/proxy_protocol/proxy_protocol.cc b/source/extensions/filters/listener/proxy_protocol/proxy_protocol.cc index f4dce6138b9c..ab4acf68d871 100644 --- a/source/extensions/filters/listener/proxy_protocol/proxy_protocol.cc +++ b/source/extensions/filters/listener/proxy_protocol/proxy_protocol.cc @@ -1,8 +1,5 @@ #include "extensions/filters/listener/proxy_protocol/proxy_protocol.h" -#include -#include - #include #include #include diff --git a/source/extensions/filters/listener/tls_inspector/tls_inspector.cc b/source/extensions/filters/listener/tls_inspector/tls_inspector.cc index d38ca293f81c..af7f79869bca 100644 --- a/source/extensions/filters/listener/tls_inspector/tls_inspector.cc +++ b/source/extensions/filters/listener/tls_inspector/tls_inspector.cc @@ -1,12 +1,11 @@ #include "extensions/filters/listener/tls_inspector/tls_inspector.h" -#include - #include #include #include #include "envoy/common/exception.h" +#include "envoy/common/platform.h" #include "envoy/event/dispatcher.h" #include "envoy/network/listen_socket.h" #include "envoy/stats/scope.h" diff --git a/source/extensions/filters/network/common/redis/codec_impl.cc b/source/extensions/filters/network/common/redis/codec_impl.cc index ab01d85d6ebb..6b62e228bfa6 100644 --- a/source/extensions/filters/network/common/redis/codec_impl.cc +++ b/source/extensions/filters/network/common/redis/codec_impl.cc @@ -5,6 +5,8 @@ #include #include +#include "envoy/common/platform.h" + #include "common/common/assert.h" #include "common/common/fmt.h" #include "common/common/stack_array.h" diff --git a/source/extensions/filters/network/http_connection_manager/config.cc b/source/extensions/filters/network/http_connection_manager/config.cc index daf2fdf04697..51887ea96e59 100644 --- a/source/extensions/filters/network/http_connection_manager/config.cc +++ b/source/extensions/filters/network/http_connection_manager/config.cc @@ -172,16 +172,19 @@ HttpConnectionManagerConfig::HttpConnectionManagerConfig( context_.listenerScope())), proxy_100_continue_(config.proxy_100_continue()), delayed_close_timeout_(PROTOBUF_GET_MS_OR_DEFAULT(config, delayed_close_timeout, 1000)), +#ifdef ENVOY_NORMALIZE_PATH_BY_DEFAULT normalize_path_(PROTOBUF_GET_WRAPPED_OR_DEFAULT( config, normalize_path, // TODO(htuch): we should have a boolean variant of featureEnabled() here. context.runtime().snapshot().featureEnabled("http_connection_manager.normalize_path", -#ifdef ENVOY_NORMALIZE_PATH_BY_DEFAULT - 100 + 100))), #else - 0 + normalize_path_(PROTOBUF_GET_WRAPPED_OR_DEFAULT( + config, normalize_path, + // TODO(htuch): we should have a boolean variant of featureEnabled() here. + context.runtime().snapshot().featureEnabled("http_connection_manager.normalize_path", + 0))), #endif - ))), merge_slashes_(config.merge_slashes()) { // If idle_timeout_ was not configured in common_http_protocol_options, use value in deprecated // idle_timeout field. diff --git a/source/extensions/filters/network/mysql_proxy/mysql_decoder.cc b/source/extensions/filters/network/mysql_proxy/mysql_decoder.cc index 7bc5bac497d7..9b102316e81b 100644 --- a/source/extensions/filters/network/mysql_proxy/mysql_decoder.cc +++ b/source/extensions/filters/network/mysql_proxy/mysql_decoder.cc @@ -1,7 +1,5 @@ #include "extensions/filters/network/mysql_proxy/mysql_decoder.h" -#include - #include "extensions/filters/network/mysql_proxy/mysql_utils.h" namespace Envoy { diff --git a/source/extensions/filters/network/mysql_proxy/mysql_utils.cc b/source/extensions/filters/network/mysql_proxy/mysql_utils.cc index ed8a86f47c04..9e154fa69167 100644 --- a/source/extensions/filters/network/mysql_proxy/mysql_utils.cc +++ b/source/extensions/filters/network/mysql_proxy/mysql_utils.cc @@ -1,7 +1,5 @@ #include "extensions/filters/network/mysql_proxy/mysql_utils.h" -#include - namespace Envoy { namespace Extensions { namespace NetworkFilters { diff --git a/source/extensions/filters/network/redis_proxy/command_splitter_impl.cc b/source/extensions/filters/network/redis_proxy/command_splitter_impl.cc index 7d9548c28cf8..3d838d9f0364 100644 --- a/source/extensions/filters/network/redis_proxy/command_splitter_impl.cc +++ b/source/extensions/filters/network/redis_proxy/command_splitter_impl.cc @@ -256,7 +256,7 @@ SplitRequestPtr MGETRequest::create(Router& router, Common::Redis::RespValuePtr& single_mget.type(Common::Redis::RespType::Array); single_mget.asArray().swap(values); - for (uint64_t i = 1; i < incoming_request->asArray().size(); i++) { + for (unsigned int i = 1; i < incoming_request->asArray().size(); i++) { request_ptr->pending_requests_.emplace_back(*request_ptr, i - 1); PendingRequest& pending_request = request_ptr->pending_requests_.back(); @@ -391,8 +391,8 @@ SplitRequestPtr MSETRequest::create(Router& router, Common::Redis::RespValuePtr& single_mset.type(Common::Redis::RespType::Array); single_mset.asArray().swap(values); - uint64_t fragment_index = 0; - for (uint64_t i = 1; i < incoming_request->asArray().size(); i += 2) { + unsigned fragment_index = 0; + for (unsigned i = 1; i < incoming_request->asArray().size(); i += 2) { request_ptr->pending_requests_.emplace_back(*request_ptr, fragment_index++); PendingRequest& pending_request = request_ptr->pending_requests_.back(); @@ -487,7 +487,7 @@ SplitRequestPtr SplitKeysSumResultRequest::create(Router& router, single_fragment.type(Common::Redis::RespType::Array); single_fragment.asArray().swap(values); - for (uint64_t i = 1; i < incoming_request->asArray().size(); i++) { + for (unsigned i = 1; i < incoming_request->asArray().size(); i++) { request_ptr->pending_requests_.emplace_back(*request_ptr, i - 1); PendingRequest& pending_request = request_ptr->pending_requests_.back(); diff --git a/source/extensions/filters/network/redis_proxy/conn_pool_impl.cc b/source/extensions/filters/network/redis_proxy/conn_pool_impl.cc index cec9e144a37c..8bdaa8656894 100644 --- a/source/extensions/filters/network/redis_proxy/conn_pool_impl.cc +++ b/source/extensions/filters/network/redis_proxy/conn_pool_impl.cc @@ -247,7 +247,7 @@ InstanceImpl::ThreadLocalPool::makeRequestToHost(const std::string& host_address host_address_map_key = host_address; } else { const auto ip_port = absl::string_view(host_address).substr(colon_pos + 1); - uint64_t ip_port_number; + uint32_t ip_port_number; if (!absl::SimpleAtoi(ip_port, &ip_port_number) || (ip_port_number > 65535)) { return nullptr; } @@ -270,7 +270,7 @@ InstanceImpl::ThreadLocalPool::makeRequestToHost(const std::string& host_address if (!ipv6) { // Only create an IPv4 address instance if we need a new Upstream::HostImpl. const auto ip_port = absl::string_view(host_address).substr(colon_pos + 1); - uint64_t ip_port_number; + uint32_t ip_port_number; if (!absl::SimpleAtoi(ip_port, &ip_port_number) || (ip_port_number > 65535)) { return nullptr; } diff --git a/source/extensions/quic_listeners/quiche/envoy_quic_packet_writer.cc b/source/extensions/quic_listeners/quiche/envoy_quic_packet_writer.cc index 02360ae9b66c..0fca1ea83772 100644 --- a/source/extensions/quic_listeners/quiche/envoy_quic_packet_writer.cc +++ b/source/extensions/quic_listeners/quiche/envoy_quic_packet_writer.cc @@ -1,22 +1,10 @@ #include "extensions/quic_listeners/quiche/envoy_quic_packet_writer.h" -#include - -#pragma GCC diagnostic push - -// QUICHE allows unused parameters. -#pragma GCC diagnostic ignored "-Wunused-parameter" -// QUICHE uses offsetof(). -#pragma GCC diagnostic ignored "-Winvalid-offsetof" - -#include "quiche/quic/core/quic_types.h" - -#pragma GCC diagnostic pop - -#include "extensions/quic_listeners/quiche/envoy_quic_utils.h" #include "common/buffer/buffer_impl.h" #include "common/network/utility.h" +#include "extensions/quic_listeners/quiche/envoy_quic_utils.h" + namespace Envoy { namespace Quic { EnvoyQuicPacketWriter::EnvoyQuicPacketWriter(Network::Socket& socket) diff --git a/source/extensions/quic_listeners/quiche/envoy_quic_utils.cc b/source/extensions/quic_listeners/quiche/envoy_quic_utils.cc index 33e0c43fc035..6d257d974474 100644 --- a/source/extensions/quic_listeners/quiche/envoy_quic_utils.cc +++ b/source/extensions/quic_listeners/quiche/envoy_quic_utils.cc @@ -1,7 +1,5 @@ #include "extensions/quic_listeners/quiche/envoy_quic_utils.h" -#include - namespace Envoy { namespace Quic { diff --git a/source/extensions/quic_listeners/quiche/envoy_quic_utils.h b/source/extensions/quic_listeners/quiche/envoy_quic_utils.h index 54b1bf07f603..9870bb8fd8bf 100644 --- a/source/extensions/quic_listeners/quiche/envoy_quic_utils.h +++ b/source/extensions/quic_listeners/quiche/envoy_quic_utils.h @@ -1,9 +1,21 @@ +#include "envoy/common/platform.h" #include "envoy/http/codec.h" #include "common/common/assert.h" #include "common/http/header_map_impl.h" #include "common/network/address_impl.h" +#pragma GCC diagnostic push + +// QUICHE allows unused parameters. +#pragma GCC diagnostic ignored "-Wunused-parameter" +// QUICHE uses offsetof(). +#pragma GCC diagnostic ignored "-Winvalid-offsetof" + +#include "quiche/quic/core/quic_types.h" + +#pragma GCC diagnostic pop + #include "quiche/quic/core/http/quic_header_list.h" #include "quiche/quic/core/quic_error_codes.h" #include "quiche/quic/platform/api/quic_ip_address.h" diff --git a/source/extensions/quic_listeners/quiche/platform/quic_aligned_impl.h b/source/extensions/quic_listeners/quiche/platform/quic_aligned_impl.h index 73659ace0e63..3f595380b720 100644 --- a/source/extensions/quic_listeners/quiche/platform/quic_aligned_impl.h +++ b/source/extensions/quic_listeners/quiche/platform/quic_aligned_impl.h @@ -9,6 +9,10 @@ // porting layer for QUICHE. #define QUIC_ALIGN_OF_IMPL alignof +#ifdef _MSC_VER +#define QUIC_ALIGNED_IMPL(X) __declspec(align(X)) +#else #define QUIC_ALIGNED_IMPL(X) __attribute__((aligned(X))) +#endif #define QUIC_CACHELINE_ALIGNED_IMPL ABSL_CACHELINE_ALIGNED #define QUIC_CACHELINE_SIZE_IMPL ABSL_CACHELINE_SIZE diff --git a/source/extensions/quic_listeners/quiche/platform/spdy_endianness_util_impl.h b/source/extensions/quic_listeners/quiche/platform/spdy_endianness_util_impl.h index f72c476b34f8..737b81ee2914 100644 --- a/source/extensions/quic_listeners/quiche/platform/spdy_endianness_util_impl.h +++ b/source/extensions/quic_listeners/quiche/platform/spdy_endianness_util_impl.h @@ -1,9 +1,9 @@ #pragma once -#include - #include +#include "envoy/common/platform.h" + // NOLINT(namespace-envoy) // This file is part of the QUICHE platform implementation, and is not to be diff --git a/source/extensions/quic_listeners/quiche/platform/string_utils.cc b/source/extensions/quic_listeners/quiche/platform/string_utils.cc index 2bcbc11c4190..d9999ac9b0ab 100644 --- a/source/extensions/quic_listeners/quiche/platform/string_utils.cc +++ b/source/extensions/quic_listeners/quiche/platform/string_utils.cc @@ -6,10 +6,10 @@ // consumed or referenced directly by other Envoy code. It serves purely as a // porting layer for QUICHE. -#include #include #include +#include "envoy/common/platform.h" #include "absl/strings/ascii.h" #include "absl/strings/escaping.h" #include "absl/strings/str_format.h" diff --git a/source/extensions/stat_sinks/common/statsd/statsd.cc b/source/extensions/stat_sinks/common/statsd/statsd.cc index 3cdf14ec6955..3e93171df0b5 100644 --- a/source/extensions/stat_sinks/common/statsd/statsd.cc +++ b/source/extensions/stat_sinks/common/statsd/statsd.cc @@ -5,10 +5,12 @@ #include #include "envoy/common/exception.h" +#include "envoy/common/platform.h" #include "envoy/event/dispatcher.h" #include "envoy/stats/scope.h" #include "envoy/upstream/cluster_manager.h" +#include "common/api/os_sys_calls_impl.h" #include "common/common/assert.h" #include "common/common/fmt.h" #include "common/common/utility.h" diff --git a/source/extensions/stat_sinks/common/statsd/statsd.h b/source/extensions/stat_sinks/common/statsd/statsd.h index a6eb91a62750..7d1dd18be2ca 100644 --- a/source/extensions/stat_sinks/common/statsd/statsd.h +++ b/source/extensions/stat_sinks/common/statsd/statsd.h @@ -1,5 +1,6 @@ #pragma once +#include "envoy/common/platform.h" #include "envoy/local_info/local_info.h" #include "envoy/network/connection.h" #include "envoy/stats/histogram.h" diff --git a/source/extensions/transport_sockets/alts/grpc_tsi.h b/source/extensions/transport_sockets/alts/grpc_tsi.h index 825f3d495d93..d3aa0a0b1592 100644 --- a/source/extensions/transport_sockets/alts/grpc_tsi.h +++ b/source/extensions/transport_sockets/alts/grpc_tsi.h @@ -4,16 +4,20 @@ // compile with -Werror, ignoring those compiler warning since we don't have // control on those source codes. This works with GCC and Clang. +#ifndef _MSC_VER #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" #pragma GCC diagnostic ignored "-Wold-style-cast" +#endif #include "grpc/grpc_security.h" #include "src/core/tsi/alts/handshaker/alts_shared_resource.h" #include "src/core/tsi/alts/handshaker/alts_tsi_handshaker.h" #include "src/core/tsi/transport_security_interface.h" +#ifndef _MSC_VER #pragma GCC diagnostic pop +#endif #include "common/common/c_smart_ptr.h" diff --git a/source/extensions/transport_sockets/tls/context_impl.cc b/source/extensions/transport_sockets/tls/context_impl.cc index 38015f81a874..0c3844e52b9a 100644 --- a/source/extensions/transport_sockets/tls/context_impl.cc +++ b/source/extensions/transport_sockets/tls/context_impl.cc @@ -1,13 +1,12 @@ #include "extensions/transport_sockets/tls/context_impl.h" -#include - #include #include #include #include #include "envoy/common/exception.h" +#include "envoy/common/platform.h" #include "envoy/stats/scope.h" #include "common/common/assert.h" diff --git a/source/server/listener_impl.cc b/source/server/listener_impl.cc index 32661629bd52..bec30d337b54 100644 --- a/source/server/listener_impl.cc +++ b/source/server/listener_impl.cc @@ -172,11 +172,11 @@ ListenerImpl::ListenerImpl(const envoy::api::v2::Listener& config, const std::st (matcher.transport_protocol().empty() && (!matcher.server_names().empty() || !matcher.application_protocols().empty())); }) && - not std::any_of(config.listener_filters().begin(), config.listener_filters().end(), - [](const auto& filter) { - return filter.name() == - Extensions::ListenerFilters::ListenerFilterNames::get().TlsInspector; - }); + !std::any_of(config.listener_filters().begin(), config.listener_filters().end(), + [](const auto& filter) { + return filter.name() == + Extensions::ListenerFilters::ListenerFilterNames::get().TlsInspector; + }); // Automatically inject TLS Inspector if it wasn't configured explicitly and it's needed. if (need_tls_inspector) { const std::string message = @@ -316,4 +316,4 @@ void ListenerImpl::setSocket(const Network::SocketSharedPtr& socket) { } } // namespace Server -} // namespace Envoy \ No newline at end of file +} // namespace Envoy diff --git a/test/common/access_log/access_log_impl_test.cc b/test/common/access_log/access_log_impl_test.cc index 71220bd9e04e..7ebc5caf1416 100644 --- a/test/common/access_log/access_log_impl_test.cc +++ b/test/common/access_log/access_log_impl_test.cc @@ -1309,7 +1309,8 @@ class SampleExtensionFilterFactory : public ExtensionFilterFactory { config, Envoy::ProtobufMessage::getNullValidationVisitor(), *this); const Json::ObjectSharedPtr filter_config = MessageUtil::getJsonObjectFromMessage(*factory_config); - return std::make_unique(filter_config->getInteger("rate")); + return std::make_unique( + static_cast(filter_config->getInteger("rate"))); } ProtobufTypes::MessagePtr createEmptyConfigProto() override { diff --git a/test/common/buffer/buffer_fuzz.cc b/test/common/buffer/buffer_fuzz.cc index fe2453905ce6..b419da61f8ba 100644 --- a/test/common/buffer/buffer_fuzz.cc +++ b/test/common/buffer/buffer_fuzz.cc @@ -1,7 +1,8 @@ #include "test/common/buffer/buffer_fuzz.h" #include -#include + +#include "envoy/common/platform.h" #include "common/buffer/buffer_impl.h" #include "common/common/assert.h" diff --git a/test/common/grpc/common_test.cc b/test/common/grpc/common_test.cc index 68128c7faf71..ec3f6d7cff91 100644 --- a/test/common/grpc/common_test.cc +++ b/test/common/grpc/common_test.cc @@ -1,4 +1,4 @@ -#include +#include "envoy/common/platform.h" #include "common/grpc/common.h" #include "common/http/headers.h" diff --git a/test/common/grpc/context_impl_test.cc b/test/common/grpc/context_impl_test.cc index 6cd6c47b3b62..e75434e0595d 100644 --- a/test/common/grpc/context_impl_test.cc +++ b/test/common/grpc/context_impl_test.cc @@ -1,4 +1,4 @@ -#include +#include "envoy/common/platform.h" #include "common/grpc/common.h" #include "common/grpc/context_impl.h" diff --git a/test/common/grpc/google_grpc_utils_test.cc b/test/common/grpc/google_grpc_utils_test.cc index 20a9836f6a20..f115d1ab3015 100644 --- a/test/common/grpc/google_grpc_utils_test.cc +++ b/test/common/grpc/google_grpc_utils_test.cc @@ -1,4 +1,4 @@ -#include +#include "envoy/common/platform.h" #include "common/grpc/google_grpc_utils.h" diff --git a/test/common/http/header_utility_test.cc b/test/common/http/header_utility_test.cc index c58318d76cfb..9b03bc64825e 100644 --- a/test/common/http/header_utility_test.cc +++ b/test/common/http/header_utility_test.cc @@ -450,7 +450,7 @@ TEST(HeaderIsValidTest, InvalidHeaderValuesAreRejected) { // values 9, 10, and 13 which are a horizontal tab, line feed, and carriage // return, respectively), and are not valid in an HTTP header, per // RFC 7230, section 3.2 - for (uint i = 0; i < 32; i++) { + for (int i = 0; i < 32; i++) { if (i == 9) { continue; } diff --git a/test/common/http/http2/codec_impl_test.cc b/test/common/http/http2/codec_impl_test.cc index 81707a9a2a48..ea9d5c480956 100644 --- a/test/common/http/http2/codec_impl_test.cc +++ b/test/common/http/http2/codec_impl_test.cc @@ -396,7 +396,7 @@ TEST_P(Http2CodecImplTest, Invalid204WithContentLength) { // maximum frame size is 16K. We will add 3,000 headers that will take us above this size and // not easily compress with HPACK. (I confirmed this generates 26,468 bytes of header data // which should contain a continuation.) - for (uint i = 1; i < 3000; i++) { + for (unsigned i = 1; i < 3000; i++) { response_headers.addCopy(std::to_string(i), std::to_string(i)); } @@ -426,7 +426,7 @@ TEST_P(Http2CodecImplTest, Invalid204WithContentLengthAllowed) { // maximum frame size is 16K. We will add 3,000 headers that will take us above this size and // not easily compress with HPACK. (I confirmed this generates 26,468 bytes of header data // which should contain a continuation.) - for (uint i = 1; i < 3000; i++) { + for (int i = 1; i < 3000; i++) { response_headers.addCopy(std::to_string(i), std::to_string(i)); } diff --git a/test/common/http/http2/frame_replay_test.cc b/test/common/http/http2/frame_replay_test.cc index af022412b8a0..e9869b2963b7 100644 --- a/test/common/http/http2/frame_replay_test.cc +++ b/test/common/http/http2/frame_replay_test.cc @@ -5,9 +5,9 @@ #include "gtest/gtest.h" -#define EXPECT_NEXT_BYTES(istream, bs...) \ +#define EXPECT_NEXT_BYTES(istream, ...) \ do { \ - std::vector expected_bytes{bs}; \ + std::vector expected_bytes{__VA_ARGS__}; \ std::vector actual_bytes(expected_bytes.size()); \ istream->read(reinterpret_cast(actual_bytes.data()), expected_bytes.size()); \ EXPECT_EQ(actual_bytes, expected_bytes); \ diff --git a/test/common/http/http2/http2_frame.cc b/test/common/http/http2/http2_frame.cc index 08f137d45517..a0b5f0a91268 100644 --- a/test/common/http/http2/http2_frame.cc +++ b/test/common/http/http2/http2_frame.cc @@ -1,9 +1,9 @@ #include "test/common/http/http2/http2_frame.h" -#include - #include +#include "envoy/common/platform.h" + namespace { // Make request stream ID in the network byte order diff --git a/test/common/http/http2/metadata_encoder_decoder_test.cc b/test/common/http/http2/metadata_encoder_decoder_test.cc index ede02d769a13..c294c7bb138e 100644 --- a/test/common/http/http2/metadata_encoder_decoder_test.cc +++ b/test/common/http/http2/metadata_encoder_decoder_test.cc @@ -10,7 +10,9 @@ // A global variable in nghttp2 to disable preface and initial settings for tests. // TODO(soya3129): Remove after issue https://github.com/nghttp2/nghttp2/issues/1246 is fixed. +extern "C" { extern int nghttp2_enable_strict_preface; +} namespace Envoy { namespace Http { @@ -202,7 +204,7 @@ TEST_F(MetadataEncoderDecoderTest, VerifyEncoderDecoderMultipleMetadataReachSize MetadataCallback cb = [](std::unique_ptr) -> void {}; initialize(cb); - int result = 0; + ssize_t result = 0; for (int i = 0; i < 100; i++) { // Cleans up the output buffer. diff --git a/test/common/network/addr_family_aware_socket_option_impl_test.cc b/test/common/network/addr_family_aware_socket_option_impl_test.cc index 379029dc2d24..c6c6d97fbe78 100644 --- a/test/common/network/addr_family_aware_socket_option_impl_test.cc +++ b/test/common/network/addr_family_aware_socket_option_impl_test.cc @@ -1,4 +1,4 @@ -#include +#include "envoy/common/platform.h" #include "common/network/addr_family_aware_socket_option_impl.h" #include "common/network/io_socket_handle_impl.h" diff --git a/test/common/network/address_impl_speed_test.cc b/test/common/network/address_impl_speed_test.cc index 481bc9a9d9f8..8694b66fb44f 100644 --- a/test/common/network/address_impl_speed_test.cc +++ b/test/common/network/address_impl_speed_test.cc @@ -1,7 +1,3 @@ -#include -#include -#include - #include "common/common/fmt.h" #include "common/network/address_impl.h" diff --git a/test/common/network/address_impl_test.cc b/test/common/network/address_impl_test.cc index fde23bbe09f0..d23df4e6b63b 100644 --- a/test/common/network/address_impl_test.cc +++ b/test/common/network/address_impl_test.cc @@ -1,15 +1,9 @@ -#include -#include -#include -#include -#include -#include - #include #include #include #include "envoy/common/exception.h" +#include "envoy/common/platform.h" #include "common/common/fmt.h" #include "common/common/utility.h" diff --git a/test/common/network/cidr_range_test.cc b/test/common/network/cidr_range_test.cc index 5f722cd1395f..51d9efd75435 100644 --- a/test/common/network/cidr_range_test.cc +++ b/test/common/network/cidr_range_test.cc @@ -1,9 +1,8 @@ -#include - #include #include #include "envoy/common/exception.h" +#include "envoy/common/platform.h" #include "common/common/fmt.h" #include "common/json/json_loader.h" diff --git a/test/common/network/connection_impl_test.cc b/test/common/network/connection_impl_test.cc index 164bcea2bb6f..0e69c4d2297b 100644 --- a/test/common/network/connection_impl_test.cc +++ b/test/common/network/connection_impl_test.cc @@ -2,6 +2,8 @@ #include #include +#include "envoy/common/platform.h" + #include "common/buffer/buffer_impl.h" #include "common/common/empty_string.h" #include "common/common/fmt.h" diff --git a/test/common/runtime/runtime_impl_test.cc b/test/common/runtime/runtime_impl_test.cc index 6e66970c2a7b..e53097f5d74b 100644 --- a/test/common/runtime/runtime_impl_test.cc +++ b/test/common/runtime/runtime_impl_test.cc @@ -375,7 +375,7 @@ TEST_F(DiskLoaderImplTest, PercentHandling) { // NOTE: high_value has to have the property that the lowest 32 bits % 100 // is less than 100. If it's greater than 100 the test will pass whether or // not the uint32 conversion is handled properly. - uint64_t high_value = 1UL << 60; + uint64_t high_value = 1ULL << 60; std::string high_value_str = std::to_string(high_value); loader_->mergeValues({{"foo", high_value_str}}); EXPECT_TRUE(loader_->snapshot().featureEnabled("foo", default_value, 0)); diff --git a/test/config_test/config_test.cc b/test/config_test/config_test.cc index 72c86b235b92..ad9461143346 100644 --- a/test/config_test/config_test.cc +++ b/test/config_test/config_test.cc @@ -1,9 +1,9 @@ -#include - #include #include #include +#include "envoy/common/platform.h" + #include "common/common/fmt.h" #include "common/protobuf/utility.h" #include "common/runtime/runtime_features.h" diff --git a/test/exe/main_common_test.cc b/test/exe/main_common_test.cc index 801fb8341a95..b34207ccd5b5 100644 --- a/test/exe/main_common_test.cc +++ b/test/exe/main_common_test.cc @@ -1,4 +1,4 @@ -#include +#include "envoy/common/platform.h" #include "common/common/lock_guard.h" #include "common/common/mutex_tracer_impl.h" diff --git a/test/extensions/filters/http/tap/tap_filter_integration_test.cc b/test/extensions/filters/http/tap/tap_filter_integration_test.cc index 2e577e502bc8..62348a93a883 100644 --- a/test/extensions/filters/http/tap/tap_filter_integration_test.cc +++ b/test/extensions/filters/http/tap/tap_filter_integration_test.cc @@ -108,7 +108,7 @@ class TapIntegrationTest : public testing::TestWithParam traces; - std::ifstream pb_file(*pb_file_name); + std::ifstream pb_file(*pb_file_name, std::ios_base::binary); Protobuf::io::IstreamInputStream stream(&pb_file); Protobuf::io::CodedInputStream coded_stream(&stream); while (true) { diff --git a/test/extensions/quic_listeners/quiche/crypto_test_utils_for_envoy.cc b/test/extensions/quic_listeners/quiche/crypto_test_utils_for_envoy.cc index b3a94737a5e6..22df487392d4 100644 --- a/test/extensions/quic_listeners/quiche/crypto_test_utils_for_envoy.cc +++ b/test/extensions/quic_listeners/quiche/crypto_test_utils_for_envoy.cc @@ -3,6 +3,7 @@ // This file defines platform dependent test utility functions which is declared // in quiche/quic/test_tools/crypto_test_utils.h. +#ifdef __GNUC__ #pragma GCC diagnostic push // QUICHE allows unused parameters. #pragma GCC diagnostic ignored "-Wunused-parameter" @@ -13,6 +14,9 @@ #include "quiche/quic/test_tools/crypto_test_utils.h" #pragma GCC diagnostic pop +#else +#include "quiche/quic/test_tools/crypto_test_utils.h" +#endif #include #include "extensions/quic_listeners/quiche/envoy_quic_fake_proof_source.h" diff --git a/test/extensions/transport_sockets/tls/context_impl_test.cc b/test/extensions/transport_sockets/tls/context_impl_test.cc index 3b6b596b5f1b..59e307b0e51e 100644 --- a/test/extensions/transport_sockets/tls/context_impl_test.cc +++ b/test/extensions/transport_sockets/tls/context_impl_test.cc @@ -672,14 +672,17 @@ TEST_F(ClientContextConfigImplTest, RSA1024Cert) { Event::SimulatedTimeSystem time_system; ContextManagerImpl manager(time_system); Stats::IsolatedStoreImpl store; - EXPECT_THROW_WITH_REGEX( - manager.createSslClientContext(store, client_context_config), EnvoyException, + + std::string error_msg( "Failed to load certificate chain from .*selfsigned_rsa_1024_cert.pem, only RSA certificates " #ifdef BORINGSSL_FIPS - "with 2048-bit or 3072-bit keys are supported in FIPS mode"); + "with 2048-bit or 3072-bit keys are supported in FIPS mode" #else - "with 2048-bit or larger keys are supported"); + "with 2048-bit or larger keys are supported" #endif + ); + EXPECT_THROW_WITH_REGEX(manager.createSslClientContext(store, client_context_config), + EnvoyException, error_msg); } // Validate that 3072-bit RSA certificates load successfully. diff --git a/test/extensions/transport_sockets/tls/integration/ssl_integration_test.cc b/test/extensions/transport_sockets/tls/integration/ssl_integration_test.cc index c3d0960dc06c..b439f2e25f97 100644 --- a/test/extensions/transport_sockets/tls/integration/ssl_integration_test.cc +++ b/test/extensions/transport_sockets/tls/integration/ssl_integration_test.cc @@ -148,8 +148,8 @@ TEST_P(SslIntegrationTest, RouterDownstreamDisconnectBeforeRequestComplete) { } TEST_P(SslIntegrationTest, RouterDownstreamDisconnectBeforeResponseComplete) { -#ifdef __APPLE__ - // Skip this test on macOS: we can't detect the early close on macOS, and we +#if defined(__APPLE__) || defined(WIN32) + // Skip this test on OS X + Windows: we can't detect the early close on non-Linux, and we // won't clean up the upstream connection until it times out. See #4294. if (downstream_protocol_ == Http::CodecClient::Type::HTTP1) { return; diff --git a/test/integration/uds_integration_test.cc b/test/integration/uds_integration_test.cc index e12d6d2a6c04..f1633a693b9f 100644 --- a/test/integration/uds_integration_test.cc +++ b/test/integration/uds_integration_test.cc @@ -9,15 +9,17 @@ namespace Envoy { +#if defined(__linux__) INSTANTIATE_TEST_SUITE_P( TestParameters, UdsUpstreamIntegrationTest, testing::Combine(testing::ValuesIn(TestEnvironment::getIpVersionsForTest()), -#if defined(__linux__) - testing::Values(false, true) + testing::Values(false, true))); #else - testing::Values(false) +INSTANTIATE_TEST_SUITE_P( + TestParameters, UdsUpstreamIntegrationTest, + testing::Combine(testing::ValuesIn(TestEnvironment::getIpVersionsForTest()), + testing::Values(false))); #endif - )); TEST_P(UdsUpstreamIntegrationTest, RouterRequestAndResponseWithBodyNoBuffer) { testRouterRequestAndResponseWithBody(1024, 512, false); @@ -39,15 +41,17 @@ TEST_P(UdsUpstreamIntegrationTest, RouterDownstreamDisconnectBeforeResponseCompl testRouterDownstreamDisconnectBeforeResponseComplete(); } +#if defined(__linux__) INSTANTIATE_TEST_SUITE_P( TestParameters, UdsListenerIntegrationTest, testing::Combine(testing::ValuesIn(TestEnvironment::getIpVersionsForTest()), -#if defined(__linux__) - testing::Values(false, true) + testing::Values(false, true))); #else - testing::Values(false) +INSTANTIATE_TEST_SUITE_P( + TestParameters, UdsListenerIntegrationTest, + testing::Combine(testing::ValuesIn(TestEnvironment::getIpVersionsForTest()), + testing::Values(false))); #endif - )); void UdsListenerIntegrationTest::initialize() { config_helper_.addConfigModifier([&](envoy::config::bootstrap::v2::Bootstrap& bootstrap) -> void { diff --git a/test/mocks/http/mocks.h b/test/mocks/http/mocks.h index 2398873d21a8..8c3995f1f189 100644 --- a/test/mocks/http/mocks.h +++ b/test/mocks/http/mocks.h @@ -465,7 +465,7 @@ class HeaderValueOfMatcher { // Test that a HeaderMap argument contains exactly one header with the given // key, whose value satisfies the given expectation. The expectation can be a // matcher, or a string that the value should equal. -template HeaderValueOfMatcher HeaderValueOf(K key, T matcher) { +template HeaderValueOfMatcher HeaderValueOf(K key, const T& matcher) { return HeaderValueOfMatcher(LowerCaseString(key), testing::SafeMatcherCast(matcher)); } diff --git a/test/test_common/environment.cc b/test/test_common/environment.cc index ec27ffbaa93e..e6fe06c0df3e 100644 --- a/test/test_common/environment.cc +++ b/test/test_common/environment.cc @@ -1,8 +1,5 @@ #include "test/test_common/environment.h" -#include -#include - // TODO(asraa): Remove and rely only on when Envoy requires // Clang >= 9. #if defined(_LIBCPP_VERSION) && !defined(__APPLE__) @@ -25,6 +22,7 @@ #include "common/common/logger.h" #include "common/common/macros.h" #include "common/common/utility.h" +#include "envoy/common/platform.h" #include "server/options_impl.h" diff --git a/test/test_common/network_utility.cc b/test/test_common/network_utility.cc index 430614e50327..cc278bf6e4b7 100644 --- a/test/test_common/network_utility.cc +++ b/test/test_common/network_utility.cc @@ -1,11 +1,10 @@ #include "test/test_common/network_utility.h" -#include -#include - #include #include +#include "envoy/common/platform.h" + #include "common/common/assert.h" #include "common/common/fmt.h" #include "common/network/address_impl.h" diff --git a/test/test_common/utility.cc b/test/test_common/utility.cc index 7b2ba59c3cd5..c8a9990984ca 100644 --- a/test/test_common/utility.cc +++ b/test/test_common/utility.cc @@ -1,16 +1,5 @@ #include "utility.h" -#ifdef WIN32 -#include -// uses macros to #define a ton of symbols, two of which (DELETE and GetMessage) -// interfere with our code. DELETE shows up in the base.pb.h header generated from -// api/envoy/api/core/base.proto. Since it's a generated header, we can't #undef DELETE at -// the top of that header to avoid the collision. Similarly, GetMessage shows up in generated -// protobuf code so we can't #undef the symbol there. -#undef DELETE -#undef GetMessage -#endif - #include #include #include @@ -26,6 +15,7 @@ #include "envoy/api/v2/rds.pb.h" #include "envoy/api/v2/route/route.pb.h" #include "envoy/buffer/buffer.h" +#include "envoy/common/platform.h" #include "envoy/http/codec.h" #include "envoy/service/discovery/v2/rtds.pb.h" @@ -37,18 +27,18 @@ #include "common/common/thread_impl.h" #include "common/common/utility.h" #include "common/config/resources.h" +#include "common/filesystem/directory.h" +#include "common/filesystem/filesystem_impl.h" #include "common/json/json_loader.h" #include "common/network/address_impl.h" #include "common/network/utility.h" -#include "common/filesystem/directory.h" -#include "common/filesystem/filesystem_impl.h" +#include "test/mocks/stats/mocks.h" #include "test/test_common/printers.h" #include "test/test_common/test_time.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include "test/mocks/stats/mocks.h" #include "gtest/gtest.h" using testing::GTEST_FLAG(random_seed);