* [PATCH] checkpatch: Update "Missing a blank line after declarations" test
[not found] ` <20140322154020.f7b6a72c.akpm@linux-foundation.org>
@ 2014-03-22 23:21 ` Joe Perches
0 siblings, 0 replies; only message in thread
From: Joe Perches @ 2014-03-22 23:21 UTC (permalink / raw)
To: Andrew Morton; +Cc: Andy Whitcroft, LKML
"struct foo *bar" does not match the regex "$Declare\s+$Ident"
$Declare matches "struct foo *" but there is no required space
between the pointer "*" and the $Ident.
Also it ends in a pointer, the $Declare variable also contains all
trailing spaces after the declaration so there is no space between
$Declare and $Ident.
ie: "struct foo * bar" does not match "$Declare\s+$Ident"
So, change the \s+ to \s* to have this regex match any of
"struct foo bar", "struct foo *bar", and "struct foo * bar"
Signed-off-by: Joe Perches <joe@perches.com>
---
scripts/checkpatch.pl | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 93beee8..bca2be0 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2259,7 +2259,7 @@ sub process {
# check for missing blank lines after declarations
if ($sline =~ /^\+\s+\S/ && #Not at char 1
# actual declarations
- ($prevline =~ /^\+\s+$Declare\s+$Ident\s*[=,;\[]/ ||
+ ($prevline =~ /^\+\s+$Declare\s*$Ident\s*[=,;\[]/ ||
# foo bar; where foo is some local typedef or #define
$prevline =~ /^\+\s+$Ident(?:\s+|\s*\*\s*)$Ident\s*[=,;\[]/ ||
# known declaration macros
@@ -2271,7 +2271,7 @@ sub process {
# not starting a section or a macro "\" extended line
$prevline =~ /(?:\{\s*|\\)$/) &&
# looks like a declaration
- !($sline =~ /^\+\s+$Declare/ ||
+ !($sline =~ /^\+\s+$Declare\s*$Ident\s*[=,;\[]/ ||
# foo bar; where foo is some local typedef or #define
$sline =~ /^\+\s+$Ident(?:\s+|\s*\*\s*)$Ident\s*[=,;\[]/ ||
# known declaration macros
--
1.8.1.2.459.gbcd45b4.dirty
^ permalink raw reply [flat|nested] only message in thread