Skip to content

Commit b8709bc

Browse files
JoePerchestorvalds
authored andcommitted
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/[email protected] Signed-off-by: Joe Perches <[email protected]> Tested-by: Randy Dunlap <[email protected]> Acked-by: Randy Dunlap <[email protected]> Cc: Andy Whitcroft <[email protected]> Cc: Dwaipayan Ray <[email protected]> Cc: Lukas Bulwahn <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 36f8b34 commit b8709bc

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

scripts/checkpatch.pl

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3479,47 +3479,47 @@ sub process {
34793479
# Kconfig supports named choices), so use a word boundary
34803480
# (\b) rather than a whitespace character (\s)
34813481
$line =~ /^\+\s*(?:config|menuconfig|choice)\b/) {
3482-
my $length = 0;
3483-
my $cnt = $realcnt;
3484-
my $ln = $linenr + 1;
3485-
my $f;
3486-
my $is_start = 0;
3487-
my $is_end = 0;
3488-
for (; $cnt > 0 && defined $lines[$ln - 1]; $ln++) {
3489-
$f = $lines[$ln - 1];
3490-
$cnt-- if ($lines[$ln - 1] !~ /^-/);
3491-
$is_end = $lines[$ln - 1] =~ /^\+/;
3482+
my $ln = $linenr;
3483+
my $needs_help = 0;
3484+
my $has_help = 0;
3485+
my $help_length = 0;
3486+
while (defined $lines[$ln]) {
3487+
my $f = $lines[$ln++];
34923488

34933489
next if ($f =~ /^-/);
3494-
last if (!$file && $f =~ /^\@\@/);
3490+
last if ($f !~ /^[\+ ]/); # !patch context
34953491

3496-
if ($lines[$ln - 1] =~ /^\+\s*(?:bool|tristate|prompt)\s*["']/) {
3497-
$is_start = 1;
3498-
} elsif ($lines[$ln - 1] =~ /^\+\s*(?:---)?help(?:---)?$/) {
3499-
$length = -1;
3492+
if ($f =~ /^\+\s*(?:bool|tristate|prompt)\s*["']/) {
3493+
$needs_help = 1;
3494+
next;
3495+
}
3496+
if ($f =~ /^\+\s*help\s*$/) {
3497+
$has_help = 1;
3498+
next;
35003499
}
35013500

3502-
$f =~ s/^.//;
3503-
$f =~ s/#.*//;
3504-
$f =~ s/^\s+//;
3505-
next if ($f =~ /^$/);
3501+
$f =~ s/^.//; # strip patch context [+ ]
3502+
$f =~ s/#.*//; # strip # directives
3503+
$f =~ s/^\s+//; # strip leading blanks
3504+
next if ($f =~ /^$/); # skip blank lines
35063505

3506+
# At the end of this Kconfig block:
35073507
# This only checks context lines in the patch
35083508
# and so hopefully shouldn't trigger false
35093509
# positives, even though some of these are
35103510
# common words in help texts
3511-
if ($f =~ /^\s*(?:config|menuconfig|choice|endchoice|
3512-
if|endif|menu|endmenu|source)\b/x) {
3513-
$is_end = 1;
3511+
if ($f =~ /^(?:config|menuconfig|choice|endchoice|
3512+
if|endif|menu|endmenu|source)\b/x) {
35143513
last;
35153514
}
3516-
$length++;
3515+
$help_length++ if ($has_help);
35173516
}
3518-
if ($is_start && $is_end && $length < $min_conf_desc_length) {
3517+
if ($needs_help &&
3518+
$help_length < $min_conf_desc_length) {
3519+
my $stat_real = get_stat_real($linenr, $ln - 1);
35193520
WARN("CONFIG_DESCRIPTION",
3520-
"please write a paragraph that describes the config symbol fully\n" . $herecurr);
3521+
"please write a help paragraph that fully describes the config symbol\n" . "$here\n$stat_real\n");
35213522
}
3522-
#print "is_start<$is_start> is_end<$is_end> length<$length>\n";
35233523
}
35243524

35253525
# check MAINTAINERS entries

0 commit comments

Comments
 (0)