From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Fabian Frederick <fabf@skynet.be>,
linux-kernel@vger.kernel.org, joe@perches.com,
ocfs2-devel@oss.oracle.com, Mark Fasheh <mfasheh@suse.com>
Subject: Re: [Ocfs2-devel] [PATCH 1/1 linux-next] ocfs2: remove unnecessary sizeof(char)
Date: Tue, 23 Dec 2014 12:14:44 +0100 [thread overview]
Message-ID: <87k31ibot7.fsf@rasmusvillemoes.dk> (raw)
In-Reply-To: <20141222133501.916a0944e5f0719e60e2c4eb@linux-foundation.org> (Andrew Morton's message of "Mon, 22 Dec 2014 13:35:01 -0800")
On Mon, Dec 22 2014, Andrew Morton <akpm@linux-foundation.org> wrote:
> On Mon, 22 Dec 2014 20:05:09 +0100 Fabian Frederick <fabf@skynet.be> wrote:
>
>>
>> - replay_map = kzalloc(sizeof(struct ocfs2_replay_map) +
>> - (osb->max_slots * sizeof(char)), GFP_KERNEL);
>> + replay_map = kzalloc(sizeof(struct ocfs2_replay_map) + osb->max_slots,
>> + GFP_KERNEL);
>>
>
> I dunno. The code at present isn't particularly idiomatic, but it has
> some documentation value and says "I know what I'm doing".
>
> It would be better if it was
>
> kzalloc(sizeof(struct ocfs2_replay_map) *
> sizeof(struct ocfs2_replay_map.rm_replay_slots[0]), ...);
>
> And it would be better if C permitted that ;)
>
> kzalloc(sizeof(struct ocfs2_replay_map) *
> sizeof((struct ocfs2_replay_map *)0)->rm_replay_slots[0]), ...);
>
> yuk.
Well, the yuckiness could be hidden behind FIELD_SIZEOF. CodingStyle
explicitly mentions that macro. No opinion on whether it's worth it in
this case.
Rasmus
prev parent reply other threads:[~2014-12-23 11:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-22 19:05 Fabian Frederick
2014-12-22 21:35 ` [Ocfs2-devel] " Andrew Morton
2014-12-23 11:14 ` Rasmus Villemoes [this message]
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=87k31ibot7.fsf@rasmusvillemoes.dk \
--to=linux@rasmusvillemoes.dk \
--cc=akpm@linux-foundation.org \
--cc=fabf@skynet.be \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mfasheh@suse.com \
--cc=ocfs2-devel@oss.oracle.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®