From 85c084f6ff2afa3cc8e1b0ebc2a225aaac58d6af Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Thu, 22 May 2014 10:43:42 +1000 Subject: [PATCH] checkpatch: improve missing blank line after declarations test 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 Signed-off-by: Andrew Morton --- scripts/checkpatch.pl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 89f44f171eaf..f2ef63a2e8d4 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -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); } -- 2.39.5