diff options
author | Gustavo A. R. Silva <gustavo@embeddedor.com> | 2019-08-08 11:53:01 -0500 |
---|---|---|
committer | Ulf Hansson <ulf.hansson@linaro.org> | 2019-09-11 15:58:39 +0200 |
commit | 159a8b4621fcac8e99afe228f6f74ea98662feb5 (patch) | |
tree | 01a81abac59ea785ff33f6abd35bceac0134b048 /drivers/scsi/scsi_ioctl.c | |
parent | 5f3ad19638165e6d9946b33f9fabe0d81748481d (diff) |
mmc: sdhci-cadence: use struct_size() helper
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 sdhci_cdns_priv {
...
struct sdhci_cdns_phy_param phy_params[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(*priv) + sizeof(priv->phy_params[0]) * nr_phy_params
with:
struct_size(priv, phy_params, nr_phy_params)
Also, notice that, in this case, variable priv_size is not necessary,
hence it is removed.
This code was detected with the help of Coccinelle.
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Diffstat (limited to 'drivers/scsi/scsi_ioctl.c')
0 files changed, 0 insertions, 0 deletions