提交 dfe7053a 编写于 作者: D Don Slutz 提交者: Blue Swirl

CHECKPATCH: Add warning for single else statement.

For an example:

WARNING: braces {} are necessary even for single statement blocks
+    } else
+        return env->regs[R_EAX];

total: 0 errors, 1 warnings, 41 lines checked
Signed-off-by: NDon Slutz <Don@CloudSwitch.com>
Signed-off-by: NBlue Swirl <blauwirbel@gmail.com>
上级 69402a69
......@@ -2547,12 +2547,16 @@ sub process {
$line !~ /\#\s*else/) {
my $allowed = 0;
# Check the pre-context.
if (substr($line, 0, $-[0]) =~ /(\}\s*)$/) {
print "APW: ALLOWED: pre<$pre> line<$line>\n"
if $dbg_adv_apw;
$allowed = 1;
}
# Check the pre-context.
if (substr($line, 0, $-[0]) =~ /(\}\s*)$/) {
my $pre = $1;
if ($line !~ /else/) {
print "APW: ALLOWED: pre<$pre> line<$line>\n"
if $dbg_adv_apw;
$allowed = 1;
}
}
my ($level, $endln, @chunks) =
ctx_statement_full($linenr, $realcnt, $-[0]);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册