Re: [PATCH/RFC] CodingStyle updates

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

 



Hi Randy,

On Thursday 07 December 2006 08:48, Randy Dunlap wrote:
[snip]
> +		3.1:  Spaces
> +
> +Linux kernel style for use of spaces depends (mostly) on
> +function-versus-keyword usage.  Use a space after (most) keywords.
> +The notable exception is "sizeof", which looks like a function
> +(and is usually used with parentheses in Linux, although they are
> +not required in the language, as in: "sizeof struct file").
> +So use a space after these keywords:
> +	if, switch, case, for, do, while
> +but not with "sizeof".  E.g.,
> +	s = sizeof(struct file);
> +
> +Do not add spaces around (inside) parenthesized expressions.
> +This example is *bad*:
> +
> +	s = sizeof( struct file );
> +
> +When declaring pointer data or a function that returns a pointer type,
> +the preferred use of '*' is adjacent to the data name or function name
> +and not adjacent to the type name.  Examples:
> +
> +	char *linux_banner;
> +	unsigned long long memparse(char *ptr, char **retptr);
> +	char *match_strdup(substring_t *s);
> +
> +Use one space around (on each side of) most binary operators, such as
> +any of these:
> +		=  +  -  <  >  *  /  %  |  &  ^  <=  >=  ==  !=
> +
> +but no space after unary operators:
> +		sizeof  ++  --  &  *  +  -  ~  !  defined

You could mention typeof too, which is a keyword but should be done like 
sizeof.

-- 
Cheers,
Alistair.

Final year Computer Science undergraduate.
1F2 55 South Clerk Street, Edinburgh, UK.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux