diff options
| author | Nicolas Schier <nsc@kernel.org> | 2026-02-20 19:55:19 +0100 |
|---|---|---|
| committer | Nicolas Schier <nsc@kernel.org> | 2026-02-27 09:26:58 +0100 |
| commit | 102d712ded3ef2ee5b38ee6afa686aff63afd444 (patch) | |
| tree | 016c78a6ab4eca91ada9f5666a9a08940c147314 /scripts/kconfig/lexer.l | |
| parent | 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f (diff) | |
kconfig: Error out on duplicated kconfig inclusion
Let kconfig exit with error on duplicated Kconfig file inclusion.
Repeated inclusion of Kbuild files are considered bad-practise with
regard to maintenance; and Kconfig language is rich enough that there
should be no need for that.
If repeated inclusion of Kconfig files is detected, error out with
messages like:
Kconfig.inc1:4: error: repeated inclusion of Kconfig.inc3
Kconfig.inc2:3: note: location of first inclusion of Kconfig.inc3
While commit f094f8a1b273 ("kconfig: allow multiple inclusion of the
same file") introduced detection of recursive inclusions of Kconfig
files, it explicitly allowed repeated inclusions, unfortunately w/o
reasoning.
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Closes: https://lore.kernel.org/all/CAHk-=wj03hLzK2D=+OYmjgcmGM+XYymp8GyaEs=C0=rXG2nb7w@mail.gmail.com/
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Link: https://patch.msgid.link/20260220-kconfig-error-out-on-duplicated-inclusion-v1-1-be78aa241a53@kernel.org
Signed-off-by: Nicolas Schier <nsc@kernel.org>
Diffstat (limited to 'scripts/kconfig/lexer.l')
| -rw-r--r-- | scripts/kconfig/lexer.l | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/scripts/kconfig/lexer.l b/scripts/kconfig/lexer.l index 6d2c92c6095d..a6155422b4a6 100644 --- a/scripts/kconfig/lexer.l +++ b/scripts/kconfig/lexer.l @@ -402,7 +402,7 @@ void zconf_initscan(const char *name) exit(1); } - cur_filename = file_lookup(name); + cur_filename = file_lookup(name, NULL, 0); yylineno = 1; } @@ -443,7 +443,7 @@ void zconf_nextfile(const char *name) } yylineno = 1; - cur_filename = file_lookup(name); + cur_filename = file_lookup(name, cur_filename, cur_lineno); } static void zconf_endfile(void) |
