Skip to contentSkip to conversation

checkpatch.pl: Allow '+' in compatible strings

PATCH In review Thierry Reding 3 participants 7 messages Jul 14, 2020 – Jul 15, 2020 Checkpatch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 checkpatch.pl: Allow '+' in compatible strings

From: Thierry Reding <[email protected]>

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.

---
 scripts/checkpatch.pl | 1 +
 1 file changed, 1 insertion(+)
scripts/checkpatch.pl +1 -0
index 4c820607540b..8104d0736e7f 100755
@@ -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;
Signature · 1 line
2.27.0
maintainer
#1 lore raw
Quoted 7 lines · Thierry Reding

From: Thierry Reding <[email protected]>

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.

Thanks

scripts/checkpatch.pl sub process { · line 3148

Quoted 13 lines
---
 scripts/checkpatch.pl | 1 +
 1 file changed, 1 insertion(+)
scripts/checkpatch.pl +1 -0
index 4c820607540b..8104d0736e7f 100755
@@ -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

Quoted 3 lines
scripts/checkpatch.pl +0 -0
 				my $compat2 = $compat;
 				$compat2 =~ s/\,[a-zA-Z0-9]*\-/\,<\.\*>\-/;
 				my $compat3 = $compat;
#2 lore raw
Quoted 22 lines · Joe Perches
Quoted 7 lines · Thierry Reding

From: Thierry Reding <[email protected]>

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.

Thanks

Quoted 11 lines
---
 scripts/checkpatch.pl | 1 +
 1 file changed, 1 insertion(+)
scripts/checkpatch.pl +0 -0
index 4c820607540b..8104d0736e7f 100755
@@ -3145,6 +3145,7 @@ sub process {
 			my $vp_file = $dt_path . "vendor-prefixes.yaml";
 
Quoted 4 lines

scripts/checkpatch.pl sub process { · line 3148

Quoted 2 lines
scripts/checkpatch.pl +1 -0
 			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

#3 lore raw
In reply to Thierry Reding
Quoted 6 lines · Thierry Reding

From: Thierry Reding <[email protected]>

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

maintainer
#4 lore raw
Quoted 9 lines · Rob Herring
Quoted 5 lines · Thierry Reding

From: Thierry Reding <[email protected]>

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

?

#5 lore raw
Quoted 24 lines · Joe Perches
Quoted 9 lines · Rob Herring
Quoted 5 lines · Thierry Reding

From: Thierry Reding <[email protected]>

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

Quoted 8 lines

So it looks like

        "("
        ")"

need to be added and escaped too

?

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

Rob

#6 lore raw
Quoted 30 lines · Rob Herring
Quoted 29 lines · Joe Perches
Quoted 9 lines · Rob Herring
Quoted 5 lines · Thierry Reding

From: Thierry Reding <[email protected]>

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

        "("
        ")"
Quoted 6 lines
Quoted 3 lines

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