forked from Minki/linux
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 <ulfalizer@gmail.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
This commit is contained in:
parent
86adf1a07e
commit
678ae162dd
@ -2797,7 +2797,10 @@ sub process {
|
|||||||
# Only applies when adding the entry originally, after that we do not have
|
# Only applies when adding the entry originally, after that we do not have
|
||||||
# sufficient context to determine whether it is indeed long enough.
|
# sufficient context to determine whether it is indeed long enough.
|
||||||
if ($realfile =~ /Kconfig/ &&
|
if ($realfile =~ /Kconfig/ &&
|
||||||
$line =~ /^\+\s*config\s+/) {
|
# 'choice' is usually the last thing on the line (though
|
||||||
|
# Kconfig supports named choices), so use a word boundary
|
||||||
|
# (\b) rather than a whitespace character (\s)
|
||||||
|
$line =~ /^\+\s*(?:config|menuconfig|choice)\b/) {
|
||||||
my $length = 0;
|
my $length = 0;
|
||||||
my $cnt = $realcnt;
|
my $cnt = $realcnt;
|
||||||
my $ln = $linenr + 1;
|
my $ln = $linenr + 1;
|
||||||
@ -2822,7 +2825,13 @@ sub process {
|
|||||||
$f =~ s/#.*//;
|
$f =~ s/#.*//;
|
||||||
$f =~ s/^\s+//;
|
$f =~ s/^\s+//;
|
||||||
next if ($f =~ /^$/);
|
next if ($f =~ /^$/);
|
||||||
if ($f =~ /^\s*config\s/) {
|
|
||||||
|
# This only checks context lines in the patch
|
||||||
|
# and so hopefully shouldn't trigger false
|
||||||
|
# positives, even though some of these are
|
||||||
|
# common words in help texts
|
||||||
|
if ($f =~ /^\s*(?:config|menuconfig|choice|endchoice|
|
||||||
|
if|endif|menu|endmenu|source)\b/x) {
|
||||||
$is_end = 1;
|
$is_end = 1;
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user