Skip to content

Commit 9819cf2

Browse files
JoePerchestorvalds
authored andcommitted
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>
1 parent afc819a commit 9819cf2

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎scripts/checkpatch.pl‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3470,6 +3470,13 @@ sub process {
34703470
}
34713471
}
34723472

3473+
# unnecessary return in a void function? (a single leading tab, then return;)
3474+
if ($sline =~ /^\+\treturn\s*;\s*$/ &&
3475+
$prevline =~ /^\+/) {
3476+
WARN("RETURN_VOID",
3477+
"void function return statements are not generally useful\n" . $herecurr);
3478+
}
3479+
34733480
# if statements using unnecessary parentheses - ie: if ((foo == bar))
34743481
if ($^V && $^V ge 5.10.0 &&
34753482
$line =~ /\bif\s*((?:\(\s*){2,})/) {

0 commit comments

Comments
 (0)