Skip to contentSkip to conversation

btrfs: Use immediate assignment when referencing cc-option

PATCH In review Victor Erminpour 2 participants 2 messages Mar 17, 2021 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 btrfs: Use immediate assignment when referencing cc-option

Calling cc-option will use KBUILD_CFLAGS, which when lazy setting subdir-ccflags-y produces the following build error:

scripts/Makefile.lib:10: *** Recursive variable `KBUILD_CFLAGS' \
references itself (eventually). Stop.

Use single := assignment for subdir-ccflags-y. The cc-option calls are done right away and we don't end up with KBUILD_CFLAGS referencing itself.

---
 fs/btrfs/Makefile | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
fs/btrfs/Makefile +4 -4
index b634c42115ea..583ca2028e08 100644
@@ -1,16 +1,16 @@
 # SPDX-License-Identifier: GPL-2.0
 
 # Subset of W=1 warnings
+subdir-ccflags-y := $(call cc-option, -Wunused-but-set-variable) \
+	$(call cc-option, -Wunused-const-variable) \
+	$(call cc-option, -Wpacked-not-aligned) \
+	$(call cc-option, -Wstringop-truncation)
 subdir-ccflags-y += -Wextra -Wunused -Wno-unused-parameter
 subdir-ccflags-y += -Wmissing-declarations
 subdir-ccflags-y += -Wmissing-format-attribute
 subdir-ccflags-y += -Wmissing-prototypes
 subdir-ccflags-y += -Wold-style-definition
 subdir-ccflags-y += -Wmissing-include-dirs
-subdir-ccflags-y += $(call cc-option, -Wunused-but-set-variable)
-subdir-ccflags-y += $(call cc-option, -Wunused-const-variable)
-subdir-ccflags-y += $(call cc-option, -Wpacked-not-aligned)
-subdir-ccflags-y += $(call cc-option, -Wstringop-truncation)
 # The following turn off the warnings enabled by -Wextra
 subdir-ccflags-y += -Wno-missing-field-initializers
 subdir-ccflags-y += -Wno-sign-compare
#1 lore raw
Quoted 20 lines · Victor Erminpour

Calling cc-option will use KBUILD_CFLAGS, which when lazy setting subdir-ccflags-y produces the following build error:

scripts/Makefile.lib:10: *** Recursive variable `KBUILD_CFLAGS' \
references itself (eventually). Stop.

Use single := assignment for subdir-ccflags-y. The cc-option calls are done right away and we don't end up with KBUILD_CFLAGS referencing itself.

---
 fs/btrfs/Makefile | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
fs/btrfs/Makefile +0 -0
index b634c42115ea..583ca2028e08 100644

fs/btrfs/Makefile line 7

Quoted 7 lines
fs/btrfs/Makefile +4 -0
@@ -1,16 +1,16 @@
 # SPDX-License-Identifier: GPL-2.0
 
 # Subset of W=1 warnings
+subdir-ccflags-y := $(call cc-option, -Wunused-but-set-variable) \
+	$(call cc-option, -Wunused-const-variable) \
+	$(call cc-option, -Wpacked-not-aligned) \
+	$(call cc-option, -Wstringop-truncation)

That's still overwriting the value unconditionally, the idea was a separate variable

https://lore.kernel.org/linux-btrfs/[email protected]