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

checkpatch: notice unbalanced else braces in a patch

Patches that add or modify code like

	} else
		<foo>
or
	else {
		<bar>

where one branch appears to have a brace and the other branch does not
have a brace should emit a --strict style message.

Link: http://lkml.kernel.org/r/c6be32747fc725cbc235802991746700a0f54fdc.1486754390.git.joe@perches.comSigned-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>
上级 1bde561e
......@@ -5104,6 +5104,12 @@ sub process {
}
}
# check for single line unbalanced braces
if ($sline =~ /.\s*\}\s*else\s*$/ ||
$sline =~ /.\s*else\s*\{\s*$/) {
CHK("BRACES", "Unbalanced braces around else statement\n" . $herecurr);
}
# check for unnecessary blank lines around braces
if (($line =~ /^.\s*}\s*$/ && $prevrawline =~ /^.\s*$/)) {
if (CHK("BRACES",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册