lkml.org 
[lkml]   [2014]   [Mar]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH] checkpatch: Update "Missing a blank line after declarations" test
From
Date
"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




\
 
 \ /
  Last update: 2014-03-23 00:41    [W:0.039 / U:0.236 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site