lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.64.0705012254160.21685@chino.kir.corp.google.com>
Date:	Tue, 1 May 2007 23:06:36 -0700 (PDT)
From:	David Rientjes <rientjes@...gle.com>
To:	Rusty Russell <rusty@...tcorp.com.au>
cc:	Andrew Morton <akpm@...ux-foundation.org>,
	linux-kernel@...r.kernel.org
Subject: Re: [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 
__attribute__((unused)).

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 
arch/i386/pci/init.c:

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

#ifdef CONFIG_PCI_DIRECT
	type = pci_direct_probe();
#endif
#ifdef CONFIG_PCI_MMCONFIG
	pci_mmcfg_init(type);
#endif
	...

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.

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