aboutsummaryrefslogtreecommitdiff
path: root/scripts/checkpatch.pl
diff options
context:
space:
mode:
authorDon Slutz <Don@CloudSwitch.com>2012-09-02 19:22:38 -0400
committerBlue Swirl <blauwirbel@gmail.com>2012-09-05 19:17:49 +0000
commitdfe7053a34353079503bf350f83cb8b6101a450d (patch)
tree112a2c9e2c4094db5a7e94b3ae02b2a9cc16eb8f /scripts/checkpatch.pl
parent69402a6944f506f51efee13c9db94bd1605eb478 (diff)
downloadqemu-dfe7053a34353079503bf350f83cb8b6101a450d.zip
qemu-dfe7053a34353079503bf350f83cb8b6101a450d.tar.gz
qemu-dfe7053a34353079503bf350f83cb8b6101a450d.tar.bz2
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: Don Slutz <Don@CloudSwitch.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'scripts/checkpatch.pl')
-rwxr-xr-xscripts/checkpatch.pl16
1 files changed, 10 insertions, 6 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 7ec8846..ec0aa4c 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -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]);