checkpatch: warn on unnecessary void function return statements
void function lines that use a single tab then "return;" are generally unnecessary. Change-Id: Ib310bf8de9f2a58aefa3e54b8c903723394ac23c 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> Git-commit: 9819cf252a0fad1bf46aac8a051cf30426e073ee Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
This commit is contained in:
parent
5078d74982
commit
0dd150bcc3
|
@ -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,})/) {
|
||||
|
|
Loading…
Reference in New Issue