Skip to content

Commit bfcb2cc

Browse files
Andy Whitcrofttorvalds
authored andcommitted
checkpatch: catch all occurences of type and cast spacing errors per line
Fix up type and cast spacing checks such that all occurences on a line are examined and reported. For example the line below has a valid cast and a bad type, but currently we check the cast first which is good and stop: u16* bar = (u16 *)baz; We will also only report one of the errors in this example: u16* bar = (u16*)bad; Move to iterating across all casts and all types, reporting any failure. [akpm@linux-foundation.org: coding-style fixes] Signed-off-by: Andy Whitcroft <apw@canonical.com> Cc: Joe Perches <joe@perches.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 6b48db2 commit bfcb2cc

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

scripts/checkpatch.pl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2209,8 +2209,9 @@ sub process {
22092209

22102210
# * goes on variable not on type
22112211
# (char*[ const])
2212-
if ($line =~ m{\($NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)\)}) {
2213-
my ($from, $to) = ($1, $1);
2212+
while ($line =~ m{(\($NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)\))}g) {
2213+
#print "AA<$1>\n";
2214+
my ($from, $to) = ($2, $2);
22142215

22152216
# Should start with a space.
22162217
$to =~ s/^(\S)/ $1/;
@@ -2225,8 +2226,10 @@ sub process {
22252226
ERROR("POINTER_LOCATION",
22262227
"\"(foo$from)\" should be \"(foo$to)\"\n" . $herecurr);
22272228
}
2228-
} elsif ($line =~ m{\b$NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)($Ident)}) {
2229-
my ($from, $to, $ident) = ($1, $1, $2);
2229+
}
2230+
while ($line =~ m{(\b$NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)($Ident))}g) {
2231+
#print "BB<$1>\n";
2232+
my ($from, $to, $ident) = ($2, $2, $3);
22302233

22312234
# Should start with a space.
22322235
$to =~ s/^(\S)/ $1/;

0 commit comments

Comments
 (0)