public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] checkpatch.pl: Allow '+' in compatible strings
@ 2020-07-14  9:41 Thierry Reding
  2020-07-14 11:14 ` Joe Perches
  2020-07-14 16:21 ` Rob Herring
  0 siblings, 2 replies; 7+ messages in thread
From: Thierry Reding @ 2020-07-14  9:41 UTC (permalink / raw)
  To: Andy Whitcroft, Joe Perches; +Cc: Rob Herring, linux-kernel

From: Thierry Reding <treding@nvidia.com>

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@nvidia.com>
---
 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/\+/\\+/;
 				my $compat2 = $compat;
 				$compat2 =~ s/\,[a-zA-Z0-9]*\-/\,<\.\*>\-/;
 				my $compat3 = $compat;
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] checkpatch.pl: Allow '+' in compatible strings
  2020-07-14  9:41 [PATCH] checkpatch.pl: Allow '+' in compatible strings Thierry Reding
@ 2020-07-14 11:14 ` Joe Perches
  2020-07-14 13:12   ` Thierry Reding
  2020-07-14 16:21 ` Rob Herring
  1 sibling, 1 reply; 7+ messages in thread
From: Joe Perches @ 2020-07-14 11:14 UTC (permalink / raw)
  To: Thierry Reding, Andy Whitcroft, Andrew Morton; +Cc: Rob Herring, linux-kernel

On Tue, 2020-07-14 at 11:41 +0200, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> 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@nvidia.com>

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
>  				my $compat2 = $compat;
>  				$compat2 =~ s/\,[a-zA-Z0-9]*\-/\,<\.\*>\-/;
>  				my $compat3 = $compat;


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] checkpatch.pl: Allow '+' in compatible strings
  2020-07-14 11:14 ` Joe Perches
@ 2020-07-14 13:12   ` Thierry Reding
  0 siblings, 0 replies; 7+ messages in thread
From: Thierry Reding @ 2020-07-14 13:12 UTC (permalink / raw)
  To: Joe Perches; +Cc: Andy Whitcroft, Andrew Morton, Rob Herring, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1411 bytes --]

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@nvidia.com>
> > 
> > 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@nvidia.com>
> 
> 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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] checkpatch.pl: Allow '+' in compatible strings
  2020-07-14  9:41 [PATCH] checkpatch.pl: Allow '+' in compatible strings Thierry Reding
  2020-07-14 11:14 ` Joe Perches
@ 2020-07-14 16:21 ` Rob Herring
  2020-07-14 17:12   ` Joe Perches
  1 sibling, 1 reply; 7+ messages in thread
From: Rob Herring @ 2020-07-14 16:21 UTC (permalink / raw)
  To: Thierry Reding; +Cc: Andy Whitcroft, Joe Perches, linux-kernel@vger.kernel.org

On Tue, Jul 14, 2020 at 3:41 AM Thierry Reding <thierry.reding@gmail.com> wrote:
>
> From: Thierry Reding <treding@nvidia.com>
>
> 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.

Ugg, looks like c6x really liked using '+'. Might need to be added in
schema checks, too. Not sure offhand.

Rob

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] checkpatch.pl: Allow '+' in compatible strings
  2020-07-14 16:21 ` Rob Herring
@ 2020-07-14 17:12   ` Joe Perches
  2020-07-14 17:42     ` Rob Herring
  0 siblings, 1 reply; 7+ messages in thread
From: Joe Perches @ 2020-07-14 17:12 UTC (permalink / raw)
  To: Rob Herring, Thierry Reding; +Cc: Andy Whitcroft, linux-kernel@vger.kernel.org

On Tue, 2020-07-14 at 10:21 -0600, Rob Herring wrote:
> On Tue, Jul 14, 2020 at 3:41 AM Thierry Reding <thierry.reding@gmail.com> wrote:
> > From: Thierry Reding <treding@nvidia.com>
> > 
> > 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.
> 
> Ugg, looks like c6x really liked using '+'. Might need to be added in
> schema checks, too. Not sure offhand.

These are the non alphanumeric characters used in .dts and .dtsi files
with 'compatible=' strings

- 44115
, 32035
. 1131
_ 259
+ 46
/ 18
) 5
( 5

So it looks like

	"("
	")"

need to be added and escaped too

?



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] checkpatch.pl: Allow '+' in compatible strings
  2020-07-14 17:12   ` Joe Perches
