From: Ralf Baechle <ralf@oss.sgi.com>
To: Paul Jackson <pj@engr.sgi.com>
Cc: William Jhun <wjhun@ayrnetworks.com>, linux-mips@oss.sgi.com
Subject: Re: [PATCH] include/asm-mips/pci.h
Date: Thu, 20 Jun 2002 12:25:26 +0200 [thread overview]
Message-ID: <20020620122525.B4835@dea.linux-mips.net> (raw)
In-Reply-To: <Pine.LNX.4.44.0206191326560.18638-100000@turbo-linux.engr.sgi.com>; from pj@engr.sgi.com on Wed, Jun 19, 2002 at 01:38:52PM -0700
On Wed, Jun 19, 2002 at 01:38:52PM -0700, Paul Jackson wrote:
> Yes - leave them out (speaking out of context here - hopefully still
> useful).
>
> Remove the warnings instead.
>
> I've gotten in the habit of having the following form to
> optional code logic:
>
> In some header file foobar.h:
>
> #if CONFIG_FOOBAR
> #define init_foobar(x) do { \
> int f = 2 * (x); \
> foobar_initialize(f); \
> | while (0)
> #else
> #define init_foobar(x) do {} while (0)
> #endif
>
> I don't see any warnings from this, and it provides just
> the right sort of syntax wrapper on the macro init_foobar(),
> forcing it to be a single statement, regardless of context,
> while providing a nested block context for any local variables.
Note your variant doesn't deal with side effects of the argument expression
x (basically none of the equivalent constructions in the kernels do!) which
is why our code in question does something like this:
#if CONFIG_FOOBAR
#define init_foobar(x) do { \
int f = 2 * (x); \
foobar_initialize(f); \
| while (0)
#else
#define init_foobar(x) do { (x); } while (0)
#endif
This can potencially expand into something like:
do { 42; } while(0)
which will result in warnings. The solution is:
#define init_foobar(x) do { (void) (x); } while (0)
Ralf
prev parent reply other threads:[~2002-06-20 10:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-06-18 17:03 [PATCH] dma_cache_wback, pci DMA cache coherency changes William Jhun
2002-06-19 9:39 ` Ralf Baechle
2002-06-19 18:22 ` [PATCH] include/asm-mips/pci.h William Jhun
2002-06-19 20:38 ` Paul Jackson
2002-06-19 20:38 ` Paul Jackson
2002-06-20 10:25 ` Ralf Baechle [this message]
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=20020620122525.B4835@dea.linux-mips.net \
--to=ralf@oss.sgi.com \
--cc=linux-mips@oss.sgi.com \
--cc=pj@engr.sgi.com \
--cc=wjhun@ayrnetworks.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.