From patchwork Sun Sep 2 23:22:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Don Slutz X-Patchwork-Id: 181271 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4B9C52C0090 for ; Mon, 3 Sep 2012 09:23:27 +1000 (EST) Received: from localhost ([::1]:58914 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8JVl-0007cS-9y for incoming@patchwork.ozlabs.org; Sun, 02 Sep 2012 19:23:25 -0400 Received: from eggs.gnu.org ([208.118.235.92]:45352) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8JVV-0007PF-Qq for qemu-devel@nongnu.org; Sun, 02 Sep 2012 19:23:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T8JVU-00064J-Rx for qemu-devel@nongnu.org; Sun, 02 Sep 2012 19:23:09 -0400 Received: from hub021-nj-6.exch021.serverdata.net ([206.225.164.222]:12802) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T8JVU-000649-OW for qemu-devel@nongnu.org; Sun, 02 Sep 2012 19:23:08 -0400 Received: from localhost.localdomain (131.239.15.22) by east.exch021.serverdata.net (10.240.4.93) with Microsoft SMTP Server (TLS) id 14.2.309.2; Sun, 2 Sep 2012 16:23:08 -0700 From: Don Slutz To: , , , Date: Sun, 2 Sep 2012 19:22:38 -0400 Message-ID: <1346628158-30403-5-git-send-email-Don@CloudSwitch.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1346515062-13067-1-git-send-email-Don@CloudSwitch.com> References: <1346515062-13067-1-git-send-email-Don@CloudSwitch.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Windows 2000 SP2+, XP SP1+ (seldom 98) X-Received-From: 206.225.164.222 Cc: Don Slutz Subject: [Qemu-devel] [PATCH v2 4/4] CHECKPATCH: Add warning for single else statement. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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]);