diff options
author | Len Baker <len.baker@gmx.com> | 2021-10-24 19:29:21 +0200 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2021-10-27 08:06:41 +0200 |
commit | d156cfcafbd0eae4224ea007d95ebda467eb0c46 (patch) | |
tree | c48d56c067bde50fa8a609760ff4e8b9303921c0 /drivers/nvme/target/admin-cmd.c | |
parent | nvmet: register discovery subsystem as 'current' (diff) | |
download | linux-d156cfcafbd0eae4224ea007d95ebda467eb0c46.tar.xz linux-d156cfcafbd0eae4224ea007d95ebda467eb0c46.zip |
nvmet: use flex_array_size and struct_size
In an effort to avoid open-coded arithmetic in the kernel [1], use the
flex_array_size() and struct_size() helpers instead of an open-coded
calculation.
[1] https://github.com/KSPP/linux/issues/160
Signed-off-by: Len Baker <len.baker@gmx.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'drivers/nvme/target/admin-cmd.c')
-rw-r--r-- | drivers/nvme/target/admin-cmd.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c index 403de678fd06..6fb24746de06 100644 --- a/drivers/nvme/target/admin-cmd.c +++ b/drivers/nvme/target/admin-cmd.c @@ -264,7 +264,7 @@ static u32 nvmet_format_ana_group(struct nvmet_req *req, u32 grpid, desc->chgcnt = cpu_to_le64(nvmet_ana_chgcnt); desc->state = req->port->ana_state[grpid]; memset(desc->rsvd17, 0, sizeof(desc->rsvd17)); - return sizeof(struct nvme_ana_group_desc) + count * sizeof(__le32); + return struct_size(desc, nsids, count); } static void nvmet_execute_get_log_page_ana(struct nvmet_req *req) |