cvs commit: src/sys/dev/sym sym_fw.h

Diomidis Spinellis dds at aueb.gr
Tue Aug 5 06:17:30 PDT 2003


Johan Karlsson wrote:
> On Tue, Aug 05, 2003 at 00:22 (-0700) +0000, Diomidis Spinellis wrote:
> > dds         2003/08/05 00:22:12 PDT
> >
> >   FreeBSD src repository
> >
> >   Modified files:
> >     sys/dev/sym          sym_fw.h
> >   Log:
> >   Remove extraneous semicolons.  They are already provided by
> >   the macro definition, and cause the generation of syntactically
> >   incorrect code that gcc happens to accept.
> 
> This is backwards.
> 
> >From style(9):
>                                                       Any final statement-ter-
>      minating semicolon should be supplied by the macro invocation rather than
>      the macro, to make parsing easier for pretty-printers and editors.
> 
> Please consider reverting this and change the macros in the file to not
> supply the terminating semicolon.

I would certainly follow the style(9) guide if the existing code allowed
it.  This case is however more complicated.  The same two 15-line macros
(SYM_GEN_FW_[AB]) are used to specify structure member declarations and
initializations:

#define SYM_GEN_FW_B(s)                             \
        SYM_GEN_B(s, no_data)                       \
        SYM_GEN_B(s, sel_for_abort)                 \
        SYM_GEN_B(s, sel_for_abort_1)               \
...

SYM_GEN_B is defined as

#define SYM_GEN_B(s, label)     s label;

in the include file for defining the structure members, and as 

#define SYM_GEN_B(s, label)     ((short) offsetof(s, label)),

in the C file for initializing the structures.  Thus SYM_GEN_FW will
always end with a semicolon or a comma.  Also note that the terminator
can not be specified as a macro argument.  The two macros could be
duplicated in semicolon-terminating and comma-separating versions (with
the last separating/terminating element missing), but I believe this
would be worse than the style rule violation.  Other ideas welcome.

Diomidis - dds@


More information about the cvs-src mailing list