From: Nitin Kuppelur <nitinkuppelur@gmail.com>
To: akpm@linux-foundation.org, joe@perches.com,
josh@joshtriplett.org, robh@kernel.org
Cc: linux-kernel@vger.kernel.org, Nitin Kuppelur <nitinkuppelur@gmail.com>
Subject: [PATCH] scripts: checkpatch.pl add warning for dummy label
Date: Tue, 9 Sep 2014 15:54:15 +0200 [thread overview]
Message-ID: <1410270855-6639-1-git-send-email-nitinkuppelur@gmail.com> (raw)
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@gmail.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
next reply other threads:[~2014-09-09 15:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-09 13:54 Nitin Kuppelur [this message]
2014-09-09 15:43 ` Joe Perches
2014-09-09 15:08 ` Nitin Kuppelur
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1410270855-6639-1-git-send-email-nitinkuppelur@gmail.com \
--to=nitinkuppelur@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=joe@perches.com \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®