Commit b8709bce authored by Joe Perches's avatar Joe Perches Committed by Linus Torvalds

checkpatch: improve Kconfig help test

The Kconfig help test erroneously counts patch context lines as part of
the help text.

Fix that and improve the message block output.

Link: https://lkml.kernel.org/r/06c0cdc157ae1502e8e9eb3624b9ea995cf11e7a.camel@perches.comSigned-off-by: default avatarJoe Perches <joe@perches.com>
Tested-by: default avatarRandy Dunlap <rdunlap@infradead.org>
Acked-by: default avatarRandy Dunlap <rdunlap@infradead.org>
Cc: Andy Whitcroft <apw@canonical.com>
Cc: Dwaipayan Ray <dwaipayanray1@gmail.com>
Cc: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 36f8b348
...@@ -3479,47 +3479,47 @@ sub process { ...@@ -3479,47 +3479,47 @@ sub process {
# Kconfig supports named choices), so use a word boundary # Kconfig supports named choices), so use a word boundary
# (\b) rather than a whitespace character (\s) # (\b) rather than a whitespace character (\s)
$line =~ /^\+\s*(?:config|menuconfig|choice)\b/) { $line =~ /^\+\s*(?:config|menuconfig|choice)\b/) {
my $length = 0; my $ln = $linenr;
my $cnt = $realcnt; my $needs_help = 0;
my $ln = $linenr + 1; my $has_help = 0;
my $f; my $help_length = 0;
my $is_start = 0; while (defined $lines[$ln]) {
my $is_end = 0; my $f = $lines[$ln++];
for (; $cnt > 0 && defined $lines[$ln - 1]; $ln++) {
$f = $lines[$ln - 1];
$cnt-- if ($lines[$ln - 1] !~ /^-/);
$is_end = $lines[$ln - 1] =~ /^\+/;
next if ($f =~ /^-/); next if ($f =~ /^-/);
last if (!$file && $f =~ /^\@\@/); last if ($f !~ /^[\+ ]/); # !patch context
if ($lines[$ln - 1] =~ /^\+\s*(?:bool|tristate|prompt)\s*["']/) { if ($f =~ /^\+\s*(?:bool|tristate|prompt)\s*["']/) {
$is_start = 1; $needs_help = 1;
} elsif ($lines[$ln - 1] =~ /^\+\s*(?:---)?help(?:---)?$/) { next;
$length = -1; }
if ($f =~ /^\+\s*help\s*$/) {
$has_help = 1;
next;
} }
$f =~ s/^.//; $f =~ s/^.//; # strip patch context [+ ]
$f =~ s/#.*//; $f =~ s/#.*//; # strip # directives
$f =~ s/^\s+//; $f =~ s/^\s+//; # strip leading blanks
next if ($f =~ /^$/); next if ($f =~ /^$/); # skip blank lines
# At the end of this Kconfig block:
# This only checks context lines in the patch # This only checks context lines in the patch
# and so hopefully shouldn't trigger false # and so hopefully shouldn't trigger false
# positives, even though some of these are # positives, even though some of these are
# common words in help texts # common words in help texts
if ($f =~ /^\s*(?:config|menuconfig|choice|endchoice| if ($f =~ /^(?:config|menuconfig|choice|endchoice|
if|endif|menu|endmenu|source)\b/x) { if|endif|menu|endmenu|source)\b/x) {
$is_end = 1;
last; last;
} }
$length++; $help_length++ if ($has_help);
} }
if ($is_start && $is_end && $length < $min_conf_desc_length) { if ($needs_help &&
$help_length < $min_conf_desc_length) {
my $stat_real = get_stat_real($linenr, $ln - 1);
WARN("CONFIG_DESCRIPTION", WARN("CONFIG_DESCRIPTION",
"please write a paragraph that describes the config symbol fully\n" . $herecurr); "please write a help paragraph that fully describes the config symbol\n" . "$here\n$stat_real\n");
} }
#print "is_start<$is_start> is_end<$is_end> length<$length>\n";
} }
# check MAINTAINERS entries # check MAINTAINERS entries
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment