]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
checkpatch: improve missing blank line after declarations test
authorJoe Perches <joe@perches.com>
Sat, 17 May 2014 13:18:35 +0000 (23:18 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Sat, 17 May 2014 13:18:35 +0000 (23:18 +1000)
A couple more modifications to the declarations tests.

o Declarations can also be bitfields so exclude things with a colon
o Make sure the current and previous lines are indented the same
  to avoid matching some macro where a struct type is passed on
  the previous line like:

next = list_entry(buffer->entry.next,
  struct binder_buffer, entry);
if (buffer_start_page(next) == buffer_end_page(buffer))

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
scripts/checkpatch.pl

index 89f44f171eafc6194798702de45e108960991825..f2ef63a2e8d43620e5f489cd5821d619e56cd173 100755 (executable)
@@ -2275,7 +2275,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
@@ -2287,7 +2287,7 @@ sub process {
                        # not starting a section or a macro "\" extended line
                      $prevline =~ /(?:\{\s*|\\)$/) &&
                        # looks like a declaration
-                   !($sline =~ /^\+\s+$Declare\s*$Ident\s*[=,;\[]/ ||
+                   !($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
@@ -2299,7 +2299,9 @@ sub process {
                        # bitfield continuation
                      $sline =~ /^\+\s+$Ident\s*:\s*\d+\s*[,;]/ ||
                        # other possible extensions of declaration lines
-                     $sline =~ /^\+\s+\(?\s*(?:$Compare|$Assignment|$Operators)/)) {
+                     $sline =~ /^\+\s+\(?\s*(?:$Compare|$Assignment|$Operators)/) &&
+                       # indentation of previous and current line are the same
+                   (($prevline =~ /\+(\s+)\S/) && $sline =~ /^\+$1\S/)) {
                        WARN("SPACING",
                             "Missing a blank line after declarations\n" . $hereprev);
                }