On Tue, Dec 11, 2012 at 06:10:09AM +0000, David Holland wrote: > On Tue, Dec 11, 2012 at 01:27:09AM +0000, Roland C. Dowdeswell wrote: > > As an example, I often define a macro when I am using Kerberos or > > GSSAPI that looks roughly like: > > > > #ifdef K5BAIL(x) do { > > ret = x; > > if (ret) { > > /* format error message and whatnot > > * in terms of #x. > > */ > > > > goto bail; > > } > > } while (0) > > The code like this in src/sys/nfs is a reliably steady source of > problems, and I'd argue that macros of this form are not at all worth > the problems they cause.
Absolutely, that is one construct I would ban. Encapsulating so you can do: if (K5BAIL(xxx(....), "error text")) goto bail; Or even separating the function name (so it can be traced) at least leaves the flow control obvious. If you embed a goto (or return) in a #define you'd better have the defininition very close to the use. David -- David Laight: da...@l8s.co.uk