@ 2020-07-14 17:42     ` Rob Herring
  2020-07-15  7:22       ` Thierry Reding
  0 siblings, 1 reply; 7+ messages in thread
From: Rob Herring @ 2020-07-14 17:42 UTC (permalink / raw)
  To: Joe Perches; +Cc: Thierry Reding, Andy Whitcroft, linux-kernel@vger.kernel.org

On Tue, Jul 14, 2020 at 11:12 AM Joe Perches <joe@perches.com> wrote:
>
> On Tue, 2020-07-14 at 10:21 -0600, Rob Herring wrote:
> > On Tue, Jul 14, 2020 at 3:41 AM Thierry Reding <thierry.reding@gmail.com> wrote:
> > > From: Thierry Reding <treding@nvidia.com>
> > >
> > > 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.
> >
> > Ugg, looks like c6x really liked using '+'. Might need to be added in
> > schema checks, too. Not sure offhand.
>
> These are the non alphanumeric characters used in .dts and .dtsi files
> with 'compatible=' strings
>
> - 44115
> , 32035
> . 1131
> _ 259
> + 46
> / 18
> ) 5
> ( 5
>
> So it looks like
>
>         "("
>         ")"
>
> need to be added and escaped too
>
> ?

No, those are 'regulator-compatible' AFAICT which is something else
and deprecated.

Rob

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] checkpatch.pl: Allow '+' in compatible strings
  2020-07-14 17:42     ` Rob Herring
@ 2020-07-15  7:22       ` Thierry Reding
  0 siblings, 0 replies; 7+ messages in thread
From: Thierry Reding @ 2020-07-15  7:22 UTC (permalink / raw)
  To: Rob Herring; +Cc: Joe Perches, Andy Whitcroft, linux-kernel@vger.kernel.org

[-- Attachment #1: Type: text/plain, Size: 1298 bytes --]

On Tue, Jul 14, 2020 at 11:42:15AM -0600, Rob Herring wrote:
> On Tue, Jul 14, 2020 at 11:12 AM Joe Perches <joe@perches.com> wrote:
> >
> > On Tue, 2020-07-14 at 10:21 -0600, Rob Herring wrote:
> > > On Tue, Jul 14, 2020 at 3:41 AM Thierry Reding <thierry.reding@gmail.com> wrote:
> > > > From: Thierry Reding <treding@nvidia.com>
> > > >
> > > > 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.
> > >
> > > Ugg, looks like c6x really liked using '+'. Might need to be added in
> > > schema checks, too. Not sure offhand.
> >
> > These are the non alphanumeric characters used in .dts and .dtsi files
> > with 'compatible=' strings
> >
> > - 44115
> > , 32035
> > . 1131
> > _ 259
> > + 46
> > / 18
> > ) 5
> > ( 5
> >
> > So it looks like
> >
> >         "("
> >         ")"
> >
> > need to be added and escaped too
> >
> > ?
> 
> No, those are 'regulator-compatible' AFAICT which is something else
> and deprecated.

Looks like we do need to escape the '.' character as well, although it
should be mostly harmless if we don't since '.' in the regex would also
match a literal '.' in the compatible string.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-07-15  7:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-14  9:41 [PATCH] checkpatch.pl: Allow '+' in compatible strings Thierry Reding
2020-07-14 11:14 ` Joe Perches
2020-07-14 13:12   ` Thierry Reding
2020-07-14 16:21 ` Rob Herring
2020-07-14 17:12   ` Joe Perches
2020-07-14 17:42     ` Rob Herring
2020-07-15  7:22       ` Thierry Reding

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox