[PATCH] kconfig: Warn on dead select or imply for choice values

Nicolas Schier posted 1 patch 1 month, 4 weeks ago
scripts/kconfig/menu.c | 4 ++++
1 file changed, 4 insertions(+)
[PATCH] kconfig: Warn on dead select or imply for choice values
Posted by Nicolas Schier 1 month, 4 weeks ago
Update the internal kconfig check to print a warning on 'select' and
'imply' statements that target on choice values.

Julian Braha reported that kconfig's 'select' and 'imply' do not work
for choice values but have no effect all.  Show a warning instead of
error-out to allow kconfig to check the whole kconfig rule set.

Reported-by: Julian Braha <julianbraha@gmail.com>
Closes: https://lore.kernel.org/linux-kbuild/20260715220149.48700-1-julianbraha@gmail.com/ # [1]
Suggested-by: Kees Cook <kees@kernel.org>
Suggested-by: Jani Nikula <jani.nikula@linux.intel.com>
Signed-off-by: Nicolas Schier <nsc@kernel.org>
---
Depends on related fixes in Kconfig files:
https://lore.kernel.org/r/20260729203845.387239-1-julianbraha@gmail.com # change-requested
https://lore.kernel.org/r/20260801160140.2391000-1-julianbraha@gmail.com # under-review
https://lore.kernel.org/r/20260714112047.2304856-1-julianbraha@gmail.com # under-review
https://lore.kernel.org/r/20260723104933.117413-1-julianbraha@gmail.com # applied to mips-next
https://lore.kernel.org/r/20260723122818.437802-1-julianbraha@gmail.com # applied
---
 scripts/kconfig/menu.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index b2d8d4e11e07..fc8d8cfe034d 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -287,6 +287,10 @@ static void sym_check_prop(struct symbol *sym)
 				    "'%s' has wrong type. '%s' only "
 				    "accept arguments of bool and "
 				    "tristate type", sym2->name, use);
+			if (sym_is_choice_value(sym2))
+				prop_warn(prop,
+					  "config symbol '%s' uses %s for '%s', but '%s' is a choice value",
+					  sym->name, use, sym2->name, sym2->name);
 			break;
 		case P_RANGE:
 			if (sym->type != S_INT && sym->type != S_HEX)

---
base-commit: 6946cd5d0aa4dd10a414ddcb7a10844fdb0ad345
change-id: 20260802-kconfig-warn-on-dead-select-for-choice-value-bd71a1de1a96
prerequisite-message-id: <20260729203845.387239-1-julianbraha@gmail.com>
prerequisite-patch-id: 3bb796da65f588d1df5003dac5af7a9d7420f266
prerequisite-message-id: <20260801160140.2391000-1-julianbraha@gmail.com>
prerequisite-patch-id: 5277c28b2d25752fb7e5827ed744b0cf0c619574
prerequisite-message-id: <20260714112047.2304856-1-julianbraha@gmail.com>
prerequisite-patch-id: bef2d24caba30e7dc2ac5189c10b6473485a1e3c
prerequisite-message-id: <20260723104933.117413-1-julianbraha@gmail.com>
prerequisite-patch-id: da49e2868fbb19afc3195cbd2868739a94aa02c3
prerequisite-message-id: <20260723122818.437802-1-julianbraha@gmail.com>
prerequisite-patch-id: 3c894964a57e4e30515fcb14226dae725555c25e

Best regards,
--  
Nicolas
Re: [PATCH] kconfig: Warn on dead select or imply for choice values
Posted by Nathan Chancellor 2 weeks ago
On Tue, 04 Aug 2026 14:45:32 +0200, Nicolas Schier wrote:
> kconfig: Warn on dead select or imply for choice values

I took the remaining warning to allow us to move this along:

  https://lore.kernel.org/20260917234456.GA1570097@ax162/

Applied to

  https://git.kernel.org/pub/scm/linux/kernel/git/kbuild/linux.git kbuild-next-unstable

Thanks!

[1/1] kconfig: Warn on dead select or imply for choice values
      https://git.kernel.org/kbuild/c/47ef078cf9ad3

