Re: [PATCH 5/5] checkpatch: fix false EXPORT_SYMBOL warning

From: Andy Whitcroft
Date: Wed Sep 30 2009 - 13:46:58 EST


On Mon, Sep 21, 2009 at 07:14:51PM -0700, Daniel Walker wrote:
> 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.

In theory the thing we are exporting can be an arbitrary number of lines
prior to the EXPORT_SYMBOL statement. We actually want to look at the
statement before the EXPORT_*.

I had a go at doing it this way and it seems to work on my test sets.
Perhaps you could test the version at the url below:

http://www.kernel.org/pub/linux/kernel/people/apw/checkpatch/checkpatch.pl-testing

NOTE: you want at least version 0.29-5-* which is in the process of
mirroring out.

-apw
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/