mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Walker <dwalker@fifo99.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Whitcroft <apw@canonical.com>,
	linux-kernel@vger.kernel.org, Daniel Walker <dwalker@fifo99.com>,
	Ingo Molnar <mingo@elte.hu>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Subject: [PATCH 5/5] checkpatch: fix false EXPORT_SYMBOL warning
Date: Mon, 21 Sep 2009 19:14:51 -0700	[thread overview]
Message-ID: <1253585691-10987-5-git-send-email-dwalker@fifo99.com> (raw)
In-Reply-To: <1253585691-10987-4-git-send-email-dwalker@fifo99.com>

Ingo reported that the following lines triggered a false warning,

static struct lock_class_key rcu_lock_key;
struct lockdep_map rcu_lock_map =
        STATIC_LOCKDEP_MAP_INIT("rcu_read_lock", &rcu_lock_key);
EXPORT_SYMBOL_GPL(rcu_lock_map);

from kernel/rcutree.c , and the false warning looked like this,

WARNING: EXPORT_SYMBOL(foo); should immediately follow its
function/variable
+EXPORT_SYMBOL_GPL(rcu_lock_map);

This change corrects this. It was caused because checkpatch doesn't check
more than one line above the "EXPORT_SYMBOL" for additional context (ie.
variable name, or initializer). Things are somewhat more complicated
because STATIC_LOCKDEP_MAP_INIT() doesn't accept the variable name that
is being initialized. I just added another check that checks two lines
above "EXPORT_SYMBOL" for the variable declaration.

Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Daniel Walker <dwalker@fifo99.com>
---
 scripts/checkpatch.pl |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index fd4fe03..9996bfb 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1629,7 +1629,7 @@ sub process {
 
 # check for initialisation to aggregates open brace on the next line
 		if (($prevline =~ /$Declare\s*$Ident\s*=\s*$/ || $prevline =~ /$Attribute\s*=\s*$/) &&
-		    $line =~ /^.\s*{/) {
+		     $line =~ /^.\s*{/) {
 			ERROR("that open brace { should be on the previous line\n" . $hereprev);
 		}
 
@@ -1665,7 +1665,9 @@ sub process {
 				^.LIST_HEAD\(\Q$name\E\)|
 				^.$Type\s*\(\s*\*\s*\Q$name\E\s*\)\s*\(|
 				\b\Q$name\E(?:\s+$Attribute)?\s*(?:;|=|\[)
-			    )/x) {
+			    )/x && defined $lines[$linenr - 3] &&
+			    $lines[$linenr - 3] !~ /(?:\b\Q$name\E(?:\s+$Attribute)?\s*(?:;|=|\[))/
+				) {
 				WARN("EXPORT_SYMBOL(foo); should immediately follow its function/variable\n" . $herecurr);
 			}
 		}
-- 
1.5.6.3


  reply	other threads:[~2009-09-22  2:15 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-22  2:14 [PATCH 1/5] checkpatch: fix false errors due to macro concatenation Daniel Walker
2009-09-22  2:14 ` [PATCH 2/5] checkpatch: fix hang in relative indent checking Daniel Walker
2009-09-22  2:14   ` [PATCH 3/5] checkpatch: add a blacklist Daniel Walker
2009-09-22  2:14     ` [PATCH 4/5] checkpatch: fix __attribute__ matching Daniel Walker
2009-09-22  2:14       ` Daniel Walker [this message]
2009-09-30 17:46         ` [PATCH 5/5] checkpatch: fix false EXPORT_SYMBOL warning Andy Whitcroft
2009-10-01 14:28           ` Daniel Walker
2009-10-02  7:39             ` Andy Whitcroft
2009-09-30 17:46       ` [PATCH 4/5] checkpatch: fix __attribute__ matching Andy Whitcroft
2009-10-01 14:26         ` Daniel Walker
2009-10-02  7:43           ` Andy Whitcroft
2009-09-22  6:29     ` [PATCH 3/5] checkpatch: add a blacklist Li Zefan
2009-09-30 15:27       ` Andy Whitcroft
2009-10-01 14:18         ` Daniel Walker
2009-10-06 19:51           ` Steven Rostedt
2009-10-06 20:50           ` Krzysztof Halasa
2009-10-07  3:52             ` Daniel Walker
2009-10-07 10:17               ` Krzysztof Halasa
2009-10-07 14:26                 ` Daniel Walker
2009-10-07 14:44                   ` Krzysztof Halasa
2009-10-07 14:57                     ` Daniel Walker
2009-10-07 15:11                       ` Alan Cox
2009-10-07 15:41                         ` Daniel Walker
2009-10-07 15:52                           ` Alan Cox
2009-10-07 16:11                             ` Daniel Walker
2009-10-07 15:08                   ` Steven Rostedt
2009-10-07 15:38                     ` Daniel Walker
2009-10-07 21:30                       ` Krzysztof Halasa
2009-10-07 21:58                         ` Daniel Walker
2009-09-30 15:24   ` [PATCH 2/5] checkpatch: fix hang in relative indent checking Andy Whitcroft
2009-09-30 17:46 ` [PATCH 1/5] checkpatch: fix false errors due to macro concatenation Andy Whitcroft
2009-10-01 14:20   ` Daniel Walker

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=1253585691-10987-5-git-send-email-dwalker@fifo99.com \
    --to=dwalker@fifo99.com \
    --cc=akpm@linux-foundation.org \
    --cc=apw@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulmck@linux.vnet.ibm.com \
    /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

Powered by JetHome