build: Enable -Wcovered-switch-default
What changed, and why it matters
This commit only changes compiler warning settings. It adds a new warning flag that alerts developers when a switch statement already handles every possible case but also has an unnecessary default label. It does not change any program behavior or fix any security bug.
No security action needed. Treat as routine build maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit enables -Wcovered-switch-default for the main build and suppresses it for the bundled LevelDB subtree, which has one such warning. This is a build-hygiene change with no functional or security impact on compiled binaries.
Changed components
CMake build configurationLevelDB subtree build flagsInspect captured patch +4 / −0
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 518e0277..e7cb8965 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -449,6 +449,7 @@ else()
try_append_cxx_flags("-Wall" TARGET warn_interface SKIP_LINK)
try_append_cxx_flags("-Wextra" TARGET warn_interface SKIP_LINK)
try_append_cxx_flags("-Wgnu" TARGET warn_interface SKIP_LINK)
+ try_append_cxx_flags("-Wcovered-switch-default" TARGET warn_interface SKIP_LINK)
# Some compilers will ignore -Wformat-security without -Wformat, so just combine the two here.
try_append_cxx_flags("-Wformat -Wformat-security" TARGET warn_interface SKIP_LINK)
try_append_cxx_flags("-Wvla" TARGET warn_interface SKIP_LINK)
diff --git a/cmake/leveldb.cmake b/cmake/leveldb.cmake
index e2119042..cff8c61f 100644
--- a/cmake/leveldb.cmake
+++ b/cmake/leveldb.cmake
@@ -87,6 +87,9 @@ else()
try_append_cxx_flags("-Wconditional-uninitialized" TARGET nowarn_leveldb_interface SKIP_LINK
IF_CHECK_PASSED "-Wno-conditional-uninitialized"
)
+ try_append_cxx_flags("-Wcovered-switch-default" TARGET nowarn_leveldb_interface SKIP_LINK
+ IF_CHECK_PASSED "-Wno-covered-switch-default"
+ )
endif()
target_link_libraries(leveldb PRIVATE
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.