From: "L. Alberto Giménez" <agimenez@sysvalve.es>
To: linux-kernel@vger.kernel.org
Cc: Andy Whitcroft <apw@canonical.com>, Joe Perches <joe@perches.com>
Subject: [PATCH] checkpatch.pl: Add warning for harmful goto labels
Date: Sat, 21 Mar 2015 22:16:14 +0100 [thread overview]
Message-ID: <1426972574-12199-1-git-send-email-agimenez@sysvalve.es> (raw)
Issue a warning for too broad goto labels that may make the code to
follow the wrong exit path, thus causing hard to debug bugs.
Signed-off-by: L. Alberto Giménez <agimenez@sysvalve.es>
---
scripts/checkpatch.pl | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index d124359..e8ce220 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -444,6 +444,11 @@ our $allowed_asm_includes = qr{(?x:
)};
# memory.h: ARM has a custom one
+our @goto_harmful_labels = qw(
+ out
+ fail
+ );
+
# Load common spelling mistakes and build regular expression list.
my $misspellings;
my %spelling_fix;
@@ -2702,6 +2707,14 @@ sub process {
}
}
+ if ($sline =~ /goto (.*);/) {
+ my $label = $1;
+ if (grep { /^$label$/ } @goto_harmful_labels) {
+ WARN("HARMFUL_GOTO_LABEL",
+ "Goto label '$label' is considered harmful\n" . $herecurr);
+ }
+ }
+
# discourage the addition of CONFIG_EXPERIMENTAL in #if(def).
if ($line =~ /^\+\s*\#\s*if.*\bCONFIG_EXPERIMENTAL\b/) {
WARN("CONFIG_EXPERIMENTAL",
--
2.1.4
next reply other threads:[~2015-03-21 21:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-21 21:16 L. Alberto Giménez [this message]
2015-03-21 21:40 ` Richard Weinberger
2015-03-21 22:06 ` L. Alberto Giménez
2015-03-21 22:12 ` Richard Weinberger
2015-03-22 2:56 ` Joe Perches
2015-03-22 12:16 ` L. Alberto Giménez
2015-03-21 21:41 ` Peter Hurley
2015-03-21 22:09 ` L. Alberto Giménez
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=1426972574-12199-1-git-send-email-agimenez@sysvalve.es \
--to=agimenez@sysvalve.es \
--cc=apw@canonical.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.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®