Skip to content

Commit 0979ae6

Browse files
JoePerchestorvalds
authored andcommitted
checkpatch: Add --strict messages for blank lines around braces
Blank lines around braces are not unnecessary. Emit a message on the use of these blank lines only when using --strict. int foo(int bar) { something or other.... } is generally written in the kernel as: int foo(int bar) { something or other... } Signed-off-by: Joe Perches <joe@perches.com> Cc: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 481eb48 commit 0979ae6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

scripts/checkpatch.pl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3189,6 +3189,16 @@ sub process {
31893189
}
31903190
}
31913191

3192+
# check for unnecessary blank lines around braces
3193+
if (($line =~ /^..*}\s*$/ && $prevline =~ /^.\s*$/)) {
3194+
CHK("BRACES",
3195+
"Blank lines aren't necessary before a close brace '}'\n" . $hereprev);
3196+
}
3197+
if (($line =~ /^.\s*$/ && $prevline =~ /^..*{\s*$/)) {
3198+
CHK("BRACES",
3199+
"Blank lines aren't necessary after an open brace '{'\n" . $hereprev);
3200+
}
3201+
31923202
# no volatiles please
31933203
my $asm_volatile = qr{\b(__asm__|asm)\s+(__volatile__|volatile)\b};
31943204
if ($line =~ /\bvolatile\b/ && $line !~ /$asm_volatile/) {

0 commit comments

Comments
 (0)