qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2] checkpatch: Don't emit spurious warnings abo


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH v2] checkpatch: Don't emit spurious warnings about block comments
Date: Thu, 24 Jan 2019 14:04:29 +0000

On Fri, 18 Jan 2019 at 17:06, Eric Blake <address@hidden> wrote:
>
> On 1/18/19 10:50 AM, Peter Maydell wrote:
> > 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.
> >
>
> Fixes: 8c06fbdf36bf4d4d486116200248730887a4d7d6
>
> > Reported-by: Thomas Huth <address@hidden>
> > Reported-by: Eric Blake <address@hidden>
> > Signed-off-by: Peter Maydell <address@hidden>
> > ---
>
> >               # Block comments use /* on a line of its own
> >               if ($rawline !~ address@hidden/\*.*\*/[ \t]*$@ &&      
> > #inline /*...*/
> > -                 $rawline =~ address@hidden/\*\*?[ \t]*.+[ \t]*$@) { # /* 
> > or /** non-blank
> > +                 $rawline =~ address@hidden/\*\*?+[ \t]*[^ \t]@) { # /* or 
> > /** non-blank
>
> Reviewed-by: Eric Blake <address@hidden>

Thanks. I'll take this via target-arm.next, just for convenience...

-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]