lkml.org 
[lkml]   [2008]   [Dec]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] HID: avoid sparse warning in HID_COMPAT_LOAD_DRIVER
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


\
 
 \ /
  Last update: 2008-12-16 20:47    [W:0.059 / U:0.228 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site