Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Further -Wundef cases #570

Closed
nathanchance opened this issue Jun 24, 2019 · 8 comments
Closed

Further -Wundef cases #570

nathanchance opened this issue Jun 24, 2019 · 8 comments
Assignees
Labels
-Wundef [BUG] linux A bug that should be fixed in the mainline kernel. [FIXED][LINUX] 5.14 This bug was fixed in Linux 5.14 low priority This bug is not critical and not a priority

Comments

@nathanchance
Copy link
Member

Joe Perches pointed out there may be further -Wundef warnings lurking.

https://lore.kernel.org/lkml/67f6cd269684c9aa8463ff4812c3b4605e6739c3.camel@perches.com/

I will need to look into whether or not these are real config variables (that may be undefined) or ones that are created with a #define directive in a C file, which may always be defined and if they can ever be triggered.

@nathanchance nathanchance added [BUG] linux A bug that should be fixed in the mainline kernel. -Wundef labels Jun 24, 2019
@nathanchance nathanchance self-assigned this Jun 24, 2019
@nickdesaulniers nickdesaulniers added the low priority This bug is not critical and not a priority label Jan 9, 2020
@nickdesaulniers
Copy link
Member

Looking at one example, kernel/futex.c:#if CONFIG_BASE_SMALL:

linux/kernel/futex.c

Lines 4045 to 4049 in 83d09ad

#if CONFIG_BASE_SMALL
futex_hashsize = 16;
#else
futex_hashsize = roundup_pow_of_two(256 * num_possible_cpus());
#endif

It seems that this is always defined; for defconfigs I see:

$ grep -n BASE_SMALL .config           
751:CONFIG_BASE_SMALL=0

so that case is fine. See it's kconfig:

linux/init/Kconfig

Lines 2043 to 2046 in 83d09ad

config BASE_SMALL
int
default 0 if BASE_FULL
default 1 if !BASE_FULL
.

So ints are probably fine. Here's the latest list on mainline @ 16fc44d

$ git grep -nP '^\s*#\s*if\s+CONFIG_[A-Z0-9_]+\s*$' *
arch/microblaze/include/asm/exceptions.h:20:#if CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR
arch/microblaze/include/asm/hash.h:34:#if CONFIG_XILINX_MICROBLAZE0_USE_BARREL
arch/microblaze/include/asm/irqflags.h:12:#if CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR
arch/microblaze/kernel/entry.S:52:#if CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR
arch/microblaze/kernel/entry.S:967:#if CONFIG_MANUAL_RESET_VECTOR
arch/microblaze/kernel/setup.c:149:#if CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR
arch/powerpc/platforms/powernv/pci.c:714:#if CONFIG_EEH
arch/x86/boot/compressed/misc.c:175:#if CONFIG_X86_NEED_RELOCS
arch/x86/boot/compressed/misc.h:82:#if CONFIG_RANDOMIZE_BASE
drivers/gpu/drm/i915/gt/sysfs_engines.c:450:#if CONFIG_DRM_I915_HEARTBEAT_INTERVAL
drivers/gpu/drm/i915/gt/sysfs_engines.c:492:#if CONFIG_DRM_I915_HEARTBEAT_INTERVAL
kernel/futex.c:4016:#if CONFIG_BASE_SMALL

arch/microblaze/Kconfig.platform:
43 config XILINX_MICROBLAZE0_USE_MSR_INSTR
44 int "USE_MSR_INSTR range (0:1)"
45 default 0

arch/microblaze/Kconfig:
169 config MANUAL_RESET_VECTOR
170 hex "Microblaze reset vector address setup"
171 default "0x0"

arch/powerpc/platforms/Kconfig
166 config EEH
167 bool

arch/x86/Kconfig
2164 config X86_NEED_RELOCS
2165 def_bool y

arch/x86/Kconfig
2128 config RANDOMIZE_BASE
2129 bool "Randomize the address of the kernel image (KASLR)"

drivers/gpu/drm/i915/Kconfig.profile
28 int "Interval between heartbeat pulses (ms)"
29 default 2500 # milliseconds

===

So only X86_NEED_RELOCS, RANDOMIZE_BASE, and EEH are boolean configs. I wonder if I can repro them with allnoconfig? Nope. It looks like the top level Makefile sets -Wundef with -Wall, but #618 in arch/x86/boot/compressed/Makefile resets that and doesn't re-set it. If we add -Wundef, and disable RANDOMIZE_BASE, it does repro. Same for X86_NEED_RELOCS.

arch/x86/boot/compressed/misc.h:82:5: warning: 'CONFIG_RANDOMIZE_BASE' is not defined, evaluates to 0 [-Wundef]
#if CONFIG_RANDOMIZE_BASE
    ^
