summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2014-06-04 16:12:09 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2014-06-04 16:54:20 -0700
commit9819cf252a0fad1bf46aac8a051cf30426e073ee (patch)
treefa33227f9a4e931a5e3c4e229a850f854f543e04 /scripts
parentafc819ab0293be3bd5c16d9eba26f9d57f61c42a (diff)
downloadlinux-9819cf252a0fad1bf46aac8a051cf30426e073ee.tar.gz
linux-9819cf252a0fad1bf46aac8a051cf30426e073ee.tar.bz2
linux-9819cf252a0fad1bf46aac8a051cf30426e073ee.zip
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 <joe@perches.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/checkpatch.pl7
1 files changed, 7 insertions, 0 deletions
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,})/) {