Re: + checkpatch-add-check-for-use-of-sizeof-without-parenthesis.patchadded to -mm tree

From: David Rientjes
Date: Mon Jul 09 2012 - 22:21:52 EST


On Mon, 9 Jul 2012, Joe Perches wrote:

> I don't really care what style a large block of code
> uses. I care that it mostly has the same form.
>

Same form?? The sizeof operator has two forms depending on whether it's a
unary expression or a type as specified by the standard.

The issue here is that you're mandating they all use the same form because
you're quoting an email from Linus four years ago that you dug up but
isn't required in the coding style and is already used in over 1000 places
in the kernel.

If you want the output of checkpatch.pl to be useful, I would think you
would want to eliminate this kind of garbage.

> > I guarantee you that those who learned from K&R don't
> > think sizeof(unsigned long) "looks like a function".
>
> Tell that to Linus. He wrote the email I referenced
> which you so apparently blithely elided.
>
> Repeating it:
>
> "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."
>

He's obviously addressing a single form of the sizeof operator, i.e. those
on unary expressions; sizeof used on a type CLEARLY DOES require the
parenthesis.

Anyway, since this is my last email on the matter since I've already
showed how your patch is completely busted, you're talking purely about
style preferences here. Don't convolute that by talking about the C
standard or Linus' email where he says "it's a coding standard." It's
not. I've layed out the two forms of the sizeof operator in every email
I've written in this thread. If you want to enforce a _style_ preference
because you saw an email four years ago that Linus wrote, then add it to
CodingStyle first and get him to mandate it. That's how you effect a
kernel-wide change; the _only_ person I know that uses checkpatch is
Andrew and you'll notice the mm directory is the one where "sizeof ..."
isn't used so just changing checkpatch here won't do much good.

Thanks and have a nice day.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/