Skip to contentSkip to conversation

checkpatch: Improve "no space after cast" test

PATCH New Joe Perches 1 participant 1 message Jul 1, 2014 Checkpatch

lore
Share & tools
lore

Joe Perches

author maintainer
#0 lore raw

PATCH 1/1 checkpatch: Improve "no space after cast" test

This --strict test previously worked only for what appeared to be cast to pointer types.

Make it work for all casts.

Also, there's no reason to show the previous line for this type of message, so don't.

---
 scripts/checkpatch.pl | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
scripts/checkpatch.pl +3 -3
index 182be0f..0a3c759 100755
@@ -2256,12 +2256,12 @@ sub process {
 			}
 		}
 
-		if ($line =~ /^\+.*\*[ \t]*\)[ \t]+(?!$Assignment|$Arithmetic)/) {
+		if ($line =~ /^\+.*\(\s*$Type\s*\)[ \t]+(?!$Assignment|$Arithmetic)/) {
 			if (CHK("SPACING",
-				"No space is necessary after a cast\n" . $hereprev) &&
+				"No space is necessary after a cast\n" . $herecurr) &&
 			    $fix) {
 				$fixed[$linenr - 1] =~
-				    s/^(\+.*\*[ \t]*\))[ \t]+/$1/;
+				    s/(\(\s*$Type\s*\))[ \t]+/$1/;
 			}
 		}