Re: [PATCH][next] bcache: Use struct_size() in kzalloc()

From: Joe Perches
Date: Thu Jun 18 2020 - 01:42:56 EST


On Thu, 2020-06-18 at 13:38 +0800, Coly Li wrote:
> On 2020/6/18 06:27, Gustavo A. R. Silva wrote:
> > Make use of the struct_size() helper instead of an open-coded version
> > in order to avoid any potential type mistakes.
[]
> > diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c
[]
> > - io = kzalloc(sizeof(struct dirty_io) +
> > - sizeof(struct bio_vec) *
> > - DIV_ROUND_UP(KEY_SIZE(&w->key),
> > - PAGE_SECTORS),
> > + io = kzalloc(struct_size(io, bio.bi_inline_vecs,
> ^^^^^^^^^^^^^^^^^^
> I like this :-)
>
> > + DIV_ROUND_UP(KEY_SIZE(&w->key), PAGE_SECTORS)),
>
> The above line seems too long for 80 characters limitation. Does
> checkpatch.pl complain for this ?

No. checkpatch has changed: