From nobody Tue Nov 4 22:05:03 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 1530897639569394.8471076287883; Fri, 6 Jul 2018 10:20:39 -0700 (PDT) Received: from localhost ([::1]:59020 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fbUPL-0004si-3g for importer@patchew.org; Fri, 06 Jul 2018 13:20:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51119) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fbUK7-0001JA-Jh for qemu-devel@nongnu.org; Fri, 06 Jul 2018 13:15:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fbUK6-0000qf-Ip for qemu-devel@nongnu.org; Fri, 06 Jul 2018 13:15:11 -0400 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]:53659) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fbUK6-0000oR-By for qemu-devel@nongnu.org; Fri, 06 Jul 2018 13:15:10 -0400 Received: by mail-wm0-x243.google.com with SMTP id b188-v6so15570719wme.3 for ; Fri, 06 Jul 2018 10:15:10 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id h40-v6sm13784683wrf.40.2018.07.06.10.15.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Jul 2018 10:15:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=2FEPgev5kcwrP2noABIeJ+Sm41hZx7Ka3ze2dZNiWiI=; b=pe2iw15Bh4QQ/lcaSDIO8U93ky9r1O2yCTTleFzibzwrLO+2Aygo0R6q4uKvP9kkPh WwFyEXRM+BKpEWwtAeRJYd/V/qcZlHpCfLqxCX4hSdpZKqUAJMG19Ft6Pq6HZLlt87/m pyODG+BSDRwZraYypQzdzoZFwJw1hnMo8mW/jvgvpjqu/SS4FZ6SUUFpR9dQb+FpXNpq obUIHZ/7CYkRQX8p0stw3D5Q94ftkvxqhMVitxA/yb1NDqaqitTZvxTv88IDaH9In77x aQ4ODAgdqSwJ7OsMOhbXVPRWCZKJMIoxipn2iy779izSoFofZg1CyEjKUeYr7a6LACig FCvw== 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:subject:date:message-id :in-reply-to:references; bh=2FEPgev5kcwrP2noABIeJ+Sm41hZx7Ka3ze2dZNiWiI=; b=pUXgdn4TyVB7O3uo2yEBjISI5M5Ng9FfrM3lL+6Q8bwPm/z+IJZz56IQMp3BFux/Fz J0iyr2i4rJ6nb7H14Y+Cdg0/YCMkZu9di5seI7HqjDv4z9V6w31DhAZKJ3ST6L6g4Sos NxH5uDW9VJyIf0jKxmtNcfcre04Cr+K4nYHa5FBxcLLuKqFjDFDSLAus74U0PUITg5gX fqEXOAiFA9bV1XmY37/Dh85Vzam1g6Nm9F9O5MHNckYi5L7XvVEIIeOb2eFQAeHDJaua 980L0HEepwcCLaWkeL+SOEf9XtZ4QsIn4IwcOD21L/xizSHTsu58VKh+7gjqiArXtTZG 7itw== X-Gm-Message-State: APt69E2WPN0cpHr8w985PrXdOCLS0z9h2x4ynxaJnMIdckyVbKyxNv0e jc6k955JHlcFvf+8C33+r0JipGMu X-Google-Smtp-Source: AAOMgpctSHPFrevOVkCQJbu7R7q1k6fNNMrMc0hQHBZEKRotMnEeHz8PcgArFSc00/QSslTaURTwfA== X-Received: by 2002:a1c:9809:: with SMTP id a9-v6mr2721778wme.15.1530897309098; Fri, 06 Jul 2018 10:15:09 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 6 Jul 2018 19:14:28 +0200 Message-Id: <1530897268-22932-9-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530897268-22932-1-git-send-email-pbonzini@redhat.com> References: <1530897268-22932-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 8/8] 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: , 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" 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 223681b..42e1c50 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 1.8.3.1