* [PATCH] checkpatch: add a rule to check devinitconst mistakes
@ 2013-04-21 3:33 Andi Kleen
0 siblings, 0 replies; 3+ messages in thread
From: Andi Kleen @ 2013-04-21 3:33 UTC (permalink / raw)
To: apw; +Cc: linux-kernel, Andi Kleen
From: Andi Kleen <ak@linux.intel.com>
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.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
scripts/checkpatch.pl | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 4de4bc4..579f92d 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -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,
--
1.7.7.6
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] checkpatch: add a rule to check devinitconst mistakes
2013-08-05 22:10 Andi Kleen
@ 2013-08-05 23:30 ` Joe Perches
0 siblings, 0 replies; 3+ messages in thread
From: Joe Perches @ 2013-08-05 23:30 UTC (permalink / raw)
To: Andi Kleen; +Cc: apw, linux-kernel, Andi Kleen
On Mon, 2013-08-05 at 15:10 -0700, Andi Kleen wrote:
> From: Andi Kleen <ak@linux.intel.com>
>
> 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.
>
> Signed-off-by: Andi Kleen <ak@linux.intel.com>
> ---
> scripts/checkpatch.pl | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 2ee9eb7..5d68d9c 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -2676,6 +2676,15 @@ sub process {
> }
> }
>
> +# 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/) {
There are no more uses of __devinitconst and
__devinitdata in the tree.
Shouldn't these be "\bconst\b", "\b__initdata\b"
and "\b__initconst\b"
I think also there'll be a few too many false
positives for function arguments.
It seems that every use of __initconst is of
the form
[static] const <type> [name] __initconst so
if ($line =~ /\b__initconst\b/ &&
$line !~ /^\+\s*(?:static\b)?\s*const\s+$Type\s*(?:$Ident)?\s*__initconst\b/) {
etc...
}
should work reasonably well.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] checkpatch: add a rule to check devinitconst mistakes
@ 2013-08-05 22:10 Andi Kleen
2013-08-05 23:30 ` Joe Perches
0 siblings, 1 reply; 3+ messages in thread
From: Andi Kleen @ 2013-08-05 22:10 UTC (permalink / raw)
To: apw; +Cc: joe, linux-kernel, Andi Kleen
From: Andi Kleen <ak@linux.intel.com>
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.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
scripts/checkpatch.pl | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 2ee9eb7..5d68d9c 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2676,6 +2676,15 @@ sub process {
}
}
+# 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,
--
1.8.3.1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-08-05 23:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-21 3:33 [PATCH] checkpatch: add a rule to check devinitconst mistakes Andi Kleen
2013-08-05 22:10 Andi Kleen
2013-08-05 23:30 ` Joe Perches
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®