Re: [patch 01/10] compiler: define __attribute_unused__

Adrian Bunk
2007-05-02T14:55:53Z

On Wed, May 02, 2007 at 12:22:24AM -0700, David Rientjes wrote:
> On Wed, 2 May 2007, Rusty Russell wrote:
>
> > That sounds exactly right to me! If the author says it's optional, it
> > might be discarded. If they say it's needed, it won't be. At least,
> > when I'm coding and gcc warns me something is unused, this is the
> > decision I have to make ("is this really needed or not?").
> >
>
> Hi Rusty,
>
> There are many instances in the tree of functions that have no callers
> whatsoever because they've been commented out temporarily, disabled
> through configuration, etc. These are marked __attribute__ ((unused))
> right now so that the compiler doesn't emit a warning (and with gcc >=3.4
> it doesn't even emit code for them). What's __optional about these
> functions if they have no callers? They're unused. So we cover all our
> bases with __maybe_unused.

"many ... are marked __attribute__ ((unused))" is not true:
$ grep -r __attribute_used__ * | wc -l
60
$

static inline functions don't result in warnings.

And for global functions, it is technically impossible for gcc to figure
out whether a function has any users.

Unused static non-inline functions are the only functions resulting in
warnings when being unused.
If we don't want gcc to emit warnings for such, we could disable them
globally.

cu
Adrian

--

"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed