aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/checkpatch.pl
diff options
context:
space:
mode:
authorAndy Whitcroft <apw@shadowen.org>2008-07-24 00:28:57 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-24 13:47:25 -0400
commitc8cb2ca37ed51aa1f3b20e3eff1e72df1c400f70 (patch)
tree1855161684a9b0db3254698509b2a0dd33ed8c1c /scripts/checkpatch.pl
parentfee61c47d15270bdea699a8a3dd867f0825c3541 (diff)
checkpatch: types: some types may also be identifiers
Some types such as typedefs may overlap real identifiers. Be more targetted about when a type can really exist. Where it cannot let it be an identifier. This prevents false reporting of the minus '-' in unary context in the following: foo[bar->bool - 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>
Diffstat (limited to 'scripts/checkpatch.pl')
-rwxr-xr-xscripts/checkpatch.pl11
1 files changed, 6 insertions, 5 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 83ae37b38621..5420db6502fc 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -171,6 +171,7 @@ our @modifierList = (
171sub build_types { 171sub build_types {
172 my $mods = "(?: \n" . join("|\n ", @modifierList) . "\n)"; 172 my $mods = "(?: \n" . join("|\n ", @modifierList) . "\n)";
173 my $all = "(?: \n" . join("|\n ", @typeList) . "\n)"; 173 my $all = "(?: \n" . join("|\n ", @typeList) . "\n)";
174 $Modifier = qr{(?:$Attribute|$Sparse|$mods)};
174 $NonptrType = qr{ 175 $NonptrType = qr{
175 (?:const\s+)? 176 (?:const\s+)?
176 (?:$mods\s+)? 177 (?:$mods\s+)?
@@ -178,15 +179,14 @@ sub build_types {
178 (?:typeof|__typeof__)\s*\(\s*\**\s*$Ident\s*\)| 179 (?:typeof|__typeof__)\s*\(\s*\**\s*$Ident\s*\)|
179 (?:${all}\b) 180 (?:${all}\b)
180 ) 181 )
181 (?:\s+$Sparse|\s+const)* 182 (?:\s+$Modifier|\s+const)*
182 }x; 183 }x;
183 $Type = qr{ 184 $Type = qr{
184 $NonptrType 185 $NonptrType
185 (?:\s*\*+\s*const|\s*\*+|(?:\s*\[\s*\])+)? 186 (?:\s*\*+\s*const|\s*\*+|(?:\s*\[\s*\])+)?
186 (?:\s+$Inline|\s+$Sparse|\s+$Attribute|\s+$mods)* 187 (?:\s+$Inline|\s+$Modifier)*
187 }x; 188 }x;
188 $Declare = qr{(?:$Storage\s+)?$Type}; 189 $Declare = qr{(?:$Storage\s+)?$Type};
189 $Modifier = qr{(?:$Attribute|$Sparse|$mods)};
190} 190}
191build_types(); 191build_types();
192 192
@@ -715,7 +715,7 @@ sub annotate_values {
715 $av_preprocessor = 0; 715 $av_preprocessor = 0;
716 } 716 }
717 717
718 } elsif ($cur =~ /^($Type)/) { 718 } elsif ($cur =~ /^($Type)\s*(?:$Ident|,|\))/) {
719 print "DECLARE($1)\n" if ($dbg_values > 1); 719 print "DECLARE($1)\n" if ($dbg_values > 1);
720 $type = 'T'; 720 $type = 'T';
721 721
@@ -800,8 +800,9 @@ sub annotate_values {
800 print "PAREN('$1')\n" if ($dbg_values > 1); 800 print "PAREN('$1')\n" if ($dbg_values > 1);
801 } 801 }
802 802
803 } elsif ($cur =~ /^($Ident)\(/o) { 803 } elsif ($cur =~ /^($Ident)\s*\(/o) {
804 print "FUNC($1)\n" if ($dbg_values > 1); 804 print "FUNC($1)\n" if ($dbg_values > 1);
805 $type = 'V';
805 $av_pending = 'V'; 806 $av_pending = 'V';
806 807
807 } elsif ($cur =~ /^($Ident|$Constant)/o) { 808 } elsif ($cur =~ /^($Ident|$Constant)/o) {