Re: [PATCH] checkpatch.pl: Allow '+' in compatible strings

From: Thierry Reding
Date: Tue Jul 14 2020 - 09:12:46 EST


On Tue, Jul 14, 2020 at 04:14:36AM -0700, Joe Perches wrote:
> On Tue, 2020-07-14 at 11:41 +0200, Thierry Reding wrote:
> > From: Thierry Reding <treding@xxxxxxxxxx>
> >
> > The current checks will interpret a '+' character as special because
> > they use regular expression matching. Escape the '+' character if it
> > appears in a compatible string.
> >
> > Signed-off-by: Thierry Reding <treding@xxxxxxxxxx>
>
> Thanks
>
> > ---
> > scripts/checkpatch.pl | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> > index 4c820607540b..8104d0736e7f 100755
> > --- a/scripts/checkpatch.pl
> > +++ b/scripts/checkpatch.pl
> > @@ -3145,6 +3145,7 @@ sub process {
> > my $vp_file = $dt_path . "vendor-prefixes.yaml";
> >
> > foreach my $compat (@compats) {
> > + $compat =~ s/\+/\\+/;
>
> This changes the @compats array for each line

I'm not overly familiar with the internals of Perl. I was assuming that
$compat would be a copy of each of the strings in @compats. From what
you're saying it sounds like it's more like a pointer to them instead.

Irrespective, does that do any harm, though? I suppose we could add an
extra local variable like we do for compat2 and compat3 and modify that
instead. That way the contents would perhaps remain unmodified.

Is that what you were suggesting?

Thierry

Attachment: signature.asc
Description: PGP signature