lkml.org 
[lkml]   [2014]   [Jun]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH] checkpatch: Warn on unnecessary void function return statements
From
Date
void function lines that use a single tab then "return;"
are generally unnecessary.

Signed-off-by: Joe Perches <joe@perches.com>
---
scripts/checkpatch.pl | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 7774025..f9bb12c 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,})/) {



\
 
 \ /
  Last update: 2014-06-02 19:41    [W:0.107 / U:0.080 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site