From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Anubhav Kokane <dev.anubhavk@gmail.com>
Cc: hansg@kernel.org, mchehab@kernel.org, andy@kernel.org,
sakari.ailus@linux.intel.com, gregkh@linuxfoundation.org,
linux-media@vger.kernel.org, linux-staging@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: media: atomisp: refactor sizeof(struct type) to sizeof(*ptr)
Date: Mon, 12 Jan 2026 21:14:31 +0200 [thread overview]
Message-ID: <aWVIF_rkHzxs3k-r@smile.fi.intel.com> (raw)
In-Reply-To: <20260112190054.9828-1-dev.anubhavk@gmail.com>
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
next prev parent reply other threads:[~2026-01-12 19:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-12 19:00 [PATCH] staging: media: atomisp: refactor sizeof(struct type) to sizeof(*ptr) Anubhav Kokane
2026-01-12 19:14 ` Andy Shevchenko [this message]
2026-01-13 10:37 ` Anubhav Kokane
2026-01-13 10:45 ` Andy Shevchenko
2026-01-13 16:08 ` Anubhav Kokane
2026-01-15 11:21 ` Anubhav Kokane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aWVIF_rkHzxs3k-r@smile.fi.intel.com \
--to=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=dev.anubhavk@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=hansg@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=mchehab@kernel.org \
--cc=sakari.ailus@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox