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>
This commit is contained in:
parent
1a83e175dc
commit
9a974fdbe3
1 changed files with 12 additions and 8 deletions
|
@ -997,23 +997,25 @@ sub annotate_values {
|
||||||
|
|
||||||
sub possible {
|
sub possible {
|
||||||
my ($possible, $line) = @_;
|
my ($possible, $line) = @_;
|
||||||
|
my $notPermitted = qr{(?:
|
||||||
print "CHECK<$possible> ($line)\n" if ($dbg_possible > 2);
|
|
||||||
if ($possible !~ /(?:
|
|
||||||
^(?:
|
^(?:
|
||||||
$Modifier|
|
$Modifier|
|
||||||
$Storage|
|
$Storage|
|
||||||
$Type|
|
$Type|
|
||||||
DEFINE_\S+|
|
DEFINE_\S+
|
||||||
|
)$|
|
||||||
|
^(?:
|
||||||
goto|
|
goto|
|
||||||
return|
|
return|
|
||||||
case|
|
case|
|
||||||
else|
|
else|
|
||||||
asm|__asm__|
|
asm|__asm__|
|
||||||
do
|
do
|
||||||
)$|
|
)(?:\s|$)|
|
||||||
^(?:typedef|struct|enum)\b
|
^(?:typedef|struct|enum)\b
|
||||||
)/x) {
|
)}x;
|
||||||
|
warn "CHECK<$possible> ($line)\n" if ($dbg_possible > 2);
|
||||||
|
if ($possible !~ $notPermitted) {
|
||||||
# Check for modifiers.
|
# Check for modifiers.
|
||||||
$possible =~ s/\s*$Storage\s*//g;
|
$possible =~ s/\s*$Storage\s*//g;
|
||||||
$possible =~ s/\s*$Sparse\s*//g;
|
$possible =~ s/\s*$Sparse\s*//g;
|
||||||
|
@ -1022,8 +1024,10 @@ sub possible {
|
||||||
} elsif ($possible =~ /\s/) {
|
} elsif ($possible =~ /\s/) {
|
||||||
$possible =~ s/\s*$Type\s*//g;
|
$possible =~ s/\s*$Type\s*//g;
|
||||||
for my $modifier (split(' ', $possible)) {
|
for my $modifier (split(' ', $possible)) {
|
||||||
warn "MODIFIER: $modifier ($possible) ($line)\n" if ($dbg_possible);
|
if ($modifier !~ $notPermitted) {
|
||||||
push(@modifierList, $modifier);
|
warn "MODIFIER: $modifier ($possible) ($line)\n" if ($dbg_possible);
|
||||||
|
push(@modifierList, $modifier);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue