checkpatch: improve "no space after cast" test
Some false positives exist on this test. For instance: *va_arg(args, signed char *) = val.s; or memset(foo, 0, sizeof(struct bar *) * baz)); Ignore lines that have an arithmetic operator or assignment after what appears to be a cast to a pointer "(foo *)". Add $Arithmetic convenience variable. Signed-off-by: Joe Perches <joe@perches.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
179f8f40fc
commit
23f780c904
1 changed files with 3 additions and 2 deletions
|
@ -241,10 +241,11 @@ our $Float = qr{$Float_hex|$Float_dec|$Float_int};
|
||||||
our $Constant = qr{$Float|$Binary|$Hex|$Int};
|
our $Constant = qr{$Float|$Binary|$Hex|$Int};
|
||||||
our $Assignment = qr{\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=};
|
our $Assignment = qr{\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=};
|
||||||
our $Compare = qr{<=|>=|==|!=|<|>};
|
our $Compare = qr{<=|>=|==|!=|<|>};
|
||||||
|
our $Arithmetic = qr{\+|-|\*|\/|%};
|
||||||
our $Operators = qr{
|
our $Operators = qr{
|
||||||
<=|>=|==|!=|
|
<=|>=|==|!=|
|
||||||
=>|->|<<|>>|<|>|!|~|
|
=>|->|<<|>>|<|>|!|~|
|
||||||
&&|\|\||,|\^|\+\+|--|&|\||\+|-|\*|\/|%
|
&&|\|\||,|\^|\+\+|--|&|\||$Arithmetic
|
||||||
}x;
|
}x;
|
||||||
|
|
||||||
our $NonptrType;
|
our $NonptrType;
|
||||||
|
@ -1885,7 +1886,7 @@ sub process {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($line =~ /^\+.*\*[ \t]*\)[ \t]+/) {
|
if ($line =~ /^\+.*\*[ \t]*\)[ \t]+(?!$Assignment|$Arithmetic)/) {
|
||||||
CHK("SPACING",
|
CHK("SPACING",
|
||||||
"No space is necessary after a cast\n" . $hereprev);
|
"No space is necessary after a cast\n" . $hereprev);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue