linux-mips
[Top] [All Lists]

Re: PATCH: io.h remove detrimental do {...} whiles, add sequence points,

To: Daniel Jacobowitz <dan@debian.org>
Subject: Re: PATCH: io.h remove detrimental do {...} whiles, add sequence points, add const modifiers
From: Ralf Baechle <ralf@oss.sgi.com>
Date: Fri, 7 Dec 2001 16:06:36 -0200
Cc: Geert Uytterhoeven <geert@linux-m68k.org>, "Bradley D. LaRonde" <brad@ltc.com>, Linux/MIPS Development <linux-mips@oss.sgi.com>
In-reply-to: <20011207123833.A23784@nevyn.them.org>; from dan@debian.org on Fri, Dec 07, 2001 at 12:38:33PM -0500
References: <20011207121416.A9583@dev1.ltc.com> <Pine.GSO.4.21.0112071830000.29896-100000@mullein.sonytel.be> <20011207123833.A23784@nevyn.them.org>
Sender: owner-linux-mips@oss.sgi.com
User-agent: Mutt/1.2.5i
On Fri, Dec 07, 2001 at 12:38:33PM -0500, Daniel Jacobowitz wrote:

> > > - do { * (unsigned long *) &mips_io_port_base = (base); } while (0)
> > > + *(unsigned long *)&mips_io_port_base = (base);
> > 
> > Now consider someone writing
> > 
> >     if (...)
> >     set_io_port_base(...);
> >     else
> >     ...
> > 
> > And see what happens...
> 
> If Bradley loses the extra semicolon, what other problem is the
> do/while construct supposed to address?  I seem to recall there being
> another problem case, but I can't remember what it is.

There is imho not very much sense in such a macro / function being written
in a way that returns any value, that is something like

  foo = set_io_port_base(...)

doesn't make obvious sense.  So it's written in a way which will take care
of any attempt to use the return type.

  Ralf

<Prev in Thread] Current Thread [Next in Thread>