Re: [PATCH] staging: media: atomisp: refactor sizeof(struct type) to sizeof(*ptr)

From: Andy Shevchenko

Date: Mon Jan 12 2026 - 14:14:36 EST


On Mon, Jan 12, 2026 at 07:00:53PM +0000, Anubhav Kokane wrote:
> Use the variable name in sizeof() operator instead of the struct type.
> This prevents errors if the type of the variable is changed in future.
>
> This fixes checkpatch checks:
> "CHECK: Prefer kzalloc(sizeof(*ptr)...) over
> kzalloc(sizeof(struct type)...)"

Yeah, but in all cases the whole buffers are less than a page and hence instead
of doing that the preferred way is to switch to use kcalloc() in all three
places.

So you should have something like

x = kcalloc(count, sizeof(*...), ...);
if (!x)
...handle error...

while (count--) {
...
}
...
err:
list_for_each... {
...
}
kfree(x);


--
With Best Regards,
Andy Shevchenko