mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Andi Kleen <andi@firstfloor.org>
Cc: apw@canonical.com, linux-kernel@vger.kernel.org,
	Andi Kleen <ak@linux.intel.com>
Subject: Re: [PATCH] checkpatch: add a rule to check devinitconst mistakes
Date: Mon, 05 Aug 2013 16:30:20 -0700	[thread overview]
Message-ID: <1375745420.1968.13.camel@joe-AO722> (raw)
In-Reply-To: <1375740651-7716-1-git-send-email-andi@firstfloor.org>

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.


  reply	other threads:[~2013-08-05 23:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-05 22:10 Andi Kleen
2013-08-05 23:30 ` Joe Perches [this message]
2013-09-15 20:26 ` [PATCH] checkpatch: add rules to check init attribute and const defects Joe Perches
2013-09-15 21:04   ` Andi Kleen
2013-09-16  2:34     ` [PATCH v2] " Joe Perches
2013-09-16  2:41       ` [untested checkpatch patch] treewide: Convert __initdata and __initconst misuses Joe Perches
  -- strict thread matches above, loose matches on Subject: below --
2013-04-21  3:33 [PATCH] checkpatch: add a rule to check devinitconst mistakes 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=1375745420.1968.13.camel@joe-AO722 \
    --to=joe@perches.com \
    --cc=ak@linux.intel.com \
    --cc=andi@firstfloor.org \
    --cc=apw@canonical.com \
    --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

all inboxes | Powered by JetHome®