提交 fb2d2c1b 编写于 作者: A Andy Whitcroft 提交者: Linus Torvalds

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: NHitoshi Mitake <mitake@dcl.info.waseda.ac.jp>
Signed-off-by: NAndy Whitcroft <apw@canonical.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 d2c0a235
......@@ -2183,15 +2183,16 @@ sub process {
my $value = $2;
# Flatten any parentheses
$value =~ s/\)\(/\) \(/g;
$value =~ s/\(/ \(/g;
$value =~ s/\)/\) /g;
while ($value =~ s/\[[^\{\}]*\]/1/ ||
$value !~ /(?:$Ident|-?$Constant)\s*
$Compare\s*
(?:$Ident|-?$Constant)/x &&
$value =~ s/\([^\(\)]*\)/1/) {
}
if ($value =~ /^(?:$Ident|-?$Constant)$/) {
#print "value<$value>\n";
if ($value =~ /^\s*(?:$Ident|-?$Constant)\s*$/) {
ERROR("return is not a function, parentheses are not required\n" . $herecurr);
} elsif ($spacing !~ /\s+/) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册