checkpatch: if should not continue a preceeding brace
authorAndy Whitcroft <apw@canonical.com>
Thu, 15 Jan 2009 21:51:06 +0000 (13:51 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 16 Jan 2009 00:39:38 +0000 (16:39 -0800)
We should not be continuing a braced section with an if, for example:

if (...) {
} if (...) {
}

Detect this and suggest adding a newline.

Signed-off-by: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
scripts/checkpatch.pl

index 696196e194f5320a176afe140fd9b871df919bc9..5ea55e330c2444bdc8a18166a094801909a77ae1 100755 (executable)
@@ -2108,6 +2108,11 @@ sub process {
                                ERROR("trailing statements should be on next line\n" . $herecurr);
                        }
                }
+# if should not continue a brace
+               if ($line =~ /}\s*if\b/) {
+                       ERROR("trailing statements should be on next line\n" .
+                               $herecurr);
+               }
 # case and default should not have general statements after them
                if ($line =~ /^.\s*(?:case\s*.*|default\s*):/g &&
                    $line !~ /\G(?: