diff options
author | Andy Whitcroft <apw@canonical.com> | 2010-10-26 17:23:12 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-26 19:52:19 -0400 |
commit | fb2d2c1b5825503d30fb6f2dc328dbe4a47d9794 (patch) | |
tree | 6fba2ec80498dcb83615ea27907c89e979902c85 /scripts/checkpatch.pl | |
parent | d2c0a23514d8ac4ed10a8e742467cfb72ca3bed8 (diff) |
checkpatch: ensure we do not collapse bracketed sections into constants
When determining if a return () sequence is a function style bracketing we
simplify the expression one bracket at a time replacing each with a
constant. However this can trigger a false merge with expressions as
below:
return (foo)0;
Prevent this false merging.
Reported-by: Hitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
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/checkpatch.pl')
-rwxr-xr-x | scripts/checkpatch.pl | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 32d6a236570d..8d010ac0efe1 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -2183,15 +2183,16 @@ sub process { | |||
2183 | my $value = $2; | 2183 | my $value = $2; |
2184 | 2184 | ||
2185 | # Flatten any parentheses | 2185 | # Flatten any parentheses |
2186 | $value =~ s/\)\(/\) \(/g; | 2186 | $value =~ s/\(/ \(/g; |
2187 | $value =~ s/\)/\) /g; | ||
2187 | while ($value =~ s/\[[^\{\}]*\]/1/ || | 2188 | while ($value =~ s/\[[^\{\}]*\]/1/ || |
2188 | $value !~ /(?:$Ident|-?$Constant)\s* | 2189 | $value !~ /(?:$Ident|-?$Constant)\s* |
2189 | $Compare\s* | 2190 | $Compare\s* |
2190 | (?:$Ident|-?$Constant)/x && | 2191 | (?:$Ident|-?$Constant)/x && |
2191 | $value =~ s/\([^\(\)]*\)/1/) { | 2192 | $value =~ s/\([^\(\)]*\)/1/) { |
2192 | } | 2193 | } |
2193 | 2194 | #print "value<$value>\n"; | |
2194 | if ($value =~ /^(?:$Ident|-?$Constant)$/) { | 2195 | if ($value =~ /^\s*(?:$Ident|-?$Constant)\s*$/) { |
2195 | ERROR("return is not a function, parentheses are not required\n" . $herecurr); | 2196 | ERROR("return is not a function, parentheses are not required\n" . $herecurr); |
2196 | 2197 | ||
2197 | } elsif ($spacing !~ /\s+/) { | 2198 | } elsif ($spacing !~ /\s+/) { |