Please look out for regression or issue reports or other follow up
comments, as they may result in the patch/series getting dropped or
reverted. Patches applied to an "unstable" branch are accepted pending
wider testing in -next and any post-commit review; they will generally
be moved to the main branch in a week if no issues are found.

Best regards,
-- 
Cheers,
Nathan
Re: [PATCH] kconfig: Warn on dead select or imply for choice values
Posted by Julian Braha 1 month, 3 weeks ago
Hi Nicolas,

On 8/4/26 13:45, Nicolas Schier wrote:
> Update the internal kconfig check to print a warning on 'select' and
> 'imply' statements that target on choice values.
> 
> Julian Braha reported that kconfig's 'select' and 'imply' do not work
> for choice values but have no effect all.  Show a warning instead of
> error-out to allow kconfig to check the whole kconfig rule set.
> 
> Reported-by: Julian Braha <julianbraha@gmail.com>
> Closes: https://lore.kernel.org/linux-kbuild/20260715220149.48700-1-julianbraha@gmail.com/ # [1]
> Suggested-by: Kees Cook <kees@kernel.org>
> Suggested-by: Jani Nikula <jani.nikula@linux.intel.com>
> Signed-off-by: Nicolas Schier <nsc@kernel.org>

Reviewed-by: Julian Braha <julianbraha@gmail.com>
Tested-by: Julian Braha <julianbraha@gmail.com>

> ---
> Depends on related fixes in Kconfig files:
> https://lore.kernel.org/r/20260729203845.387239-1-julianbraha@gmail.com # change-requested
> https://lore.kernel.org/r/20260801160140.2391000-1-julianbraha@gmail.com # under-review
> https://lore.kernel.org/r/20260714112047.2304856-1-julianbraha@gmail.com # under-review
> https://lore.kernel.org/r/20260723104933.117413-1-julianbraha@gmail.com # applied to mips-next
> https://lore.kernel.org/r/20260723122818.437802-1-julianbraha@gmail.com # applied

Note that there was actually a 6th of these broken select-choices that I
had forgotten to list. Though my patch for that has also already been
applied:
https://lore.kernel.org/all/20260722220618.198164-1-julianbraha@gmail.com/

> ---
>  scripts/kconfig/menu.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
> index b2d8d4e11e07..fc8d8cfe034d 100644
> --- a/scripts/kconfig/menu.c
> +++ b/scripts/kconfig/menu.c
> @@ -287,6 +287,10 @@ static void sym_check_prop(struct symbol *sym)
>  				    "'%s' has wrong type. '%s' only "
>  				    "accept arguments of bool and "
>  				    "tristate type", sym2->name, use);
> +			if (sym_is_choice_value(sym2))
> +				prop_warn(prop,
> +					  "config symbol '%s' uses %s for '%s', but '%s' is a choice value",
> +					  sym->name, use, sym2->name, sym2->name);
>  			break;
>  		case P_RANGE:
>  			if (sym->type != S_INT && sym->type != S_HEX)
> 
> ---
> base-commit: 6946cd5d0aa4dd10a414ddcb7a10844fdb0ad345
> change-id: 20260802-kconfig-warn-on-dead-select-for-choice-value-bd71a1de1a96
> prerequisite-message-id: <20260729203845.387239-1-julianbraha@gmail.com>
> prerequisite-patch-id: 3bb796da65f588d1df5003dac5af7a9d7420f266
> prerequisite-message-id: <20260801160140.2391000-1-julianbraha@gmail.com>
> prerequisite-patch-id: 5277c28b2d25752fb7e5827ed744b0cf0c619574
> prerequisite-message-id: <20260714112047.2304856-1-julianbraha@gmail.com>
> prerequisite-patch-id: bef2d24caba30e7dc2ac5189c10b6473485a1e3c
> prerequisite-message-id: <20260723104933.117413-1-julianbraha@gmail.com>
> prerequisite-patch-id: da49e2868fbb19afc3195cbd2868739a94aa02c3
> prerequisite-message-id: <20260723122818.437802-1-julianbraha@gmail.com>
> prerequisite-patch-id: 3c894964a57e4e30515fcb14226dae725555c25e
> 
> Best regards,
> --  
> Nicolas
> 

- Julian Braha