Skip to content

Commit 678ae16

Browse files
ulfalizermasahir0y
authored andcommitted
checkpatch: kconfig: check help texts for menuconfig and choice
Currently, only Kconfig symbols are checked for a missing or short help text, and are only checked if they are defined with the 'config' keyword. To make the check more general, extend it to also check help texts for choices and for symbols defined with the 'menuconfig' keyword. This increases the accuracy of the check for symbols that would already have been checked as well, since e.g. a 'menuconfig' symbol after a help text will be recognized as ending the preceding symbol/choice definition. To increase the accuracy of the check further, also recognize 'if', 'endif', 'menu', 'endmenu', 'endchoice', and 'source' as ending a symbol/choice definition. Signed-off-by: Ulf Magnusson <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]>
1 parent 86adf1a commit 678ae16

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

scripts/checkpatch.pl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2797,7 +2797,10 @@ sub process {
27972797
# Only applies when adding the entry originally, after that we do not have
27982798
# sufficient context to determine whether it is indeed long enough.
27992799
if ($realfile =~ /Kconfig/ &&
2800-
$line =~ /^\+\s*config\s+/) {
2800+
# 'choice' is usually the last thing on the line (though
2801+
# Kconfig supports named choices), so use a word boundary
2802+
# (\b) rather than a whitespace character (\s)
2803+
$line =~ /^\+\s*(?:config|menuconfig|choice)\b/) {
28012804
my $length = 0;
28022805
my $cnt = $realcnt;
28032806
my $ln = $linenr + 1;
@@ -2822,7 +2825,13 @@ sub process {
28222825
$f =~ s/#.*//;
28232826
$f =~ s/^\s+//;
28242827
next if ($f =~ /^$/);
2825-
if ($f =~ /^\s*config\s/) {
2828+
2829+
# This only checks context lines in the patch
2830+
# and so hopefully shouldn't trigger false
2831+
# positives, even though some of these are
2832+
# common words in help texts
2833+
if ($f =~ /^\s*(?:config|menuconfig|choice|endchoice|
2834+
if|endif|menu|endmenu|source)\b/x) {
28262835
$is_end = 1;
28272836
last;
28282837
}

0 commit comments

Comments
 (0)