Re: [PATCH v2][next] virt: acrn: Prefer array_size and struct_size over open coded arithmetic
From: Gustavo A. R. Silva
Date: Mon Oct 25 2021 - 18:17:56 EST
On Sat, Oct 23, 2021 at 12:15:54PM +0200, Len Baker wrote:
[..]
> diff --git a/drivers/virt/acrn/mm.c b/drivers/virt/acrn/mm.c
> index c4f2e15c8a2b..a881742cd48d 100644
> --- a/drivers/virt/acrn/mm.c
> +++ b/drivers/virt/acrn/mm.c
> @@ -168,7 +168,7 @@ int acrn_vm_ram_map(struct acrn_vm *vm, struct acrn_vm_memmap *memmap)
>
> /* Get the page number of the map region */
> nr_pages = memmap->len >> PAGE_SHIFT;
> - pages = vzalloc(nr_pages * sizeof(struct page *));
> + pages = vzalloc(array_size(nr_pages, sizeof(struct page *)));
This form is better:
array_size(nr_pages, sizeof(*pages))
Thanks
--
Gustavo