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>
This commit is contained in:
Joe Perches 2015-02-13 14:38:46 -08:00 коммит произвёл Linus Torvalds
Родитель 021158b4c7
Коммит f8e58219dc
1 изменённых файлов: 10 добавлений и 4 удалений

Просмотреть файл

@ -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