Linux kbuild/kconfig development
 help / color / mirror / Atom feed
* [PATCH] Documentation: warn users not to use select on choice options in Kconfig
@ 2026-07-15 22:01 Julian Braha
  2026-07-16  4:19 ` Kees Cook
  0 siblings, 1 reply; 3+ messages in thread
From: Julian Braha @ 2026-07-15 22:01 UTC (permalink / raw)
  To: nathan, nsc, corbet, skhan
  Cc: arnd, stefan.hengelein, linux-kbuild, linux-kernel, linux-doc,
	nico, officialnaumansabir, rdunlap, vegard.nossum, kees, tj,
	Julian Braha

Hengelein's master thesis about Kconfig from 2015 wrote that 'select'
does not work on member options inside of a 'choice'.

So I've re-implemented his check as part of kconfirm:
https://github.com/julianbraha/kconfirm

and discovered several instances of these dead selects in use, and
fixing them is not always trivial. For example, see:
https://lore.kernel.org/all/a3b7a752-8cc4-492a-bb62-43121b852c41@app.fastmail.com/

Let's add a warning to the documentation (a place where developers
are more likely to see it than a master's thesis...)

Signed-off-by: Julian Braha <julianbraha@gmail.com>
---
 Documentation/kbuild/kconfig-language.rst | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Documentation/kbuild/kconfig-language.rst b/Documentation/kbuild/kconfig-language.rst
index d9338407c1c6..ab2822d7ca1c 100644
--- a/Documentation/kbuild/kconfig-language.rst
+++ b/Documentation/kbuild/kconfig-language.rst
@@ -164,6 +164,11 @@ applicable everywhere (see syntax).
 	That will limit the usefulness but on the other hand avoid
 	the illegal configurations all over.
 
+	select should also not be used on the member options of a choice.
+	Selecting a choice option will do nothing (dead code). Instead,
+	consider making these a dependency, or using the defaults of the
+	choice to enable the member option when it's needed.
+
 	If "select" <symbol> is followed by "if" <expr>, <symbol> will be
 	selected by the logical AND of the value of the current menu symbol
 	and <expr>. This means, the lower limit can be downgraded due to the
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Documentation: warn users not to use select on choice options in Kconfig
  2026-07-15 22:01 [PATCH] Documentation: warn users not to use select on choice options in Kconfig Julian Braha
@ 2026-07-16  4:19 ` Kees Cook
  2026-07-16  6:04   ` Julian Braha
  0 siblings, 1 reply; 3+ messages in thread
From: Kees Cook @ 2026-07-16  4:19 UTC (permalink / raw)
  To: Julian Braha
  Cc: nathan, nsc, corbet, skhan, arnd, stefan.hengelein, linux-kbuild,
	linux-kernel, linux-doc, nico, officialnaumansabir, rdunlap,
	vegard.nossum, tj

On Wed, Jul 15, 2026 at 11:01:49PM +0100, Julian Braha wrote:
> Hengelein's master thesis about Kconfig from 2015 wrote that 'select'
> does not work on member options inside of a 'choice'.
> 
> So I've re-implemented his check as part of kconfirm:
> https://github.com/julianbraha/kconfirm
> 
> and discovered several instances of these dead selects in use, and
> fixing them is not always trivial. For example, see:
> https://lore.kernel.org/all/a3b7a752-8cc4-492a-bb62-43121b852c41@app.fastmail.com/
> 
> Let's add a warning to the documentation (a place where developers
> are more likely to see it than a master's thesis...)
> 
> Signed-off-by: Julian Braha <julianbraha@gmail.com>

Yeah, it'd be good to add a checkpatch or even build-time check too.

Reviewed-by: Kees Cook <kees@kernel.org>

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Documentation: warn users not to use select on choice options in Kconfig
  2026-07-16  4:19 ` Kees Cook
@ 2026-07-16  6:04   ` Julian Braha
  0 siblings, 0 replies; 3+ messages in thread
From: Julian Braha @ 2026-07-16  6:04 UTC (permalink / raw)
  To: Kees Cook
  Cc: nathan, nsc, corbet, skhan, arnd, stefan.hengelein, linux-kbuild,
	linux-kernel, linux-doc, nico, officialnaumansabir, rdunlap,
	vegard.nossum, tj

Hi Kees,

On 7/16/26 05:19, Kees Cook wrote:
> Yeah, it'd be good to add a checkpatch or even build-time check too.

I'll look into adding a check for this into the kconfig interpreter.

- Julian Braha

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-07-16  6:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-15 22:01 [PATCH] Documentation: warn users not to use select on choice options in Kconfig Julian Braha
2026-07-16  4:19 ` Kees Cook
2026-07-16  6:04   ` Julian Braha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox