From: Andrew Morton <akpm@linux-foundation.org>
To: Fabian Frederick <fabf@skynet.be>
Cc: 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: Mon, 22 Dec 2014 13:35:01 -0800 [thread overview]
Message-ID: <20141222133501.916a0944e5f0719e60e2c4eb@linux-foundation.org> (raw)
In-Reply-To: <1419275109-11641-1-git-send-email-fabf@skynet.be>
On Mon, 22 Dec 2014 20:05:09 +0100 Fabian Frederick <fabf@skynet.be> wrote:
> sizeof(char) is always 1.
>
> ...
>
> --- a/fs/ocfs2/journal.c
> +++ b/fs/ocfs2/journal.c
> @@ -129,8 +129,8 @@ int ocfs2_compute_replay_slots(struct ocfs2_super *osb)
> if (osb->replay_map)
> return 0;
>
> - 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);
>
> if (!replay_map) {
> mlog_errno(-ENOMEM);
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.
next prev parent reply other threads:[~2014-12-22 21:35 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 ` Andrew Morton [this message]
2014-12-23 11:14 ` [Ocfs2-devel] " Rasmus Villemoes
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=20141222133501.916a0944e5f0719e60e2c4eb@linux-foundation.org \
--to=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®