Subject: Re: a new KNF (and some comments)
To: Luke Mewburn <>
From: Dan Winship <danw@MIT.EDU>
List: tech-kern
Date: 01/20/2000 23:13:59
>  * Style guide for the NetBSD KNF (Kernel Normal Form).

But it's not just for kernels any more! The comment should explain
that it's for all NetBSD code.

>  * Use the __P macro from the include file <sys/cdefs.h> for prototypes
>  * in header files, for compatibility with non-ANSI compilers.  I.e,
>  *	void function __P((int));
>  */
> static char	*function(int, int, float, int);
> static void	usage(void);

Adding "Don't use it for prototypes in C files." to the end of the
comment would make this section a lot easier to understand.

> 	 * Forever loops are done with for's, not while's.

Is there some good reason for that? (And there's a lot of code in the
tree that doesn't obey this.)

> 	/* Second level indents are four spaces. */

[This is my least favorite rule. But I digress.]

> 	 * Unary operators don't require spaces, binary operators do.  Don't
> 	 * use parenthesis unless they're required for precedence, or the
> 	 * statement is really confusing without them, such as:

I agree with whoever said we shouldn't discourage non-gratuitous

> 	 * Function declarations (which are ANSI style) should go in the

Shouldn't that be "Function prototypes"? (Which would make the
parenthetical comment unnecessary.)

> 	va_end(ap);		/* No return needed for void functions. */
> }

I think that comment counts as "obvious". (If not, it at least belongs
on its own line, since it's not talking about the va_end.)

-- Dan