checkpatch: handle casts better fixing false categorisation of : as binary
authorAndy Whitcroft <apw@canonical.com>
Tue, 26 Oct 2010 21:23:13 +0000 (14:23 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
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 <khali@linux-fr.org>
Signed-off-by: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
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';