From nobody Fri Nov 7 09:09:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 154783033963116.496052576306965; Fri, 18 Jan 2019 08:52:19 -0800 (PST) Received: from localhost ([127.0.0.1]:42650 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkXNS-0000J9-Cf for importer@patchew.org; Fri, 18 Jan 2019 11:52:18 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43476) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkXM9-00088b-By for qemu-devel@nongnu.org; Fri, 18 Jan 2019 11:50:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gkXM8-0006ep-6x for qemu-devel@nongnu.org; Fri, 18 Jan 2019 11:50:57 -0500 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]:36032) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gkXM8-0006bw-0O for qemu-devel@nongnu.org; Fri, 18 Jan 2019 11:50:56 -0500 Received: by mail-wr1-x42b.google.com with SMTP id u4so15875764wrp.3 for ; Fri, 18 Jan 2019 08:50:55 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id c13sm94209872wrb.38.2019.01.18.08.50.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 Jan 2019 08:50:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8V7CmVRC1aKeWn1+3jasoRgnR6lwREnHDIjkoli711A=; b=PpOqkASo7RjpVk4sad1/cReCDPNe7JMktGRVYcOYP1xP0dWJ5lx2ETJKZ7Eb34NELs 3v3XkS9OtAb/E8O1uVragzk6aIakScFHCwquFSlnN39iQeO5XUHVknvosU5/ut9qm0tU 0Y1UZYp1jq5FrUL8leJkyLp0GFT0hbzni+LU4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8V7CmVRC1aKeWn1+3jasoRgnR6lwREnHDIjkoli711A=; b=qmI1FVG7/30NzAUbtP/Z+f6nTLF4RR7jZdhY7KF3Lo5KNJw8RonKUr5L0S6rjGJ9O9 KTSIXHpE2QYREi9F/vR7CZA7vJYbXmP53PYEmpYrQeDRd5m5AcdBIrZNHJBBES3ojwGW lFYL0R5+qw9R8R+eJsgLIP0/6VK0loFhGgJeosnHQIqJOy3NKgXBuN0fZq9mq83ZHetE g7gY3zsXM+xL7tAbXuRyIleFud+1itANsmDS/kAMnji4DCbl0agUr2mAsdzyfz93+pOv gCNSznSpvVJUZQeZhsW2CKBQTalTb07cEo4kqXBRsO//FbkSjXCjGD4UjzLBxSpbPCqQ z78g== X-Gm-Message-State: AJcUukdKuuXSXuzdarCR27hxaykXqpxoAbip8FXxVx1Q5Sn/AsHxijR8 KnKerybB1TWSSpWQepGpX5/GFp+eOARbiw== X-Google-Smtp-Source: ALg8bN6iEGNdDzEa8f5HwdCLrIwxjy3/2Jo+Q4hcp5rc78pMgN3Hid9vS7fbRbiWBLRVAwaJhG2xuA== X-Received: by 2002:adf:f903:: with SMTP id b3mr18080951wrr.82.1547830252618; Fri, 18 Jan 2019 08:50:52 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 18 Jan 2019 16:50:50 +0000 Message-Id: <20190118165050.22270-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42b Subject: [Qemu-devel] [PATCH v2] checkpatch: Don't emit spurious warnings about block comments 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: Thomas Huth , patches@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" In checkpatch we attempt to check for and warn about block comments which start with /* or /** followed by a non-blank. Unfortunately a bug in the regex meant that we would incorrectly warn about comments starting with "/**" with no following text: git show 9813dc6ac3954d58ba16b3920556f106f97e1c67|./scripts/checkpatch.pl= - WARNING: Block comments use a leading /* on a separate line #34: FILE: tests/libqtest.h:233: +/** The sequence "/\*\*?" was intended to match either "/*" or "/**", but Perl's semantics for '?' allow it to backtrack and try the "matches 0 chars" option if the "matches 1 char" choice leads to a failure of the rest of the regex to match. Switch to "/\*\*?+" which uses what perlre(1) calls the "possessive" quantifier form: this means that if it matches the "/**" string it will not later backtrack to matching just the "/*" prefix. The other end of the regex is also wrong: it is attempting to check for "/* or /** followed by something that isn't just whitespace", but [ \t]*.+[ \t]* will match on pure whitespace. This is less significant but means that a line with just a comment-starter followed by trailing whitespace will generate an incorrect warning about block comment style as well as the correct error about trailing whitespace which a different checkpatch test emits. Reported-by: Thomas Huth Reported-by: Eric Blake Signed-off-by: Peter Maydell Reviewed-by: Eric Blake --- This comment check is unique to QEMU checkpatch so the bugs don't exist in the Linux version. v1->v2 changes: Add the fix to the other end of the regex pointed out by Eric, so that we don't emit spurious warnings for block comment starters with trailing whitespace. --- scripts/checkpatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index d10dddf1be4..88682cb0a9f 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1624,7 +1624,7 @@ sub process { =20 # Block comments use /* on a line of its own if ($rawline !~ m@^\+.*/\*.*\*/[ \t]*$@ && #inline /*...*/ - $rawline =3D~ m@^\+.*/\*\*?[ \t]*.+[ \t]*$@) { # /* or /** non-blank + $rawline =3D~ m@^\+.*/\*\*?+[ \t]*[^ \t]@) { # /* or /** non-blank WARN("Block comments use a leading /* on a separate line\n" . $herecurr= ); } =20 --=20 2.20.1