qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Don Slutz <Don@CloudSwitch.com>
To: qemu-devel@nongnu.org,
	blauwirbel@gmail.comqemu-devel@nongnu.orgblauwirbel@gmail.com
Cc: Don Slutz <Don@CloudSwitch.com>
Subject: [Qemu-devel] [PATCH v2 4/4] CHECKPATCH: Add warning for single else statement.
Date: Sun, 2 Sep 2012 19:22:38 -0400	[thread overview]
Message-ID: <1346628158-30403-5-git-send-email-Don@CloudSwitch.com> (raw)
In-Reply-To: <1346515062-13067-1-git-send-email-Don@CloudSwitch.com>

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>
---
 scripts/checkpatch.pl |   16 ++++++++++------
 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]);
-- 
1.7.1

      parent reply	other threads:[~2012-09-02 23:23 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-01 15:57 [Qemu-devel] [PATCH] CHECKPATCH Don Slutz
2012-09-01 15:57 ` [Qemu-devel] [PATCH] CHECKPATCH: Add warning for single else statement Don Slutz
2012-09-02 10:52   ` Blue Swirl
2012-09-02 10:51 ` [Qemu-devel] [PATCH] CHECKPATCH Blue Swirl
2012-09-06 15:32   ` Avi Kivity
2012-09-08  7:33     ` Blue Swirl
2012-09-02 23:22 ` [Qemu-devel] [PATCH v2 0/4] CHECKPATCH: Add warning for single else statement Don Slutz
2012-09-05 19:46   ` Blue Swirl
2012-09-06 10:32     ` Andreas Färber
2012-09-08  7:08       ` Blue Swirl
2012-09-02 23:22 ` [Qemu-devel] [PATCH v2 1/4] CHECKPATCH: Add --debug adv_dcs Don Slutz
2012-09-02 23:22 ` [Qemu-devel] [PATCH v2 2/4] CHECKPATCH: Add --debug adv_checking Don Slutz
2012-09-02 23:22 ` [Qemu-devel] [PATCH v2 3/4] CHECKPATCH: Add --debug adv_apw Don Slutz
2012-09-02 23:22 ` Don Slutz [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1346628158-30403-5-git-send-email-Don@CloudSwitch.com \
    --to=don@cloudswitch.com \
    --cc=blauwirbel@gmail.comqemu-devel \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).