On Mon, 2012-07-09 at 16:47 -0700, David Rientjes wrote: > On Mon, 9 Jul 2012, Joe Perches wrote: > > > > So, nack, don't start enforcing your own coding style and preferences in > > > checkpatch.pl. > > > > Not just my opinion. > > > > https://lkml.org/lkml/2008/12/23/138 > > -------------------------------------------------------- > > Date: Tue, 23 Dec 2008 10:08:50 -0800 (PST) > > From: Linus Torvalds <> > > [] > > Another example of this is "sizeof". The kernel universally (I hope) has > > parenthesis around the sizeof argument, even though it's clearly not > > required by the C language. > > > > Well, let's add Linus to the cc then because it's certainly not a C > standard. The sizeof operator requires parenthesis for type names, you > can't do "sizeof unsigned long", for example, it requires > "sizeof (unsigned long)". All other unary operators do not need the > parenthesis by ANY C standard. > > Documentation/CodingStyle does not ask for the parenthesis to be added > just like it doesn't ask for parenthesis to do things like (i++); which is > another unary operator.
CodingStyle already does suggest parenthesis around sizeof 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 exceptions are sizeof, typeof, alignof, and __attribute__, which look somewhat like functions (and are usually used with parentheses in Linux, although they are not required in the language, as in: "sizeof info" after "struct fileinfo info;" is declared). So use a space after these keywords: if, switch, case, for, do, while but not with sizeof, typeof, alignof, or __attribute__. E.g., s = sizeof(struct file); and Chapter 14: Allocating memory [] The preferred form for passing a size of a struct is the following: p = kmalloc(sizeof(*p), ...); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/