tech-toolchain archive

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

Re: [patch] C99 & /usr/share/misc/style



Joseph Koshy <jkoshy%netbsd.org@localhost> writes:

> +// C99 single-line comments are allowed.
> +
> +// C99 single-line comments can also be used to write longer form
> +// comments.  Fill these so they look like real paragraphs.
> +
>  /*
>   * Attempt to wrap lines longer than 80 characters appropriately.
>   * Refer to the examples below for more information.


I don't like this.  This is C++ creeping into C, and the kernel has been
C forever (well early 70s).  But more seriously, there is currently one
way to write comments, and having both C and C++ comments is a mess as
it will be inconsistent, which is just bad style before you even talk
about code.  I don't think anyone wants to mass edit /* to //.

> @@ -147,10 +152,13 @@
>  
>  #define	DOUBLE(x) ((x) * 2)
>  
> -/* Enum constants are capitalized.  No comma on the last element. */
> +/*
> + * Enum constants are capitalized.  Commas are recommended for the last
> + * element as using them can minimize diffs.
> + */
>  enum enumtype {
>  	ONE,
> -	TWO
> +	TWO,
>  };

-1 from me.


>  /*
> @@ -260,8 +268,10 @@
>  	 * Braces around single-line bodies are optional; use discretion.
>  	 *
>  	 * Forever loops are done with for's, not while's.
> +	 *
> +	 * Use narrow scopes for loop variables where possible.
>  	 */
> -	for (p = buf; *p != '\0'; ++p)
> +	for (char *p = buf; *p != '\0'; ++p)
>  		continue;		/* Explicit no-op */
>  	for (;;)
>  		stmt;

seems ok


Home | Main Index | Thread Index | Old Index