linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josh Triplett <josh@joshtriplett.org>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: Andi Kleen <ak@linux.intel.com>, Wei Yongjun <weiyj.lk@gmail.com>,
	linux-sparse@vger.kernel.org
Subject: Re: [BUG] sparse warning EXPORT_SYMBOL()'d symbol non-static
Date: Sun, 24 Nov 2013 14:34:20 -0800	[thread overview]
Message-ID: <20131124223420.GA15608@leaf> (raw)
In-Reply-To: <1385326370.23961.9.camel@jlt4.sipsolutions.net>

On Sun, Nov 24, 2013 at 09:52:50PM +0100, Johannes Berg wrote:
> On Sun, 2013-11-24 at 21:48 +0100, Johannes Berg wrote:
> > On Sun, 2013-11-24 at 12:45 -0800, Josh Triplett wrote:
> > > On Sun, Nov 24, 2013 at 12:28:51PM -0800, Andi Kleen wrote:
> > > > > Well, sparse is clearly "right", for all it cares it might very well be
> > > > > static, but it seems this is necessary for something in the kernel and
> > > > > we clearly can't forward-declare it in a header file. Perhaps we can add
> > > > > some annotation to say
> > > > > "__attribute__((yes_I_know_but_really_dont_want_this_to_be_static))" to
> > > > > suppress this warning? This is getting annoying to me as well :-)
> > > > 
> > > > We could do something like
> > > > 
> > > > typeof(foo); 
> > > > 
> > > > in the macro. Not sure if that would make sparse happy.
> > > 
> > > If you're just looking to mollify sparse,
> > 
> > I am, pretty much, since now I get a ton of output and have to either
> > grep it or dig through it... :)
> > 
> > > the easiest way is to
> > > put a prototype of the symbol right before the symbol itself.
> > 
> > Oh, right, good point, thanks Josh. Andi, do you want to do that?
> > Otherwise I can post a patch.
> 
> The below seems to mollify sparse, but all the attributes make my head
> spin so I'm not sure it's really what we need.
> 
> --- a/include/linux/export.h
> +++ b/include/linux/export.h
> @@ -59,6 +59,7 @@ extern struct module __this_module;
>  	static const char __kstrtab_##sym[]			\
>  	__attribute__((section("__ksymtab_strings"), aligned(1))) \
>  	= VMLINUX_SYMBOL_STR(sym);				\
> +	extern const struct kernel_symbol __ksymtab_##sym;	\
>  	__visible const struct kernel_symbol __ksymtab_##sym	\
>  	__used							\
>  	__attribute__((section("___ksymtab" sec "+" #sym), unused))	\

Yes, that should work as a workaround, though I still think making it
possible for the symbol to be static would be preferable.

- Josh Triplett

      reply	other threads:[~2013-11-24 22:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-15  6:46 [BUG] sparse warning EXPORT_SYMBOL()'d symbol non-static Wei Yongjun
2013-11-24 19:49 ` Johannes Berg
2013-11-24 20:28   ` Andi Kleen
2013-11-24 20:36     ` Johannes Berg
2013-11-24 20:45     ` Josh Triplett
2013-11-24 20:48       ` Johannes Berg
2013-11-24 20:52         ` Johannes Berg
2013-11-24 22:34           ` Josh Triplett [this message]

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=20131124223420.GA15608@leaf \
    --to=josh@joshtriplett.org \
    --cc=ak@linux.intel.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-sparse@vger.kernel.org \
    --cc=weiyj.lk@gmail.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;
as well as URLs for NNTP newsgroup(s).