From patchwork Sun Feb 25 03:13:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Su Hang X-Patchwork-Id: 877496 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 3zpqnN5L8Bz9s1R for ; Sun, 25 Feb 2018 14:14:31 +1100 (AEDT) Received: from localhost ([::1]:52588 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1epmla-00082U-FF for incoming@patchwork.ozlabs.org; Sat, 24 Feb 2018 22:14:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48600) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1epmlE-00081A-Mt for qemu-devel@nongnu.org; Sat, 24 Feb 2018 22:14:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1epml9-0005U3-Jt for qemu-devel@nongnu.org; Sat, 24 Feb 2018 22:14:00 -0500 Received: from smtp23.cstnet.cn ([159.226.251.23]:53641 helo=cstnet.cn) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1epml9-0005Mb-0j for qemu-devel@nongnu.org; Sat, 24 Feb 2018 22:13:55 -0500 Received: from localhost.localdomain (unknown [36.110.80.218]) by APP-03 (Coremail) with SMTP id rQCowAAXHe3uKZJaKoPQBQ--.15440S3; Sun, 25 Feb 2018 11:13:50 +0800 (CST) From: Su Hang To: thuth@redhat.com, eblake@redhat.com, stefanha@redhat.com Date: Sun, 25 Feb 2018 11:13:09 +0800 Message-Id: <1519528389-14023-1-git-send-email-suhang16@mails.ucas.ac.cn> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519480458-9573-1-git-send-email-suhang16@mails.ucas.ac.cn> References: <1519480458-9573-1-git-send-email-suhang16@mails.ucas.ac.cn> X-CM-TRANSID: rQCowAAXHe3uKZJaKoPQBQ--.15440S3 X-Coremail-Antispam: 1UD129KBjvdXoW7JFyfGr48ZF48tF47CFyrtFb_yoWDuFX_Zr 97tr17XrykAr909Fn0yr429340kw4UZaykZ3W5Zr9ru3s5GFsrua97Jr9xXw4jga4IvFyY 9r98XF97CFn3ZjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbc8YjsxI4VW3JwAYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I 6I8E6xAIw20EY4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l8cAvFVAK0II2c7xJM2 8CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVWUJVWUCwA2z4x0Y4vE2Ix0 cI8IcVCY1x0267AKxVWUJVW8JwA2z4x0Y4vEx4A2jsIE14v26r4j6F4UM28EF7xvwVC2z2 80aVCY1x0267AKxVW8JVW8Jr1lnxkEFVAIw20F6cxK64vIFxWle2I262IYc4CY6c8Ij28I cVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx 0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCF 04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r 18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vI r41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr 1lIxAIcVCF04k26cxKx2IYs7xG6rW3Jr0E3s1lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAI cVC2z280aVCY1x0267AKxVWUJVW8JbIYCTnIWIevJa73UjIFyTuYvjxU4oUDDUUUU 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 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` 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` statement. 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..7e332135e177 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(if|for|while)\b/ && + $line !~ /\#\s*(if|for|while)/) { my ($level, $endln, @chunks) = ctx_statement_full($linenr, $realcnt, 1); if ($dbg_adv_apw) {