summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2015-02-14 01:38:46 +0300
committerLinus Torvalds <torvalds@linux-foundation.org>2015-02-14 08:21:39 +0300
commitf8e58219dc58cce633697fe15e6c5597bedb296b (patch)
treedcdcdff6091b759cc047ab3bf80bf01dfce12319 /scripts
parent021158b4c7bd8d0ec4dc8d09c013288429da7ee2 (diff)
downloadlinux-f8e58219dc58cce633697fe15e6c5597bedb296b.tar.xz
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>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/checkpatch.pl14
1 files changed, 10 insertions, 4 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 6705576198a6..059c032d8882 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4461,12 +4461,18 @@ sub process {
# check for unnecessary blank lines around braces
if (($line =~ /^.\s*}\s*$/ && $prevrawline =~ /^.\s*$/)) {
- CHK("BRACES",
- "Blank lines aren't necessary before a close brace '}'\n" . $hereprev);
+ if (CHK("BRACES",
+ "Blank lines aren't necessary before a close brace '}'\n" . $hereprev) &&
+ $fix && $prevrawline =~ /^\+/) {
+ fix_delete_line($fixlinenr - 1, $prevrawline);
+ }
}
if (($rawline =~ /^.\s*$/ && $prevline =~ /^..*{\s*$/)) {
- CHK("BRACES",
- "Blank lines aren't necessary after an open brace '{'\n" . $hereprev);
+ if (CHK("BRACES",
+ "Blank lines aren't necessary after an open brace '{'\n" . $hereprev) &&
+ $fix) {
+ fix_delete_line($fixlinenr, $rawline);
+ }
}
# no volatiles please