x86/boot/compressed: enable -Wundef
PATCH 1/1 x86/boot/compressed: enable -Wundef
A discussion around -Wundef showed that there were still a few boolean Kconfigs where #if was used rather than #ifdef to guard different code. Kconfig doesn't define boolean configs, which can result in -Wundef warnings.
arch/x86/boot/compressed/Makefile resets the CFLAGS used for this directory, and doesn't re-enable -Wundef as the top level Makefile does. If re-added, with RANDOMIZE_BASE and X86_NEED_RELOCS disabled, the following warnings are visible.
arch/x86/boot/compressed/misc.h:82:5: warning: 'CONFIG_RANDOMIZE_BASE' is not defined, evaluates to 0 [-Wundef]
^
arch/x86/boot/compressed/misc.c:175:5: warning: 'CONFIG_X86_NEED_RELOCS'
is not defined, evaluates to 0 [-Wundef]
^Simply fix these and re-enable this warning for this directory.
--- arch/x86/boot/compressed/Makefile | 1 + arch/x86/boot/compressed/misc.c | 2 +- arch/x86/boot/compressed/misc.h | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-)
arch/x86/boot/compressed/Makefile +1 -0
@@ -30,6 +30,7 @@ targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \ KBUILD_CFLAGS := -m$(BITS) -O2 KBUILD_CFLAGS += -fno-strict-aliasing -fPIE +KBUILD_CFLAGS += -Wundef KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING cflags-$(CONFIG_X86_32) := -march=i386 cflags-$(CONFIG_X86_64) := -mcmodel=small -mno-red-zone
arch/x86/boot/compressed/misc.c +1 -1
@@ -172,7 +172,7 @@ void __puthex(unsigned long value) } } -#if CONFIG_X86_NEED_RELOCS +#ifdef CONFIG_X86_NEED_RELOCS static void handle_relocations (void *output,unsigned long output_len,unsigned long virt_addr) {
arch/x86/boot/compressed/misc.h +1 -1
@@ -79,7 +79,7 @@ struct mem_vector {u64 size; }; -#if CONFIG_RANDOMIZE_BASE +#ifdef CONFIG_RANDOMIZE_BASE /* kaslr.c */ void choose_random_location(unsigned long input, unsigned long input_size,
base-commit: 16fc44d6387e260f4932e9248b985837324705d8
Signature · 1 line
2.31.1.498.g6c1eba8ee3d-goog
Quoted 17 lines · Nick Desaulniers
A discussion around -Wundef showed that there were still a few boolean Kconfigs where #if was used rather than #ifdef to guard different code.
Kconfigdoesn't define boolean configs, which can result in -Wundef warnings.
arch/x86/boot/compressed/Makefileresets the CFLAGS used for this directory, and doesn't re-enable -Wundef as the top levelMakefiledoes. If re-added, withRANDOMIZE_BASEandX86_NEED_RELOCSdisabled, the following warnings are visible.
arch/x86/boot/compressed/misc.h:82:5: warning: 'CONFIG_RANDOMIZE_BASE' is not defined, evaluates to 0 [-Wundef]^ arch/x86/boot/compressed/misc.c:175:5: warning: 'CONFIG_X86_NEED_RELOCS' is not defined, evaluates to 0 [-Wundef] ^
Quoted 7 lines
Simply fix these and re-enable this warning for this directory.
Thanks!
Signature · 1 line
Kees Cook
Quoted 10 lines · Nick Desaulniers
A discussion around -Wundef showed that there were still a few boolean Kconfigs where #if was used rather than #ifdef to guard different code.
Kconfigdoesn't define boolean configs, which can result in -Wundef warnings.
arch/x86/boot/compressed/Makefileresets the CFLAGS used for this directory, and doesn't re-enable -Wundef as the top levelMakefiledoes. If re-added, withRANDOMIZE_BASEandX86_NEED_RELOCSdisabled, the following warnings are visible.
Quoted 8 lines
arch/x86/boot/compressed/misc.h:82:5: warning: 'CONFIG_RANDOMIZE_BASE' is not defined, evaluates to 0 [-Wundef]^ arch/x86/boot/compressed/misc.c:175:5: warning: 'CONFIG_X86_NEED_RELOCS' is not defined, evaluates to 0 [-Wundef] ^Simply fix these and re-enable this warning for this directory.
I wonder if it is worth turning on -Wall for this directory...
Quoted 5 lines
Quoted 49 lines
--- arch/x86/boot/compressed/Makefile | 1 + arch/x86/boot/compressed/misc.c | 2 +- arch/x86/boot/compressed/misc.h | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-)arch/x86/boot/compressed/Makefile +1
-0@@ -30,6 +30,7 @@ targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \ KBUILD_CFLAGS := -m$(BITS) -O2 KBUILD_CFLAGS += -fno-strict-aliasing -fPIE +KBUILD_CFLAGS += -Wundef KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING cflags-$(CONFIG_X86_32) := -march=i386 cflags-$(CONFIG_X86_64) := -mcmodel=small -mno-red-zonearch/x86/boot/compressed/misc.c +1
-1@@ -172,7 +172,7 @@ void __puthex(unsigned long value) } } -#if CONFIG_X86_NEED_RELOCS +#ifdef CONFIG_X86_NEED_RELOCS static void handle_relocations (void *output,unsigned long output_len,unsigned long virt_addr) {arch/x86/boot/compressed/misc.h +1
-1@@ -79,7 +79,7 @@ struct mem_vector {u64 size; }; -#if CONFIG_RANDOMIZE_BASE +#ifdef CONFIG_RANDOMIZE_BASE /* kaslr.c */ void choose_random_location(unsigned long input, unsigned long input_size,base-commit:
16fc44d6387e260f4932e9248b985837324705d8Signature · 1 line
2.31.1.498.g6c1eba8ee3d-goog
Borislav Petkov
maintainerQuoted 1 line · Nathan Chancellor
I wonder if it is worth turning on -Wall for this directory...
Yeah, I don't see why not. That is, until someone sits down and converts that file to include the toplevel Makefile flags...
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette[tip: x86/urgent] x86/boot/compressed: Enable -Wundef
In reply to Nick DesaulniersThe following commit has been merged into the x86/urgent branch of tip:
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: a554e740b66a83c7560b30e6b50bece37555ced3 Gitweb: https://git.kernel.org/tip/a554e740b66a83c7560b30e6b50bece37555ced3 Author: Nick Desaulniers <[email protected]> AuthorDate: Thu, 22 Apr 2021 12:04:42 -07:00 Committer: Ingo Molnar <[email protected]> CommitterDate: Wed, 12 May 2021 21:39:56 +02:00
x86/boot/compressed: Enable -Wundef
A discussion around -Wundef showed that there were still a few boolean Kconfigs where #if was used rather than #ifdef to guard different code. Kconfig doesn't define boolean configs, which can result in -Wundef warnings.
arch/x86/boot/compressed/Makefile resets the CFLAGS used for this directory, and doesn't re-enable -Wundef as the top level Makefile does. If re-added, with RANDOMIZE_BASE and X86_NEED_RELOCS disabled, the following warnings are visible.
arch/x86/boot/compressed/misc.h:82:5: warning: 'CONFIG_RANDOMIZE_BASE' is not defined, evaluates to 0 [-Wundef]
^
arch/x86/boot/compressed/misc.c:175:5: warning: 'CONFIG_X86_NEED_RELOCS'
is not defined, evaluates to 0 [-Wundef]
^Simply fix these and re-enable this warning for this directory.
--- arch/x86/boot/compressed/Makefile | 1 + arch/x86/boot/compressed/misc.c | 2 +- arch/x86/boot/compressed/misc.h | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-)
arch/x86/boot/compressed/Makefile +1 -0
@@ -30,6 +30,7 @@ targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \ KBUILD_CFLAGS := -m$(BITS) -O2 KBUILD_CFLAGS += -fno-strict-aliasing -fPIE +KBUILD_CFLAGS += -Wundef KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING cflags-$(CONFIG_X86_32) := -march=i386 cflags-$(CONFIG_X86_64) := -mcmodel=small -mno-red-zone
arch/x86/boot/compressed/misc.c +1 -1
@@ -172,7 +172,7 @@ void __puthex(unsigned long value) } } -#if CONFIG_X86_NEED_RELOCS +#ifdef CONFIG_X86_NEED_RELOCS static void handle_relocations (void *output,unsigned long output_len,unsigned long virt_addr) {
arch/x86/boot/compressed/misc.h +1 -1
@@ -79,7 +79,7 @@ struct mem_vector {u64 size; }; -#if CONFIG_RANDOMIZE_BASE +#ifdef CONFIG_RANDOMIZE_BASE /* kaslr.c */ void choose_random_location(unsigned long input, unsigned long input_size,