From: Vinod Koul <vkoul@kernel.org>
To: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Cc: Dan Williams <dan.j.williams@intel.com>,
dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ioat/dca: Use struct_size() helper
Date: Wed, 4 Sep 2019 10:18:22 +0530 [thread overview]
Message-ID: <20190904044822.GX2672@vkoul-mobl> (raw)
In-Reply-To: <20190828184015.GA4273@embeddedor>
On 28-08-19, 13:40, Gustavo A. R. Silva wrote:
> One of the more common cases of allocation size calculations is finding
> the size of a structure that has a zero-sized array at the end, along
> with memory for some number of elements for that array. For example:
>
> struct ioat_dca_priv {
> ...
> struct ioat_dca_slot req_slots[0];
> };
>
> Make use of the struct_size() helper instead of an open-coded version
> in order to avoid any potential type mistakes.
>
> So, replace the following form:
>
> sizeof(*ioatdca) + (sizeof(struct ioat_dca_slot) * slots)
>
> with:
>
> struct_size(ioatdca, req_slots, slots)
>
> This code was detected with the help of Coccinelle.
Please do not invent subsystem tags, git log should tell you the
convention to be used!
Applied after fixing tags, thanks
--
~Vinod
prev parent reply other threads:[~2019-09-04 4:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-28 18:40 [PATCH] ioat/dca: Use struct_size() helper Gustavo A. R. Silva
2019-08-28 19:38 ` Dave Jiang
2019-09-04 4:48 ` Vinod Koul [this message]
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=20190904044822.GX2672@vkoul-mobl \
--to=vkoul@kernel.org \
--cc=dan.j.williams@intel.com \
--cc=dmaengine@vger.kernel.org \
--cc=gustavo@embeddedor.com \
--cc=linux-kernel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.