Commit b43ae21b authored by Joe Perches's avatar Joe Perches Committed by Linus Torvalds

checkpatch: reduce false positives when checking void function return statements

The previous patch had a few too many false positives on styles that
should be acceptable.
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Tested-by: default avatarAnish Bhatt <anish@chelsio.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent f9af420f
...@@ -3476,12 +3476,17 @@ sub process { ...@@ -3476,12 +3476,17 @@ sub process {
} }
} }
# unnecessary return in a void function? (a single leading tab, then return;) # unnecessary return in a void function
if ($sline =~ /^\+\treturn\s*;\s*$/ && # at end-of-function, with the previous line a single leading tab, then return;
$prevline =~ /^\+/) { # and the line before that not a goto label target like "out:"
if ($sline =~ /^[ \+]}\s*$/ &&
$prevline =~ /^\+\treturn\s*;\s*$/ &&
$linenr >= 3 &&
$lines[$linenr - 3] =~ /^[ +]/ &&
$lines[$linenr - 3] !~ /^[ +]\s*$Ident\s*:/) {
WARN("RETURN_VOID", WARN("RETURN_VOID",
"void function return statements are not generally useful\n" . $herecurr); "void function return statements are not generally useful\n" . $hereprev);
} }
# if statements using unnecessary parentheses - ie: if ((foo == bar)) # if statements using unnecessary parentheses - ie: if ((foo == bar))
if ($^V && $^V ge 5.10.0 && if ($^V && $^V ge 5.10.0 &&
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment