[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <00b0a06a-b220-9176-5046-cd6068bf22fd@gmail.com>
Date: Mon, 17 Jul 2023 10:16:23 +0800
From: Joseph Qi <jiangqi903@...il.com>
To: Christophe JAILLET <christophe.jaillet@...adoo.fr>,
Mark Fasheh <mark@...heh.com>,
Joel Becker <jlbec@...lplan.org>,
akpm <akpm@...ux-foundation.org>
Cc: linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org,
ocfs2-devel@...ts.linux.dev,
Joseph Qi <joseph.qi@...ux.alibaba.com>
Subject: Re: [PATCH 2/2] ocfs2: Use struct_size()
On 7/17/23 2:48 AM, Christophe JAILLET wrote:
> Use struct_size() instead of hand-writing it, when allocating a structure
> with a flex array.
>
> This is less verbose.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
Looks fine.
Reviewed-by: Joseph Qi <joseph.qi@...ux.alibaba.com>
> ---
> It will also be helpful if the __counted_by() annotation is added with a
> Coccinelle script such as:
> https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/commit/?h=devel/counted_by&id=adc5b3cb48a049563dc673f348eab7b6beba8a9b
> ---
> fs/ocfs2/journal.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
> index 2f7e70109020..4e779efe2a4e 100644
> --- a/fs/ocfs2/journal.c
> +++ b/fs/ocfs2/journal.c
> @@ -114,9 +114,9 @@ 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(struct_size(replay_map, rm_replay_slots,
> + osb->max_slots),
> + GFP_KERNEL);
> if (!replay_map) {
> mlog_errno(-ENOMEM);
> return -ENOMEM;
Powered by blists - more mailing lists