]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
kconfig: add kconfig-sym-check static checker
authorAndrew Jones <andrew.jones@linux.dev>
Wed, 27 May 2026 14:27:03 +0000 (09:27 -0500)
committerNathan Chancellor <nathan@kernel.org>
Thu, 4 Jun 2026 02:20:04 +0000 (19:20 -0700)
commitf58316a441b4626324993db585fa4b7b7c780fac
treec733d44c45c2a447d82657a103905de5e376797c
parenta48bd961fb203a7ce68f8110fc53a85f90e24b33
kconfig: add kconfig-sym-check static checker

Add 'make kconfig-sym-check', a static checker that finds Kconfig
symbols referenced in expressions (select, depends on, default, etc.)
but never defined via config/menuconfig anywhere in the tree. New
dangling symbols are reported as errors (exit 1) unless they are
listed in an exclusion file, e.g.

 KCONFIG_SYM_CHECK_EXCLUDES=sym-check-excludes make kconfig-sym-check

The exclusion file lists one symbol per line; blank lines and lines
starting with '#' are ignored.

The checker also warns about uppercase N/Y/M used as tristate literal
values following the same logic as checkpatch.

This new static checker is the script used for [1] with a few
improvements to avoid some false positives.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=216748
Assisted-by: Claude:claude-sonnet-4-6
Signed-off-by: Andrew Jones <andrew.jones@linux.dev>
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Tested-by: Randy Dunlap <rdunlap@infradead.org>
Tested-by: Julian Braha <julianbraha@gmail.com>
Tested-by: Nicolas Schier <nsc@kernel.org>
Acked-by: Nicolas Schier <nsc@kernel.org>
Link: https://patch.msgid.link/20260527142703.107110-1-andrew.jones@linux.dev
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Makefile
scripts/kconfig/kconfig-sym-check.pl [new file with mode: 0755]