checkpatch: handle casts better fixing false categorisation of : as binary
authorAndy Whitcroft <[email protected]>
Tue, 26 Oct 2010 21:23:13 +0000 (14:23 -0700)
committerLinus Torvalds <[email protected]>
Tue, 26 Oct 2010 23:52:20 +0000 (16:52 -0700)
The following incantation is triggering categorisation of its colon (:) as
a binary form, which it is not:

return foo ? (s8)bar : baz;

Handle casts differently from types in the categoriser, allowing us to
better track (s8)bar as a value and not a declaration.

Reported-by: Jean Delvare <[email protected]>
Signed-off-by: Andy Whitcroft <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
scripts/checkpatch.pl

index 8d010ac0efe151b5bc1cd23237c935cb80b2724b..3cec2990d51ef05842bf1f1fa93cc9ba78572d2e 100755 (executable)
@@ -845,6 +845,11 @@ sub annotate_values {
                                $av_preprocessor = 0;
                        }
 
+               } elsif ($cur =~ /^(\(\s*$Type\s*)\)/) {
+                       print "CAST($1)\n" if ($dbg_values > 1);
+                       push(@av_paren_type, $type);
+                       $type = 'C';
+
                } elsif ($cur =~ /^($Type)\s*(?:$Ident|,|\)|\(|\s*$)/) {
                        print "DECLARE($1)\n" if ($dbg_values > 1);
                        $type = 'T';