* [PATCH 0/4] checkpatch: Line spacing tests and Kconfig help
@ 2014-06-23 16:35 Joe Perches
2014-06-23 16:35 ` [PATCH 1/4] checkpatch: Add test for blank lines after function/struct/union/enum Joe Perches
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Joe Perches @ 2014-06-23 16:35 UTC (permalink / raw)
To: Andrew Morton; +Cc: Jean Delvare, Andy Whitcroft, linux-kernel
Add some vertical spacing tests.
Quiet Kconfig help false positives.
Joe Perches (4):
checkpatch: Add test for blank lines after function/struct/union/enum
checkpatch: Add a multiple blank lines test
checkpatch: Change blank line after declaration type to "LINE_SPACING"
checkpatch: Quiet Kconfig help message checking
scripts/checkpatch.pl | 35 +++++++++++++++++++++++++++++++----
1 file changed, 31 insertions(+), 4 deletions(-)
--
1.8.1.2.459.gbcd45b4.dirty
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/4] checkpatch: Add test for blank lines after function/struct/union/enum
2014-06-23 16:35 [PATCH 0/4] checkpatch: Line spacing tests and Kconfig help Joe Perches
@ 2014-06-23 16:35 ` Joe Perches
2014-06-23 16:35 ` [PATCH 2/4] checkpatch: Add a multiple blank lines test Joe Perches
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Joe Perches @ 2014-06-23 16:35 UTC (permalink / raw)
To: Andrew Morton; +Cc: Jean Delvare, Andy Whitcroft, linux-kernel
Add a --strict test asking for a blank line after
function/struct/union/enum declarations.
Allow exceptions for several attributes and macro uses.
Signed-off-by: Joe Perches <joe@perches.com>
---
scripts/checkpatch.pl | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 538105a..4bb4218 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2291,6 +2291,21 @@ sub process {
"networking block comments put the trailing */ on a separate line\n" . $herecurr);
}
+# check for missing blank lines after struct/union declarations
+# with exceptions for various attributes and macros
+ if ($prevline =~ /^[\+ ]};?\s*$/ &&
+ !($line =~ /^\+\s*$/ ||
+ $line =~ /^\+\s*EXPORT_SYMBOL/ ||
+ $line =~ /^\+\s*MODULE_/i ||
+ $line =~ /^\+\s*\#\s*(?:end|elif|else)/ ||
+ $line =~ /^\+[a-z_]*init/ ||
+ $line =~ /^\+\s*(?:static\s+)?[A-Z_]*ATTR/ ||
+ $line =~ /^\+\s*DECLARE/ ||
+ $line =~ /^\+\s*__setup/)) {
+ CHK("LINE_SPACING",
+ "Please use a blank line after function/struct/union/enum declarations\n" . $hereprev);
+ }
+
# check for missing blank lines after declarations
if ($sline =~ /^\+\s+\S/ && #Not at char 1
# actual declarations
--
1.8.1.2.459.gbcd45b4.dirty
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/4] checkpatch: Add a multiple blank lines test
2014-06-23 16:35 [PATCH 0/4] checkpatch: Line spacing tests and Kconfig help Joe Perches
2014-06-23 16:35 ` [PATCH 1/4] checkpatch: Add test for blank lines after function/struct/union/enum Joe Perches
@ 2014-06-23 16:35 ` Joe Perches
2014-06-23 16:35 ` [PATCH 3/4] checkpatch: Change blank line after declaration type to "LINE_SPACING" Joe Perches
2014-06-23 16:35 ` [PATCH 4/4] checkpatch: Quiet Kconfig help message checking Joe Perches
3 siblings, 0 replies; 5+ messages in thread
From: Joe Perches @ 2014-06-23 16:35 UTC (permalink / raw)
To: Andrew Morton; +Cc: Jean Delvare, Andy Whitcroft, linux-kernel
Multiple consecutive blank lines waste screen space.
Emit a --strict only message with these blank lines.
Signed-off-by: Joe Perches <joe@perches.com>
---
scripts/checkpatch.pl | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 4bb4218..3d6dea6 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1642,6 +1642,8 @@ sub process {
my $non_utf8_charset = 0;
+ my $last_blank_line = 0;
+
our @report = ();
our $cnt_lines = 0;
our $cnt_error = 0;
@@ -2306,6 +2308,15 @@ sub process {
"Please use a blank line after function/struct/union/enum declarations\n" . $hereprev);
}
+# check for multiple consecutive blank lines
+ if ($prevline =~ /^[\+ ]\s*$/ &&
+ $line =~ /^\+\s*$/ &&
+ $last_blank_line != ($linenr - 1)) {
+ CHK("LINE_SPACING",
+ "Please don't use multiple blank lines\n" . $hereprev);
+ $last_blank_line = $linenr;
+ }
+
# check for missing blank lines after declarations
if ($sline =~ /^\+\s+\S/ && #Not at char 1
# actual declarations
--
1.8.1.2.459.gbcd45b4.dirty
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/4] checkpatch: Change blank line after declaration type to "LINE_SPACING"
2014-06-23 16:35 [PATCH 0/4] checkpatch: Line spacing tests and Kconfig help Joe Perches
2014-06-23 16:35 ` [PATCH 1/4] checkpatch: Add test for blank lines after function/struct/union/enum Joe Perches
2014-06-23 16:35 ` [PATCH 2/4] checkpatch: Add a multiple blank lines test Joe Perches
@ 2014-06-23 16:35 ` Joe Perches
2014-06-23 16:35 ` [PATCH 4/4] checkpatch: Quiet Kconfig help message checking Joe Perches
3 siblings, 0 replies; 5+ messages in thread
From: Joe Perches @ 2014-06-23 16:35 UTC (permalink / raw)
To: Andrew Morton; +Cc: Jean Delvare, Andy Whitcroft, linux-kernel
Make it consistent with the other missing or multiple blank line tests.
Signed-off-by: Joe Perches <joe@perches.com>
---
scripts/checkpatch.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 3d6dea6..9795844 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2351,7 +2351,7 @@ sub process {
$sline =~ /^\+\s+\(?\s*(?:$Compare|$Assignment|$Operators)/) &&
# indentation of previous and current line are the same
(($prevline =~ /\+(\s+)\S/) && $sline =~ /^\+$1\S/)) {
- WARN("SPACING",
+ WARN("LINE_SPACING",
"Missing a blank line after declarations\n" . $hereprev);
}
--
1.8.1.2.459.gbcd45b4.dirty
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 4/4] checkpatch: Quiet Kconfig help message checking
2014-06-23 16:35 [PATCH 0/4] checkpatch: Line spacing tests and Kconfig help Joe Perches
` (2 preceding siblings ...)
2014-06-23 16:35 ` [PATCH 3/4] checkpatch: Change blank line after declaration type to "LINE_SPACING" Joe Perches
@ 2014-06-23 16:35 ` Joe Perches
3 siblings, 0 replies; 5+ messages in thread
From: Joe Perches @ 2014-06-23 16:35 UTC (permalink / raw)
To: Andrew Morton; +Cc: Jean Delvare, Andy Whitcroft, linux-kernel
Editing Kconfig dependencies can emit unnecessary messages about
missing or too short help entries.
Only emit the message when adding help sections to Kconfig files.
Signed-off-by: Joe Perches <joe@perches.com>
Reported-by: Jean Delvare <jdelvare@suse.de>
Tested-by: Jean Delvare <jdelvare@suse.de>
---
scripts/checkpatch.pl | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 9795844..2a7a32c 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2051,7 +2051,7 @@ 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+/) {
+ $line =~ /^\+\s*config\s+/) {
my $length = 0;
my $cnt = $realcnt;
my $ln = $linenr + 1;
@@ -2064,10 +2064,11 @@ sub process {
$is_end = $lines[$ln - 1] =~ /^\+/;
next if ($f =~ /^-/);
+ last if (!$file && $f =~ /^\@\@/);
- if ($lines[$ln - 1] =~ /.\s*(?:bool|tristate)\s*\"/) {
+ if ($lines[$ln - 1] =~ /^\+\s*(?:bool|tristate)\s*\"/) {
$is_start = 1;
- } elsif ($lines[$ln - 1] =~ /.\s*(?:---)?help(?:---)?$/) {
+ } elsif ($lines[$ln - 1] =~ /^\+\s*(?:---)?help(?:---)?$/) {
$length = -1;
}
--
1.8.1.2.459.gbcd45b4.dirty
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-06-23 16:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-23 16:35 [PATCH 0/4] checkpatch: Line spacing tests and Kconfig help Joe Perches
2014-06-23 16:35 ` [PATCH 1/4] checkpatch: Add test for blank lines after function/struct/union/enum Joe Perches
2014-06-23 16:35 ` [PATCH 2/4] checkpatch: Add a multiple blank lines test Joe Perches
2014-06-23 16:35 ` [PATCH 3/4] checkpatch: Change blank line after declaration type to "LINE_SPACING" Joe Perches
2014-06-23 16:35 ` [PATCH 4/4] checkpatch: Quiet Kconfig help message checking Joe Perches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox