checkpatch.pl: Allow '+' in compatible strings
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
@@ -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
Joe Perches
maintainerQuoted 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.
Signed-off-by Thierry Reding <[email protected]>
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@@ -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
-0my $compat2 = $compat; $compat2 =~ s/\,[a-zA-Z0-9]*\-/\,<\.\*>\-/; my $compat3 = $compat;
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.
Signed-off-by Thierry Reding <[email protected]>Thanks
Quoted 11 lines
--- scripts/checkpatch.pl | 1 + 1 file changed, 1 insertion(+)scripts/checkpatch.pl +0
-0@@ -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
-0foreach 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
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
Joe Perches
maintainerQuoted 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
?
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
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
( 5So 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