Skip to content

Commit

Permalink
checkpatch: possible types -- prevent illegal modifiers being added
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Andy Whitcroft authored and Linus Torvalds committed Oct 29, 2009
1 parent 1a83e17 commit 9a974fd
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -997,23 +997,25 @@ sub annotate_values {

sub possible {
my ($possible, $line) = @_;

print "CHECK<$possible> ($line)\n" if ($dbg_possible > 2);
if ($possible !~ /(?:
my $notPermitted = qr{(?:
^(?:
$Modifier|
$Storage|
$Type|
DEFINE_\S+|
DEFINE_\S+
)$|
^(?:
goto|
return|
case|
else|
asm|__asm__|
do
)$|
)(?:\s|$)|
^(?:typedef|struct|enum)\b
)/x) {
)}x;
warn "CHECK<$possible> ($line)\n" if ($dbg_possible > 2);
if ($possible !~ $notPermitted) {
# Check for modifiers.
$possible =~ s/\s*$Storage\s*//g;
$possible =~ s/\s*$Sparse\s*//g;
Expand All @@ -1022,8 +1024,10 @@ sub possible {
} elsif ($possible =~ /\s/) {
$possible =~ s/\s*$Type\s*//g;
for my $modifier (split(' ', $possible)) {
warn "MODIFIER: $modifier ($possible) ($line)\n" if ($dbg_possible);
push(@modifierList, $modifier);
if ($modifier !~ $notPermitted) {
warn "MODIFIER: $modifier ($possible) ($line)\n" if ($dbg_possible);
push(@modifierList, $modifier);
}
}

} else {
Expand Down

0 comments on commit 9a974fd

Please sign in to comment.