Commit 9446ef569c288e683225fec8337a0b2b81e75cc5

Authored by Andy Whitcroft
Committed by Linus Torvalds
1 parent fb2d2c1b58

checkpatch: handle casts better fixing false categorisation of : as binary

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>

Showing 1 changed file with 5 additions and 0 deletions Side-by-side Diff

scripts/checkpatch.pl
... ... @@ -845,6 +845,11 @@
845 845 $av_preprocessor = 0;
846 846 }
847 847  
  848 + } elsif ($cur =~ /^(\(\s*$Type\s*)\)/) {
  849 + print "CAST($1)\n" if ($dbg_values > 1);
  850 + push(@av_paren_type, $type);
  851 + $type = 'C';
  852 +
848 853 } elsif ($cur =~ /^($Type)\s*(?:$Ident|,|\)|\(|\s*$)/) {
849 854 print "DECLARE($1)\n" if ($dbg_values > 1);
850 855 $type = 'T';