From: Joe Perches <joe@perches.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Whitcroft <apw@shadowen.org>,
Andi Kleen <andi@firstfloor.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH] checkpatch: Add a test for const with __read_mostly uses
Date: Wed, 08 Apr 2015 17:14:49 -0700 [thread overview]
Message-ID: <1428538489.22406.65.camel@perches.com> (raw)
In-Reply-To: <20150408235239.GU2366@two.firstfloor.org>
const objects shouldn't be __read_mostly. They are read-only.
Marking these objects as __read_mostly causes section conflicts
with LTO linking.
So add a test to try to avoid this issue.
Signed-off-by: Joe Perches <joe@perches.com>
---
scripts/checkpatch.pl | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 9a8b2bd..199d81b 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4777,6 +4777,16 @@ sub process {
}
}
+# check for __read_mostly with const non-pointer (should just be const)
+ if ($line =~ /\b__read_mostly\b/ &&
+ $line =~ /($Type)\s*$Ident/ && $1 !~ /\*\s*$/ && $1 =~ /\bconst\b/) {
+ if (ERROR("CONST_READ_MOSTLY",
+ "Invalid use of __read_mostly with const type\n" . $herecurr) &&
+ $fix) {
+ $fixed[$fixlinenr] =~ s/\s+__read_mostly\b//;
+ }
+ }
+
# don't use __constant_<foo> functions outside of include/uapi/
if ($realfile !~ m@^include/uapi/@ &&
$line =~ /(__constant_(?:htons|ntohs|[bl]e(?:16|32|64)_to_cpu|cpu_to_[bl]e(?:16|32|64)))\s*\(/) {
next prev parent reply other threads:[~2015-04-09 0:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-08 13:06 [PATCH 1/2] Don't let LATENCYTOP and LOCKDEP select KALLSYMS_ALL Andi Kleen
2015-04-08 13:06 ` [PATCH 2/2] test-hexdump.c: Fix initconst confusion Andi Kleen
2015-04-08 22:35 ` Andrew Morton
2015-04-08 23:52 ` Andi Kleen
2015-04-09 0:14 ` Joe Perches [this message]
2015-04-09 0:28 ` [PATCH] checkpatch: Add a test for const with __read_mostly uses Andi Kleen
2015-04-09 0:33 ` Joe Perches
2015-04-16 19:33 ` [PATCH 2/2] test-hexdump.c: Fix initconst confusion Geert Uytterhoeven
2015-04-16 21:21 ` Andi Kleen
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=1428538489.22406.65.camel@perches.com \
--to=joe@perches.com \
--cc=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=apw@shadowen.org \
--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