linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Hannes Eder" <hannes@hanneseder.net>
To: "Ben Dooks" <ben-linux@fluff.org>
Cc: "Jiri Kosina" <jkosina@suse.cz>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] HID: avoid sparse warning in HID_COMPAT_LOAD_DRIVER
Date: Tue, 16 Dec 2008 20:44:56 +0100	[thread overview]
Message-ID: <154e089b0812161144x3c9579f5g8731b616fde6484c@mail.gmail.com> (raw)
In-Reply-To: <20081216194113.GF12431@fluff.org.uk>

On Tue, Dec 16, 2008 at 5:01 PM, Jiri Kosina <jkosina@suse.cz> wrote:
> On Tue, 16 Dec 2008, Ben Dooks wrote:
>
>> >  #ifdef CONFIG_HID_COMPAT
>> >  #define HID_COMPAT_LOAD_DRIVER(name)       \
>> > +/* prototype to avoid sparse warning */    \
>> > +extern void hid_compat_##name(void);       \
>> >  void hid_compat_##name(void) { }   \
>> surely this could simply be changed to 'static void
>> hid_compat_##name(void)' if it is only being defined to be an empty
>
> This will cause gcc emit warnings about unused symbols.

The real problem is that the symbol (in that case the function) is not
exported if defined static.

e.g.:

$ cat >foobar.c <<EOF
> static void foo(void) {}
> extern void foo(void);
>
> void bar(void) {}
> EOF
$ gcc -c foobar.c
$ nm foobar.o
00000005 T bar
00000000 t foo

from the nm manpage:
The  symbol  type. ... If lowercase, the symbol is local; if
uppercase, the symbol is global (external)

i.e. foo is local

see http://lkml.org/lkml/2008/9/4/495 for what ANSI C Std has to say
about that and about the proposed change.

But, don't ask my why the void functions with empty function bodies
are exported.

On Tue, Dec 16, 2008 at 8:41 PM, Ben Dooks <ben-linux@fluff.org> wrote:
> sorry, 'static inline void' then.

in that case the symbol would not even be local as it is not used with
the translation unit.

$ nm
00000005 T bar

-Hannes

  reply	other threads:[~2008-12-16 19:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-16 12:31 [PATCH] HID: avoid sparse warning in HID_COMPAT_LOAD_DRIVER Hannes Eder
2008-12-16 13:35 ` Jiri Kosina
2008-12-16 15:58 ` Ben Dooks
2008-12-16 16:01   ` Jiri Kosina
2008-12-16 19:41     ` Ben Dooks
2008-12-16 19:44       ` Hannes Eder [this message]
2008-12-19  8:31         ` Jiri Slaby
2008-12-19  9:37           ` Jiri Kosina
2008-12-20 16:55             ` Jiri Slaby
2009-02-06 16:07               ` Jiri Kosina

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=154e089b0812161144x3c9579f5g8731b616fde6484c@mail.gmail.com \
    --to=hannes@hanneseder.net \
    --cc=ben-linux@fluff.org \
    --cc=jkosina@suse.cz \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).