Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9819cf25 authored by Joe Perches's avatar Joe Perches Committed by Linus Torvalds
Browse files

checkpatch: warn on unnecessary void function return statements



void function lines that use a single tab then "return;" are generally
unnecessary.

Signed-off-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent afc819ab
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -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,})/) {