aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorAndy Whitcroft <apw@canonical.com>2009-10-26 19:50:12 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-10-29 10:39:31 -0400
commit9a974fdbe3fbb4b0f6d552579dc79ac237412c61 (patch)
treebf865361b93077ae8464f459280cb86a9f414ad5 /scripts
parent1a83e175dc2c7be931a3ea9c7fb0769e6de55e90 (diff)
checkpatch: possible types -- prevent illegal modifiers being added
Prevent known non types being detected as modifiers. Ensure we do not look at any type which starts with a keyword. 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>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/checkpatch.pl20
1 files changed, 12 insertions, 8 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 87bbb8bce9bf..b43e309c38ff 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -997,23 +997,25 @@ sub annotate_values {
997 997
998sub possible { 998sub possible {
999 my ($possible, $line) = @_; 999 my ($possible, $line) = @_;
1000 1000 my $notPermitted = qr{(?:
1001 print "CHECK<$possible> ($line)\n" if ($dbg_possible > 2);
1002 if ($possible !~ /(?:
1003 ^(?: 1001 ^(?:
1004 $Modifier| 1002 $Modifier|
1005 $Storage| 1003 $Storage|
1006 $Type| 1004 $Type|
1007 DEFINE_\S+| 1005 DEFINE_\S+
1006 )$|
1007 ^(?:
1008 goto| 1008 goto|
1009 return| 1009 return|
1010 case| 1010 case|
1011 else| 1011 else|
1012 asm|__asm__| 1012 asm|__asm__|
1013 do 1013 do
1014 )$| 1014 )(?:\s|$)|
1015 ^(?:typedef|struct|enum)\b 1015 ^(?:typedef|struct|enum)\b
1016 )/x) { 1016 )}x;
1017 warn "CHECK<$possible> ($line)\n" if ($dbg_possible > 2);
1018 if ($possible !~ $notPermitted) {
1017 # Check for modifiers. 1019 # Check for modifiers.
1018 $possible =~ s/\s*$Storage\s*//g; 1020 $possible =~ s/\s*$Storage\s*//g;
1019 $possible =~ s/\s*$Sparse\s*//g; 1021 $possible =~ s/\s*$Sparse\s*//g;
@@ -1022,8 +1024,10 @@ sub possible {
1022 } elsif ($possible =~ /\s/) { 1024 } elsif ($possible =~ /\s/) {
1023 $possible =~ s/\s*$Type\s*//g; 1025 $possible =~ s/\s*$Type\s*//g;
1024 for my $modifier (split(' ', $possible)) { 1026 for my $modifier (split(' ', $possible)) {
1025 warn "MODIFIER: $modifier ($possible) ($line)\n" if ($dbg_possible); 1027 if ($modifier !~ $notPermitted) {
1026 push(@modifierList, $modifier); 1028 warn "MODIFIER: $modifier ($possible) ($line)\n" if ($dbg_possible);
1029 push(@modifierList, $modifier);
1030 }
1027 } 1031 }
1028 1032
1029 } else { 1033 } else {