From patchwork Sat Feb 24 13:54: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: 10240371 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0C4BC602B8 for ; Sat, 24 Feb 2018 13:55:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE0F629C16 for ; Sat, 24 Feb 2018 13:55:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E189229C19; Sat, 24 Feb 2018 13:55:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5ED2A29C16 for ; Sat, 24 Feb 2018 13:55:13 +0000 (UTC) Received: from localhost ([::1]:50234 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1epaIC-0004cb-SD for patchwork-qemu-devel@patchwork.kernel.org; Sat, 24 Feb 2018 08:55:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59267) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1epaHV-0004DF-Rg for qemu-devel@nongnu.org; Sat, 24 Feb 2018 08:54:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1epaHS-0007tx-OK for qemu-devel@nongnu.org; Sat, 24 Feb 2018 08:54:29 -0500 Received: from smtp23.cstnet.cn ([159.226.251.23]:39317 helo=cstnet.cn) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1epaHS-0007r8-2g for qemu-devel@nongnu.org; Sat, 24 Feb 2018 08:54:26 -0500 Received: from Sword.lan (unknown [210.77.26.65]) by APP-03 (Coremail) with SMTP id rQCowAD39_WKbpFaX2alBQ--.9109S3; Sat, 24 Feb 2018 21:54:19 +0800 (CST) From: Su Hang To: thuth@redhat.com, stefanha@redhat.com, eblake@redhat.com Date: Sat, 24 Feb 2018 21:54:18 +0800 Message-Id: <1519480458-9573-1-git-send-email-suhang16@mails.ucas.ac.cn> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: rQCowAD39_WKbpFaX2alBQ--.9109S3 X-Coremail-Antispam: 1UD129KBjvdXoW7JFyfGr48ZF48tF47Ar4UXFb_yoWDZFc_Zr 97tr17XrykAr909Fn0yr4293s5K39rua95X3W5ZrZxu3s5GFZruFZ7Jr9xXw47ta4IvFya 9r98XF97CFn3ZjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbs8YjsxI4VW3JwAYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I 6I8E6xAIw20EY4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l8cAvFVAK0II2c7xJM2 8CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVWUCVW8JwA2z4x0Y4vE2Ix0 cI8IcVCY1x0267AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I 8E87Iv6xkF7I0E14v26r4UJVWxJr1lnxkEFVAIw20F6cxK64vIFxWle2I262IYc4CY6c8I j28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr 4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxG rwCY02Avz4vE14v_Xr4l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2 IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v2 6r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2 IY6xkF7I0E14v26r1j6r4UMIIF0xvE42xK8VAvwI8IcIk0rVWrZr1j6s0DMIIF0xvEx4A2 jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Jr0_GrUvcSsGvfC2KfnxnUUI43 ZEXa7IU0sF4tUUUUU== X-CM-SenderInfo: pvxkt0rjrwqzpdlo2hpxfd2hldfou0/ X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 159.226.251.23 Subject: [Qemu-devel] [PATCH 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add check for `while` and `for` statement, 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`. Suggested-by: Eric Blake Suggested-by: Thomas Huth Signed-off-by: Su Hang --- scripts/checkpatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 1b4b812e28fa..cfe7e77d156f 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2353,7 +2353,7 @@ sub process { } # check for missing bracing round if etc - if ($line =~ /(^.*)\bif\b/ && $line !~ /\#\s*if/) { + if ($line =~ /(^.*)\b(if|for|while)\b/ && $line !~ /\#\s*(if|for|while)/) { my ($level, $endln, @chunks) = ctx_statement_full($linenr, $realcnt, 1); if ($dbg_adv_apw) {