From: Joe Perches <joe@perches.com>
To: Borislav Petkov <bp@suse.de>, Andrew Morton <akpm@linux-foundation.org>
Cc: Andres Freund <andres@anarazel.de>,
x86@kernel.org, linux-kernel@vger.kernel.org,
"H. Peter Anvin" <hpa@linux.intel.com>,
Ingo Molnar <mingo@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
Andy Whitcroft <apw@canonical.com>
Subject: [PATCH] checkpatch: Warn on #defines ending in semicolon
Date: Fri, 09 May 2014 14:31:46 -0700 [thread overview]
Message-ID: <1399671106.2912.21.camel@joe-AO725> (raw)
In-Reply-To: <20140509103303.GC16058@pd.tnic>
Using a #define ending in a semicolon is poor style
and can lead to unexpected code paths being executed.
Warn on uses of these #define types:
#define foo[(...)] bar;
#define foo[(...)] \
bar;
Original-patch-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Joe Perches <joe@perches.com>
---
scripts/checkpatch.pl | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 34eb216..3b5651a 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3782,6 +3782,17 @@ sub process {
WARN("DO_WHILE_MACRO_WITH_TRAILING_SEMICOLON",
"do {} while (0) macros should not be semicolon terminated\n" . "$herectx");
}
+ } elsif ($dstat =~ /^\+\s*#\s*define\s+$Ident.*;\s*$/) {
+ $ctx =~ s/\n*$//;
+ my $cnt = statement_rawlines($ctx);
+ my $herectx = $here . "\n";
+
+ for (my $n = 0; $n < $cnt; $n++) {
+ $herectx .= raw_line($linenr, $n) . "\n";
+ }
+
+ WARN("TRAILING_SEMICOLON",
+ "macros should not use a trailing semicolon\n" . "$herectx");
}
}
next prev parent reply other threads:[~2014-05-09 21:31 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-09 1:29 Andres Freund
2014-05-09 1:29 ` [PATCH 1/2] x86: Fix typo preventing msr_set/clear_bit from having an effect Andres Freund
2014-05-09 7:54 ` Borislav Petkov
2014-05-09 10:39 ` Andres Freund
2014-05-09 10:46 ` Borislav Petkov
2014-05-09 16:31 ` [tip:x86/urgent] x86: Fix typo preventing msr_set/ clear_bit " tip-bot for Andres Freund
2014-05-09 1:29 ` [PATCH 2/2] x86: Fix typo in MSR_IA32_MISC_ENABLE_LIMIT_CPUID macro Andres Freund
2014-05-09 7:57 ` Borislav Petkov
2014-05-09 10:33 ` Borislav Petkov
2014-05-09 17:02 ` Joe Perches
2014-05-09 21:31 ` Joe Perches [this message]
2014-05-09 21:47 ` [PATCH] checkpatch: Warn on #defines ending in semicolon Thomas Gleixner
2014-05-09 21:59 ` Joe Perches
2014-05-09 16:31 ` [tip:x86/urgent] x86: Fix typo in MSR_IA32_MISC_ENABLE_LIMIT_CPUID macro tip-bot for Andres Freund
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=1399671106.2912.21.camel@joe-AO725 \
--to=joe@perches.com \
--cc=akpm@linux-foundation.org \
--cc=andres@anarazel.de \
--cc=apw@canonical.com \
--cc=bp@suse.de \
--cc=hpa@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@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®