From nobody Sat Oct 25 09:08:51 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520343908029240.68659274290633; Tue, 6 Mar 2018 05:45:08 -0800 (PST) Received: from localhost ([::1]:55844 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etCtv-0003JA-9c for importer@patchew.org; Tue, 06 Mar 2018 08:45:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48279) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etCVi-0005N7-Pg for qemu-devel@nongnu.org; Tue, 06 Mar 2018 08:20:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etCVe-0006Uq-Ah for qemu-devel@nongnu.org; Tue, 06 Mar 2018 08:20:06 -0500 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:38807) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1etCVe-0006UE-3i for qemu-devel@nongnu.org; Tue, 06 Mar 2018 08:20:02 -0500 Received: by mail-wm0-x243.google.com with SMTP id z9so22089062wmb.3 for ; Tue, 06 Mar 2018 05:20:02 -0800 (PST) Received: from 640k.lan (94-36-191-219.adsl-ull.clienti.tiscali.it. [94.36.191.219]) by smtp.gmail.com with ESMTPSA id l38sm25652538wrc.96.2018.03.06.05.19.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Mar 2018 05:20:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Lv9gOqmu9FgJ7NdfG8Zud8R7mAvfm/jlJqnOoPBYVZA=; b=ADzkBOusX9hY1srTxw06W3+ONgnE04/HqPZ3TD/PmVdraQBsGSVeBIHrdmhfbjb2Nm HXuCuTkp/Vmz/app6c+JdPR5wQ50sFEmbmz/CiSbiQE9djKGTkxsdNSzaDzlkfNfsr0o t+mqLDpnl/Rvf1QLIwclk+6NGlv45Dq6wziQxF7N7U2TI4ltcX1yqISGmO1Ly3SebVms unVcPT7kpEmxZI1hjHSq86gGK/OwRZb9yvCuQC9SYELhdd4gstXdb6AGN0GyMjOqtT33 rxL4uyu12E+93EqDexWOmrtjbTd+KNq3F5EmIzwHDHzShpJBBf1WRMzS8/gKDpTjxQqT sfBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Lv9gOqmu9FgJ7NdfG8Zud8R7mAvfm/jlJqnOoPBYVZA=; b=lhqURQQ2JcXZAMl5l8BvMFtSzXtxz6XvvGyIyh2SAw8okaU3ft3Lhaijn66HGmvCQL dpu0qgjYowHdvvOYVtLTxsD0CPpF6TViZeQPJlU6CMIvZfuEh9NS4S3Mu7ydLJRl6xky EG2u798z9oqnNaK9hXssHTZfr4AZAFcAjVljjwnqK+2LQFljGEPWJQXyzYGHBXIq3IBI 546i+/x1JDHghUD5EDyThLug41zi/xzCDIOTJW0WcXXZ7whEMU266/dExilyjMmkCqq4 GkfngQ3EqGMboHIhDl9z0EhuOjL5DJWgLzmEed0nQZm7xaQgnA/2ATqVrrZ1VJQOEY7h LLtQ== X-Gm-Message-State: AElRT7HlCbEKni0tTOh1Uhdt1VPMhEkiDMwyyADV1FoBzy3/tsGfBQd5 TOnuIgSLAH6wGc0CvCxt1FR1t7Wj X-Google-Smtp-Source: AG47ELsmdS0rCI0PjWYYJqTkM5sIkAzqUlzkvX+oHFlaIdBW8pTPkxn3aDNTabq7uODxAoz0/Hmmdw== X-Received: by 10.28.111.145 with SMTP id c17mr10283895wmi.74.1520342400729; Tue, 06 Mar 2018 05:20:00 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 6 Mar 2018 14:19:19 +0100 Message-Id: <1520342370-123606-24-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1520342370-123606-1-git-send-email-pbonzini@redhat.com> References: <1520342370-123606-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::243 Subject: [Qemu-devel] [PULL 23/34] checkpatch: 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: Su Hang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Su Hang Adding 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. Using `(?:...)` instead of `(...)` in regex pattern catch. Because `(?:...)` is faster and avoids unwanted side-effect. Suggested-by: Stefan Hajnoczi Suggested-by: Eric Blake Suggested-by: Thomas Huth Signed-off-by: Su Hang Message-Id: <1520319890-19761-1-git-send-email-suhang16@mails.ucas.ac.cn> Signed-off-by: Paolo Bonzini --- scripts/checkpatch.pl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index a88af61..d1fe79b 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2352,8 +2352,9 @@ sub process { } } =20 -# check for missing bracing round if etc - if ($line =3D~ /(^.*)\bif\b/ && $line !~ /\#\s*if/) { +# check for missing bracing around if etc + if ($line =3D~ /(^.*)\b(?:if|while|for)\b/ && + $line !~ /\#\s*if/) { my ($level, $endln, @chunks) =3D ctx_statement_full($linenr, $realcnt, 1); if ($dbg_adv_apw) { --=20 1.8.3.1