aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2014-06-23 16:22:07 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-06-23 19:47:44 -0400
commitb43ae21bd1d8199df10548f3fc0d806052027f29 (patch)
tree41100aa4d0e3f03840b999418e075e0792de9228 /scripts
parentf9af420fc8208d3add2fe3198dc5d8215f5a81ba (diff)
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: Joe Perches <joe@perches.com> Tested-by: Anish Bhatt <anish@chelsio.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/checkpatch.pl15
1 files changed, 10 insertions, 5 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 010b18ef4ea0..182be0f12407 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3476,12 +3476,17 @@ sub process {
3476 } 3476 }
3477 } 3477 }
3478 3478
3479# unnecessary return in a void function? (a single leading tab, then return;) 3479# unnecessary return in a void function
3480 if ($sline =~ /^\+\treturn\s*;\s*$/ && 3480# at end-of-function, with the previous line a single leading tab, then return;
3481 $prevline =~ /^\+/) { 3481# and the line before that not a goto label target like "out:"
3482 if ($sline =~ /^[ \+]}\s*$/ &&
3483 $prevline =~ /^\+\treturn\s*;\s*$/ &&
3484 $linenr >= 3 &&
3485 $lines[$linenr - 3] =~ /^[ +]/ &&
3486 $lines[$linenr - 3] !~ /^[ +]\s*$Ident\s*:/) {
3482 WARN("RETURN_VOID", 3487 WARN("RETURN_VOID",
3483 "void function return statements are not generally useful\n" . $herecurr); 3488 "void function return statements are not generally useful\n" . $hereprev);
3484 } 3489 }
3485 3490
3486# if statements using unnecessary parentheses - ie: if ((foo == bar)) 3491# if statements using unnecessary parentheses - ie: if ((foo == bar))
3487 if ($^V && $^V ge 5.10.0 && 3492 if ($^V && $^V ge 5.10.0 &&