public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Frank van Maarseveen <frankvm@xs4all.nl>
To: Linux Kernel List <linux-kernel@vger.kernel.org>
Subject: Re: __attribute__((unused))
Date: Fri, 15 Oct 2004 14:33:00 +0200	[thread overview]
Message-ID: <20041015123300.GA12530@janus> (raw)
In-Reply-To: <20041014220243.B28649@flint.arm.linux.org.uk>

On Thu, Oct 14, 2004 at 10:02:43PM +0100, Russell King wrote:
> 
> I notice that module.h contains stuff like:
> 
> #define MODULE_GENERIC_TABLE(gtype,name)                        \
> extern const struct gtype##_id __mod_##gtype##_table            \
>   __attribute__ ((unused, alias(__stringify(name))))
> 
> and even:
> 
> #define __MODULE_INFO(tag, name, info)                                    \
> static const char __module_cat(name,__LINE__)[]                           \
>   __attribute_used__                                                      \
>   __attribute__((section(".modinfo"),unused)) = __stringify(tag) "=" info
> 
> My understanding is that we shouldn't be using __attribute__((unused))
> in either of these - can someone confirm.
> 
> The second one looks fairly dodgy since we're telling a compiler that
> it's both used and unused.  That sounds a bit like a HHGTTG puzzle (you
> have tea and no tea.)

This makes sense, assuming the gcc info pages are correct:
`unused'
     This attribute, attached to a function, means that the function is
     meant to be possibly unused.  GCC will not produce a warning for
     this function.  GNU C++ does not currently support this attribute
     as definitions without parameters are valid in C++.

`used'
     This attribute, attached to a function, means that code must be
     emitted for the function even if it appears that the function is
     not referenced.  This is useful, for example, when the function is
     referenced only in inline assembly.

So, a function could be "used" and "unused" at the same time:

	unused -> don't warn
	used -> don't discard

-- 
Frank

  parent reply	other threads:[~2004-10-15 12:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-14 21:02 __attribute__((unused)) Russell King
2004-10-14 22:04 ` __attribute__((unused)) David Woodhouse
2004-10-14 22:08   ` __attribute__((unused)) Russell King
2004-10-14 23:28     ` __attribute__((unused)) Maciej W. Rozycki
2004-10-15 12:31     ` __attribute__((unused)) Alan Cox
2004-10-15 13:50       ` __attribute__((unused)) Richard B. Johnson
2004-10-15 12:33 ` Frank van Maarseveen [this message]
2004-10-15 13:15   ` __attribute__((unused)) Maciej W. Rozycki

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=20041015123300.GA12530@janus \
    --to=frankvm@xs4all.nl \
    --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