From: Joe Perches <joe@perches.com>
To: David Rientjes <rientjes@google.com>
Cc: linux-kernel@vger.kernel.org, mm-commits@vger.kernel.org,
apw@canonical.com
Subject: Re: + checkpatch-add-check-for-use-of-sizeof-without-parenthesis.patch added to -mm tree
Date: Mon, 09 Jul 2012 15:36:16 -0700 [thread overview]
Message-ID: <1341873376.6118.56.camel@joe2Laptop> (raw)
In-Reply-To: <alpine.DEB.2.00.1207091514310.32082@chino.kir.corp.google.com>
On Mon, 2012-07-09 at 15:23 -0700, David Rientjes wrote:
> On Mon, 9 Jul 2012, akpm@linux-foundation.org wrote:
>
> > From: Joe Perches <joe@perches.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@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
next prev parent reply other threads:[~2012-07-09 22:36 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20120709215256.9A4F71E0043@wpzn4.hot.corp.google.com>
2012-07-09 22:23 ` David Rientjes
2012-07-09 22:36 ` Joe Perches [this message]
2012-07-09 22:55 ` David Rientjes
2012-07-09 23:21 ` Joe Perches
2012-07-09 23:47 ` David Rientjes
2012-07-10 0:55 ` Joe Perches
2012-07-10 1:50 ` David Rientjes
2012-07-10 2:03 ` Joe Perches
2012-07-10 2:21 ` David Rientjes
2012-07-10 5:12 ` Joe Perches
2012-07-10 2:28 ` Linus Torvalds
2012-07-10 2:49 ` David Rientjes
2012-07-12 5:23 ` [PATCH V2] checkpatch: Add check for use of sizeof without parenthesis Joe Perches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1341873376.6118.56.camel@joe2Laptop \
--to=joe@perches.com \
--cc=apw@canonical.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mm-commits@vger.kernel.org \
--cc=rientjes@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®