Skip to contentSkip to conversation

checkpatch: Fix unescaped left brace

PATCH Applied Dwaipayan Ray 2 participants 5 messages Nov 15, 2020 – Nov 17, 2020 Checkpatch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 checkpatch: Fix unescaped left brace

There is an unescaped left brace in a regex in OPEN_BRACE check. This throws a runtime error when checkpatch is run with --fix flag and the OPEN_BRACE check is executed.

Fix it by escaping the left brace.

Fixes 8d1824780f2f ("checkpatch: add --fix option for a couple OPEN_BRACE misuses")
---
 scripts/checkpatch.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/checkpatch.pl +1 -1
index 2749f32dffe9..0da6422cd0fd 100755
@@ -4505,7 +4505,7 @@ sub process {
 			    $fix) {
 				fix_delete_line($fixlinenr, $rawline);
 				my $fixed_line = $rawline;
-				$fixed_line =~ /(^..*$Type\s*$Ident\(.*\)\s*){(.*)$/;
+				$fixed_line =~ /(^..*$Type\s*$Ident\(.*\)\s*)\{(.*)$/;
 				my $line1 = $1;
 				my $line2 = $2;
 				fix_insert_line($fixlinenr, ltrim($line1));
Signature · 6 lines
2.27.0

_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Dwaipayan Ray

There is an unescaped left brace in a regex in OPEN_BRACE check. This throws a runtime error when checkpatch is run with --fix flag and the OPEN_BRACE check is executed.

Fix it by escaping the left brace.

Fixes 8d1824780f2f ("checkpatch: add --fix option for a couple OPEN_BRACE misuses")

Thanks Dwaipayan.

Obviously that code path hasn't been tested in awhile.

I think the notice to require an escape for a { was added back in perl 5.16 or so.

Quoted 17 lines

---
 scripts/checkpatch.pl | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/checkpatch.pl +1 -1
index 2749f32dffe9..0da6422cd0fd 100755
@@ -4505,7 +4505,7 @@ sub process {
  			    $fix) {
  				fix_delete_line($fixlinenr, $rawline);
  				my $fixed_line = $rawline;
-				$fixed_line =~ /(^..*$Type\s*$Ident\(.*\)\s*){(.*)$/;
+				$fixed_line =~ /(^..*$Type\s*$Ident\(.*\)\s*)\{(.*)$/;
  				my $line1 = $1;
  				my $line2 = $2;
  				fix_insert_line($fixlinenr, ltrim($line1));
maintainer
#2 lore raw
Quoted 10 lines · Joe Perches
Quoted 8 lines · Dwaipayan Ray

There is an unescaped left brace in a regex in OPEN_BRACE check. This throws a runtime error when checkpatch is run with --fix flag and the OPEN_BRACE check is executed.

Fix it by escaping the left brace.

Fixes 8d1824780f2f ("checkpatch: add --fix option for a couple OPEN_BRACE misuses")
Quoted 6 lines

Thanks Dwaipayan.

Obviously that code path hasn't been tested in awhile.

I think the notice to require an escape for a { was added back in perl 5.16 or so.

Just fyi: it seems the requirement was actually implemented in perl 5.22 and this code predates the release of perl 5.22

https://github.com/Perl/perl5/blob/blead/pod/perl5220delta.pod

_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

#3 lore raw
Quoted 16 lines · Joe Perches
Quoted 14 lines · Joe Perches
Quoted 8 lines · Dwaipayan Ray

There is an unescaped left brace in a regex in OPEN_BRACE check. This throws a runtime error when checkpatch is run with --fix flag and the OPEN_BRACE check is executed.

Fix it by escaping the left brace.

Fixes 8d1824780f2f ("checkpatch: add --fix option for a couple OPEN_BRACE misuses")

Thanks Dwaipayan.

Obviously that code path hasn't been tested in awhile.

Quoted 8 lines
Quoted 2 lines

I think the notice to require an escape for a { was added back in perl 5.16 or so.

Just fyi: it seems the requirement was actually implemented in perl 5.22 and this code predates the release of perl 5.22

https://github.com/Perl/perl5/blob/blead/pod/perl5220delta.pod

That's pretty interesting. Apart from that I have seen that the perl_version_ok check mandates perl 5.10 which was released more than 10 years back.

Do you think that check could be removed completely? Maybe sometime in the future or just have it lay around for backward compatibility?

Thanks,
Dwaipayan.
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

maintainer
#4 lore raw
Quoted 7 lines · Dwaipayan Ray

I have seen that
the perl_version_ok check mandates perl 5.10 which was released more than 10 years back.

Do you think that check could be removed completely? Maybe sometime in the future or just have it lay around for backward compatibility?

I think having the check in the code isn't burdensome.

_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees