linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] checkkconfigsymbols.py: Remove skipping of help lines in parse_kconfig_file
@ 2021-09-01 16:49 Ariel Marcovitch
  2021-09-10  2:12 ` Masahiro Yamada
  0 siblings, 1 reply; 2+ messages in thread
From: Ariel Marcovitch @ 2021-09-01 16:49 UTC (permalink / raw)
  To: masahiroy, valentinrothberg; +Cc: arielmarcovitch, linux-kernel, linux-kbuild

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>
---
 scripts/checkkconfigsymbols.py | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/scripts/checkkconfigsymbols.py b/scripts/checkkconfigsymbols.py
index b9b0f15e5880..4f9dc98f3f60 100755
--- a/scripts/checkkconfigsymbols.py
+++ b/scripts/checkkconfigsymbols.py
@@ -34,7 +34,6 @@ REGEX_SOURCE_SYMBOL = re.compile(SOURCE_SYMBOL)
 REGEX_KCONFIG_DEF = re.compile(DEF)
 REGEX_KCONFIG_EXPR = re.compile(EXPR)
 REGEX_KCONFIG_STMT = re.compile(STMT)
-REGEX_KCONFIG_HELP = re.compile(r"^\s+help\s*$")
 REGEX_FILTER_SYMBOLS = re.compile(r"[A-Za-z0-9]$")
 REGEX_NUMERIC = re.compile(r"0[xX][0-9a-fA-F]+|[0-9]+")
 REGEX_QUOTES = re.compile("(\"(.*?)\")")
@@ -432,7 +431,6 @@ def parse_kconfig_file(kfile):
     lines = []
     defined = []
     references = []
-    skip = False
 
     if not os.path.exists(kfile):
         return defined, references
@@ -448,12 +446,6 @@ def parse_kconfig_file(kfile):
         if REGEX_KCONFIG_DEF.match(line):
             symbol_def = REGEX_KCONFIG_DEF.findall(line)
             defined.append(symbol_def[0])
-            skip = False
-        elif REGEX_KCONFIG_HELP.match(line):
-            skip = True
-        elif skip:
-            # ignore content of help messages
-            pass
         elif REGEX_KCONFIG_STMT.match(line):
             line = REGEX_QUOTES.sub("", line)
             symbols = get_symbols_in_line(line)

base-commit: 087e856cfb76e9eef9a3a6e000854794f3c36e24
-- 
2.25.1


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

* Re: [PATCH v2] checkkconfigsymbols.py: Remove skipping of help lines in parse_kconfig_file
  2021-09-01 16:49 [PATCH v2] checkkconfigsymbols.py: Remove skipping of help lines in parse_kconfig_file Ariel Marcovitch
@ 2021-09-10  2:12 ` Masahiro Yamada
  0 siblings, 0 replies; 2+ messages in thread
From: Masahiro Yamada @ 2021-09-10  2:12 UTC (permalink / raw)
  To: Ariel Marcovitch
  Cc: Valentin Rothberg, Linux Kernel Mailing List, Linux Kbuild mailing list

On Thu, Sep 2, 2021 at 1:50 AM Ariel Marcovitch
<arielmarcovitch@gmail.com> wrote:
>
> 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>
> ---

Applied to linux-kbuild. Thanks.


>  scripts/checkkconfigsymbols.py | 8 --------
>  1 file changed, 8 deletions(-)
>
> diff --git a/scripts/checkkconfigsymbols.py b/scripts/checkkconfigsymbols.py
> index b9b0f15e5880..4f9dc98f3f60 100755
> --- a/scripts/checkkconfigsymbols.py
> +++ b/scripts/checkkconfigsymbols.py
> @@ -34,7 +34,6 @@ REGEX_SOURCE_SYMBOL = re.compile(SOURCE_SYMBOL)
>  REGEX_KCONFIG_DEF = re.compile(DEF)
>  REGEX_KCONFIG_EXPR = re.compile(EXPR)
>  REGEX_KCONFIG_STMT = re.compile(STMT)
> -REGEX_KCONFIG_HELP = re.compile(r"^\s+help\s*$")
>  REGEX_FILTER_SYMBOLS = re.compile(r"[A-Za-z0-9]$")
>  REGEX_NUMERIC = re.compile(r"0[xX][0-9a-fA-F]+|[0-9]+")
>  REGEX_QUOTES = re.compile("(\"(.*?)\")")
> @@ -432,7 +431,6 @@ def parse_kconfig_file(kfile):
>      lines = []
>      defined = []
>      references = []
> -    skip = False
>
>      if not os.path.exists(kfile):
>          return defined, references
> @@ -448,12 +446,6 @@ def parse_kconfig_file(kfile):
>          if REGEX_KCONFIG_DEF.match(line):
>              symbol_def = REGEX_KCONFIG_DEF.findall(line)
>              defined.append(symbol_def[0])
> -            skip = False
> -        elif REGEX_KCONFIG_HELP.match(line):
> -            skip = True
> -        elif skip:
> -            # ignore content of help messages
> -            pass
>          elif REGEX_KCONFIG_STMT.match(line):
>              line = REGEX_QUOTES.sub("", line)
>              symbols = get_symbols_in_line(line)
>
> base-commit: 087e856cfb76e9eef9a3a6e000854794f3c36e24
> --
> 2.25.1
>


-- 
Best Regards
Masahiro Yamada

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

end of thread, other threads:[~2021-09-10  2:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-01 16:49 [PATCH v2] checkkconfigsymbols.py: Remove skipping of help lines in parse_kconfig_file Ariel Marcovitch
2021-09-10  2:12 ` Masahiro Yamada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).