Skip to contentSkip to conversation

checkpatch: add a rule to check devinitconst mistakes

PATCH New Andi Kleen 1 participant 1 message Apr 21, 2013 Checkpatch

lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

PATCH 1/1 checkpatch: add a rule to check devinitconst mistakes

From: Andi Kleen <[email protected]>

Check for const __devinitdata and non const __devinitconst

People get this regularly wrong and it breaks the LTO builds, as it causes a section attribute conflict.

This doesn't catch all mistakes -- spreading over multiple lines, getting const pointers wrong, but hopefully the common ones.

---
 scripts/checkpatch.pl |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
scripts/checkpatch.pl +9 -0
index 4de4bc4..579f92d 100755
@@ -2466,6 +2466,15 @@ sub process {
 			 "missing space after $1 definition\n" . $herecurr);
 		}
 
+# check for __devinitdata with const or const without __devintconst
+# XXX should scan multiple lines and handle misplaced consts for pointers
+		if ($line =~ /const/ && $line =~ /__(dev)?initdata/) {
+		    ERROR("DEVINITCONST", "const init definition must use __devinitconst");
+		}
+		if ($line =~ /__(dev)?initconst/ && $line !~ /\Wconst\W/) {
+		    ERROR("DEVINITCONST", "__devinitconst must have have const definition");
+		}
+
 # check for spacing round square brackets; allowed:
 #  1. with a type on the left -- int [] a;
 #  2. at the beginning of a line for slice initialisers -- [0...10] = 5,
Signature · 1 line
1.7.7.6