[lkml]   [2007]   [May]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [patch 01/10] compiler: define __attribute_unused__
On Wed, 2 May 2007, Rusty Russell wrote:

> Adding this macro doesn't give us anything that simply saying
> "__attribute__((unused))" doesn't give. But it does add a layer of
> kernel-specific indirection.

That's obviously true since we're defining __attribute_unused__ to be

We were trying to clean up the misconception that the current
__attribute_used__ was created to suppress warnings when, in fact, that
was not its purpose. It was created to emit the code for a function that
appeared to be unreferenced and only suppressed warnings as a side-effect
in gcc <3.4.

> If we're going to get kernel-specific, I'd prefer to see:
> __needed: suppress warning and don't discard,

That would be the current definition of __attribute_used__ (i.e. we're
saying that we use the function in inline assembly even though it appears
we don't use it at all).

> __unneeded: suppress warning and might discard.

That would be the patched definition of __attribute_unused__.

So let's go back to the problem this was initially supposed to fix from

static __init int pci_access_init(void)
int type = 0;

type = pci_direct_probe();

and type is unreferenced for the remainder of the function. Obviously we
could add #if defined(CONFIG_PCI_DIRECT) || defined(CONFIG_PCI_MMCONFIG)
before the declaration of 'type', but that becomes sloppy pretty quickly.

The patched version makes this:

int type __attribute_unused__ = 0;

which definitely tells you that you're using a compiler attribute that
will be attached to that automatic. In your case:

int type __unneeded = 0;

doesn't say anything in this case. It doesn't resemble any attribute that
a programmer might be familiar with and begs the question of why we've
declared it if it's truly "unneeded"?

By the way, there are tons of these instances where __attribute__((used))
needs to be added in driver code to suppress unreferenced warnings.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2007-05-02 08:09    [W:0.076 / U:0.424 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site