lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Tue,  9 Sep 2014 15:54:15 +0200
From:	Nitin Kuppelur <nitinkuppelur@...il.com>
To:	akpm@...ux-foundation.org, joe@...ches.com, josh@...htriplett.org,
	robh@...nel.org
Cc:	linux-kernel@...r.kernel.org,
	Nitin Kuppelur <nitinkuppelur@...il.com>
Subject: [PATCH] scripts: checkpatch.pl add warning for dummy label

Added new warning DUMMY_LABEL in checkpatch.pl. This warns
if return statement is encountered just after goto label target
like "out:". In such scenario it is best to call "return;" directly
instead of "goto out;"

Signed-off-by: Nitin Kuppelur <nitinkuppelur@...il.com>
---
 scripts/checkpatch.pl | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index b602ed2..399c2b5 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3798,10 +3798,14 @@ sub process {
 		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" . $hereprev);
+		    $lines[$linenr - 3] =~ /^[ +]/) {
+			if ($lines[$linenr - 3] !~ /^[ +]\s*$Ident\s*:/) {
+				WARN("RETURN_VOID",
+				     "void function return statements are not generally useful\n" . $hereprev);
+			} elsif ($lines[$linenr - 3] =~ /^[ +]\s*$Ident\s*:/) {
+				WARN("DUMMY_LABEL",
+				     "labels doing nothing are not generally useful\n" . $hereprev);
+			}
                }
 
 # if statements using unnecessary parentheses - ie: if ((foo == bar))
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