From 4401624e2a2f9148ea56472a838d2468bfcfee92 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Tue, 28 Mar 2023 13:55:58 -0400 Subject: [PATCH] Stop disabling warnings in some public configs. (#25854) Disabling warnings in a public config will disable those warnings for anything that depends on the thing using the config. This led to a bunch of warnings being disabled incorrectly for consumers of third-party libraries. --- .../example/ExampleCredentialIssuerCommands.h | 2 +- .../chip-tool/commands/pairing/PairingCommand.h | 1 + examples/common/websocket-server/BUILD.gn | 7 +++++++ .../commands/common/MTRError.mm | 1 + .../commands/tests/TestCommandBridge.h | 2 -- src/lib/support/CodeUtils.h | 2 ++ third_party/boringssl/repo/BUILD.gn | 16 ++++++++++++---- third_party/editline/BUILD.gn | 4 ++++ third_party/jsoncpp/BUILD.gn | 4 ++++ third_party/libwebsockets/BUILD.gn | 7 +++++-- third_party/nlunit-test/BUILD.gn | 3 +++ 11 files changed, 40 insertions(+), 9 deletions(-) diff --git a/examples/chip-tool/commands/example/ExampleCredentialIssuerCommands.h b/examples/chip-tool/commands/example/ExampleCredentialIssuerCommands.h index a8694f02ff894e..a23b45eae10627 100644 --- a/examples/chip-tool/commands/example/ExampleCredentialIssuerCommands.h +++ b/examples/chip-tool/commands/example/ExampleCredentialIssuerCommands.h @@ -81,7 +81,7 @@ class ExampleCredentialIssuerCommands : public CredentialIssuerCommands { mDacVerifier->EnableCdTestKeySupport(isEnabled); } - + break; default: break; } diff --git a/examples/chip-tool/commands/pairing/PairingCommand.h b/examples/chip-tool/commands/pairing/PairingCommand.h index f12353e010a40c..5c2a356d6aec73 100644 --- a/examples/chip-tool/commands/pairing/PairingCommand.h +++ b/examples/chip-tool/commands/pairing/PairingCommand.h @@ -85,6 +85,7 @@ class PairingCommand : public CHIPCommand, break; case PairingMode::Code: AddArgument("skip-commissioning-complete", 0, 1, &mSkipCommissioningComplete); + FALLTHROUGH; case PairingMode::CodePaseOnly: AddArgument("payload", &mOnboardingPayload); AddArgument("discover-once", 0, 1, &mDiscoverOnce); diff --git a/examples/common/websocket-server/BUILD.gn b/examples/common/websocket-server/BUILD.gn index fdd17300cecd06..d3f2aa35ff8ac9 100644 --- a/examples/common/websocket-server/BUILD.gn +++ b/examples/common/websocket-server/BUILD.gn @@ -15,6 +15,11 @@ import("//build_overrides/build.gni") import("//build_overrides/chip.gni") +config("websocket_server_config_disable_warnings") { + # Unfortunately, some of the libwebsockets headers include -Wshadow failures. + cflags = [ "-Wno-shadow" ] +} + static_library("websocket-server") { output_name = "libWebSocketServer" @@ -28,4 +33,6 @@ static_library("websocket-server") { "${chip_root}/src/lib/support", "${chip_root}/third_party/libwebsockets", ] + + configs += [ ":websocket_server_config_disable_warnings" ] } diff --git a/examples/darwin-framework-tool/commands/common/MTRError.mm b/examples/darwin-framework-tool/commands/common/MTRError.mm index 5d348c83c7fdf3..770c947e05d94b 100644 --- a/examples/darwin-framework-tool/commands/common/MTRError.mm +++ b/examples/darwin-framework-tool/commands/common/MTRError.mm @@ -87,6 +87,7 @@ CHIP_ERROR MTRErrorToCHIPErrorCode(NSError * error) break; } // Weird error we did not create. Fall through. + FALLTHROUGH; default: code = CHIP_ERROR_INTERNAL.AsInteger(); break; diff --git a/examples/darwin-framework-tool/commands/tests/TestCommandBridge.h b/examples/darwin-framework-tool/commands/tests/TestCommandBridge.h index 0828e1d1eccac5..b99c5976588b3b 100644 --- a/examples/darwin-framework-tool/commands/tests/TestCommandBridge.h +++ b/examples/darwin-framework-tool/commands/tests/TestCommandBridge.h @@ -236,8 +236,6 @@ class TestCommandBridge : public CHIPCommandBridge, MTRBaseDevice * _Nullable GetDevice(const char * _Nullable identity) { - MTRDeviceController * controller = GetCommissioner(identity); - SetIdentity(identity); return mConnectedDevices[identity]; } diff --git a/src/lib/support/CodeUtils.h b/src/lib/support/CodeUtils.h index 3b754e0b9e5e12..4f393dfaad0b8b 100644 --- a/src/lib/support/CodeUtils.h +++ b/src/lib/support/CodeUtils.h @@ -677,6 +677,8 @@ inline void chipDie(void) #if defined(__clang__) #define FALLTHROUGH [[clang::fallthrough]] +#elif defined(__GNUC__) +#define FALLTHROUGH __attribute__((fallthrough)) #else #define FALLTHROUGH (void) 0 #endif diff --git a/third_party/boringssl/repo/BUILD.gn b/third_party/boringssl/repo/BUILD.gn index 634be1687232a8..425f52270d2411 100644 --- a/third_party/boringssl/repo/BUILD.gn +++ b/third_party/boringssl/repo/BUILD.gn @@ -20,6 +20,12 @@ import("BUILD.generated.gni") config("boringssl_config") { include_dirs = [ "src/include" ] + # We want the basic crypto impl with no asm primitives until we hook-up platform-based + # support to the build later. + defines = [ "OPENSSL_NO_ASM=1" ] +} + +config("boringssl_config_disable_warnings") { cflags = [ "-Wno-unused-variable", "-Wno-conversion", @@ -28,11 +34,8 @@ config("boringssl_config") { if (is_clang) { cflags += [ "-Wno-shorten-64-to-32" ] } - - # We want the basic crypto impl with no asm primitives until we hook-up platform-based - # support to the build later. - defines = [ "OPENSSL_NO_ASM=1" ] } + all_sources = crypto_sources all_headers = crypto_headers @@ -45,4 +48,9 @@ static_library("boringssl") { sources = all_sources public_configs = [ ":boringssl_config" ] + + # The disable-warnings config should not be a public config, since + # that would make it apply to compilations of anything that depends + # on boringssl, not just boringssl itself. + configs += [ ":boringssl_config_disable_warnings" ] } diff --git a/third_party/editline/BUILD.gn b/third_party/editline/BUILD.gn index ec2cdd4a2e3bb2..cc48d31ac0d365 100644 --- a/third_party/editline/BUILD.gn +++ b/third_party/editline/BUILD.gn @@ -17,7 +17,9 @@ import("${build_root}/config/compiler/compiler.gni") config("editline_config") { include_dirs = [ "repo/include" ] +} +config("editline_config_disable_warnings") { cflags = [ "-Wno-conversion" ] if (is_clang) { @@ -38,5 +40,7 @@ static_library("editline") { public_configs = [ ":editline_config" ] + configs += [ ":editline_config_disable_warnings" ] + include_dirs = [ "include" ] } diff --git a/third_party/jsoncpp/BUILD.gn b/third_party/jsoncpp/BUILD.gn index aae8f025e2feca..13dcc203cce6e5 100644 --- a/third_party/jsoncpp/BUILD.gn +++ b/third_party/jsoncpp/BUILD.gn @@ -17,7 +17,9 @@ import("//build_overrides/chip.gni") config("jsoncpp_config") { include_dirs = [ "repo/include" ] +} +config("jsoncpp_config_disable_warnings") { cflags = [ "-Wno-implicit-fallthrough" ] } @@ -41,6 +43,8 @@ source_set("jsoncpp") { public_configs = [ ":jsoncpp_config" ] + configs += [ ":jsoncpp_config_disable_warnings" ] + defines = [ "JSON_USE_EXCEPTION=0", "JSON_USE_NULLREF=0", diff --git a/third_party/libwebsockets/BUILD.gn b/third_party/libwebsockets/BUILD.gn index 37d7bf1acbef24..9b96fb734c402d 100644 --- a/third_party/libwebsockets/BUILD.gn +++ b/third_party/libwebsockets/BUILD.gn @@ -18,14 +18,16 @@ config("libwebsockets_config") { "repo/include", ] + defines = [] +} + +config("libwebsockets_config_disable_warnings") { cflags = [ "-Wno-shadow", "-Wno-unreachable-code", "-Wno-format-nonliteral", "-Wno-implicit-fallthrough", ] - - defines = [] } source_set("libwebsockets") { @@ -107,4 +109,5 @@ source_set("libwebsockets") { } public_configs = [ ":libwebsockets_config" ] + configs += [ ":libwebsockets_config_disable_warnings" ] } diff --git a/third_party/nlunit-test/BUILD.gn b/third_party/nlunit-test/BUILD.gn index d6907714acd446..f56d0a5e9d2cb5 100644 --- a/third_party/nlunit-test/BUILD.gn +++ b/third_party/nlunit-test/BUILD.gn @@ -17,7 +17,9 @@ import("${build_root}/config/compiler/compiler.gni") config("nlunit-test_config") { include_dirs = [ "repo/src" ] +} +config("nlunit-test_config_disable_warnings") { cflags = [ "-Wno-conversion" ] if (is_clang) { @@ -36,4 +38,5 @@ static_library("nlunit-test") { ] public_configs = [ ":nlunit-test_config" ] + configs += [ ":nlunit-test_config_disable_warnings" ] }