Skip to content

Commit a554e74

Browse files
nickdesaulniersIngo Molnar
authored andcommitted
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. Suggested-by: Nathan Chancellor <[email protected]> Suggested-by: Joe Perches <[email protected]> Signed-off-by: Nick Desaulniers <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Acked-by: Kees Cook <[email protected]> Reviewed-by: Nathan Chancellor <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 059e5c3 commit a554e74

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

arch/x86/boot/compressed/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma \
3030

3131
KBUILD_CFLAGS := -m$(BITS) -O2
3232
KBUILD_CFLAGS += -fno-strict-aliasing -fPIE
33+
KBUILD_CFLAGS += -Wundef
3334
KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
3435
cflags-$(CONFIG_X86_32) := -march=i386
3536
cflags-$(CONFIG_X86_64) := -mcmodel=small -mno-red-zone

arch/x86/boot/compressed/misc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ void __puthex(unsigned long value)
172172
}
173173
}
174174

175-
#if CONFIG_X86_NEED_RELOCS
175+
#ifdef CONFIG_X86_NEED_RELOCS
176176
static void handle_relocations(void *output, unsigned long output_len,
177177
unsigned long virt_addr)
178178
{

arch/x86/boot/compressed/misc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ struct mem_vector {
7979
u64 size;
8080
};
8181

82-
#if CONFIG_RANDOMIZE_BASE
82+
#ifdef CONFIG_RANDOMIZE_BASE
8383
/* kaslr.c */
8484
void choose_random_location(unsigned long input,
8585
unsigned long input_size,

0 commit comments

Comments
 (0)