diff options
author | Joe Perches <joe@perches.com> | 2013-07-03 18:05:31 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-07-03 19:07:45 -0400 |
commit | 23f780c90496eb1cc158e862e7035c8468dfa052 (patch) | |
tree | 568616787bf5f25ad3bc5da9520ed321e5b02383 /scripts/checkpatch.pl | |
parent | 179f8f40fc3ae7cd49e96b3a7d5182166c36bdab (diff) |
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>
Diffstat (limited to 'scripts/checkpatch.pl')
-rwxr-xr-x | scripts/checkpatch.pl | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index c2d223c406e8..ab39ceb38286 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -241,10 +241,11 @@ our $Float = qr{$Float_hex|$Float_dec|$Float_int}; | |||
241 | our $Constant = qr{$Float|$Binary|$Hex|$Int}; | 241 | our $Constant = qr{$Float|$Binary|$Hex|$Int}; |
242 | our $Assignment = qr{\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=}; | 242 | our $Assignment = qr{\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=}; |
243 | our $Compare = qr{<=|>=|==|!=|<|>}; | 243 | our $Compare = qr{<=|>=|==|!=|<|>}; |
244 | our $Arithmetic = qr{\+|-|\*|\/|%}; | ||
244 | our $Operators = qr{ | 245 | our $Operators = qr{ |
245 | <=|>=|==|!=| | 246 | <=|>=|==|!=| |
246 | =>|->|<<|>>|<|>|!|~| | 247 | =>|->|<<|>>|<|>|!|~| |
247 | &&|\|\||,|\^|\+\+|--|&|\||\+|-|\*|\/|% | 248 | &&|\|\||,|\^|\+\+|--|&|\||$Arithmetic |
248 | }x; | 249 | }x; |
249 | 250 | ||
250 | our $NonptrType; | 251 | our $NonptrType; |
@@ -1885,7 +1886,7 @@ sub process { | |||
1885 | } | 1886 | } |
1886 | } | 1887 | } |
1887 | 1888 | ||
1888 | if ($line =~ /^\+.*\*[ \t]*\)[ \t]+/) { | 1889 | if ($line =~ /^\+.*\*[ \t]*\)[ \t]+(?!$Assignment|$Arithmetic)/) { |
1889 | CHK("SPACING", | 1890 | CHK("SPACING", |
1890 | "No space is necessary after a cast\n" . $hereprev); | 1891 | "No space is necessary after a cast\n" . $hereprev); |
1891 | } | 1892 | } |