summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2015-04-16 12:44:42 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2015-04-17 09:03:58 -0400
commitc17893c7407fbe988f5901596c3e5e75c0dc0f67 (patch)
treef3e590db15b6f5fac82efbc8b5353d9c382b715d /scripts
parentd7fe8065ad891a2ad38b73ff10b97d08f0fb3b0b (diff)
downloadlinux-c17893c7407fbe988f5901596c3e5e75c0dc0f67.tar.gz
linux-c17893c7407fbe988f5901596c3e5e75c0dc0f67.tar.bz2
linux-c17893c7407fbe988f5901596c3e5e75c0dc0f67.zip
checkpatch: add a test for const with __read_mostly uses
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> Cc: Andy Whitcroft <apw@shadowen.org> Cc: Andi Kleen <andi@firstfloor.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/checkpatch.pl10
1 files changed, 10 insertions, 0 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 78a951f80706..28516587baba 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4791,6 +4791,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*\(/) {