提交 f8e58219 编写于 作者: J Joe Perches 提交者: Linus Torvalds

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: NJoe Perches <joe@perches.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 021158b4
...@@ -4461,12 +4461,18 @@ sub process { ...@@ -4461,12 +4461,18 @@ sub process {
# check for unnecessary blank lines around braces # check for unnecessary blank lines around braces
if (($line =~ /^.\s*}\s*$/ && $prevrawline =~ /^.\s*$/)) { if (($line =~ /^.\s*}\s*$/ && $prevrawline =~ /^.\s*$/)) {
CHK("BRACES", if (CHK("BRACES",
"Blank lines aren't necessary before a close brace '}'\n" . $hereprev); "Blank lines aren't necessary before a close brace '}'\n" . $hereprev) &&
$fix && $prevrawline =~ /^\+/) {
fix_delete_line($fixlinenr - 1, $prevrawline);
}
} }
if (($rawline =~ /^.\s*$/ && $prevline =~ /^..*{\s*$/)) { if (($rawline =~ /^.\s*$/ && $prevline =~ /^..*{\s*$/)) {
CHK("BRACES", if (CHK("BRACES",
"Blank lines aren't necessary after an open brace '{'\n" . $hereprev); "Blank lines aren't necessary after an open brace '{'\n" . $hereprev) &&
$fix) {
fix_delete_line($fixlinenr, $rawline);
}
} }
# no volatiles please # no volatiles please
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册