Commit 8e761b04a34288a3b0b29c0f49cdf157d7db8863
Committed by
Linus Torvalds
1 parent
5fe3af119b
Exists in
master
and in
4 other branches
checkpatch: detect multiple bitfield declarations
Detect the colons (:) which make up secondary bitfield declarations and apply binary colon checks. For example the following is common idiom: int foo:1, bar:1; Signed-off-by: Andy Whitcroft <apw@shadowen.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 9 additions and 5 deletions Side-by-side Diff
scripts/checkpatch.pl
... | ... | @@ -844,11 +844,11 @@ |
844 | 844 | $type = 'V'; |
845 | 845 | $av_pending = 'V'; |
846 | 846 | |
847 | - } elsif ($cur =~ /^($Ident\s*):/) { | |
848 | - if ($type eq 'E') { | |
849 | - $av_pend_colon = 'L'; | |
850 | - } elsif ($type eq 'T') { | |
847 | + } elsif ($cur =~ /^($Ident\s*):(?:\s*\d+\s*(,|=|;))?/) { | |
848 | + if (defined $2 && $type eq 'C' || $type eq 'T') { | |
851 | 849 | $av_pend_colon = 'B'; |
850 | + } elsif ($type eq 'E') { | |
851 | + $av_pend_colon = 'L'; | |
852 | 852 | } |
853 | 853 | print "IDENT_COLON($1,$type>$av_pend_colon)\n" if ($dbg_values > 1); |
854 | 854 | $type = 'V'; |
... | ... | @@ -866,6 +866,10 @@ |
866 | 866 | $type = 'E'; |
867 | 867 | $av_pend_colon = 'O'; |
868 | 868 | |
869 | + } elsif ($cur =~/^(,)/) { | |
870 | + print "COMMA($1)\n" if ($dbg_values > 1); | |
871 | + $type = 'C'; | |
872 | + | |
869 | 873 | } elsif ($cur =~ /^(\?)/o) { |
870 | 874 | print "QUESTION($1)\n" if ($dbg_values > 1); |
871 | 875 | $type = 'N'; |
... | ... | @@ -881,7 +885,7 @@ |
881 | 885 | } |
882 | 886 | $av_pend_colon = 'O'; |
883 | 887 | |
884 | - } elsif ($cur =~ /^(;|\[)/o) { | |
888 | + } elsif ($cur =~ /^(\[)/o) { | |
885 | 889 | print "CLOSE($1)\n" if ($dbg_values > 1); |
886 | 890 | $type = 'N'; |
887 | 891 |