From: Joe Perches Date: Wed, 4 Jun 2014 23:12:09 +0000 (-0700) Subject: checkpatch: warn on unnecessary void function return statements X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=9819cf252a0fad1bf46aac8a051cf30426e073ee;p=openwrt%2Fstaging%2Fblogic.git checkpatch: warn on unnecessary void function return statements void function lines that use a single tab then "return;" are generally unnecessary. Signed-off-by: Joe Perches Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 862cc7a740e2..f354ae619da0 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -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,})/) {