Skip to content

Commit f8e5821

Browse files
JoePerchestorvalds
authored andcommitted
checkpatch: add ability to --fix unnecessary blank lines around braces
There's a --strict test for these blank lines. Add the ability to automatically remove them with --fix. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 021158b commit f8e5821

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

scripts/checkpatch.pl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4461,12 +4461,18 @@ sub process {
44614461

44624462
# check for unnecessary blank lines around braces
44634463
if (($line =~ /^.\s*}\s*$/ && $prevrawline =~ /^.\s*$/)) {
4464-
CHK("BRACES",
4465-
"Blank lines aren't necessary before a close brace '}'\n" . $hereprev);
4464+
if (CHK("BRACES",
4465+
"Blank lines aren't necessary before a close brace '}'\n" . $hereprev) &&
4466+
$fix && $prevrawline =~ /^\+/) {
4467+
fix_delete_line($fixlinenr - 1, $prevrawline);
4468+
}
44664469
}
44674470
if (($rawline =~ /^.\s*$/ && $prevline =~ /^..*{\s*$/)) {
4468-
CHK("BRACES",
4469-
"Blank lines aren't necessary after an open brace '{'\n" . $hereprev);
4471+
if (CHK("BRACES",
4472+
"Blank lines aren't necessary after an open brace '{'\n" . $hereprev) &&
4473+
$fix) {
4474+
fix_delete_line($fixlinenr, $rawline);
4475+
}
44704476
}
44714477

44724478
# no volatiles please

0 commit comments

Comments
 (0)