public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ulf Magnusson <ulfalizer@gmail.com>
To: apw@canonical.com, joe@perches.com
Cc: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org,
	Ulf Magnusson <ulfalizer@gmail.com>
Subject: [PATCH 2/3] checkpatch: kconfig: check help texts for menuconfig and choice
Date: Fri, 16 Feb 2018 21:22:54 +0100	[thread overview]
Message-ID: <20180216202255.25307-3-ulfalizer@gmail.com> (raw)
In-Reply-To: <20180216202255.25307-1-ulfalizer@gmail.com>

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>
---
 scripts/checkpatch.pl | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 2b404317daea..54b782fab4fd 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2797,7 +2797,10 @@ sub process {
 # Only applies when adding the entry originally, after that we do not have
 # sufficient context to determine whether it is indeed long enough.
 		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 $cnt = $realcnt;
 			my $ln = $linenr + 1;
@@ -2822,7 +2825,13 @@ sub process {
 				$f =~ s/#.*//;
 				$f =~ s/^\s+//;
 				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;
 					last;
 				}
-- 
2.14.1

  parent reply	other threads:[~2018-02-16 20:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-16 20:22 [PATCH 0/3] Improve and extend checkpatch.pl Kconfig help text checks Ulf Magnusson
2018-02-16 20:22 ` [PATCH 1/3] checkpatch: kconfig: recognize more prompts when checking help texts Ulf Magnusson
2018-02-16 20:22 ` Ulf Magnusson [this message]
2018-03-22 15:13   ` [PATCH 2/3] checkpatch: kconfig: check help texts for menuconfig and choice Masahiro Yamada
2018-02-16 20:22 ` [PATCH 3/3] checkpatch: kconfig: prefer 'help' over '---help---' Ulf Magnusson
2018-03-22 15:19   ` Masahiro Yamada
2018-02-16 21:14 ` [PATCH 0/3] Improve and extend checkpatch.pl Kconfig help text checks Joe Perches
2018-02-23  1:30   ` Ulf Magnusson
2018-02-24 13:53     ` Masahiro Yamada
2018-03-06  4:52       ` Ulf Magnusson
2018-03-06  5:13         ` Masahiro Yamada
2018-03-22 15:09           ` Masahiro Yamada

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180216202255.25307-3-ulfalizer@gmail.com \
    --to=ulfalizer@gmail.com \
    --cc=apw@canonical.com \
    --cc=joe@perches.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox