Subject: Re: CVS commit: src/usr.sbin/installboot
To: David Laight <david@l8s.co.uk>
From: Christos Zoulas <christos@zoulas.com>
List: source-changes
Date: 10/30/2006 16:31:26
On Oct 30,  9:20pm, david@l8s.co.uk (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