Re: [PATCH] block: genhd: Use struct_size() helper

From: Jens Axboe
Date: Sat Jun 15 2019 - 03:51:47 EST


On 5/31/19 12:47 PM, 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, in particular in the
> context in which this code is being used.
>
> So, replace the following form:
>
> sizeof(*new_ptbl) + target * sizeof(new_ptbl->part[0])
>
> with:
>
> struct_size(new_ptbl, part, target)
>
> Also, notice that variable size is unnecessary, hence it is removed.
>
> This code was detected with the help of Coccinelle.

Applied, thanks.

--
Jens Axboe