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

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

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
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -3476,11 +3476,16 @@ sub process {
			}
		}

# unnecessary return in a void function? (a single leading tab, then return;)
		if ($sline =~ /^\+\treturn\s*;\s*$/ &&
		    $prevline =~ /^\+/) {
# unnecessary return in a void function
# at end-of-function, with the previous line a single leading tab, then return;
# 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",
			     "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))