Subject: Re: a new KNF (and some comments)
To: Jason Thorpe <firstname.lastname@example.org>
From: Dave Sainty <email@example.com>
Date: 01/21/2000 23:57:53
Jason Thorpe writes:
> I do have a few change requests, tho...
> > #include <sys/cdefs.h>
> > #ifndef lint
> > __COPYRIGHT("@(#) Copyright (c) 1999\n\
> > The NetBSD Foundation, inc. All rights reserved.\n");
> > __RCSID("$NetBSD$");
> > #endif /* not lint */
> Actually, I think the __COPYRIGHT() and __RCSID() should be changed in the
> header files to provide their own ;'s, and the source and guide updated
> appropriately. This way if you conditionally compile out the RCS IDs, the
> compiler won't choke on you (nor will lint(1)).
Not having ';'s will confuse some auto-indenters. Just a comment, in
most cases the indenter can be fixed :)
> > /*
> > * ANSI function declarations for private functions (i.e. functions not used
> > * elsewhere) go at the top of the source module. Only the kernel has a name
> > * associated with the types. I.e. in the kernel use:
> > * void function(int a);
> > * in user-land use:
> > * void function(int);
> Please nuke the "kernel version" of that. As I recently discovered, this
> can have somewhat annoying side-effects if you're scanning a tree with
> e.g. id-utils for an instance of a global variable, and function prototypes
> have an argument in them of the same name.
But having the parameter name can be a very useful form of
documentation. Although 'a' is unlikely to be helpful, 'fd' or
'bitnum' are more so.
void function(int /* fd */, int /* bitnum */);
... would work. Awfully ugly though, at least on first glance...