Re: + checkpatch-add-check-for-use-of-sizeof-without-parenthesis.patchadded to -mm tree
From: David Rientjes
Date: Mon Jul 09 2012 - 18:55:53 EST
On Mon, 9 Jul 2012, Joe Perches wrote:
> Huh? Maybe I misunderstand you.
>
> $ cat sizeof.c
> #include <stdio.h>
> #include <stdlib.h>
> #include <strings.h>
>
> struct foo {
> int bar[20];
> char *baz;
> };
>
> int main(int argc, char **argv)
> {
> struct foo bar;
> struct foo *baz;
>
> printf("1: %zu\n", sizeof(struct foo));
Parenthesis are required for type names such as this and is normally
written as "sizeof (struct foo)" in gcc, glibc, the C99 standard, etc.,
but the Linux coding style asks that no space is introduced.
> printf("2: %zu\n", sizeof bar);
This is a unary expression and no parenthesis are required either by the
C99 standard nor the Linux coding style and there are over 1000
occurrences where there are no parenthesis for unary operators currently
in the kernel.
So, nack, don't start enforcing your own coding style and preferences in
checkpatch.pl.
--
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/