Subject: Re: a new KNF (and some comments)
To: Jason Thorpe <thorpej@nas.nasa.gov>
From: Simon Burge <simonb@netbsd.org>
List: tech-kern
Date: 01/21/2000 13:15:34
Jason Thorpe wrote:

>  > #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)).

Can we put the "#ifndef lint" inside the __COPYRIGHT and __RCSID macros?
It would be a little easier on the eyes...

>  > 	/* No spaces after function names. */
>  > 	if (error = function(a1, a2))
>  > 		exit(error);
> 
> That should read:
> 
> 	if ((error = function(a1, a2)))
> 
> but I personally prefer:
> 
> 	if ((error = function(a1, a2)) != 0)
> 
> ...for additional clarity.

Doesn't one of the gcc warnings barf about "testing assignment value" or
something?  I think there are circumstances where you do need the "!= 0"
bit to keep it happy.

Simon.