From nobody Tue Nov 4 18:51:45 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; 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 1530720816028570.273665643056; Wed, 4 Jul 2018 09:13:36 -0700 (PDT) Received: from localhost ([::1]:48072 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fakPL-0001dM-8b for importer@patchew.org; Wed, 04 Jul 2018 12:13:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37247) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fakOC-00015m-4r for qemu-devel@nongnu.org; Wed, 04 Jul 2018 12:12:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fakO7-0004rt-Gj for qemu-devel@nongnu.org; Wed, 04 Jul 2018 12:12:20 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54768 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fakO7-0004rb-B7 for qemu-devel@nongnu.org; Wed, 04 Jul 2018 12:12:15 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C5DD17262D; Wed, 4 Jul 2018 16:12:14 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-117-235.ams2.redhat.com [10.36.117.235]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1FD552156880; Wed, 4 Jul 2018 16:12:13 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 4 Jul 2018 18:12:13 +0200 Message-Id: <20180704161213.30687-1-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 04 Jul 2018 16:12:14 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Wed, 04 Jul 2018 16:12:14 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'pbonzini@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH] checkpatch: handle token pasting better 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: amarkovic@wavecomp.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The mechanism to find possible type tokens can sometimes be confused and go= into an infinite loop. This happens for example in QEMU for a line that looks like uint## BITS ##_t S =3D _S, T =3D _T; \ uint## BITS ##_t as, at, xs, xt, xd; \ Because the token pasting operator does not have a space before _t, it does= not match $notPermitted. However, (?x) is turned on in the regular expression = for modifiers, and thus ##_t matches the empty string. As a result, annotate_v= alues goes in an infinite loop. The solution is simply to remove token pasting operators from the string be= fore looking for modifiers. In the example above, the string uintBITS_t will be evaluated as a candidate modifier. This is not optimal, but it works as lo= ng as people do not write things like a##s##m, and it fits nicely into sub possible. For a similar reason, \# should be rejected always, even if it is not at end of line or followed by whitespace. The same patch was sent to the Linux kernel mailing list. Reported-by: Aleksandar Markovic Signed-off-by: Paolo Bonzini --- scripts/checkpatch.pl | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 223681bfd0..42e1c50dd8 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1132,11 +1132,10 @@ sub possible { case| else| asm|__asm__| - do| - \#| - \#\# + do )(?:\s|$)| - ^(?:typedef|struct|enum)\b + ^(?:typedef|struct|enum)\b| + ^\# )}x; warn "CHECK<$possible> ($line)\n" if ($dbg_possible > 2); if ($possible !~ $notPermitted) { @@ -1146,7 +1145,7 @@ sub possible { if ($possible =3D~ /^\s*$/) { =20 } elsif ($possible =3D~ /\s/) { - $possible =3D~ s/\s*$Type\s*//g; + $possible =3D~ s/\s*(?:$Type|\#\#)\s*//g; for my $modifier (split(' ', $possible)) { if ($modifier !~ $notPermitted) { warn "MODIFIER: $modifier ($possible) ($line)\n" if ($dbg_possible); --=20 2.17.1