提交 b43ae21b 编写于 作者: J Joe Perches 提交者: Linus Torvalds

checkpatch: reduce false positives when checking void function return statements

The previous patch had a few too many false positives on styles that
should be acceptable.
Signed-off-by: NJoe Perches <joe@perches.com>
Tested-by: NAnish Bhatt <anish@chelsio.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 f9af420f
...@@ -3476,12 +3476,17 @@ sub process { ...@@ -3476,12 +3476,17 @@ sub process {
} }
} }
# unnecessary return in a void function? (a single leading tab, then return;) # unnecessary return in a void function
if ($sline =~ /^\+\treturn\s*;\s*$/ && # at end-of-function, with the previous line a single leading tab, then return;
$prevline =~ /^\+/) { # and the line before that not a goto label target like "out:"
if ($sline =~ /^[ \+]}\s*$/ &&
$prevline =~ /^\+\treturn\s*;\s*$/ &&
$linenr >= 3 &&
$lines[$linenr - 3] =~ /^[ +]/ &&
$lines[$linenr - 3] !~ /^[ +]\s*$Ident\s*:/) {
WARN("RETURN_VOID", WARN("RETURN_VOID",
"void function return statements are not generally useful\n" . $herecurr); "void function return statements are not generally useful\n" . $hereprev);
} }
# if statements using unnecessary parentheses - ie: if ((foo == bar)) # if statements using unnecessary parentheses - ie: if ((foo == bar))
if ($^V && $^V ge 5.10.0 && if ($^V && $^V ge 5.10.0 &&
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册