All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Whitcroft <apw@canonical.com>, linux-kernel@vger.kernel.org
Subject: [PATCH 2/3 V2] [PATCH] checkpatch: Add error on use of attribute((weak)) or __weak declarations
Date: Wed, 15 Oct 2014 13:46:04 -0700	[thread overview]
Message-ID: <1413405964.7484.16.camel@perches.com> (raw)
In-Reply-To: <20141015130102.43f322c4db1ed1bf736e97f1@linux-foundation.org>

Using weak declarations can have unintended link defects.
Emit an error on its use.

Signed-off-by: Joe Perches <joe@perches.com>
---
Maybe you prefer this.
It only warns on declarations.

 scripts/checkpatch.pl | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 696254e..8a577aa 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4671,6 +4671,15 @@ sub process {
 			}
 		}
 
+# Check for __attribute__ weak, or __weak declarations (may have link issues)
+		if ($^V && $^V ge 5.10.0 &&
+		    $line =~ /(?:$Declare|$DeclareMisordered)\s*$Ident\s*$balanced_parens\s*(?:$Attribute)?\s*;/ &&
+		    ($line =~ /\b__attribute__\s*\(\s*\(.*\bweak\b/ ||
+		     $line =~ /\b__weak\b/)) {
+			ERROR("WEAK_DECLARATION",
+			      "Using weak declarations can have unintended link defects\n" . $herecurr);
+		}
+
 # check for sizeof(&)
 		if ($line =~ /\bsizeof\s*\(\s*\&/) {
 			WARN("SIZEOF_ADDRESS",
-- 
2.1.0




  reply	other threads:[~2014-10-15 20:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-15 19:32 [PATCH 0/3] checkpatch: Miscellaneous cleanups Joe Perches
2014-10-15 19:32 ` [PATCH 1/3] checkpatch: Add an error test for no space before comma Joe Perches
2014-10-15 19:32 ` [PATCH 2/3] checkpatch: Add error on use of attribute((weak)) or __weak Joe Perches
2014-10-15 19:42   ` Andrew Morton
2014-10-15 19:45     ` Joe Perches
2014-10-15 19:50       ` Andrew Morton
2014-10-15 19:52         ` Joe Perches
2014-10-15 20:01           ` Andrew Morton
2014-10-15 20:46             ` Joe Perches [this message]
2014-10-15 19:32 ` [PATCH 3/3] checkpatch: Improve test for no space after cast Joe Perches

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=1413405964.7484.16.camel@perches.com \
    --to=joe@perches.com \
    --cc=akpm@linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.