Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/usr.sbin/installboot



On Oct 30,  9:20pm, david%l8s.co.uk@localhost (David Laight) wrote:
-- Subject: Re: CVS commit: src/usr.sbin/installboot

| On Mon, Oct 30, 2006 at 03:59:21PM +0000, Christos Zoulas wrote:
| > >
| > >I've also deliberatly used:
| > >
| > >#define x(y)   if (y); else {...}
| > >
| > >To avoid having to wrap the expansion inside do ... while (0);
| > 
| > How is one supposed to use this macro?
| 
| I remember now, it would be for single statement conditionals. eg:
| 
| #define return_nz(r) if (!r); else return (r)
| 
| Which is quite happy as:
| 
|       return_nz(a);
|       if (b)
|               return_nz(a);
|       if (c)
|               ...
|       else
|               return_nz(a);
| 


    #define return_nz(r) if (!r) {} else return (r)

avoids the warning; I undestand that this macro is useful, but if I wanted
to make it safe, I would write it as a do while anyway.

christos



Home | Main Index | Thread Index | Old Index