From patchwork Mon Feb 26 02:53:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Su Hang X-Patchwork-Id: 877666 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mails.ucas.ac.cn Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zqRHy568yz9s1p for ; Mon, 26 Feb 2018 13:54:37 +1100 (AEDT) Received: from localhost ([::1]:56848 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eq8vy-000788-3a for incoming@patchwork.ozlabs.org; Sun, 25 Feb 2018 21:54:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42222) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eq8va-00077u-5X for qemu-devel@nongnu.org; Sun, 25 Feb 2018 21:54:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eq8vX-00051S-3S for qemu-devel@nongnu.org; Sun, 25 Feb 2018 21:54:10 -0500 Received: from smtp16.cstnet.cn ([159.226.251.16]:46071 helo=cstnet.cn) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eq8vW-0004zm-F6 for qemu-devel@nongnu.org; Sun, 25 Feb 2018 21:54:07 -0500 Received: from localhost.localdomain (unknown [36.110.80.218]) by APP-07 (Coremail) with SMTP id zwCowAB3EJrGdpNair_PCg--.2238S3; Mon, 26 Feb 2018 10:53:58 +0800 (CST) From: Su Hang To: thuth@redhat.com, eblake@redhat.com, stefanha@redhat.com Date: Mon, 26 Feb 2018 10:53:18 +0800 Message-Id: <1519613598-12270-1-git-send-email-suhang16@mails.ucas.ac.cn> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: zwCowAB3EJrGdpNair_PCg--.2238S3 X-Coremail-Antispam: 1UD129KBjvdXoW7JFyfGr48ZF48tF47CryDJrb_yoWDuwc_Ar yktr17XrWkAr9Y9F1qyr429340k3yDua1DXr15Zr9ru3s5GF4DuFZ7Xr9rXw42ga4IvF1Y 9r95XF9ruFn3ZjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbckYjsxI4VW3JwAYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I 6I8E6xAIw20EY4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l8cAvFVAK0II2c7xJM2 8CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW8JVW5JwA2z4x0Y4vE2Ix0 cI8IcVCY1x0267AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I 8E87Iv6xkF7I0E14v26r4UJVWxJr1lnxkEFVAIw20F6cxK64vIFxWle2I262IYc4CY6c8I j28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jrv_JF 1lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxG rwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r 1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij 64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr 0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6Fyj6rWUJwCI42IY6I8E87Iv67AKxVWUJVW8JwCI 42IY6I8E87Iv6xkF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x07jo2NtUUUUU= X-CM-SenderInfo: pvxkt0rjrwqzpdlo2hpxfd2hldfou0/ X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 159.226.251.16 Subject: [Qemu-devel] [PATCH v2 RFC] scripts/checkpatch.pl: add check for `while` and `for` X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Add check for `while` and `for` statements, which condition has more than one line. The former checkpatch.pl can check `if` statement, which condition has more than one line, whether block misses brace round, like this: ''' if (cond1 || cond2) statement; ''' But it doesn't do the same check for `for` and `while` statements. Suggested-by: Eric Blake Suggested-by: Thomas Huth Signed-off-by: Su Hang --- scripts/checkpatch.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 1b4b812e28fa..10c138344fa9 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2353,7 +2353,8 @@ sub process { } # check for missing bracing round if etc - if ($line =~ /(^.*)\bif\b/ && $line !~ /\#\s*if/) { + if ($line =~ /(^.*)\b(for|while|if)\b/ && + $line !~ /\#\s*(for|while|if)/) { my ($level, $endln, @chunks) = ctx_statement_full($linenr, $realcnt, 1); if ($dbg_adv_apw) {