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

checkpatch: warn on unnecessary void function return statements

void function lines that use a single tab then "return;" are generally
unnecessary.
Signed-off-by: NJoe Perches <joe@perches.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 afc819ab
......@@ -3470,6 +3470,13 @@ sub process {
}
}
# unnecessary return in a void function? (a single leading tab, then return;)
if ($sline =~ /^\+\treturn\s*;\s*$/ &&
$prevline =~ /^\+/) {
WARN("RETURN_VOID",
"void function return statements are not generally useful\n" . $herecurr);
}
# if statements using unnecessary parentheses - ie: if ((foo == bar))
if ($^V && $^V ge 5.10.0 &&
$line =~ /\bif\s*((?:\(\s*){2,})/) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册