mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Alexander Potapenko <glider@google.com>
Cc: apw@canonical.com, dwaipayanray1@gmail.com,
	Lukas Bulwahn <lukas.bulwahn@gmail.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: Infinite loop in checkpatch.pl
Date: Sun, 05 Mar 2023 16:05:18 -0800	[thread overview]
Message-ID: <3e32e97858d5bf9d88cc03136d7abc7af2dd7f30.camel@perches.com> (raw)
In-Reply-To: <CAG_fn=XDzM_+nXpypPFG95r7EKRWhPGd7C=JZOy7kYrpcC+XDQ@mail.gmail.com>

On Fri, 2023-03-03 at 21:53 +0100, Alexander Potapenko wrote:
> On Fri, Mar 3, 2023 at 5:53 PM Joe Perches <joe@perches.com> wrote:
> > 
> > On Fri, 2023-03-03 at 15:28 +0100, Alexander Potapenko wrote:
> > > Hi folks,
> > > 
> > > I've noticed that checkpatch.pl chokes on the following file (also attached):
> > > 
> > > ==================================
> > > $ cat test-checkpatch.txt
> > > diff --git a/mm/kmsan/kmsan_test.c b/mm/kmsan/kmsan_test.c
> > > @@ -504,6 +504,25 @@ static void
> > > test_memcpy_aligned_to_unaligned2(struct kunit *test)
> > > + EXPECTATION_NO_REPORT(expect);                              \
> > > + volatile uint##size##_t uninit;                             \
> > 
> > checkpatch isn't a syntax complete c parser.  Don't expect to be.
> 
> That's understandable, and I sure don't. But as a user I expect it to
> not loop infinitely, and I think that's also reasonable.
> The example I gave is not a randomly generated code snippet, but an
> excerpt from a valid patch that I sent earlier today:
> https://lore.kernel.org/lkml/20230303141433.3422671-4-glider@google.com/,
> which checkpatch cannot process.

I think this may be appropriate instead.  Andy W?
---
 scripts/checkpatch.pl | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index bd44d12965c98..3328fb9f6d048 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -999,7 +999,9 @@ if (defined($typedefsfile)) {
 }
 
 sub build_types {
-	my $mods = "(?x:  \n" . join("|\n  ", (@modifierList, @modifierListFile)) . "\n)";
+	my $mods = "(?x:  \n" . join("|\n  ", @modifierList);
+	$mods .= "|(?^:  \n" . join("|\n  ", @modifierListFile) . "\n)" if ($#modifierListFile >= 0);
+	$mods .= ')';
 	my $all = "(?x:  \n" . join("|\n  ", (@typeList, @typeListFile)) . "\n)";
 	my $Misordered = "(?x:  \n" . join("|\n  ", @typeListMisordered) . "\n)";
 	my $allWithAttr = "(?x:  \n" . join("|\n  ", @typeListWithAttr) . "\n)";

      reply	other threads:[~2023-03-06  0:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-03 14:28 Alexander Potapenko
2023-03-03 16:52 ` Joe Perches
2023-03-03 20:53   ` Alexander Potapenko
2023-03-06  0:05     ` Joe Perches [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3e32e97858d5bf9d88cc03136d7abc7af2dd7f30.camel@perches.com \
    --to=joe@perches.com \
    --cc=apw@canonical.com \
    --cc=dwaipayanray1@gmail.com \
    --cc=glider@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lukas.bulwahn@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®