[PATCH 1/2] btrfs: avoid Wmaybe-uninitialized warnings

From: Arnd Bergmann
Date: Wed Jul 05 2023 - 10:01:30 EST


From: Arnd Bergmann <arnd@xxxxxxxx>

The -Wmaybe-uninitialized warning option in gcc produces tons of false
positive warnings when KASAN is enabled, as that turns off some required
optimizations.

Rework the makefile to only enable the warning in btrfs when KASAN is
disabled, as it was before commit 78a5255ffb6a1 ("Stop the ad-hoc games
with -Wno-maybe-initialized") turned it off globally.

Fixes: 1ec49744ba83f ("btrfs: turn on -Wmaybe-uninitialized")
Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
---
fs/btrfs/Makefile | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/Makefile b/fs/btrfs/Makefile
index 90d53209755bf..a4927bf2ce7ee 100644
--- a/fs/btrfs/Makefile
+++ b/fs/btrfs/Makefile
@@ -11,8 +11,12 @@ condflags := \
$(call cc-option, -Wunused-but-set-variable) \
$(call cc-option, -Wunused-const-variable) \
$(call cc-option, -Wpacked-not-aligned) \
- $(call cc-option, -Wstringop-truncation) \
- $(call cc-option, -Wmaybe-uninitialized)
+ $(call cc-option, -Wstringop-truncation)
+
+ifndef CONFIG_KASAN
+conflags += $(call cc-option, -Wmaybe-uninitialized)
+endif
+
subdir-ccflags-y += $(condflags)
# The following turn off the warnings enabled by -Wextra
subdir-ccflags-y += -Wno-missing-field-initializers
--
2.39.2