From: Leon Romanovsky <leon@kernel.org>
To: Doug Ledford <dledford@redhat.com>
Cc: SF Markus Elfring <elfring@users.sourceforge.net>,
Devesh Sharma <devesh.sharma@avagotech.com>,
Hal Rosenstock <hal.rosenstock@gmail.com>,
Sean Hefty <sean.hefty@intel.com>,
Selvin Xavier <selvin.xavier@avagotech.com>,
Yuval Shaia <yuval.shaia@oracle.com>,
linux-rdma@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH v2 03/12] IB/ocrdma: Improve size determinations in ten functions
Date: Sun, 23 Apr 2017 10:33:11 +0300 [thread overview]
Message-ID: <20170423073311.GA14088@mtr-leonro.local> (raw)
In-Reply-To: <755f6c2c-03a2-7248-a5e3-9190d119cdaf@users.sourceforge.net>
[-- Attachment #1: Type: text/plain, Size: 7071 bytes --]
On Sat, Apr 22, 2017 at 04:36:19PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 22 Apr 2017 13:26:49 +0200
>
> Replace the specification of data types by pointer dereferences
> as the parameter for the operator "sizeof" to make the corresponding size
> determinations a bit safer according to the Linux coding style convention.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>
> v2:
> Changes were rebased on source files from Linux next-20170421.
> These were recombined as requested by Doug Ledford.
Hi Doug,
I recommend you to be extra cautious with this blind automatic
conversions. It requires inspection that every size before and after
match each other.
I already asked it and would be like to repeat it. Please DON'T take any
patches from Markus, which are related to mlx4/mlx5/rxe without our explicit
review of them.
Thanks
>
> drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 28 ++++++++++++----------------
> drivers/infiniband/hw/ocrdma/ocrdma_main.c | 2 +-
> drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 4 ++--
> 3 files changed, 15 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
> index d5a3127b6df8..7e58a74102f6 100644
> --- a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
> +++ b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
> @@ -352,7 +352,7 @@ static void *ocrdma_init_emb_mqe(u8 opcode, u32 cmd_len)
> {
> struct ocrdma_mqe *mqe;
>
> - mqe = kzalloc(sizeof(struct ocrdma_mqe), GFP_KERNEL);
> + mqe = kzalloc(sizeof(*mqe), GFP_KERNEL);
> if (!mqe)
> return NULL;
> mqe->hdr.spcl_sge_cnt_emb |=
> @@ -890,7 +890,7 @@ static int ocrdma_mq_cq_handler(struct ocrdma_dev *dev, u16 cq_id)
> ocrdma_process_acqe(dev, cqe);
> else if (cqe->valid_ae_cmpl_cons & OCRDMA_MCQE_CMPL_MASK)
> ocrdma_process_mcqe(dev, cqe);
> - memset(cqe, 0, sizeof(struct ocrdma_mcqe));
> + memset(cqe, 0, sizeof(*cqe));
> ocrdma_mcq_inc_tail(dev);
> }
> ocrdma_ring_cq_db(dev, dev->mq.cq.id, true, false, cqe_popped);
> @@ -1302,7 +1302,7 @@ int ocrdma_mbx_rdma_stats(struct ocrdma_dev *dev, bool reset)
> mqe->u.nonemb_req.sge[0].len = dev->stats_mem.size;
>
> /* Cache the old stats */
> - memcpy(old_stats, req, sizeof(struct ocrdma_rdma_stats_resp));
> + memcpy(old_stats, req, sizeof(*old_stats));
> memset(req, 0, dev->stats_mem.size);
>
> ocrdma_init_mch((struct ocrdma_mbx_hdr *)req,
> @@ -1315,7 +1315,7 @@ int ocrdma_mbx_rdma_stats(struct ocrdma_dev *dev, bool reset)
> status = ocrdma_nonemb_mbx_cmd(dev, mqe, dev->stats_mem.va);
> if (status)
> /* Copy from cache, if mbox fails */
> - memcpy(req, old_stats, sizeof(struct ocrdma_rdma_stats_resp));
> + memcpy(req, old_stats, sizeof(*old_stats));
> else
> ocrdma_le32_to_cpu(req, dev->stats_mem.size);
>
> @@ -1331,7 +1331,7 @@ static int ocrdma_mbx_get_ctrl_attribs(struct ocrdma_dev *dev)
> struct ocrdma_get_ctrl_attribs_rsp *ctrl_attr_rsp;
> struct mgmt_hba_attribs *hba_attribs;
>
> - mqe = kzalloc(sizeof(struct ocrdma_mqe), GFP_KERNEL);
> + mqe = kzalloc(sizeof(*mqe), GFP_KERNEL);
> if (!mqe)
> return status;
>
> @@ -1595,8 +1595,7 @@ void ocrdma_alloc_pd_pool(struct ocrdma_dev *dev)
> {
> int status;
>
> - dev->pd_mgr = kzalloc(sizeof(struct ocrdma_pd_resource_mgr),
> - GFP_KERNEL);
> + dev->pd_mgr = kzalloc(sizeof(*dev->pd_mgr), GFP_KERNEL);
> if (!dev->pd_mgr)
> return;
>
> @@ -2487,7 +2486,7 @@ int ocrdma_mbx_query_qp(struct ocrdma_dev *dev, struct ocrdma_qp *qp,
> if (status)
> goto mbx_err;
> rsp = (struct ocrdma_query_qp_rsp *)cmd;
> - memcpy(param, &rsp->params, sizeof(struct ocrdma_qp_params));
> + memcpy(param, &rsp->params, sizeof(*param));
> mbx_err:
> kfree(cmd);
> return status;
> @@ -2901,9 +2900,8 @@ static int ocrdma_mbx_get_dcbx_config(struct ocrdma_dev *dev, u32 ptype,
> struct pci_dev *pdev = dev->nic_info.pdev;
> struct ocrdma_mqe_sge *mqe_sge = cmd.u.nonemb_req.sge;
>
> - memset(&cmd, 0, sizeof(struct ocrdma_mqe));
> - cmd.hdr.pyld_len = max_t (u32, sizeof(struct ocrdma_get_dcbx_cfg_rsp),
> - sizeof(struct ocrdma_get_dcbx_cfg_req));
> + memset(&cmd, 0, sizeof(cmd));
> + cmd.hdr.pyld_len = max_t(u32, sizeof(*rsp), sizeof(*req));
> req = dma_alloc_coherent(&pdev->dev, cmd.hdr.pyld_len, &pa, GFP_KERNEL);
> if (!req) {
> status = -ENOMEM;
> @@ -2915,8 +2913,7 @@ static int ocrdma_mbx_get_dcbx_config(struct ocrdma_dev *dev, u32 ptype,
> mqe_sge->pa_lo = (u32) (pa & 0xFFFFFFFFUL);
> mqe_sge->pa_hi = (u32) upper_32_bits(pa);
> mqe_sge->len = cmd.hdr.pyld_len;
> -
> - memset(req, 0, sizeof(struct ocrdma_get_dcbx_cfg_req));
> + memset(req, 0, sizeof(*req));
> ocrdma_init_mch(&req->hdr, OCRDMA_CMD_GET_DCBX_CONFIG,
> OCRDMA_SUBSYS_DCBX, cmd.hdr.pyld_len);
> req->param_type = ptype;
> @@ -2926,9 +2923,8 @@ static int ocrdma_mbx_get_dcbx_config(struct ocrdma_dev *dev, u32 ptype,
> goto mbx_err;
>
> rsp = (struct ocrdma_get_dcbx_cfg_rsp *)req;
> - ocrdma_le32_to_cpu(rsp, sizeof(struct ocrdma_get_dcbx_cfg_rsp));
> - memcpy(dcbxcfg, &rsp->cfg, sizeof(struct ocrdma_dcbx_cfg));
> -
> + ocrdma_le32_to_cpu(rsp, sizeof(*rsp));
> + memcpy(dcbxcfg, &rsp->cfg, sizeof(*dcbxcfg));
> mbx_err:
> dma_free_coherent(&pdev->dev, cmd.hdr.pyld_len, req, pa);
> mem_err:
> diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_main.c b/drivers/infiniband/hw/ocrdma/ocrdma_main.c
> index 91705b10f269..e2aa67d6cbb8 100644
> --- a/drivers/infiniband/hw/ocrdma/ocrdma_main.c
> +++ b/drivers/infiniband/hw/ocrdma/ocrdma_main.c
> @@ -303,7 +303,7 @@ static struct ocrdma_dev *ocrdma_add(struct be_dev_info *dev_info)
> u8 lstate = 0;
> struct ocrdma_dev *dev;
>
> - dev = (struct ocrdma_dev *)ib_alloc_device(sizeof(struct ocrdma_dev));
> + dev = (struct ocrdma_dev *)ib_alloc_device(sizeof(*dev));
> if (!dev) {
> pr_err("Unable to allocate ib device\n");
> return NULL;
> diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
> index 146601c97158..f12d1d458f28 100644
> --- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
> +++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
> @@ -1914,7 +1914,7 @@ struct ib_srq *ocrdma_create_srq(struct ib_pd *ibpd,
> if (srq->idx_bit_fields == NULL)
> goto arm_err;
> memset(srq->idx_bit_fields, 0xff,
> - srq->bit_fields_len * sizeof(u32));
> + srq->bit_fields_len * sizeof(*srq->idx_bit_fields));
> }
>
> if (init_attr->attr.srq_limit) {
> @@ -3029,7 +3029,7 @@ struct ib_mr *ocrdma_alloc_mr(struct ib_pd *ibpd,
> if (!mr)
> return ERR_PTR(-ENOMEM);
>
> - mr->pages = kcalloc(max_num_sg, sizeof(u64), GFP_KERNEL);
> + mr->pages = kcalloc(max_num_sg, sizeof(*mr->pages), GFP_KERNEL);
> if (!mr->pages) {
> status = -ENOMEM;
> goto pl_err;
> --
> 2.12.2
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2017-04-23 7:33 UTC|newest]
Thread overview: 88+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <fc421509-4069-da8a-b308-60b49ea91ada@users.sourceforge.net>
2017-03-08 12:36 ` [PATCH 01/26] IB/ocrdma: Use kcalloc() in ocrdma_create_eqs() SF Markus Elfring
2017-03-08 12:41 ` [PATCH 02/26] IB/ocrdma: Use kcalloc() in ocrdma_mbx_alloc_pd_range() SF Markus Elfring
2017-03-08 14:03 ` Yuval Shaia
2017-04-20 20:40 ` Doug Ledford
2017-03-08 12:45 ` [PATCH 03/26] IB/ocrdma: Improve size determinations in ocrdma_mbx_get_dcbx_config() SF Markus Elfring
2017-03-08 13:54 ` Yuval Shaia
2017-03-08 14:46 ` Devesh Sharma
2017-03-08 12:48 ` [PATCH 04/26] IB/ocrdma: Delete unnecessary variable initialisations " SF Markus Elfring
2017-03-08 14:06 ` Yuval Shaia
2017-03-08 12:50 ` [PATCH 05/26] IB/ocrdma: Improve another size determination in ocrdma_mbx_query_qp() SF Markus Elfring
2017-03-08 14:07 ` Yuval Shaia
2017-03-08 12:53 ` [PATCH 06/26] IB/ocrdma: Improve another size determination in ocrdma_alloc_pd_pool() SF Markus Elfring
2017-03-08 12:55 ` [PATCH 07/26] IB/ocrdma: Improve another size determination in ocrdma_mbx_get_ctrl_attribs() SF Markus Elfring
2017-03-08 14:08 ` Yuval Shaia
2017-03-08 12:58 ` [PATCH 08/26] IB/ocrdma: Improve size determinations in ocrdma_mbx_rdma_stats() SF Markus Elfring
2017-03-08 14:20 ` Yuval Shaia
2017-03-08 13:00 ` [PATCH 09/26] IB/ocrdma: Improve another size determination in ocrdma_mq_cq_handler() SF Markus Elfring
2017-03-08 14:22 ` Yuval Shaia
2017-03-08 13:02 ` [PATCH 10/26] IB/ocrdma: Improve another size determination in ocrdma_init_emb_mqe() SF Markus Elfring
2017-03-08 14:22 ` Yuval Shaia
2017-03-08 14:42 ` Devesh Sharma
2017-03-08 13:04 ` [PATCH 11/26] IB/ocrdma: Delete unnecessary braces SF Markus Elfring
2017-03-08 14:24 ` Yuval Shaia
2017-03-08 14:59 ` Devesh Sharma
2017-03-08 13:07 ` [PATCH 12/26] IB/ocrdma: Adjust ten checks for null pointers SF Markus Elfring
2017-03-08 14:27 ` Yuval Shaia
2017-03-08 13:09 ` [PATCH 13/26] IB/ocrdma: Use kcalloc() in ocrdma_alloc_resources() SF Markus Elfring
2017-03-08 13:10 ` [PATCH 14/26] IB/ocrdma: Improve another size determination in ocrdma_add() SF Markus Elfring
2017-03-08 14:27 ` Yuval Shaia
2017-03-08 13:13 ` [PATCH 15/26] IB/ocrdma: Delete an error message for a failed memory allocation " SF Markus Elfring
2017-03-08 15:03 ` Devesh Sharma
2017-03-08 15:26 ` Yuval Shaia
2017-03-08 13:15 ` [PATCH 16/26] IB/ocrdma: Adjust a null pointer check in ocrdma_alloc_resources() SF Markus Elfring
2017-03-08 15:03 ` Devesh Sharma
2017-03-09 11:42 ` Yuval Shaia
2017-03-08 13:17 ` [PATCH 17/26] IB/ocrdma: Use kmalloc_array() in ocrdma_create_srq() SF Markus Elfring
2017-03-08 15:05 ` Devesh Sharma
2017-03-08 13:19 ` [PATCH 18/26] IB/ocrdma: Use kcalloc() in three functions SF Markus Elfring
2017-03-08 15:10 ` Devesh Sharma
2017-03-08 13:20 ` [PATCH 19/26] IB/ocrdma: Improve another size determination in ocrdma_alloc_mr() SF Markus Elfring
2017-03-08 15:07 ` Devesh Sharma
2017-03-09 12:03 ` Yuval Shaia
2017-03-08 13:22 ` [PATCH 20/26] IB/ocrdma: Delete an unnecessary variable assignment " SF Markus Elfring
2017-03-08 15:13 ` Devesh Sharma
2017-03-09 11:59 ` Yuval Shaia
2017-03-08 13:24 ` [PATCH 21/26] IB/ocrdma: Improve another size determination in ocrdma_create_srq() SF Markus Elfring
2017-03-08 15:15 ` Devesh Sharma
2017-03-09 11:46 ` Yuval Shaia
2017-03-08 13:26 ` [PATCH 22/26] IB/ocrdma: Returning only value constants in ocrdma_resize_cq() SF Markus Elfring
2017-03-08 15:16 ` Devesh Sharma
2017-03-09 12:01 ` Yuval Shaia
2017-03-08 13:28 ` [PATCH 23/26] IB/ocrdma: Delete an unnecessary variable in ocrdma_dealloc_pd() SF Markus Elfring
2017-03-08 15:16 ` Devesh Sharma
2017-03-09 11:57 ` Yuval Shaia
2017-03-08 13:30 ` [PATCH 24/26] IB/ocrdma: One jump label less in ocrdma_alloc_ucontext_pd() SF Markus Elfring
2017-03-08 15:17 ` Devesh Sharma
2017-03-09 11:55 ` Yuval Shaia
2017-03-08 13:32 ` [PATCH 25/26] IB/ocrdma: Delete unnecessary braces SF Markus Elfring
2017-03-09 11:50 ` Yuval Shaia
2017-03-08 13:34 ` [PATCH 26/26] IB/ocrdma: Adjust further ten checks for null pointers SF Markus Elfring
2017-03-08 15:18 ` Devesh Sharma
2017-03-09 11:43 ` Yuval Shaia
[not found] ` <1492720999.3041.18.camel@redhat.com>
2017-04-22 14:26 ` [PATCH v2 00/12] InfiniBand-OCRDMA: Fine-tuning for several function implementations SF Markus Elfring
2017-04-22 14:30 ` [PATCH v2 01/12] IB/ocrdma: Use kcalloc() in ocrdma_mbx_alloc_pd_range() SF Markus Elfring
2017-04-24 16:27 ` Devesh Sharma
2017-04-25 17:02 ` Doug Ledford
2017-08-08 17:26 ` [v2 " SF Markus Elfring
2017-08-09 6:43 ` Leon Romanovsky
2017-04-22 14:33 ` [PATCH v2 02/12] IB/ocrdma: Use kcalloc() in five functions SF Markus Elfring
2017-04-22 14:36 ` [PATCH v2 03/12] IB/ocrdma: Improve size determinations in ten functions SF Markus Elfring
2017-04-23 7:33 ` Leon Romanovsky [this message]
2017-04-24 12:54 ` Dennis Dalessandro
2017-04-24 13:23 ` SF Markus Elfring
2017-04-24 14:33 ` Leon Romanovsky
2017-04-24 14:54 ` SF Markus Elfring
2017-04-24 16:38 ` [PATCH v2 03/12] " Doug Ledford
2017-04-24 18:02 ` Leon Romanovsky
2017-04-24 16:38 ` Doug Ledford
2017-04-22 14:40 ` [PATCH v2 04/12] IB/ocrdma: Delete unnecessary variable initialisations in ocrdma_mbx_get_dcbx_config() SF Markus Elfring
2017-04-22 14:43 ` [PATCH v2 05/12] IB/ocrdma: Delete unnecessary braces SF Markus Elfring
2017-04-22 14:45 ` [PATCH v2 06/12] IB/ocrdma: Use kmalloc_array() in ocrdma_create_srq() SF Markus Elfring
2017-04-22 14:47 ` [PATCH v2 07/12] IB/ocrdma: Adjust 21 checks for null pointers SF Markus Elfring
2017-04-23 6:07 ` Leon Romanovsky
2017-04-22 14:48 ` [PATCH v2 08/12] IB/ocrdma: Delete an error message for a failed memory allocation in ocrdma_add() SF Markus Elfring
2017-04-22 14:49 ` [PATCH v2 09/12] IB/ocrdma: Delete an unnecessary variable assignment in ocrdma_alloc_mr() SF Markus Elfring
2017-04-22 14:50 ` [PATCH v2 10/12] IB/ocrdma: Returning only value constants in ocrdma_resize_cq() SF Markus Elfring
2017-04-22 14:51 ` [PATCH v2 11/12] IB/ocrdma: Delete an unnecessary variable in ocrdma_dealloc_pd() SF Markus Elfring
2017-04-22 14:54 ` [PATCH v2 12/12] IB/ocrdma: One jump label less in ocrdma_alloc_ucontext_pd() SF Markus Elfring
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=20170423073311.GA14088@mtr-leonro.local \
--to=leon@kernel.org \
--cc=devesh.sharma@avagotech.com \
--cc=dledford@redhat.com \
--cc=elfring@users.sourceforge.net \
--cc=hal.rosenstock@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=sean.hefty@intel.com \
--cc=selvin.xavier@avagotech.com \
--cc=yuval.shaia@oracle.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
Powered by JetHome