Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

checkkconfigsymbols.py: Remove skipping of help lines in parse_kconfig_file

When parsing Kconfig files to find symbol definitions and references,
lines after a 'help' line are skipped until a new config definition
starts.

However, Kconfig statements can actually be after a help section, as
long as these have shallower indentation. These are skipped by the
parser.

This means that symbols referenced in this kind of statements are
ignored by this function and thus are not considered undefined
references in case the symbol is not defined.

Remove the 'skip' logic entirely, as it is not needed if we just use the
STMT regex to find the end of help lines.

However, this means that keywords that appear as part of the help
message (i.e. with the same indentation as the help lines) it will be
considered as a reference/definition. This can happen now as well, but
only with REGEX_KCONFIG_DEF lines. Also, the keyword must have a SYMBOL
after it, which probably means that someone referenced a config in the
help so it seems like a bonus :)

The real solution is to keep track of the indentation when a the first
help line in encountered and then handle DEF and STMT lines only if the
indentation is shallower.

Signed-off-by: Ariel Marcovitch <arielmarcovitch@gmail.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

authored by

Ariel Marcovitch and committed by
Masahiro Yamada
aa0f5ea1 d62d5aed

-8
-8
scripts/checkkconfigsymbols.py
··· 34 34 REGEX_KCONFIG_DEF = re.compile(DEF) 35 35 REGEX_KCONFIG_EXPR = re.compile(EXPR) 36 36 REGEX_KCONFIG_STMT = re.compile(STMT) 37 - REGEX_KCONFIG_HELP = re.compile(r"^\s+help\s*$") 38 37 REGEX_FILTER_SYMBOLS = re.compile(r"[A-Za-z0-9]$") 39 38 REGEX_NUMERIC = re.compile(r"0[xX][0-9a-fA-F]+|[0-9]+") 40 39 REGEX_QUOTES = re.compile("(\"(.*?)\")") ··· 434 435 lines = [] 435 436 defined = [] 436 437 references = [] 437 - skip = False 438 438 439 439 if not os.path.exists(kfile): 440 440 return defined, references ··· 449 451 if REGEX_KCONFIG_DEF.match(line): 450 452 symbol_def = REGEX_KCONFIG_DEF.findall(line) 451 453 defined.append(symbol_def[0]) 452 - skip = False 453 - elif REGEX_KCONFIG_HELP.match(line): 454 - skip = True 455 - elif skip: 456 - # ignore content of help messages 457 - pass 458 454 elif REGEX_KCONFIG_STMT.match(line): 459 455 line = REGEX_QUOTES.sub("", line) 460 456 symbols = get_symbols_in_line(line)