History

checkpatch: warn on unnecessary void function return statements

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

Joe Perches committed 12 years ago

Commit 9819cf21 parent afc819a1 file · +7 −0Browse files

Showing the changes to scripts/checkpatch.pl (1 of 1 file). Show all

Unified · Split

scripts/checkpatch.pl+7−0
@@ -3470,6 +3470,13 @@ sub process { · 3469 unmodified lines
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,})/) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t