tech-kern archive

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

Re: KNF and the C preprocessor

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.

 > Again, though, this method needs to be used sparingly and obviously (that
 > is, it should be obvious that you are doing it.)

...which it isn't likely to be in code maintained by more than one
person or that goes more than six months at a time without being
looked at.

David A. Holland

Home | Main Index | Thread Index | Old Index