Skip to contentSkip to conversation

checkpatch: Fix unescaped left brace

PATCH In review Dwaipayan Ray 2 participants 3 messages Nov 15, 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.

---
 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
#1 lore raw
Quoted 7 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.

Can you find with 'git blame' which commit introduced this issue and add a Fixes: tag?

Other than that, it looks good.

Lukas

Quoted 19 lines
---
 scripts/checkpatch.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/checkpatch.pl +1 -2
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));
--
Quoted 2 lines

2.27.0

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

#2 lore raw
Quoted 7 lines · Lukas Bulwahn
Quoted 5 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.

Quoted 7 lines
Quoted 2 lines

Fix it by escaping the left brace.

Can you find with 'git blame' which commit introduced this issue and add a Fixes: tag?

Other than that, it looks good.

Apparently it was introduced back in 2014 when it was first written by commit 8d1824780f2f. I guess perl depreciated allowing unescaped left braces at some point.

I will add that and send it off.

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