arch/x86/boot/compressed/misc.c:175:5: warning: 'CONFIG_X86_NEED_RELOCS' is not defined, evaluates to 0 [-Wundef]
#if CONFIG_X86_NEED_RELOCS
    ^

I will send a patch.

@nickdesaulniers
Copy link
Member

Sent https://lore.kernel.org/lkml/20210422190450.3903999-1-ndesaulniers@google.com/T/#u for x86. Will post a fix for CONFIG_EEH, too.

@nickdesaulniers nickdesaulniers added the [PATCH] Submitted A patch has been submitted for review label Apr 22, 2021
@nickdesaulniers
Copy link
Member

CONFIG_EEH can't be disabled for this file, so it's not possible to get an error out of is.

ruscur pushed a commit to ruscur/linux that referenced this issue Apr 22, 2021
While looking at -Wundef warnings, the #if CONFIG_EEH stood out as a
possible candidate to convert to #ifdef CONFIG_EEH, but it seems that
based on Kconfig dependencies it's not possible to build this file
without CONFIG_EEH enabled.

Suggested-by: Nathan Chancellor <nathan@kernel.org>
Suggested-by: Joe Perches <joe@perches.com>
Link: ClangBuiltLinux#570
Link: https://lore.kernel.org/lkml/67f6cd269684c9aa8463ff4812c3b4605e6739c3.camel@perches.com/
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
@nickdesaulniers
Copy link
Member

But the else case can probably be deleted.

Menuconfig for CONFIG_EEH:
x Depends on: (PPC_POWERNV [=y] || PPC_PSERIES [=n]) && PCI [=y])

Sent: https://lore.kernel.org/linuxppc-dev/20210422195405.4053917-1-ndesaulniers@google.com/

@nickdesaulniers
Copy link
Member

the x86 patch landed as a554e74. I've pinged the ppc one.

@nickdesaulniers
Copy link
Member

ruscur pushed a commit to ruscur/linux that referenced this issue May 18, 2021
While looking at -Wundef warnings, the #if CONFIG_EEH stood out as a
possible candidate to convert to #ifdef CONFIG_EEH.

It seems that based on Kconfig dependencies it's not possible to build
this file without CONFIG_EEH enabled, but based on upstream discussion,
it's not clear yet that CONFIG_EEH should be enabled by default.

For now, simply fix the -Wundef warning.

Suggested-by: Nathan Chancellor <nathan@kernel.org>
Suggested-by: Joe Perches <joe@perches.com>
Link: ClangBuiltLinux#570
Link: https://lore.kernel.org/lkml/67f6cd269684c9aa8463ff4812c3b4605e6739c3.camel@perches.com/
Link: https://lore.kernel.org/lkml/CAOSf1CGoN5R0LUrU=Y=UWho1Z_9SLgCX8s3SbFJXwJXc5BYz4A@mail.gmail.com/
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
mpe pushed a commit to linuxppc/linux-ci that referenced this issue May 23, 2021
While looking at -Wundef warnings, the #if CONFIG_EEH stood out as a
possible candidate to convert to #ifdef CONFIG_EEH.

It seems that based on Kconfig dependencies it's not possible to build
this file without CONFIG_EEH enabled, but based on upstream discussion,
it's not clear yet that CONFIG_EEH should be enabled by default.

For now, simply fix the -Wundef warning.

Suggested-by: Nathan Chancellor <nathan@kernel.org>
Suggested-by: Joe Perches <joe@perches.com>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: ClangBuiltLinux/linux#570
Link: https://lore.kernel.org/lkml/67f6cd269684c9aa8463ff4812c3b4605e6739c3.camel@perches.com/
Link: https://lore.kernel.org/lkml/CAOSf1CGoN5R0LUrU=Y=UWho1Z_9SLgCX8s3SbFJXwJXc5BYz4A@mail.gmail.com/
Link: https://lore.kernel.org/r/20210518204044.2390064-1-ndesaulniers@google.com
@nickdesaulniers nickdesaulniers added [PATCH] Accepted A submitted patch has been accepted upstream and removed [PATCH] Submitted A patch has been submitted for review labels Jun 7, 2021
@nickdesaulniers
Copy link
Member

73e6e4e

@nickdesaulniers nickdesaulniers added [FIXED][LINUX] 5.14 This bug was fixed in Linux 5.14 and removed [PATCH] Accepted A submitted patch has been accepted upstream labels Jul 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-Wundef [BUG] linux A bug that should be fixed in the mainline kernel. [FIXED][LINUX] 5.14 This bug was fixed in Linux 5.14 low priority This bug is not critical and not a priority
Projects
None yet
Development

No branches or pull requests

2 participants