[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1341873376.6118.56.camel@joe2Laptop>
Date: Mon, 09 Jul 2012 15:36:16 -0700
From: Joe Perches <joe@...ches.com>
To: David Rientjes <rientjes@...gle.com>
Cc: linux-kernel@...r.kernel.org, mm-commits@...r.kernel.org,
apw@...onical.com
Subject: Re: +
checkpatch-add-check-for-use-of-sizeof-without-parenthesis.patch added to
-mm tree
On Mon, 2012-07-09 at 15:23 -0700, David Rientjes wrote:
> On Mon, 9 Jul 2012, akpm@...ux-foundation.org wrote:
>
> > From: Joe Perches <joe@...ches.com>
> > Subject: checkpatch: Add acheck for use of sizeof without parenthesis
> >
> > Kernel style uses parenthesis around sizeof.
> >
>
> Nack, there's a difference between "sizeof *task" and
> "sizeof(struct task_struct)". The former operates on a unary expression
> and the latter operates on a type. There are over 1000 occurrences in the
> kernel where the sizeof operator, the former, is used on a unary
> expression.
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));
printf("2: %zu\n", sizeof bar);
printf("3: %zu\n", sizeof *baz);
return 0;
}
$ gcc sizeof.c
$ ./a.out
1: 84
2: 84
3: 84
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@...r.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists