History

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.

Ulf Magnusson committed 8 years ago

Commit 678ae161 parent 86adf1a1 file · +11 −2Browse files

Showing the changes to scripts/checkpatch.pl (1 of 1 file). Show all

Unified · Split

scripts/checkpatch.pl+11−2
@@ -2797,7 +2797,10 @@ sub process { · 2796 unmodified lines
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 { · 18 unmodified lines
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 }