[PATCH] nvmet: prefer struct_size over open coded arithmetic
Gustavo A. R. Silva
gustavoars at kernel.org
Sat Oct 23 13:14:38 PDT 2021
On Sat, Oct 23, 2021 at 01:28:38PM +0200, Len Baker wrote:
> Hi Gustavo,
>
> first of all, thanks for this review (and all others reviews as
> well) ;)
No problem. :)
> I think that it is better to use the dynamic allocation since in the
> future the struct size could be dynamic.
Yep; that seems sensible.
> it's not one single element. The "sizeof(struct nvme_ana_group_desc)" is
> multiplied by "ctrl->nanagrpid" and then added "ctrl->max_namespaces * sizeof(__le32)".
You're right. The whole expression got me a bit confused.
> > drivers/nvme/target/admin-cmd.c:267: return sizeof(struct nvme_ana_group_desc) + count * sizeof(__le32);
>
> Ok. I forgot it. Apologies.
No apologies. Thanks for your patches.
> Again, thanks for your time and advises,
Anytime.
Thanks
--
Gustavo
More information about the Linux-nvme
mailing list