InfiniBand-OCRDMA: Fine-tuning for several function implementations
Subsystems (3)
cover InfiniBand-OCRDMA: Fine-tuning for several function implementations
From: Markus Elfring <[email protected]>
Date: Wed, 8 Mar 2017 13:14:56 +0100
Several update suggestions were taken into account from static source code analysis.
Markus Elfring (26):
Use kcalloc() in ocrdma_create_eqs()
Use kcalloc() in ocrdma_mbx_alloc_pd_range()
Improve size determinations in ocrdma_mbx_get_dcbx_config() Delete unnecessary variable initialisations in ocrdma_mbx_get_dcbx_config() Improve another size determination in ocrdma_mbx_query_qp() Improve another size determination in ocrdma_alloc_pd_pool() Improve another size determination in ocrdma_mbx_get_ctrl_attribs() Improve size determinations in ocrdma_mbx_rdma_stats()
Improve another size determination in ocrdma_mq_cq_handler() Improve another size determination in ocrdma_init_emb_mqe() Delete unnecessary braces
Adjust ten checks for null pointers
Use kcalloc() in ocrdma_alloc_resources()
Improve another size determination in ocrdma_add()
Delete an error message for a failed memory allocation in ocrdma_add() Adjust a null pointer check in ocrdma_alloc_resources()
Use kmalloc_array() in ocrdma_create_srq()
Use kcalloc() in three functions
Improve another size determination in ocrdma_alloc_mr()
Delete an unnecessary variable assignment in ocrdma_alloc_mr() Improve another size determination in ocrdma_create_srq() Returning only value constants in ocrdma_resize_cq()
Delete an unnecessary variable in ocrdma_dealloc_pd()
One jump label less in ocrdma_alloc_ucontext_pd()
Delete unnecessary braces
Adjust further ten checks for null pointers
drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 88 ++++++++++----------- drivers/infiniband/hw/ocrdma/ocrdma_main.c | 19 +++-- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 118 ++++++++++++---------------- 3 files changed, 100 insertions(+), 125 deletions(-)
Signature · 6 lines
2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 1/26 IB/ocrdma: Use kcalloc() in ocrdma_create_eqs()
From: Markus Elfring <[email protected]>
Date: Tue, 7 Mar 2017 17:56:45 +0100
* A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus reuse the corresponding function "kcalloc".
This issue was detected by using the Coccinelle software.
* Replace the specification of a data structure by a pointer dereference to make the corresponding size determination a bit safer according to the Linux coding style convention.
--- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +1 -1
@@ -3103,7 +3103,7 @@ static int ocrdma_create_eqs(struct ocrdma_dev *dev)if (!num_eq)return -EINVAL ; - dev->eq_tbl =kzalloc (sizeof (struct ocrdma_eq ) * num_eq,GFP_KERNEL ); + dev->eq_tbl =kcalloc (num_eq,sizeof (*dev->eq_tbl),GFP_KERNEL );if (!dev->eq_tbl)return -ENOMEM ;
Signature · 1 line
2.12.0
PATCH 2/26 IB/ocrdma: Use kcalloc() in ocrdma_mbx_alloc_pd_range()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 7 Mar 2017 18:23:54 +0100
* Multiplications for the size determination of memory allocations indicated that array data structures should be processed. Thus reuse the corresponding function "kcalloc".
This issue was detected by using the Coccinelle software.
* Delete the local variable "pd_bitmap_size" which became unnecessary with this refactoring.
--- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +8 -7
@@ -1505,7 +1505,6 @@ int ocrdma_mbx_dealloc_pd(struct ocrdma_dev *dev, struct ocrdma_pd *pd)static int ocrdma_mbx_alloc_pd_range (struct ocrdma_dev *dev) {int status = -ENOMEM ; -size_t pd_bitmap_size;struct ocrdma_alloc_pd_range *cmd;struct ocrdma_alloc_pd_range_rsp *rsp;
@@ -1527,10 +1526,10 @@ static int ocrdma_mbx_alloc_pd_range(struct ocrdma_dev *dev) dev->pd_mgr->pd_dpp_start = rsp->dpp_page_pdid &OCRDMA_ALLOC_PD_RNG_RSP_START_PDID_MASK ; dev->pd_mgr->max_dpp_pd = rsp->pd_count; - pd_bitmap_size -BITS_TO_LONGS (rsp->pd_count) *sizeof (long ); - dev->pd_mgr->pd_dpp_bitmap =kzalloc (pd_bitmap_size, -GFP_KERNEL ); + dev->pd_mgr->pd_dpp_bitmap + =kcalloc (BITS_TO_LONGS (rsp->pd_count), +sizeof (long ), +GFP_KERNEL ); }kfree (cmd); }
@@ -1546,9 +1545,10 @@ static int ocrdma_mbx_alloc_pd_range(struct ocrdma_dev *dev) dev->pd_mgr->pd_norm_start = rsp->dpp_page_pdid &OCRDMA_ALLOC_PD_RNG_RSP_START_PDID_MASK ; dev->pd_mgr->max_normal_pd = rsp->pd_count; - pd_bitmap_size =BITS_TO_LONGS (rsp->pd_count) *sizeof (long ); - dev->pd_mgr->pd_norm_bitmap =kzalloc (pd_bitmap_size, -GFP_KERNEL ); + dev->pd_mgr->pd_norm_bitmap + =kcalloc (BITS_TO_LONGS (rsp->pd_count), +sizeof (long ), +GFP_KERNEL ); }kfree (cmd);
Signature · 1 line
2.12.0
Re: [PATCH 02/26] IB/ocrdma: Use kcalloc() in ocrdma_mbx_alloc_pd_range()
Quoted 30 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 7 Mar 2017 18:23:54 +0100* Multiplications for the size determination of memory allocations indicated that array data structures should be processed. Thus reuse the corresponding function "kcalloc".
This issue was detected by using the Coccinelle software.
* Delete the local variable "
pd_bitmap_size" which became unnecessary with this refactoring.Signed-off-by Markus Elfring <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)drivers/infiniband/hw/ocrdma/ocrdma_hw.c +0
-1@@ -1505,7 +1505,6 @@ int ocrdma_mbx_dealloc_pd(struct ocrdma_dev *dev, struct ocrdma_pd *pd)static int ocrdma_mbx_alloc_pd_range (struct ocrdma_dev *dev) {int status = -ENOMEM ; -size_t pd_bitmap_size;struct ocrdma_alloc_pd_range *cmd;struct ocrdma_alloc_pd_range_rsp *rsp;
drivers/infiniband/hw/ocrdma/ocrdma_hw.c static int ocrdma_mbx_alloc_pd_range(struct ocrdma_dev *dev) · line 1532
Quoted 10 lines
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +4
-3@@ -1527,10 +1526,10 @@ static int ocrdma_mbx_alloc_pd_range(struct ocrdma_dev *dev) dev->pd_mgr->pd_dpp_start = rsp->dpp_page_pdid &OCRDMA_ALLOC_PD_RNG_RSP_START_PDID_MASK ; dev->pd_mgr->max_dpp_pd = rsp->pd_count; - pd_bitmap_size > -BITS_TO_LONGS (rsp->pd_count) *sizeof (long ); - dev->pd_mgr->pd_dpp_bitmap =kzalloc (pd_bitmap_size, -GFP_KERNEL ); + dev->pd_mgr->pd_dpp_bitmap + =kcalloc (BITS_TO_LONGS (rsp->pd_count), +sizeof (long ), +GFP_KERNEL );
kzalloc gives "clean" buffer.
Just making sure that it is fine with you if the array is not "clean". (looking at _ocrdma_pd_mgr_get_bitmap i think it should).
Quoted 24 lines
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +4
-3}kfree (cmd); }@@ -1546,9 +1545,10 @@ static int ocrdma_mbx_alloc_pd_range(struct ocrdma_dev *dev) dev->pd_mgr->pd_norm_start = rsp->dpp_page_pdid &OCRDMA_ALLOC_PD_RNG_RSP_START_PDID_MASK ; dev->pd_mgr->max_normal_pd = rsp->pd_count; - pd_bitmap_size =BITS_TO_LONGS (rsp->pd_count) *sizeof (long ); - dev->pd_mgr->pd_norm_bitmap =kzalloc (pd_bitmap_size, -GFP_KERNEL ); + dev->pd_mgr->pd_norm_bitmap + =kcalloc (BITS_TO_LONGS (rsp->pd_count), +sizeof (long ), +GFP_KERNEL ); }kfree (cmd);Signature · 6 lines
2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 02/26] IB/ocrdma: Use kcalloc() in ocrdma_mbx_alloc_pd_range()
Quoted 49 lines · Yuval Shaia
Quoted 48 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 7 Mar 2017 18:23:54 +0100* Multiplications for the size determination of memory allocations indicated that array data structures should be processed. Thus reuse the corresponding function "kcalloc".
This issue was detected by using the Coccinelle software.
* Delete the local variable "
pd_bitmap_size" which became unnecessary with
this refactoring.Signed-off-by Markus Elfring <[email protected]>---
drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 16 ++++++++--------1 file changed, 8 insertions(+), 8 deletions(-)drivers/infiniband/hw/ocrdma/ocrdma_hw.c +0
-1@@ -1505,7 +1505,6 @@ int ocrdma_mbx_dealloc_pd(struct ocrdma_dev *dev, struct ocrdma_pd *pd) static int ocrdma_mbx_alloc_pd_range(struct ocrdma_dev *dev) { int status = -ENOMEM; -size_t pd_bitmap_size; struct ocrdma_alloc_pd_range *cmd; struct ocrdma_alloc_pd_range_rsp *rsp;drivers/infiniband/hw/ocrdma/ocrdma_hw.c +0
-0@@ -1527,10 +1526,10 @@ static int ocrdma_mbx_alloc_pd_range(struct ocrdma_dev *dev)
dev->pd_mgr->pd_dpp_start= rsp-Quoted 1 line
dpp_page_pdid&
OCRDMA_ALLOC_PD_RNG_RSP_START_PDID_MASK;
dev->pd_mgr->max_dpp_pd=rsp->pd_count;drivers/infiniband/hw/ocrdma/ocrdma_hw.c +0
-1- pd_bitmap_size > > - BITS_TO_LONGS(rsp->pd_count) *sizeof(long);
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +0
-2- dev->pd_mgr->pd_dpp_bitmap > > kzalloc(pd_bitmap_size, - GFP_KERNEL);
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +2
-0+ dev->pd_mgr->pd_dpp_bitmap + = kcalloc(BITS_TO_LONGS(rsp-Quoted 1 line
pd_count),
Quoted 9 lines
Quoted 4 lines
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +1
-0+ sizeof(long),
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +1
-0+GFP_KERNEL );
kzalloc gives "clean" buffer.
Just making sure that it is fine with you if the array is not "clean".
(looking at_ocrdma_pd_mgr_get_bitmapi think it should).
kcalloc is documented to return memory set to 0.
Quoted 29 lines
Quoted 29 lines
}
kfree(cmd);
}drivers/infiniband/hw/ocrdma/ocrdma_hw.c +0
-0@@ -1546,9 +1545,10 @@ static int ocrdma_mbx_alloc_pd_range(struct ocrdma_dev *dev)
dev->pd_mgr->pd_norm_start=rsp->dpp_page_pdid&OCRDMA_ALLOC_PD_RNG_RSP_START_PDID_MASK;
dev->pd_mgr->max_normal_pd=rsp->pd_count;drivers/infiniband/hw/ocrdma/ocrdma_hw.c +0
-1- pd_bitmap_size = BITS_TO_LONGS(rsp->pd_count) *sizeof(long);
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +4
-2- dev->pd_mgr->pd_norm_bitmap > > kzalloc(pd_bitmap_size, - GFP_KERNEL); + dev->pd_mgr->pd_norm_bitmap + =kcalloc (BITS_TO_LONGS (rsp->pd_count), +sizeof (long ), +GFP_KERNEL );}
kfree(cmd);
--
2.12.0--
To unsubscribe from this list: send the line "unsubscribe linux- rdma" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 4 lines
Doug Ledford <[email protected]> GPG KeyID: B826A3330E572FDD Key fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD
PATCH 3/26 IB/ocrdma: Improve size determinations in ocrdma_mbx_get_dcbx_config()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 7 Mar 2017 19:09:20 +0100
Replace the specification of data structures by references for variables as the parameter for the operator "sizeof" to make the corresponding size determinations a bit safer according to the Linux coding style convention.
--- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +5 -8
@@ -2901,9 +2901,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 +2914,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 +2924,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:
Signature · 1 line
2.12.0
Re: [PATCH 03/26] IB/ocrdma: Improve size determinations in ocrdma_mbx_get_dcbx_config()
Quoted 40 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 7 Mar 2017 19:09:20 +0100Replace the specification of data structures by references for variables 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 <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)drivers/infiniband/hw/ocrdma/ocrdma_hw.c +3
-5@@ -2901,9 +2901,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 +2914,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 +2924,8 @@ static int ocrdma_mbx_get_dcbx_config(struct ocrdma_dev *dev, u32 ptype, goto mbx_err;
drivers/infiniband/hw/ocrdma/ocrdma_hw.c static int ocrdma_mbx_get_dcbx_config(struct ocrdma_dev *dev, u32 ptype, · line 2931
Quoted 10 lines
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +2
-3rsp = (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:
Quoted 7 lines
Signature · 6 lines
2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Devesh Sharma
Acked-byRe: [PATCH 03/26] IB/ocrdma: Improve size determinations in ocrdma_mbx_get_dcbx_config()
Quoted 61 lines · Yuval Shaia
Quoted 40 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 7 Mar 2017 19:09:20 +0100Replace the specification of data structures by references for variables 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 <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)drivers/infiniband/hw/ocrdma/ocrdma_hw.c +3
-5@@ -2901,9 +2901,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 +2914,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 +2924,8 @@ static int ocrdma_mbx_get_dcbx_config(struct ocrdma_dev *dev, u32 ptype, goto mbx_err;drivers/infiniband/hw/ocrdma/ocrdma_hw.c static int ocrdma_mbx_get_dcbx_config(struct ocrdma_dev *dev, u32 ptype, · line 2931
Quoted 10 lines
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +2
-3rsp = (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:Reviewed-by Yuval Shaia <[email protected]>Quoted 7 lines
--
2.12.0--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 4/26 IB/ocrdma: Delete unnecessary variable initialisations in ocrdma_mbx_get_dcbx_config()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 7 Mar 2017 19:25:55 +0100
The local variables "req" and "rsp" will be set to appropriate pointers a bit later. Thus omit the explicit initialisations at the beginning.
--- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +2 -3
@@ -2895,9 +2895,8 @@ static int ocrdma_mbx_get_dcbx_config(struct ocrdma_dev *dev, u32 ptype,int status;dma_addr_t pa;struct ocrdma_mqe cmd; - -struct ocrdma_get_dcbx_cfg_req *req =NULL ; -struct ocrdma_get_dcbx_cfg_rsp *rsp =NULL ; +struct ocrdma_get_dcbx_cfg_req *req; +struct ocrdma_get_dcbx_cfg_rsp *rsp;struct pci_dev *pdev = dev->nic_info.pdev;struct ocrdma_mqe_sge *mqe_sge = cmd.u.nonemb_req.sge;
Signature · 1 line
2.12.0
Re: [PATCH 04/26] IB/ocrdma: Delete unnecessary variable initialisations in ocrdma_mbx_get_dcbx_config()
Quoted 16 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 7 Mar 2017 19:25:55 +0100The local variables "req" and "rsp" will be set to appropriate pointers a bit later. Thus omit the explicit initialisations at the beginning.
Signed-off-by Markus Elfring <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/infiniband/hw/ocrdma/ocrdma_hw.c +0
-0
drivers/infiniband/hw/ocrdma/ocrdma_hw.c static int ocrdma_mbx_get_dcbx_config(struct ocrdma_dev *dev, u32 ptype, · line 2899
Quoted 8 lines
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +2
-3@@ -2895,9 +2895,8 @@ static int ocrdma_mbx_get_dcbx_config(struct ocrdma_dev *dev, u32 ptype,int status;dma_addr_t pa;struct ocrdma_mqe cmd; - -struct ocrdma_get_dcbx_cfg_req *req =NULL ; -struct ocrdma_get_dcbx_cfg_rsp *rsp =NULL ; +struct ocrdma_get_dcbx_cfg_req *req; +struct ocrdma_get_dcbx_cfg_rsp *rsp;
Quoted 10 lines
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +0
-0struct pci_dev *pdev = dev->nic_info.pdev;struct ocrdma_mqe_sge *mqe_sge = cmd.u.nonemb_req.sge;Signature · 6 lines
2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 5/26 IB/ocrdma: Improve another size determination in ocrdma_mbx_query_qp()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 7 Mar 2017 19:40:31 +0100
Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.
--- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +1 -1
@@ -2487,7 +2487,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;
Signature · 1 line
2.12.0
Re: [PATCH 05/26] IB/ocrdma: Improve another size determination in ocrdma_mbx_query_qp()
Quoted 18 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 7 Mar 2017 19:40:31 +0100Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.
Signed-off-by Markus Elfring <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/infiniband/hw/ocrdma/ocrdma_hw.c +0
-0
drivers/infiniband/hw/ocrdma/ocrdma_hw.c int ocrdma_mbx_query_qp(struct ocrdma_dev *dev, struct ocrdma_qp *qp, · line 2493
Quoted 8 lines
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +1
-1@@ -2487,7 +2487,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;
Quoted 6 lines
2.12.0
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 6/26 IB/ocrdma: Improve another size determination in ocrdma_alloc_pd_pool()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 7 Mar 2017 19:54:38 +0100
Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.
--- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +1 -2
@@ -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 ;
Signature · 1 line
2.12.0
PATCH 7/26 IB/ocrdma: Improve another size determination in ocrdma_mbx_get_ctrl_attribs()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 7 Mar 2017 20:07:25 +0100
Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.
--- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +1 -1
@@ -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;
Signature · 1 line
2.12.0
Re: [PATCH 07/26] IB/ocrdma: Improve another size determination in ocrdma_mbx_get_ctrl_attribs()
Quoted 17 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 7 Mar 2017 20:07:25 +0100Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.
Signed-off-by Markus Elfring <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/infiniband/hw/ocrdma/ocrdma_hw.c +0
-0
drivers/infiniband/hw/ocrdma/ocrdma_hw.c static int ocrdma_mbx_get_ctrl_attribs(struct ocrdma_dev *dev) · line 1337
Quoted 8 lines
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +1
-1@@ -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;
Quoted 7 lines
Signature · 6 lines
2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 8/26 IB/ocrdma: Improve size determinations in ocrdma_mbx_rdma_stats()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 7 Mar 2017 20:16:16 +0100
Replace the specification of two data structures 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.
--- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +2 -2
@@ -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);
Signature · 1 line
2.12.0
Re: [PATCH 08/26] IB/ocrdma: Improve size determinations in ocrdma_mbx_rdma_stats()
Quoted 17 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 7 Mar 2017 20:16:16 +0100Replace the specification of two data structures 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 <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/infiniband/hw/ocrdma/ocrdma_hw.c +0
-0
drivers/infiniband/hw/ocrdma/ocrdma_hw.c int ocrdma_mbx_rdma_stats(struct ocrdma_dev *dev, bool reset) · line 1305
Quoted 5 lines
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +1
-1@@ -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));
Isn't sizeof(req) smaller than sizeof(*old_stats)?
drivers/infiniband/hw/ocrdma/ocrdma_hw.c int ocrdma_mbx_rdma_stats(struct ocrdma_dev *dev, bool reset) · line 1318
Quoted 9 lines
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +1
-1memset (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));
Fix itself looks fine but original code seems strange and makes me anxious since resp is (much) bigger than req.
Quoted 10 lines
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +0
-0else ocrdma_le32_to_cpu (req, dev->stats_mem.size);Signature · 6 lines
2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 9/26 IB/ocrdma: Improve another size determination in ocrdma_mq_cq_handler()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 7 Mar 2017 20:20:45 +0100
Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.
--- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +1 -1
@@ -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);
Signature · 1 line
2.12.0
Re: [PATCH 09/26] IB/ocrdma: Improve another size determination in ocrdma_mq_cq_handler()
Quoted 17 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 7 Mar 2017 20:20:45 +0100Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.
Signed-off-by Markus Elfring <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/infiniband/hw/ocrdma/ocrdma_hw.c +0
-0
drivers/infiniband/hw/ocrdma/ocrdma_hw.c static int ocrdma_mq_cq_handler(struct ocrdma_dev *dev, u16 cq_id) · line 895
Quoted 7 lines
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +1
-1@@ -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); }
Quoted 8 lines
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +0
-0ocrdma_ring_cq_db (dev, dev->mq.cq.id, true, false, cqe_popped);Signature · 6 lines
2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 10/26 IB/ocrdma: Improve another size determination in ocrdma_init_emb_mqe()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 7 Mar 2017 20:33:29 +0100
Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.
--- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +1 -1
@@ -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 |--
2.12.0
Re: [PATCH 10/26] IB/ocrdma: Improve another size determination in ocrdma_init_emb_mqe()
Quoted 17 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 7 Mar 2017 20:33:29 +0100Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.
Signed-off-by Markus Elfring <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/infiniband/hw/ocrdma/ocrdma_hw.c +0
-0
drivers/infiniband/hw/ocrdma/ocrdma_hw.c static void *ocrdma_init_emb_mqe(u8 opcode, u32 cmd_len) · line 358
Quoted 8 lines
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +1
-1@@ -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 |
Quoted 7 lines
Signature · 6 lines
2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Devesh Sharma
Acked-byRe: [PATCH 10/26] IB/ocrdma: Improve another size determination in ocrdma_init_emb_mqe()
Quoted 36 lines · Yuval Shaia
Quoted 17 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 7 Mar 2017 20:33:29 +0100Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.
Signed-off-by Markus Elfring <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/infiniband/hw/ocrdma/ocrdma_hw.c +0
-0drivers/infiniband/hw/ocrdma/ocrdma_hw.c static void *ocrdma_init_emb_mqe(u8 opcode, u32 cmd_len) · line 358
Quoted 8 lines
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +1
-1@@ -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 |=Reviewed-by Yuval Shaia <[email protected]>Quoted 7 lines
--
2.12.0--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 11/26 IB/ocrdma: Delete unnecessary braces
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 7 Mar 2017 21:12:56 +0100
Do not use curly brackets at some source code places where a single statement should be sufficient.
--- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +8 -9
@@ -1092,14 +1092,14 @@ static int ocrdma_mbx_cmd(struct ocrdma_dev *dev, struct ocrdma_mqe *mqe)if (cqe_status || ext_status) {pr_err ("%s() cqe_status=0x%x, ext_status=0x%x," , __func__, cqe_status, ext_status); -if (rsp) { +if (rsp)/* This is for embedded cmds. */ pr_err ("opcode=0x%x, subsystem=0x%x\n" , (rsp->subsys_op &OCRDMA_MBX_RSP_OPCODE_MASK ) >>OCRDMA_MBX_RSP_OPCODE_SHIFT , (rsp->subsys_op &OCRDMA_MBX_RSP_SUBSYS_MASK ) >>OCRDMA_MBX_RSP_SUBSYS_SHIFT ); - } + status =ocrdma_get_mbx_cqe_errno (cqe_status); goto mbx_err; }
@@ -1600,10 +1600,9 @@ void ocrdma_alloc_pd_pool(struct ocrdma_dev *dev)return ; status =ocrdma_mbx_alloc_pd_range (dev); -if (status) { +if (status)pr_err ("%s(%d) Unable to initialize PD pool, using default.\n" , __func__, dev->id); - } }static void ocrdma_free_pd_pool (struct ocrdma_dev *dev)
@@ -2997,11 +2996,10 @@ static int ocrdma_parse_dcbxcfg_rsp(struct ocrdma_dev *dev, int ptype, goto out; } } -if (slindx =OCRDMA_MAX_SERVICE_LEVEL_INDEX ) { +if (slindx =OCRDMA_MAX_SERVICE_LEVEL_INDEX )pr_info ("%s ocrdma%d application priority not set for 0x%x protocol\n" ,dev_name (&dev->nic_info.pdev->dev), dev->id, proto); - } } }
@@ -3158,16 +3156,17 @@ static int ocrdma_modify_eqd(struct ocrdma_dev *dev, struct ocrdma_eq *eq, int num) {int num_eqs, i =0 ; -if (num >8 ) { + +if (num >8 )while (num) { num_eqs =min (num,8 );ocrdma_mbx_modify_eqd (dev, &eq[i], num_eqs); i += num_eqs; num -= num_eqs; } - }else { +else ocrdma_mbx_modify_eqd (dev, eq, num); - } +return 0 ; }
Signature · 1 line
2.12.0
Re: [PATCH 11/26] IB/ocrdma: Delete unnecessary braces
Quoted 19 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 7 Mar 2017 21:12:56 +0100Do not use curly brackets at some source code places where a single statement should be sufficient.
Signed-off-by Markus Elfring <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)drivers/infiniband/hw/ocrdma/ocrdma_hw.c +0
-0@@ -1092,14 +1092,14 @@ static int ocrdma_mbx_cmd(struct ocrdma_dev *dev, struct ocrdma_mqe *mqe)if (cqe_status || ext_status) {pr_err ("%s() cqe_status=0x%x, ext_status=0x%x," , __func__, cqe_status, ext_status);
drivers/infiniband/hw/ocrdma/ocrdma_hw.c static int ocrdma_mbx_cmd(struct ocrdma_dev *dev, struct ocrdma_mqe *mqe) · line 1102
Quoted 10 lines
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +2
-2-if (rsp) { +if (rsp)/* This is for embedded cmds. */ pr_err ("opcode=0x%x, subsystem=0x%x\n" , (rsp->subsys_op &OCRDMA_MBX_RSP_OPCODE_MASK ) >>OCRDMA_MBX_RSP_OPCODE_SHIFT , (rsp->subsys_op &OCRDMA_MBX_RSP_SUBSYS_MASK ) >>OCRDMA_MBX_RSP_SUBSYS_SHIFT ); - } +
Quoted 56 lines
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +6
-7status =ocrdma_get_mbx_cqe_errno (cqe_status); goto mbx_err; }@@ -1600,10 +1600,9 @@ void ocrdma_alloc_pd_pool(struct ocrdma_dev *dev)return ; status =ocrdma_mbx_alloc_pd_range (dev); -if (status) { +if (status)pr_err ("%s(%d) Unable to initialize PD pool, using default.\n" , __func__, dev->id); - } }static void ocrdma_free_pd_pool (struct ocrdma_dev *dev)@@ -2997,11 +2996,10 @@ static int ocrdma_parse_dcbxcfg_rsp(struct ocrdma_dev *dev, int ptype, goto out; } } -if (slindx =OCRDMA_MAX_SERVICE_LEVEL_INDEX ) { +if (slindx =OCRDMA_MAX_SERVICE_LEVEL_INDEX )pr_info ("%s ocrdma%d application priority not set for 0x%x protocol\n" ,dev_name (&dev->nic_info.pdev->dev), dev->id, proto); - } } }@@ -3158,16 +3156,17 @@ static int ocrdma_modify_eqd(struct ocrdma_dev *dev, struct ocrdma_eq *eq, int num) {int num_eqs, i =0 ; -if (num >8 ) { + +if (num >8 )while (num) { num_eqs =min (num,8 );ocrdma_mbx_modify_eqd (dev, &eq[i], num_eqs); i += num_eqs; num -= num_eqs; } - }else { +else ocrdma_mbx_modify_eqd (dev, eq, num); - } +return 0 ; }Signature · 6 lines
2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 11/26] IB/ocrdma: Delete unnecessary braces
In reply to SF Markus ElfringQuoted 60 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 7 Mar 2017 21:12:56 +0100Do not use curly brackets at some source code places where a single statement should be sufficient.
Signed-off-by Markus Elfring <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)drivers/infiniband/hw/ocrdma/ocrdma_hw.c +4
-6@@ -1092,14 +1092,14 @@ static int ocrdma_mbx_cmd(struct ocrdma_dev *dev, struct ocrdma_mqe *mqe)if (cqe_status || ext_status) {pr_err ("%s() cqe_status=0x%x, ext_status=0x%x," , __func__, cqe_status, ext_status); -if (rsp) { +if (rsp)/* This is for embedded cmds. */ pr_err ("opcode=0x%x, subsystem=0x%x\n" , (rsp->subsys_op &OCRDMA_MBX_RSP_OPCODE_MASK ) >>OCRDMA_MBX_RSP_OPCODE_SHIFT , (rsp->subsys_op &OCRDMA_MBX_RSP_SUBSYS_MASK ) >>OCRDMA_MBX_RSP_SUBSYS_SHIFT ); - } + status =ocrdma_get_mbx_cqe_errno (cqe_status); goto mbx_err; }@@ -1600,10 +1600,9 @@ void ocrdma_alloc_pd_pool(struct ocrdma_dev *dev)return ; status =ocrdma_mbx_alloc_pd_range (dev); -if (status) { +if (status)pr_err ("%s(%d) Unable to initialize PD pool, using default.\n" , __func__, dev->id); - } }static void ocrdma_free_pd_pool (struct ocrdma_dev *dev)@@ -2997,11 +2996,10 @@ static int ocrdma_parse_dcbxcfg_rsp(struct ocrdma_dev *dev, int ptype, goto out; } } -if (slindx ==OCRDMA_MAX_SERVICE_LEVEL_INDEX ) { +if (slindx ==OCRDMA_MAX_SERVICE_LEVEL_INDEX )pr_info ("%s ocrdma%d application priority not set for 0x%x protocol\n" ,dev_name (&dev->nic_info.pdev->dev), dev->id, proto); - } } }@@ -3158,16 +3156,17 @@ static int ocrdma_modify_eqd(struct ocrdma_dev *dev, struct ocrdma_eq *eq, int num) {
drivers/infiniband/hw/ocrdma/ocrdma_hw.c static int ocrdma_modify_eqd(struct ocrdma_dev *dev, struct ocrdma_eq *eq, · line 3166
Quoted 10 lines
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +2
-1int num_eqs, i =0 ; -if (num >8 ) { + +if (num >8 )while (num) { num_eqs =min (num,8 );ocrdma_mbx_modify_eqd (dev, &eq[i], num_eqs); i += num_eqs; num -= num_eqs; }
May be compiler would give you a warning here, could you check once?
Quoted 11 lines
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +2
-3- }else { +else ocrdma_mbx_modify_eqd (dev, eq, num); - } +return 0 ; } --2.12.0
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 12/26 IB/ocrdma: Adjust ten checks for null pointers
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 7 Mar 2017 21:32:22 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The script “checkpatch.pl“ pointed information out like the following.
Comparison to NULL could be written !…
Thus fix the affected source code places.
--- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +10 -10
@@ -665,7 +665,7 @@ static void ocrdma_process_qpcat_error(struct ocrdma_dev *dev,enum ib_qp_state new_ib_qps =IB_QPS_ERR ;enum ib_qp_state old_ib_qps; -if (qp =NULL ) +if (!qp)BUG ();ocrdma_qp_state_change (qp, new_ib_qps, &old_ib_qps); }
@@ -693,7 +693,7 @@ static void ocrdma_dispatch_ibevent(struct ocrdma_dev *dev,if (cqe->qpvalid_qpid &OCRDMA_AE_MCQE_QPVALID ) {if (qpid < dev->attr.max_qp) qp = dev->qp_tbl[qpid]; -if (qp =NULL ) { +if (!qp) {pr_err ("ocrdma%d:Async event - qpid %u is not valid\n" , dev->id, qpid);return ;
@@ -703,7 +703,7 @@ static void ocrdma_dispatch_ibevent(struct ocrdma_dev *dev,if (cqe->cqvalid_cqid &OCRDMA_AE_MCQE_CQVALID ) {if (cqid < dev->attr.max_cq) cq = dev->cq_tbl[cqid]; -if (cq =NULL ) { +if (!cq) {pr_err ("ocrdma%d:Async event - cqid %u is not valid\n" , dev->id, cqid);return ;
@@ -882,7 +882,7 @@ static int ocrdma_mq_cq_handler(struct ocrdma_dev *dev, u16 cq_id)while (1 ) { cqe =ocrdma_get_mcqe (dev); -if (cqe =NULL ) +if (!cqe)break ;ocrdma_le32_to_cpu (cqe,sizeof (*cqe)); cqe_popped +=1 ;
@@ -948,7 +948,7 @@ static void ocrdma_qp_buddy_cq_handler(struct ocrdma_dev *dev,* false - Check for RQ CQ */ bcq =_ocrdma_qp_buddy_cq_handler (dev, cq, true); -if (bcq =NULL ) +if (!bcq) bcq =_ocrdma_qp_buddy_cq_handler (dev, cq, false);spin_unlock_irqrestore (&dev->flush_q_lock, flags);
@@ -969,7 +969,7 @@ static void ocrdma_qp_cq_handler(struct ocrdma_dev *dev, u16 cq_idx)BUG (); cq = dev->cq_tbl[cq_idx]; -if (cq =NULL ) +if (!cq)return ;if (cq->ibcq.comp_handler) {
@@ -1289,7 +1289,7 @@ int ocrdma_mbx_rdma_stats(struct ocrdma_dev *dev, bool reset)int status; old_stats =kmalloc (sizeof (*old_stats),GFP_KERNEL ); -if (old_stats =NULL ) +if (!old_stats)return -ENOMEM ;memset (mqe,0 ,sizeof (*mqe));
@@ -1676,12 +1676,12 @@ static int ocrdma_mbx_create_ah_tbl(struct ocrdma_dev *dev) dev->av_tbl.pbl.va =dma_alloc_coherent (&pdev->dev,PAGE_SIZE , &dev->av_tbl.pbl.pa,GFP_KERNEL ); -if (dev->av_tbl.pbl.va =NULL ) +if (!dev->av_tbl.pbl.va) goto mem_err; dev->av_tbl.va =dma_alloc_coherent (&pdev->dev, dev->av_tbl.size, &pa,GFP_KERNEL ); -if (dev->av_tbl.va =NULL ) +if (!dev->av_tbl.va) goto mem_err_ah; dev->av_tbl.pa = pa; dev->av_tbl.num_ah = max_ah;
@@ -1722,7 +1722,7 @@ static void ocrdma_mbx_delete_ah_tbl(struct ocrdma_dev *dev)struct ocrdma_delete_ah_tbl *cmd;struct pci_dev *pdev = dev->nic_info.pdev; -if (dev->av_tbl.va =NULL ) +if (!dev->av_tbl.va)return ; cmd =ocrdma_init_emb_mqe (OCRDMA_CMD_DELETE_AH_TBL ,sizeof (*cmd));
Signature · 1 line
2.12.0
Re: [PATCH 12/26] IB/ocrdma: Adjust ten checks for null pointers
Quoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 7 Mar 2017 21:32:22 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bitThe script “checkpatch.pl“ pointed information out like the following.
Comparison to NULL could be written !…
Good to know.
Quoted 2 lines
Thus fix the affected source code places.
Above line can be removed.
Quoted 104 lines
Signed-off-by Markus Elfring <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)drivers/infiniband/hw/ocrdma/ocrdma_hw.c +10
-10@@ -665,7 +665,7 @@ static void ocrdma_process_qpcat_error(struct ocrdma_dev *dev,enum ib_qp_state new_ib_qps =IB_QPS_ERR ;enum ib_qp_state old_ib_qps; -if (qp =NULL ) +if (!qp)BUG ();ocrdma_qp_state_change (qp, new_ib_qps, &old_ib_qps); }@@ -693,7 +693,7 @@ static void ocrdma_dispatch_ibevent(struct ocrdma_dev *dev,if (cqe->qpvalid_qpid &OCRDMA_AE_MCQE_QPVALID ) {if (qpid < dev->attr.max_qp) qp = dev->qp_tbl[qpid]; -if (qp =NULL ) { +if (!qp) {pr_err ("ocrdma%d:Async event - qpid %u is not valid\n" , dev->id, qpid);return ;@@ -703,7 +703,7 @@ static void ocrdma_dispatch_ibevent(struct ocrdma_dev *dev,if (cqe->cqvalid_cqid &OCRDMA_AE_MCQE_CQVALID ) {if (cqid < dev->attr.max_cq) cq = dev->cq_tbl[cqid]; -if (cq =NULL ) { +if (!cq) {pr_err ("ocrdma%d:Async event - cqid %u is not valid\n" , dev->id, cqid);return ;@@ -882,7 +882,7 @@ static int ocrdma_mq_cq_handler(struct ocrdma_dev *dev, u16 cq_id)while (1 ) { cqe =ocrdma_get_mcqe (dev); -if (cqe =NULL ) +if (!cqe)break ;ocrdma_le32_to_cpu (cqe,sizeof (*cqe)); cqe_popped +=1 ;@@ -948,7 +948,7 @@ static void ocrdma_qp_buddy_cq_handler(struct ocrdma_dev *dev,* false - Check for RQ CQ */ bcq =_ocrdma_qp_buddy_cq_handler (dev, cq, true); -if (bcq =NULL ) +if (!bcq) bcq =_ocrdma_qp_buddy_cq_handler (dev, cq, false);spin_unlock_irqrestore (&dev->flush_q_lock, flags);@@ -969,7 +969,7 @@ static void ocrdma_qp_cq_handler(struct ocrdma_dev *dev, u16 cq_idx)BUG (); cq = dev->cq_tbl[cq_idx]; -if (cq =NULL ) +if (!cq)return ;if (cq->ibcq.comp_handler) {@@ -1289,7 +1289,7 @@ int ocrdma_mbx_rdma_stats(struct ocrdma_dev *dev, bool reset)int status; old_stats =kmalloc (sizeof (*old_stats),GFP_KERNEL ); -if (old_stats =NULL ) +if (!old_stats)return -ENOMEM ;memset (mqe,0 ,sizeof (*mqe));@@ -1676,12 +1676,12 @@ static int ocrdma_mbx_create_ah_tbl(struct ocrdma_dev *dev) dev->av_tbl.pbl.va =dma_alloc_coherent (&pdev->dev,PAGE_SIZE , &dev->av_tbl.pbl.pa,GFP_KERNEL ); -if (dev->av_tbl.pbl.va =NULL ) +if (!dev->av_tbl.pbl.va) goto mem_err; dev->av_tbl.va =dma_alloc_coherent (&pdev->dev, dev->av_tbl.size, &pa,GFP_KERNEL ); -if (dev->av_tbl.va =NULL ) +if (!dev->av_tbl.va) goto mem_err_ah; dev->av_tbl.pa = pa; dev->av_tbl.num_ah = max_ah;@@ -1722,7 +1722,7 @@ static void ocrdma_mbx_delete_ah_tbl(struct ocrdma_dev *dev)struct ocrdma_delete_ah_tbl *cmd;struct pci_dev *pdev = dev->nic_info.pdev; -if (dev->av_tbl.va =NULL ) +if (!dev->av_tbl.va)return ; cmd =ocrdma_init_emb_mqe (OCRDMA_CMD_DELETE_AH_TBL ,sizeof (*cmd));Signature · 6 lines
2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 13/26 IB/ocrdma: Use kcalloc() in ocrdma_alloc_resources()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 7 Mar 2017 21:55:42 +0100
* Multiplications for the size determination of memory allocations indicated that array data structures should be processed. Thus reuse the corresponding function "kcalloc".
This issue was detected by using the Coccinelle software.
* Replace the specification of data types by pointer dereferences to make the corresponding size determinations a bit safer according to the Linux coding style convention.
--- drivers/infiniband/hw/ocrdma/ocrdma_main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_main.c +5 -5
@@ -225,19 +225,19 @@ static int ocrdma_register_device(struct ocrdma_dev *dev)static int ocrdma_alloc_resources (struct ocrdma_dev *dev) {mutex_init (&dev->dev_lock); - dev->cq_tbl =kzalloc (sizeof (struct ocrdma_cq *) * -OCRDMA_MAX_CQ ,GFP_KERNEL ); + dev->cq_tbl =kcalloc (OCRDMA_MAX_CQ ,sizeof (*dev->cq_tbl),GFP_KERNEL );if (!dev->cq_tbl) goto alloc_err;if (dev->attr.max_qp) { - dev->qp_tbl =kzalloc (sizeof (struct ocrdma_qp *) * -OCRDMA_MAX_QP ,GFP_KERNEL ); + dev->qp_tbl =kcalloc (OCRDMA_MAX_QP ,sizeof (*dev->qp_tbl), +GFP_KERNEL );if (!dev->qp_tbl) goto alloc_err; } - dev->stag_arr =kzalloc (sizeof (u64) *OCRDMA_MAX_STAG ,GFP_KERNEL ); + dev->stag_arr =kcalloc (OCRDMA_MAX_STAG ,sizeof (*dev->stag_arr), +GFP_KERNEL );if (dev->stag_arr =NULL ) goto alloc_err;
Signature · 1 line
2.12.0
PATCH 14/26 IB/ocrdma: Improve another size determination in ocrdma_add()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 7 Mar 2017 22:12:36 +0100
Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.
--- drivers/infiniband/hw/ocrdma/ocrdma_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/ocrdma/ocrdma_main.c +1 -1
@@ -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 ;
Signature · 1 line
2.12.0
Re: [PATCH 14/26] IB/ocrdma: Improve another size determination in ocrdma_add()
Quoted 17 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 7 Mar 2017 22:12:36 +0100Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.
Signed-off-by Markus Elfring <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/infiniband/hw/ocrdma/ocrdma_main.c +0
-0
drivers/infiniband/hw/ocrdma/ocrdma_main.c static struct ocrdma_dev *ocrdma_add(struct be_dev_info *dev_info) · line 309
Quoted 8 lines
drivers/infiniband/hw/ocrdma/ocrdma_main.c +1
-1@@ -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 ;
Quoted 7 lines
Signature · 6 lines
2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 15/26 IB/ocrdma: Delete an error message for a failed memory allocation in ocrdma_add()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 7 Mar 2017 22:23:17 +0100
Omit an extra message for a memory allocation failure in this function.
--- drivers/infiniband/hw/ocrdma/ocrdma_main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_main.c +2 -3
@@ -304,10 +304,9 @@ static struct ocrdma_dev *ocrdma_add(struct be_dev_info *dev_info)struct ocrdma_dev *dev; dev = (struct ocrdma_dev *)ib_alloc_device (sizeof (*dev)); -if (!dev) { -pr_err ("Unable to allocate ib device\n" ); +if (!dev)return NULL ; - } + dev->mbx_cmd =kzalloc (sizeof (struct ocrdma_mqe_emb_cmd ),GFP_KERNEL );if (!dev->mbx_cmd) goto idr_err;
Signature · 1 line
2.12.0
Re: [PATCH 15/26] IB/ocrdma: Delete an error message for a failed memory allocation in ocrdma_add()
Quoted 31 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 7 Mar 2017 22:23:17 +0100Omit an extra message for a memory allocation failure in this function.
Signed-off-by Markus Elfring <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/infiniband/hw/ocrdma/ocrdma_main.c +2
-4@@ -304,10 +304,9 @@ static struct ocrdma_dev *ocrdma_add(struct be_dev_info *dev_info)struct ocrdma_dev *dev; dev = (struct ocrdma_dev *)ib_alloc_device (sizeof (*dev)); -if (!dev) { -pr_err ("Unable to allocate ib device\n" ); +if (!dev)return NULL ; - } + dev->mbx_cmd =kzalloc (sizeof (struct ocrdma_mqe_emb_cmd ),GFP_KERNEL );if (!dev->mbx_cmd) goto idr_err; --2.12.0
Re: [PATCH 15/26] IB/ocrdma: Delete an error message for a failed memory allocation in ocrdma_add()
In reply to SF Markus ElfringQuoted 6 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 7 Mar 2017 22:23:17 +0100Omit an extra message for a memory allocation failure in this function.
Suggesting to add blank line here.
Quoted 10 lines
Signed-off-by Markus Elfring <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/infiniband/hw/ocrdma/ocrdma_main.c +0
-0
drivers/infiniband/hw/ocrdma/ocrdma_main.c static struct ocrdma_dev *ocrdma_add(struct be_dev_info *dev_info) · line 309
Quoted 9 lines
drivers/infiniband/hw/ocrdma/ocrdma_main.c +2
-3@@ -304,10 +304,9 @@ static struct ocrdma_dev *ocrdma_add(struct be_dev_info *dev_info)struct ocrdma_dev *dev; dev = (struct ocrdma_dev *)ib_alloc_device (sizeof (*dev)); -if (!dev) { -pr_err ("Unable to allocate ib device\n" ); +if (!dev)return NULL ; - } +
Quoted 10 lines
drivers/infiniband/hw/ocrdma/ocrdma_main.c +0
-0dev->mbx_cmd =kzalloc (sizeof (struct ocrdma_mqe_emb_cmd ),GFP_KERNEL );if (!dev->mbx_cmd) goto idr_err;Signature · 6 lines
2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 16/26 IB/ocrdma: Adjust a null pointer check in ocrdma_alloc_resources()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Tue, 7 Mar 2017 22:34:33 +0100
The script "checkpatch.pl" pointed information out like the following.
Comparison to NULL could be written "!dev->stag_arr".
Thus fix the affected source code place.
--- drivers/infiniband/hw/ocrdma/ocrdma_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/ocrdma/ocrdma_main.c +1 -1
@@ -238,7 +238,7 @@ static int ocrdma_alloc_resources(struct ocrdma_dev *dev) dev->stag_arr =kcalloc (OCRDMA_MAX_STAG ,sizeof (*dev->stag_arr),GFP_KERNEL ); -if (dev->stag_arr =NULL ) +if (!dev->stag_arr) goto alloc_err;ocrdma_alloc_pd_pool (dev);
Signature · 1 line
2.12.0
Re: [PATCH 16/26] IB/ocrdma: Adjust a null pointer check in ocrdma_alloc_resources()
Quoted 30 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 7 Mar 2017 22:34:33 +0100The script "checkpatch.pl" pointed information out like the following.
Comparison to NULL could be written "!dev->stag_arr".
Thus fix the affected source code place.
Signed-off-by Markus Elfring <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/infiniband/hw/ocrdma/ocrdma_main.c +1
-2@@ -238,7 +238,7 @@ static int ocrdma_alloc_resources(struct ocrdma_dev *dev) dev->stag_arr =kcalloc (OCRDMA_MAX_STAG ,sizeof (*dev->stag_arr),GFP_KERNEL ); -if (dev->stag_arr ==NULL ) +if (!dev->stag_arr) goto alloc_err;ocrdma_alloc_pd_pool (dev); --2.12.0
Re: [PATCH 16/26] IB/ocrdma: Adjust a null pointer check in ocrdma_alloc_resources()
In reply to SF Markus ElfringQuoted 19 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Tue, 7 Mar 2017 22:34:33 +0100The script "checkpatch.pl" pointed information out like the following.
Comparison to NULL could be written "!dev->stag_arr".
Thus fix the affected source code place.
Signed-off-by Markus Elfring <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/infiniband/hw/ocrdma/ocrdma_main.c +0
-0
drivers/infiniband/hw/ocrdma/ocrdma_main.c static int ocrdma_alloc_resources(struct ocrdma_dev *dev) · line 242
Quoted 6 lines
drivers/infiniband/hw/ocrdma/ocrdma_main.c +1
-1@@ -238,7 +238,7 @@ static int ocrdma_alloc_resources(struct ocrdma_dev *dev) dev->stag_arr =kcalloc (OCRDMA_MAX_STAG ,sizeof (*dev->stag_arr),GFP_KERNEL ); -if (dev->stag_arr =NULL ) +if (!dev->stag_arr) goto alloc_err;
Quoted 9 lines
drivers/infiniband/hw/ocrdma/ocrdma_main.c +0
-0ocrdma_alloc_pd_pool (dev);Signature · 6 lines
2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 17/26 IB/ocrdma: Use kmalloc_array() in ocrdma_create_srq()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 8 Mar 2017 08:45:31 +0100
* A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus use the corresponding function "kmalloc_array".
This issue was detected by using the Coccinelle software.
* Replace the specification of a data type by a pointer dereference to make the corresponding size determination a bit safer according to the Linux coding style convention.
--- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +3 -1
@@ -1910,8 +1910,9 @@ struct ib_srq *ocrdma_create_srq(struct ib_pd *ibpd, srq->bit_fields_len = (srq->rq.max_cnt /32 ) + (srq->rq.max_cnt %32 ?1 :0 ); - srq->idx_bit_fields -kmalloc (srq->bit_fields_len *sizeof (u32),GFP_KERNEL ); + srq->idx_bit_fields =kmalloc_array (srq->bit_fields_len, +sizeof (*srq->idx_bit_fields), +GFP_KERNEL );if (srq->idx_bit_fields =NULL ) goto arm_err; memset(srq->idx_bit_fields, 0xff,
Signature · 1 line
2.12.0
Re: [PATCH 17/26] IB/ocrdma: Use kmalloc_array() in ocrdma_create_srq()
Quoted 23 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 8 Mar 2017 08:45:31 +0100* A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus use the corresponding function "
kmalloc_array".This issue was detected by using the Coccinelle software.
* Replace the specification of a data type by a pointer dereference to make the corresponding size determination a bit safer according to the Linux coding style convention.
Signed-off-by Markus Elfring <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +0
-0
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c struct ib_srq *ocrdma_create_srq(struct ib_pd *ibpd, · line 1914
Quoted 5 lines
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +0
-2@@ -1910,8 +1910,9 @@ struct ib_srq *ocrdma_create_srq(struct ib_pd *ibpd, srq->bit_fields_len = (srq->rq.max_cnt /32 ) + (srq->rq.max_cnt %32 ?1 :0 ); - srq->idx_bit_fields = -kmalloc (srq->bit_fields_len *sizeof (u32),GFP_KERNEL );
Lets stick to kmalloc here?
Quoted 9 lines
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +3
-1+ srq->idx_bit_fields =kmalloc_array (srq->bit_fields_len, +sizeof (*srq->idx_bit_fields), +GFP_KERNEL );if (srq->idx_bit_fields ==NULL ) goto arm_err; memset(srq->idx_bit_fields, 0xff, --2.12.0
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 18/26 IB/ocrdma: Use kcalloc() in three functions
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 8 Mar 2017 09:19:47 +0100
* Multiplications for the size determination of memory allocations indicated that array data structures should be processed. Thus reuse the corresponding function "kcalloc".
This issue was detected by using the Coccinelle software.
* Replace the specification of data types by pointer dereferences to make the corresponding size determinations a bit safer according to the Linux coding style convention.
--- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +9 -8
@@ -879,9 +879,8 @@ static int ocrdma_build_pbl_tbl(struct ocrdma_dev *dev, struct ocrdma_hw_mr *mr)void *va;dma_addr_t pa; - mr->pbl_table =kzalloc (sizeof (struct ocrdma_pbl ) * - mr->num_pbls,GFP_KERNEL ); - + mr->pbl_table =kcalloc (mr->num_pbls,sizeof (*mr->pbl_table), +GFP_KERNEL );if (!mr->pbl_table)return -ENOMEM ;
@@ -1362,13 +1361,12 @@ static void ocrdma_set_qp_db(struct ocrdma_dev *dev, struct ocrdma_qp *qp,static int ocrdma_alloc_wr_id_tbl (struct ocrdma_qp *qp) { - qp->wqe_wr_id_tbl -kzalloc (sizeof (*(qp->wqe_wr_id_tbl)) * qp->sq.max_cnt, -GFP_KERNEL ); + qp->wqe_wr_id_tbl =kcalloc (qp->sq.max_cnt,sizeof (*qp->wqe_wr_id_tbl), +GFP_KERNEL );if (qp->wqe_wr_id_tbl =NULL )return -ENOMEM ; - qp->rqe_wr_id_tbl -kzalloc (sizeof (u64) * qp->rq.max_cnt,GFP_KERNEL ); + qp->rqe_wr_id_tbl =kcalloc (qp->rq.max_cnt,sizeof (*qp->rqe_wr_id_tbl), +GFP_KERNEL );if (qp->rqe_wr_id_tbl =NULL )return -ENOMEM ;
@@ -1903,8 +1901,9 @@ struct ib_srq *ocrdma_create_srq(struct ib_pd *ibpd, goto err;if (udata =NULL ) { - srq->rqe_wr_id_tbl =kzalloc (sizeof (u64) * srq->rq.max_cnt, -GFP_KERNEL ); + srq->rqe_wr_id_tbl =kcalloc (srq->rq.max_cnt, +sizeof (*srq->rqe_wr_id_tbl), +GFP_KERNEL );if (srq->rqe_wr_id_tbl =NULL ) goto arm_err;
Signature · 1 line
2.12.0
Re: [PATCH 18/26] IB/ocrdma: Use kcalloc() in three functions
Quoted 71 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 8 Mar 2017 09:19:47 +0100* Multiplications for the size determination of memory allocations indicated that array data structures should be processed. Thus reuse the corresponding function "kcalloc".
This issue was detected by using the Coccinelle software.
* Replace the specification of data types by pointer dereferences to make the corresponding size determinations a bit safer according to the Linux coding style convention.
Signed-off-by Markus Elfring <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +9
-11@@ -879,9 +879,8 @@ static int ocrdma_build_pbl_tbl(struct ocrdma_dev *dev, struct ocrdma_hw_mr *mr)void *va;dma_addr_t pa; - mr->pbl_table =kzalloc (sizeof (struct ocrdma_pbl ) * - mr->num_pbls,GFP_KERNEL ); - + mr->pbl_table =kcalloc (mr->num_pbls,sizeof (*mr->pbl_table), +GFP_KERNEL );if (!mr->pbl_table)return -ENOMEM ;@@ -1362,13 +1361,12 @@ static void ocrdma_set_qp_db(struct ocrdma_dev *dev, struct ocrdma_qp *qp,static int ocrdma_alloc_wr_id_tbl (struct ocrdma_qp *qp) { - qp->wqe_wr_id_tbl = -kzalloc (sizeof (*(qp->wqe_wr_id_tbl)) * qp->sq.max_cnt, -GFP_KERNEL ); + qp->wqe_wr_id_tbl =kcalloc (qp->sq.max_cnt,sizeof (*qp->wqe_wr_id_tbl), +GFP_KERNEL );if (qp->wqe_wr_id_tbl ==NULL )return -ENOMEM ; - qp->rqe_wr_id_tbl = -kzalloc (sizeof (u64) * qp->rq.max_cnt,GFP_KERNEL ); + qp->rqe_wr_id_tbl =kcalloc (qp->rq.max_cnt,sizeof (*qp->rqe_wr_id_tbl), +GFP_KERNEL );if (qp->rqe_wr_id_tbl ==NULL )return -ENOMEM ;@@ -1903,8 +1901,9 @@ struct ib_srq *ocrdma_create_srq(struct ib_pd *ibpd, goto err;if (udata ==NULL ) { - srq->rqe_wr_id_tbl =kzalloc (sizeof (u64) * srq->rq.max_cnt, -GFP_KERNEL ); + srq->rqe_wr_id_tbl =kcalloc (srq->rq.max_cnt, +sizeof (*srq->rqe_wr_id_tbl), +GFP_KERNEL );if (srq->rqe_wr_id_tbl ==NULL ) goto arm_err; --2.12.0
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 19/26 IB/ocrdma: Improve another size determination in ocrdma_alloc_mr()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 8 Mar 2017 09:54:42 +0100
Replace the specification of a data type by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.
--- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +1 -1
@@ -3030,7 +3030,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;
Signature · 1 line
2.12.0
Re: [PATCH 19/26] IB/ocrdma: Improve another size determination in ocrdma_alloc_mr()
Quoted 32 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 8 Mar 2017 09:54:42 +0100Replace the specification of a data type by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.
Signed-off-by Markus Elfring <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +1
-2@@ -3030,7 +3030,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.0
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 19/26] IB/ocrdma: Improve another size determination in ocrdma_alloc_mr()
In reply to SF Markus ElfringQuoted 17 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 8 Mar 2017 09:54:42 +0100Replace the specification of a data type by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.
Signed-off-by Markus Elfring <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +0
-0
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c struct ib_mr *ocrdma_alloc_mr(struct ib_pd *ibpd, · line 3033
Quoted 5 lines
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +1
-1@@ -3030,7 +3030,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 );
Quoted 10 lines
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +0
-0if (!mr->pages) { status = -ENOMEM ; goto pl_err;Signature · 6 lines
2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 20/26 IB/ocrdma: Delete an unnecessary variable assignment in ocrdma_alloc_mr()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 8 Mar 2017 10:00:41 +0100
Delete an assignment for the local variable "status" in an if branch because the desired failure indication is already specified by a constant error code at the end.
--- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +1 -3
@@ -3031,10 +3031,8 @@ struct ib_mr *ocrdma_alloc_mr(struct ib_pd *ibpd,return ERR_PTR (-ENOMEM ); mr->pages =kcalloc (max_num_sg,sizeof (*mr->pages),GFP_KERNEL ); -if (!mr->pages) { - status = -ENOMEM ; +if (!mr->pages) goto pl_err; - } status =ocrdma_get_pbl_info (dev, mr, max_num_sg);if (status)
Signature · 1 line
2.12.0
Re: [PATCH 20/26] IB/ocrdma: Delete an unnecessary variable assignment in ocrdma_alloc_mr()
Quoted 31 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 8 Mar 2017 10:00:41 +0100Delete an assignment for the local variable "status" in an if branch because the desired failure indication is already specified by a constant error code at the end.
Signed-off-by Markus Elfring <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +1
-4@@ -3031,10 +3031,8 @@ struct ib_mr *ocrdma_alloc_mr(struct ib_pd *ibpd,return ERR_PTR (-ENOMEM ); mr->pages =kcalloc (max_num_sg,sizeof (*mr->pages),GFP_KERNEL ); -if (!mr->pages) { - status = -ENOMEM ; +if (!mr->pages) goto pl_err; - } status =ocrdma_get_pbl_info (dev, mr, max_num_sg);if (status) --2.12.0
Re: [PATCH 20/26] IB/ocrdma: Delete an unnecessary variable assignment in ocrdma_alloc_mr()
In reply to SF Markus ElfringQuoted 17 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 8 Mar 2017 10:00:41 +0100Delete an assignment for the local variable "status" in an if branch because the desired failure indication is already specified by a constant error code at the end.
Signed-off-by Markus Elfring <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +0
-0
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c struct ib_mr *ocrdma_alloc_mr(struct ib_pd *ibpd, · line 3036
Quoted 9 lines
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +1
-3@@ -3031,10 +3031,8 @@ struct ib_mr *ocrdma_alloc_mr(struct ib_pd *ibpd,return ERR_PTR (-ENOMEM ); mr->pages =kcalloc (max_num_sg,sizeof (*mr->pages),GFP_KERNEL ); -if (!mr->pages) { - status = -ENOMEM ; +if (!mr->pages) goto pl_err; - }
Quoted 9 lines
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +0
-0status =ocrdma_get_pbl_info (dev, mr, max_num_sg);if (status)Signature · 6 lines
2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 21/26 IB/ocrdma: Improve another size determination in ocrdma_create_srq()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 8 Mar 2017 10:10:50 +0100
Replace the specification of a data type by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.
--- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +1 -1
@@ -1915,7 +1915,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) {
Signature · 1 line
2.12.0
Re: [PATCH 21/26] IB/ocrdma: Improve another size determination in ocrdma_create_srq()
Quoted 26 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 8 Mar 2017 10:10:50 +0100Replace the specification of a data type by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.
Signed-off-by Markus Elfring <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +1
-2@@ -1915,7 +1915,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) { --
Quoted 2 lines
2.12.0
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 21/26] IB/ocrdma: Improve another size determination in ocrdma_create_srq()
In reply to SF Markus ElfringQuoted 17 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 8 Mar 2017 10:10:50 +0100Replace the specification of a data type by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.
Signed-off-by Markus Elfring <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +0
-0
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c struct ib_srq *ocrdma_create_srq(struct ib_pd *ibpd, · line 1919
Quoted 6 lines
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +1
-1@@ -1915,7 +1915,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)); }
Quoted 9 lines
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +0
-0if (init_attr->attr.srq_limit) {Signature · 6 lines
2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 22/26 IB/ocrdma: Returning only value constants in ocrdma_resize_cq()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 8 Mar 2017 10:48:24 +0100
Return constant integer values without storing them in the local variable "status".
--- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +3 -6
@@ -1123,15 +1123,12 @@ struct ib_cq *ocrdma_create_cq(struct ib_device *ibdev,int ocrdma_resize_cq (struct ib_cq *ibcq,int new_cnt,struct ib_udata *udata) { -int status =0 ;struct ocrdma_cq *cq =get_ocrdma_cq (ibcq); -if (new_cnt <1 || new_cnt > cq->max_hw_cqe) { - status = -EINVAL ; -return status; - } +if (new_cnt <1 || new_cnt > cq->max_hw_cqe) +return -EINVAL ; ibcq->cqe = new_cnt; -return status; +return 0 ; }static void ocrdma_flush_cq (struct ocrdma_cq *cq)
Signature · 1 line
2.12.0
Re: [PATCH 22/26] IB/ocrdma: Returning only value constants in ocrdma_resize_cq()
Quoted 37 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 8 Mar 2017 10:48:24 +0100Return constant integer values without storing them in the local variable "status".
Signed-off-by Markus Elfring <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +3
-7@@ -1123,15 +1123,12 @@ struct ib_cq *ocrdma_create_cq(struct ib_device *ibdev,int ocrdma_resize_cq (struct ib_cq *ibcq,int new_cnt,struct ib_udata *udata) { -int status =0 ;struct ocrdma_cq *cq =get_ocrdma_cq (ibcq); -if (new_cnt <1 || new_cnt > cq->max_hw_cqe) { - status = -EINVAL ; -return status; - } +if (new_cnt <1 || new_cnt > cq->max_hw_cqe) +return -EINVAL ; ibcq->cqe = new_cnt; -return status; +return 0 ; }static void ocrdma_flush_cq (struct ocrdma_cq *cq) --2.12.0
Re: [PATCH 22/26] IB/ocrdma: Returning only value constants in ocrdma_resize_cq()
In reply to SF Markus ElfringQuoted 21 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 8 Mar 2017 10:48:24 +0100Return constant integer values without storing them in the local variable "status".
Signed-off-by Markus Elfring <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +0
-1@@ -1123,15 +1123,12 @@ struct ib_cq *ocrdma_create_cq(struct ib_device *ibdev,int ocrdma_resize_cq (struct ib_cq *ibcq,int new_cnt,struct ib_udata *udata) { -int status =0 ;struct ocrdma_cq *cq =get_ocrdma_cq (ibcq);
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c struct ib_cq *ocrdma_create_cq(struct ib_device *ibdev, · line 1131
Quoted 10 lines
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +3
-5-if (new_cnt <1 || new_cnt > cq->max_hw_cqe) { - status = -EINVAL ; -return status; - } +if (new_cnt <1 || new_cnt > cq->max_hw_cqe) +return -EINVAL ; ibcq->cqe = new_cnt; -return status; +return 0 ;
Quoted 10 lines
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +0
-0}static void ocrdma_flush_cq (struct ocrdma_cq *cq)Signature · 6 lines
2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 23/26 IB/ocrdma: Delete an unnecessary variable in ocrdma_dealloc_pd()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 8 Mar 2017 10:58:34 +0100
1. Return zero in one case directly.
2. Return the value from a call of the function "_ocrdma_dealloc_pd" without using an extra assignment for the local variable.
3. Remove the variable "status" in this function then.
--- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +2 -4
@@ -755,7 +755,6 @@ int ocrdma_dealloc_pd(struct ib_pd *ibpd)struct ocrdma_pd *pd =get_ocrdma_pd (ibpd);struct ocrdma_dev *dev =get_ocrdma_dev (ibpd->device);struct ocrdma_ucontext *uctx =NULL ; -int status =0 ;u64 usr_db; uctx = pd->uctx;
@@ -769,11 +768,10 @@ int ocrdma_dealloc_pd(struct ib_pd *ibpd)if (is_ucontext_pd (uctx, pd)) {ocrdma_release_ucontext_pd (uctx); -return status; +return 0 ; } } - status =_ocrdma_dealloc_pd (dev, pd); -return status; +return _ocrdma_dealloc_pd (dev, pd); } static int ocrdma_alloc_lkey(struct ocrdma_dev *dev, struct ocrdma_mr *mr,
Signature · 1 line
2.12.0
Re: [PATCH 23/26] IB/ocrdma: Delete an unnecessary variable in ocrdma_dealloc_pd()
Quoted 48 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 8 Mar 2017 10:58:34 +01001. Return zero in one case directly.
2. Return the value from a call of the function "
_ocrdma_dealloc_pd" without using an extra assignment for the local variable.3. Remove the variable "status" in this function then.
Signed-off-by Markus Elfring <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +2
-5@@ -755,7 +755,6 @@ int ocrdma_dealloc_pd(struct ib_pd *ibpd)struct ocrdma_pd *pd =get_ocrdma_pd (ibpd);struct ocrdma_dev *dev =get_ocrdma_dev (ibpd->device);struct ocrdma_ucontext *uctx =NULL ; -int status =0 ;u64 usr_db; uctx = pd->uctx;@@ -769,11 +768,10 @@ int ocrdma_dealloc_pd(struct ib_pd *ibpd)if (is_ucontext_pd (uctx, pd)) {ocrdma_release_ucontext_pd (uctx); -return status; +return 0 ; } } - status =_ocrdma_dealloc_pd (dev, pd); -return status; +return _ocrdma_dealloc_pd (dev, pd); } static int ocrdma_alloc_lkey(struct ocrdma_dev *dev, struct ocrdma_mr *mr, --2.12.0
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 23/26] IB/ocrdma: Delete an unnecessary variable in ocrdma_dealloc_pd()
In reply to SF Markus ElfringQuoted 29 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 8 Mar 2017 10:58:34 +01001. Return zero in one case directly.
2. Return the value from a call of the function "
_ocrdma_dealloc_pd" without using an extra assignment for the local variable.3. Remove the variable "status" in this function then.
Signed-off-by Markus Elfring <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +0
-1@@ -755,7 +755,6 @@ int ocrdma_dealloc_pd(struct ib_pd *ibpd)struct ocrdma_pd *pd =get_ocrdma_pd (ibpd);struct ocrdma_dev *dev =get_ocrdma_dev (ibpd->device);struct ocrdma_ucontext *uctx =NULL ; -int status =0 ;u64 usr_db; uctx = pd->uctx;@@ -769,11 +768,10 @@ int ocrdma_dealloc_pd(struct ib_pd *ibpd)
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c int ocrdma_dealloc_pd(struct ib_pd *ibpd) · line 775
Quoted 10 lines
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +2
-3if (is_ucontext_pd (uctx, pd)) {ocrdma_release_ucontext_pd (uctx); -return status; +return 0 ; } } - status =_ocrdma_dealloc_pd (dev, pd); -return status; +return _ocrdma_dealloc_pd (dev, pd); }
Quoted 9 lines
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +0
-0static int ocrdma_alloc_lkey(struct ocrdma_dev *dev, struct ocrdma_mr *mr,Signature · 6 lines
2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 24/26 IB/ocrdma: One jump label less in ocrdma_alloc_ucontext_pd()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 8 Mar 2017 11:11:35 +0100
This issue was detected by using the Coccinelle software.
1. Return directly if a call of the function "_ocrdma_alloc_pd" failed.
2. Reduce the scope for the local variable "status" to one case of an if statement.
3. Delete the jump label "err" then.
4. Return zero as a constant at the end.
--- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +4 -6
@@ -484,19 +484,17 @@ static int ocrdma_alloc_ucontext_pd(struct ocrdma_dev *dev,struct ocrdma_ucontext *uctx, struct ib_udata *udata) { - int status = 0; - uctx->cntxt_pd = _ocrdma_alloc_pd(dev, uctx, udata);if (IS_ERR (uctx->cntxt_pd)) { - status =PTR_ERR (uctx->cntxt_pd); +int status =PTR_ERR (uctx->cntxt_pd); + uctx->cntxt_pd =NULL ; - goto err; +return status; } uctx->cntxt_pd->uctx = uctx; uctx->cntxt_pd->ibpd.device = &dev->ibdev; -err: -return status; +return 0 ; }static int ocrdma_dealloc_ucontext_pd (struct ocrdma_ucontext *uctx)
Signature · 1 line
2.12.0
Re: [PATCH 24/26] IB/ocrdma: One jump label less in ocrdma_alloc_ucontext_pd()
Quoted 48 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 8 Mar 2017 11:11:35 +0100This issue was detected by using the Coccinelle software.
1. Return directly if a call of the function "
_ocrdma_alloc_pd" failed.2. Reduce the scope for the local variable "status" to one case of an if statement.
3. Delete the jump label "err" then.
4. Return zero as a constant at the end.
Signed-off-by Markus Elfring <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +4
-7@@ -484,19 +484,17 @@ static int ocrdma_alloc_ucontext_pd(struct ocrdma_dev *dev,struct ocrdma_ucontext *uctx, struct ib_udata *udata) { - int status = 0; - uctx->cntxt_pd = _ocrdma_alloc_pd(dev, uctx, udata);if (IS_ERR (uctx->cntxt_pd)) { - status =PTR_ERR (uctx->cntxt_pd); +int status =PTR_ERR (uctx->cntxt_pd); + uctx->cntxt_pd =NULL ; - goto err; +return status; } uctx->cntxt_pd->uctx = uctx; uctx->cntxt_pd->ibpd.device = &dev->ibdev; -err: -return status; +return 0 ; }static int ocrdma_dealloc_ucontext_pd (struct ocrdma_ucontext *uctx) --
Quoted 2 lines
2.12.0
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 24/26] IB/ocrdma: One jump label less in ocrdma_alloc_ucontext_pd()
In reply to SF Markus ElfringQuoted 35 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 8 Mar 2017 11:11:35 +0100This issue was detected by using the Coccinelle software.
1. Return directly if a call of the function "
_ocrdma_alloc_pd" failed.2. Reduce the scope for the local variable "status" to one case of an if statement.
3. Delete the jump label "err" then.
4. Return zero as a constant at the end.
Signed-off-by Markus Elfring <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +2
-3@@ -484,19 +484,17 @@ static int ocrdma_alloc_ucontext_pd(struct ocrdma_dev *dev,struct ocrdma_ucontext *uctx, struct ib_udata *udata) { - int status = 0; - uctx->cntxt_pd = _ocrdma_alloc_pd(dev, uctx, udata);if (IS_ERR (uctx->cntxt_pd)) { - status =PTR_ERR (uctx->cntxt_pd); +int status =PTR_ERR (uctx->cntxt_pd); + uctx->cntxt_pd =NULL ;
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c static int ocrdma_alloc_ucontext_pd(struct ocrdma_dev *dev, · line 498
Quoted 10 lines
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +2
-3- goto err; +return status; } uctx->cntxt_pd->uctx = uctx; uctx->cntxt_pd->ibpd.device = &dev->ibdev; -err: -return status; +return 0 ; }
Quoted 9 lines
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +0
-0static int ocrdma_dealloc_ucontext_pd (struct ocrdma_ucontext *uctx)Signature · 6 lines
2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 25/26 IB/ocrdma: Delete unnecessary braces
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 8 Mar 2017 12:36:41 +0100
Do not use curly brackets at some source code places where a single statement should be sufficient.
--- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 41 +++++++++++------------------ 1 file changed, 16 insertions(+), 25 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +16 -25
@@ -502,10 +502,10 @@ static int ocrdma_dealloc_ucontext_pd(struct ocrdma_ucontext *uctx)struct ocrdma_pd *pd = uctx->cntxt_pd;struct ocrdma_dev *dev =get_ocrdma_dev (pd->ibpd.device); -if (uctx->pd_in_use) { +if (uctx->pd_in_use)pr_err ("%s(%d) Freeing in use pdid=0x%x.\n" , __func__, dev->id, pd->id); - } + uctx->cntxt_pd =NULL ; (void )_ocrdma_dealloc_pd (dev, pd);return 0 ;
@@ -739,11 +739,10 @@ struct ib_pd *ocrdma_alloc_pd(struct ib_device *ibdev,return &pd->ibpd; err: -if (is_uctx_pd) { +if (is_uctx_pd)ocrdma_release_ucontext_pd (uctx); - }else { +else status =_ocrdma_dealloc_pd (dev, pd); - } exit:return ERR_PTR (status); }
@@ -1018,10 +1017,10 @@ int ocrdma_dereg_mr(struct ib_mr *ib_mr)kfree (mr);/* Don't stop cleanup, in case FW is unresponsive */ -if (dev->mqe_ctx.fw_error_state) { +if (dev->mqe_ctx.fw_error_state)pr_err ("%s(%d) fw not responding.\n" , __func__, dev->id); - } +return 0 ; }
@@ -1410,10 +1409,10 @@ struct ib_qp *ocrdma_create_qp(struct ib_pd *ibpd, goto gen_err;memset (&ureq,0 ,sizeof (ureq)); -if (udata) { +if (udata)if (ib_copy_from_udata (&ureq, udata,sizeof (ureq)))return ERR_PTR (-EFAULT ); - } + qp =kzalloc (sizeof (*qp),GFP_KERNEL );if (!qp) { status = -ENOMEM ;
@@ -2829,15 +2828,11 @@ static bool ocrdma_poll_rcqe(struct ocrdma_qp *qp, struct ocrdma_cqe *cqe,bool expand = false; ibwc->wc_flags =0 ; -if (qp->qp_type =IB_QPT_UD || qp->qp_type =IB_QPT_GSI ) { - status = (le32_to_cpu (cqe->flags_status_srcqpn) & -OCRDMA_CQE_UD_STATUS_MASK ) >> -OCRDMA_CQE_UD_STATUS_SHIFT ; - }else { - status = (le32_to_cpu (cqe->flags_status_srcqpn) & -OCRDMA_CQE_STATUS_MASK ) >>OCRDMA_CQE_STATUS_SHIFT ; - } - + status = (qp->qp_type =IB_QPT_UD || qp->qp_type =IB_QPT_GSI ) + ? ((le32_to_cpu (cqe->flags_status_srcqpn) & +OCRDMA_CQE_UD_STATUS_MASK ) >>OCRDMA_CQE_UD_STATUS_SHIFT ) + : ((le32_to_cpu (cqe->flags_status_srcqpn) & +OCRDMA_CQE_STATUS_MASK ) >>OCRDMA_CQE_STATUS_SHIFT );if (status =OCRDMA_CQE_SUCCESS ) { *polled = true;ocrdma_poll_success_rcqe (qp, cqe, ibwc);
@@ -2885,13 +2880,9 @@ static int ocrdma_poll_hwcq(struct ocrdma_cq *cq, int num_entries, qp = dev->qp_tbl[qpn];BUG_ON (qp =NULL ); -if (is_cqe_for_sq (cqe)) { - expand =ocrdma_poll_scqe (qp, cqe, ibwc, &polled, - &stop); - }else { - expand =ocrdma_poll_rcqe (qp, cqe, ibwc, &polled, - &stop); - } + expand =is_cqe_for_sq (cqe) + ?ocrdma_poll_scqe (qp, cqe, ibwc, &polled, &stop) + :ocrdma_poll_rcqe (qp, cqe, ibwc, &polled, &stop);if (expand) goto expand_cqe;if (stop)
Signature · 1 line
2.12.0
Re: [PATCH 25/26] IB/ocrdma: Delete unnecessary braces
Quoted 97 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 8 Mar 2017 12:36:41 +0100Do not use curly brackets at some source code places where a single statement should be sufficient.
Signed-off-by Markus Elfring <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 41 +++++++++++------------------ 1 file changed, 16 insertions(+), 25 deletions(-)drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +13
-21@@ -502,10 +502,10 @@ static int ocrdma_dealloc_ucontext_pd(struct ocrdma_ucontext *uctx)struct ocrdma_pd *pd = uctx->cntxt_pd;struct ocrdma_dev *dev =get_ocrdma_dev (pd->ibpd.device); -if (uctx->pd_in_use) { +if (uctx->pd_in_use)pr_err ("%s(%d) Freeing in use pdid=0x%x.\n" , __func__, dev->id, pd->id); - } + uctx->cntxt_pd =NULL ; (void )_ocrdma_dealloc_pd (dev, pd);return 0 ;@@ -739,11 +739,10 @@ struct ib_pd *ocrdma_alloc_pd(struct ib_device *ibdev,return &pd->ibpd; err: -if (is_uctx_pd) { +if (is_uctx_pd)ocrdma_release_ucontext_pd (uctx); - }else { +else status =_ocrdma_dealloc_pd (dev, pd); - } exit:return ERR_PTR (status); }@@ -1018,10 +1017,10 @@ int ocrdma_dereg_mr(struct ib_mr *ib_mr)kfree (mr);/* Don't stop cleanup, in case FW is unresponsive */ -if (dev->mqe_ctx.fw_error_state) { +if (dev->mqe_ctx.fw_error_state)pr_err ("%s(%d) fw not responding.\n" , __func__, dev->id); - } +return 0 ; }@@ -1410,10 +1409,10 @@ struct ib_qp *ocrdma_create_qp(struct ib_pd *ibpd, goto gen_err;memset (&ureq,0 ,sizeof (ureq)); -if (udata) { +if (udata)if (ib_copy_from_udata (&ureq, udata,sizeof (ureq)))return ERR_PTR (-EFAULT ); - } + qp =kzalloc (sizeof (*qp),GFP_KERNEL );if (!qp) { status = -ENOMEM ;@@ -2829,15 +2828,11 @@ static bool ocrdma_poll_rcqe(struct ocrdma_qp *qp, struct ocrdma_cqe *cqe,bool expand = false; ibwc->wc_flags =0 ; -if (qp->qp_type =IB_QPT_UD || qp->qp_type =IB_QPT_GSI ) { - status = (le32_to_cpu (cqe->flags_status_srcqpn) & -OCRDMA_CQE_UD_STATUS_MASK ) >> -OCRDMA_CQE_UD_STATUS_SHIFT ; - }else { - status = (le32_to_cpu (cqe->flags_status_srcqpn) & -OCRDMA_CQE_STATUS_MASK ) >>OCRDMA_CQE_STATUS_SHIFT ; - } - + status = (qp->qp_type =IB_QPT_UD || qp->qp_type =IB_QPT_GSI ) + ? ((le32_to_cpu (cqe->flags_status_srcqpn) & +OCRDMA_CQE_UD_STATUS_MASK ) >>OCRDMA_CQE_UD_STATUS_SHIFT ) + : ((le32_to_cpu (cqe->flags_status_srcqpn) & +OCRDMA_CQE_STATUS_MASK ) >>OCRDMA_CQE_STATUS_SHIFT );if (status =OCRDMA_CQE_SUCCESS ) { *polled = true;ocrdma_poll_success_rcqe (qp, cqe, ibwc);@@ -2885,13 +2880,9 @@ static int ocrdma_poll_hwcq(struct ocrdma_cq *cq, int num_entries, qp = dev->qp_tbl[qpn];BUG_ON (qp =NULL ); -if (is_cqe_for_sq (cqe)) { - expand =ocrdma_poll_scqe (qp, cqe, ibwc, &polled, - &stop);
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c static int ocrdma_poll_hwcq(struct ocrdma_cq *cq, int num_entries, · line 2888
Quoted 10 lines
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +3
-4- }else { - expand =ocrdma_poll_rcqe (qp, cqe, ibwc, &polled, - &stop); - } + expand =is_cqe_for_sq (cqe) + ?ocrdma_poll_scqe (qp, cqe, ibwc, &polled, &stop) + :ocrdma_poll_rcqe (qp, cqe, ibwc, &polled, &stop);if (expand) goto expand_cqe;if (stop)
Quoted 6 lines
2.12.0
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 26/26 IB/ocrdma: Adjust further ten checks for null pointers
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 8 Mar 2017 12:50:14 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The script “checkpatch.pl“ pointed information out like the following.
Comparison to NULL could be written !…
Thus fix affected source code places.
--- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +10 -10
@@ -267,7 +267,7 @@ static int ocrdma_add_mmap(struct ocrdma_ucontext *uctx, u64 phy_addr,struct ocrdma_mm *mm; mm =kzalloc (sizeof (*mm),GFP_KERNEL ); -if (mm =NULL ) +if (!mm)return -ENOMEM ; mm->key.phy_addr = phy_addr; mm->key.len = len;
@@ -1187,7 +1187,7 @@ static int ocrdma_add_qpn_map(struct ocrdma_dev *dev, struct ocrdma_qp *qp) {int status = -EINVAL ; -if (qp->id <OCRDMA_MAX_QP && dev->qp_tbl[qp->id] =NULL ) { +if (qp->id <OCRDMA_MAX_QP && !dev->qp_tbl[qp->id]) { dev->qp_tbl[qp->id] = qp; status =0 ; }
@@ -1355,11 +1355,11 @@ static int ocrdma_alloc_wr_id_tbl(struct ocrdma_qp *qp) { qp->wqe_wr_id_tbl =kcalloc (qp->sq.max_cnt,sizeof (*qp->wqe_wr_id_tbl),GFP_KERNEL ); -if (qp->wqe_wr_id_tbl =NULL ) +if (!qp->wqe_wr_id_tbl)return -ENOMEM ; qp->rqe_wr_id_tbl =kcalloc (qp->rq.max_cnt,sizeof (*qp->rqe_wr_id_tbl),GFP_KERNEL ); -if (qp->rqe_wr_id_tbl =NULL ) +if (!qp->rqe_wr_id_tbl)return -ENOMEM ;return 0 ;
@@ -1419,7 +1419,7 @@ struct ib_qp *ocrdma_create_qp(struct ib_pd *ibpd, goto gen_err; }ocrdma_set_qp_init_params (qp, pd, attrs); -if (udata =NULL ) +if (!udata) qp->cap_flags |= (OCRDMA_QP_MW_BIND |OCRDMA_QP_LKEY0 |OCRDMA_QP_FAST_REG );
@@ -1431,7 +1431,7 @@ struct ib_qp *ocrdma_create_qp(struct ib_pd *ibpd, goto mbx_err;/* user space QP's wr_id table are managed in library */ -if (udata =NULL ) { +if (!udata) { status =ocrdma_alloc_wr_id_tbl (qp);if (status) goto map_err;
@@ -1892,11 +1892,11 @@ struct ib_srq *ocrdma_create_srq(struct ib_pd *ibpd,if (status) goto err; -if (udata =NULL ) { +if (!udata) { srq->rqe_wr_id_tbl =kcalloc (srq->rq.max_cnt,sizeof (*srq->rqe_wr_id_tbl),GFP_KERNEL ); -if (srq->rqe_wr_id_tbl =NULL ) +if (!srq->rqe_wr_id_tbl) goto arm_err; srq->bit_fields_len = (srq->rq.max_cnt / 32) +
@@ -1904,7 +1904,7 @@ struct ib_srq *ocrdma_create_srq(struct ib_pd *ibpd, srq->idx_bit_fields =kmalloc_array (srq->bit_fields_len,sizeof (*srq->idx_bit_fields),GFP_KERNEL ); -if (srq->idx_bit_fields =NULL ) +if (!srq->idx_bit_fields) goto arm_err;memset (srq->idx_bit_fields,0xff , srq->bit_fields_len *sizeof (*srq->idx_bit_fields));
@@ -2878,7 +2878,7 @@ static int ocrdma_poll_hwcq(struct ocrdma_cq *cq, int num_entries,if (qpn =0 ) goto skip_cqe; qp = dev->qp_tbl[qpn]; -BUG_ON (qp =NULL ); +BUG_ON (!qp); expand =is_cqe_for_sq (cqe) ? ocrdma_poll_scqe(qp, cqe, ibwc, &polled, &stop)
Signature · 1 line
2.12.0
Re: [PATCH 26/26] IB/ocrdma: Adjust further ten checks for null pointers
Quoted 104 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 8 Mar 2017 12:50:14 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bitThe script “checkpatch.pl“ pointed information out like the following.
Comparison to NULL could be written !…
Thus fix affected source code places.
Signed-off-by Markus Elfring <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +10
-11@@ -267,7 +267,7 @@ static int ocrdma_add_mmap(struct ocrdma_ucontext *uctx, u64 phy_addr,struct ocrdma_mm *mm; mm =kzalloc (sizeof (*mm),GFP_KERNEL ); -if (mm ==NULL ) +if (!mm)return -ENOMEM ; mm->key.phy_addr = phy_addr; mm->key.len = len;@@ -1187,7 +1187,7 @@ static int ocrdma_add_qpn_map(struct ocrdma_dev *dev, struct ocrdma_qp *qp) {int status = -EINVAL ; -if (qp->id <OCRDMA_MAX_QP && dev->qp_tbl[qp->id] ==NULL ) { +if (qp->id <OCRDMA_MAX_QP && !dev->qp_tbl[qp->id]) { dev->qp_tbl[qp->id] = qp; status =0 ; }@@ -1355,11 +1355,11 @@ static int ocrdma_alloc_wr_id_tbl(struct ocrdma_qp *qp) { qp->wqe_wr_id_tbl =kcalloc (qp->sq.max_cnt,sizeof (*qp->wqe_wr_id_tbl),GFP_KERNEL ); -if (qp->wqe_wr_id_tbl ==NULL ) +if (!qp->wqe_wr_id_tbl)return -ENOMEM ; qp->rqe_wr_id_tbl =kcalloc (qp->rq.max_cnt,sizeof (*qp->rqe_wr_id_tbl),GFP_KERNEL ); -if (qp->rqe_wr_id_tbl ==NULL ) +if (!qp->rqe_wr_id_tbl)return -ENOMEM ;return 0 ;@@ -1419,7 +1419,7 @@ struct ib_qp *ocrdma_create_qp(struct ib_pd *ibpd, goto gen_err; }ocrdma_set_qp_init_params (qp, pd, attrs); -if (udata ==NULL ) +if (!udata) qp->cap_flags |= (OCRDMA_QP_MW_BIND |OCRDMA_QP_LKEY0 |OCRDMA_QP_FAST_REG );@@ -1431,7 +1431,7 @@ struct ib_qp *ocrdma_create_qp(struct ib_pd *ibpd, goto mbx_err;/* user space QP's wr_id table are managed in library */ -if (udata ==NULL ) { +if (!udata) { status =ocrdma_alloc_wr_id_tbl (qp);if (status) goto map_err;@@ -1892,11 +1892,11 @@ struct ib_srq *ocrdma_create_srq(struct ib_pd *ibpd,if (status) goto err; -if (udata ==NULL ) { +if (!udata) { srq->rqe_wr_id_tbl =kcalloc (srq->rq.max_cnt,sizeof (*srq->rqe_wr_id_tbl),GFP_KERNEL ); -if (srq->rqe_wr_id_tbl ==NULL ) +if (!srq->rqe_wr_id_tbl) goto arm_err; srq->bit_fields_len = (srq->rq.max_cnt / 32) +@@ -1904,7 +1904,7 @@ struct ib_srq *ocrdma_create_srq(struct ib_pd *ibpd, srq->idx_bit_fields =kmalloc_array (srq->bit_fields_len,sizeof (*srq->idx_bit_fields),GFP_KERNEL ); -if (srq->idx_bit_fields ==NULL ) +if (!srq->idx_bit_fields) goto arm_err;memset (srq->idx_bit_fields,0xff , srq->bit_fields_len *sizeof (*srq->idx_bit_fields));@@ -2878,7 +2878,7 @@ static int ocrdma_poll_hwcq(struct ocrdma_cq *cq, int num_entries,if (qpn ==0 ) goto skip_cqe; qp = dev->qp_tbl[qpn]; -BUG_ON (qp ==NULL ); +BUG_ON (!qp); expand =is_cqe_for_sq (cqe) ? ocrdma_poll_scqe(qp, cqe, ibwc, &polled, &stop) --
Quoted 2 lines
2.12.0
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Yuval Shaia
Reviewed-byRe: [PATCH 26/26] IB/ocrdma: Adjust further ten checks for null pointers
Quoted 1 line · Devesh Sharma
Acked-by Devesh Sharma <[email protected]>
Quoted 113 lines
Quoted 104 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 8 Mar 2017 12:50:14 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bitThe script “checkpatch.pl“ pointed information out like the following.
Comparison to NULL could be written !…
Thus fix affected source code places.
Signed-off-by Markus Elfring <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +10
-11@@ -267,7 +267,7 @@ static int ocrdma_add_mmap(struct ocrdma_ucontext *uctx, u64 phy_addr,struct ocrdma_mm *mm; mm =kzalloc (sizeof (*mm),GFP_KERNEL ); -if (mm =NULL ) +if (!mm)return -ENOMEM ; mm->key.phy_addr = phy_addr; mm->key.len = len;@@ -1187,7 +1187,7 @@ static int ocrdma_add_qpn_map(struct ocrdma_dev *dev, struct ocrdma_qp *qp) {int status = -EINVAL ; -if (qp->id <OCRDMA_MAX_QP && dev->qp_tbl[qp->id] =NULL ) { +if (qp->id <OCRDMA_MAX_QP && !dev->qp_tbl[qp->id]) { dev->qp_tbl[qp->id] = qp; status =0 ; }@@ -1355,11 +1355,11 @@ static int ocrdma_alloc_wr_id_tbl(struct ocrdma_qp *qp) { qp->wqe_wr_id_tbl =kcalloc (qp->sq.max_cnt,sizeof (*qp->wqe_wr_id_tbl),GFP_KERNEL ); -if (qp->wqe_wr_id_tbl =NULL ) +if (!qp->wqe_wr_id_tbl)return -ENOMEM ; qp->rqe_wr_id_tbl =kcalloc (qp->rq.max_cnt,sizeof (*qp->rqe_wr_id_tbl),GFP_KERNEL ); -if (qp->rqe_wr_id_tbl =NULL ) +if (!qp->rqe_wr_id_tbl)return -ENOMEM ;return 0 ;@@ -1419,7 +1419,7 @@ struct ib_qp *ocrdma_create_qp(struct ib_pd *ibpd, goto gen_err; }ocrdma_set_qp_init_params (qp, pd, attrs); -if (udata =NULL ) +if (!udata) qp->cap_flags |= (OCRDMA_QP_MW_BIND |OCRDMA_QP_LKEY0 |OCRDMA_QP_FAST_REG );@@ -1431,7 +1431,7 @@ struct ib_qp *ocrdma_create_qp(struct ib_pd *ibpd, goto mbx_err;/* user space QP's wr_id table are managed in library */ -if (udata =NULL ) { +if (!udata) { status =ocrdma_alloc_wr_id_tbl (qp);if (status) goto map_err;@@ -1892,11 +1892,11 @@ struct ib_srq *ocrdma_create_srq(struct ib_pd *ibpd,if (status) goto err; -if (udata =NULL ) { +if (!udata) { srq->rqe_wr_id_tbl =kcalloc (srq->rq.max_cnt,sizeof (*srq->rqe_wr_id_tbl),GFP_KERNEL ); -if (srq->rqe_wr_id_tbl =NULL ) +if (!srq->rqe_wr_id_tbl) goto arm_err; srq->bit_fields_len = (srq->rq.max_cnt / 32) +@@ -1904,7 +1904,7 @@ struct ib_srq *ocrdma_create_srq(struct ib_pd *ibpd, srq->idx_bit_fields =kmalloc_array (srq->bit_fields_len,sizeof (*srq->idx_bit_fields),GFP_KERNEL ); -if (srq->idx_bit_fields =NULL ) +if (!srq->idx_bit_fields) goto arm_err;memset (srq->idx_bit_fields,0xff , srq->bit_fields_len *sizeof (*srq->idx_bit_fields));@@ -2878,7 +2878,7 @@ static int ocrdma_poll_hwcq(struct ocrdma_cq *cq, int num_entries,if (qpn =0 ) goto skip_cqe; qp = dev->qp_tbl[qpn]; -BUG_ON (qp =NULL ); +BUG_ON (!qp); expand =is_cqe_for_sq (cqe) ? ocrdma_poll_scqe(qp, cqe, ibwc, &polled, &stop) --Quoted 2 lines
2.12.0
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): fc421509-4069-da8a-b308-60b49ea91ada-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Quoted 5 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 8 Mar 2017 13:14:56 +0100Several update suggestions were taken into account from static source code analysis.
I've dropped this entire series. If you want me to consider it, you need to respin it with the following changes:
1) Put all similar corrections in a single patch. If you are replacing a sizeof() usage with a safer sizeof() usage, then I don't want one patch per replacement, I want one patch for all replacements.
2) Use reasonable git commit messages. "Improve another" is never a reasonable commit message because it implicitly refereces another git commit message. Unless this is a fix for a previous commit, all commit messages should be standalone.
3) Keep your git commit message subject lines within the recommended size. You have many that are too long. As trivial as all of these changes are, I'm not going to go fixup 29 commit messages to take them.
4) Make sure to preserve the reviewed-by tags on the resubmission.
Quoted 36 lines
Markus Elfring (26):
Usekcalloc()inocrdma_create_eqs()
Usekcalloc()inocrdma_mbx_alloc_pd_range()
Improve size determinations inocrdma_mbx_get_dcbx_config()Delete unnecessary variable initialisations inocrdma_mbx_get_dcbx_config()
Improve another size determination inocrdma_mbx_query_qp()Improve another size determination inocrdma_alloc_pd_pool()Improve another size determination inocrdma_mbx_get_ctrl_attribs()Improve size determinations inocrdma_mbx_rdma_stats()Improve another size determination inocrdma_mq_cq_handler()Improve another size determination inocrdma_init_emb_mqe()Delete unnecessary braces
Adjust ten checks for null pointers
Usekcalloc()inocrdma_alloc_resources()
Improve another size determination inocrdma_add()Delete an error message for a failed memory allocation inocrdma_add()
Adjust a null pointer check inocrdma_alloc_resources()Usekmalloc_array()inocrdma_create_srq()
Usekcalloc()in three functions
Improve another size determination inocrdma_alloc_mr()Delete an unnecessary variable assignment inocrdma_alloc_mr()Improve another size determination inocrdma_create_srq()Returning only value constants inocrdma_resize_cq()Delete an unnecessary variable inocrdma_dealloc_pd()One jump label less inocrdma_alloc_ucontext_pd()
Delete unnecessary braces
Adjust further ten checks for null pointersdrivers/infiniband/hw/ocrdma/ocrdma_hw.c | 88 ++++++++++------
-----
drivers/infiniband/hw/ocrdma/ocrdma_main.c | 19 +++--drivers/infiniband/hw/ocrdma/ocrdma_verbs.c| 118 ++++++++++++----
------------3 files changed, 100 insertions(+), 125 deletions(-)
Signature · 9 lines
Doug Ledford <[email protected]> GPG KeyID: B826A3330E572FDD Key fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
v2 cover InfiniBand-OCRDMA: Fine-tuning for several function implementations
From: Markus Elfring <[email protected]>
Date: Sat, 22 Apr 2017 16:16:06 +0200
Several update suggestions were taken into account from static source code analysis.
Markus Elfring (12):
Use kcalloc() in ocrdma_mbx_alloc_pd_range()
Use kcalloc() in five functions
Improve size determinations in ten functions
Delete unnecessary variable initialisations in ocrdma_mbx_get_dcbx_config() Delete unnecessary braces
Use kmalloc_array() in ocrdma_create_srq()
Adjust 21 checks for null pointers
Delete an error message for a failed memory allocation in ocrdma_add() Delete an unnecessary variable assignment in ocrdma_alloc_mr() Returning only value constants in ocrdma_resize_cq()
Delete an unnecessary variable in ocrdma_dealloc_pd()
One jump label less in ocrdma_alloc_ucontext_pd()
---
v2:
Changes were rebased on source files from Linux next-20170421. Some of them were recombined into bigger update steps as requested by Doug Ledford.
drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 88 ++++++++++----------- drivers/infiniband/hw/ocrdma/ocrdma_main.c | 19 +++-- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 118 ++++++++++++---------------- 3 files changed, 100 insertions(+), 125 deletions(-)
Signature · 1 line
2.12.2
PATCH v2 1/12 IB/ocrdma: Use kcalloc() in ocrdma_mbx_alloc_pd_range()
From: Markus Elfring <[email protected]>
Date: Sat, 22 Apr 2017 11:33:25 +0200
* Multiplications for the size determination of memory allocations indicated that array data structures should be processed. Thus reuse the corresponding function "kcalloc".
This issue was detected by using the Coccinelle software.
* Delete the local variable "pd_bitmap_size" which became unnecessary with this refactoring.
--- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +8 -7
@@ -1505,7 +1505,6 @@ int ocrdma_mbx_dealloc_pd(struct ocrdma_dev *dev, struct ocrdma_pd *pd)static int ocrdma_mbx_alloc_pd_range (struct ocrdma_dev *dev) {int status = -ENOMEM ; -size_t pd_bitmap_size;struct ocrdma_alloc_pd_range *cmd;struct ocrdma_alloc_pd_range_rsp *rsp;
@@ -1527,10 +1526,10 @@ static int ocrdma_mbx_alloc_pd_range(struct ocrdma_dev *dev) dev->pd_mgr->pd_dpp_start = rsp->dpp_page_pdid &OCRDMA_ALLOC_PD_RNG_RSP_START_PDID_MASK ; dev->pd_mgr->max_dpp_pd = rsp->pd_count; - pd_bitmap_size -BITS_TO_LONGS (rsp->pd_count) *sizeof (long ); - dev->pd_mgr->pd_dpp_bitmap =kzalloc (pd_bitmap_size, -GFP_KERNEL ); + dev->pd_mgr->pd_dpp_bitmap + =kcalloc (BITS_TO_LONGS (rsp->pd_count), +sizeof (long ), +GFP_KERNEL ); }kfree (cmd); }
@@ -1546,9 +1545,10 @@ static int ocrdma_mbx_alloc_pd_range(struct ocrdma_dev *dev) dev->pd_mgr->pd_norm_start = rsp->dpp_page_pdid &OCRDMA_ALLOC_PD_RNG_RSP_START_PDID_MASK ; dev->pd_mgr->max_normal_pd = rsp->pd_count; - pd_bitmap_size =BITS_TO_LONGS (rsp->pd_count) *sizeof (long ); - dev->pd_mgr->pd_norm_bitmap =kzalloc (pd_bitmap_size, -GFP_KERNEL ); + dev->pd_mgr->pd_norm_bitmap + =kcalloc (BITS_TO_LONGS (rsp->pd_count), +sizeof (long ), +GFP_KERNEL ); }kfree (cmd);
Signature · 1 line
2.12.2
Re: [PATCH v2 01/12] IB/ocrdma: Use kcalloc() in ocrdma_mbx_alloc_pd_range()
Quoted 65 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 22 Apr 2017 11:33:25 +0200* Multiplications for the size determination of memory allocations indicated that array data structures should be processed. Thus reuse the corresponding function "kcalloc".
This issue was detected by using the Coccinelle software.
* Delete the local variable "
pd_bitmap_size" which became unnecessary with this refactoring.Signed-off-by Markus Elfring <[email protected]>--- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)drivers/infiniband/hw/ocrdma/ocrdma_hw.c +8
-9@@ -1505,7 +1505,6 @@ int ocrdma_mbx_dealloc_pd(struct ocrdma_dev *dev, struct ocrdma_pd *pd)static int ocrdma_mbx_alloc_pd_range (struct ocrdma_dev *dev) {int status = -ENOMEM ; -size_t pd_bitmap_size;struct ocrdma_alloc_pd_range *cmd;struct ocrdma_alloc_pd_range_rsp *rsp;@@ -1527,10 +1526,10 @@ static int ocrdma_mbx_alloc_pd_range(struct ocrdma_dev *dev) dev->pd_mgr->pd_dpp_start = rsp->dpp_page_pdid &OCRDMA_ALLOC_PD_RNG_RSP_START_PDID_MASK ; dev->pd_mgr->max_dpp_pd = rsp->pd_count; - pd_bitmap_size = -BITS_TO_LONGS (rsp->pd_count) *sizeof (long ); - dev->pd_mgr->pd_dpp_bitmap =kzalloc (pd_bitmap_size, -GFP_KERNEL ); + dev->pd_mgr->pd_dpp_bitmap + =kcalloc (BITS_TO_LONGS (rsp->pd_count), +sizeof (long ), +GFP_KERNEL ); }kfree (cmd); }@@ -1546,9 +1545,10 @@ static int ocrdma_mbx_alloc_pd_range(struct ocrdma_dev *dev) dev->pd_mgr->pd_norm_start = rsp->dpp_page_pdid &OCRDMA_ALLOC_PD_RNG_RSP_START_PDID_MASK ; dev->pd_mgr->max_normal_pd = rsp->pd_count; - pd_bitmap_size =BITS_TO_LONGS (rsp->pd_count) *sizeof (long ); - dev->pd_mgr->pd_norm_bitmap =kzalloc (pd_bitmap_size, -GFP_KERNEL ); + dev->pd_mgr->pd_norm_bitmap + =kcalloc (BITS_TO_LONGS (rsp->pd_count), +sizeof (long ), +GFP_KERNEL ); }kfree (cmd); --2.12.2
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 01/12] IB/ocrdma: Use kcalloc() in ocrdma_mbx_alloc_pd_range()
Quoted 1 line · Devesh Sharma
Acked-by Devesh Sharma <[email protected]>
Devesh, after you have reviewed any of Markus' patches that you care to review, if you wish any of them to go into my tree, please submit them to me yourself. Thanks.
Signature · 4 lines
Doug Ledford <[email protected]> GPG KeyID: B826A3330E572FDD Key fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD
Re: [v2 01/12] IB/ocrdma: Use kcalloc() in ocrdma_mbx_alloc_pd_range()
Hello,
How will the clarification be continued for the shown change possibilities?
Regards,
Markus
Re: [v2 01/12] IB/ocrdma: Use kcalloc() in ocrdma_mbx_alloc_pd_range()
Quoted 3 lines · SF Markus Elfring
Hello,
How will the clarification be continued for the shown change possibilities?
Every sub-maintainer will decide on his own what and how to proceed with these patches.
Thanks
Quoted 3 lines
Regards,
Markus
PATCH v2 2/12 IB/ocrdma: Use kcalloc() in five functions
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 22 Apr 2017 11:41:55 +0200
* Multiplications for the size determination of memory allocations indicated that array data structures should be processed. Thus use the corresponding function "kcalloc".
This issue was detected by using the Coccinelle software.
* Replace the specification of data types by pointer dereferences to make the corresponding size determinations a bit safer according to the Linux coding style convention.
---
v2:
Changes were rebased on source files from Linux next-20170421. These were recombined as requested by Doug Ledford.
drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 2 +- drivers/infiniband/hw/ocrdma/ocrdma_main.c | 10 +++++----- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 19 +++++++++---------- 3 files changed, 15 insertions(+), 16 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +1 -1
@@ -3103,7 +3103,7 @@ static int ocrdma_create_eqs(struct ocrdma_dev *dev)if (!num_eq)return -EINVAL ; - dev->eq_tbl =kzalloc (sizeof (struct ocrdma_eq ) * num_eq,GFP_KERNEL ); + dev->eq_tbl =kcalloc (num_eq,sizeof (*dev->eq_tbl),GFP_KERNEL );if (!dev->eq_tbl)return -ENOMEM ;
drivers/infiniband/hw/ocrdma/ocrdma_main.c +5 -5
@@ -225,19 +225,19 @@ static int ocrdma_register_device(struct ocrdma_dev *dev)static int ocrdma_alloc_resources (struct ocrdma_dev *dev) {mutex_init (&dev->dev_lock); - dev->cq_tbl =kzalloc (sizeof (struct ocrdma_cq *) * -OCRDMA_MAX_CQ ,GFP_KERNEL ); + dev->cq_tbl =kcalloc (OCRDMA_MAX_CQ ,sizeof (*dev->cq_tbl),GFP_KERNEL );if (!dev->cq_tbl) goto alloc_err;if (dev->attr.max_qp) { - dev->qp_tbl =kzalloc (sizeof (struct ocrdma_qp *) * -OCRDMA_MAX_QP ,GFP_KERNEL ); + dev->qp_tbl =kcalloc (OCRDMA_MAX_QP ,sizeof (*dev->qp_tbl), +GFP_KERNEL );if (!dev->qp_tbl) goto alloc_err; } - dev->stag_arr =kzalloc (sizeof (u64) *OCRDMA_MAX_STAG ,GFP_KERNEL ); + dev->stag_arr =kcalloc (OCRDMA_MAX_STAG ,sizeof (*dev->stag_arr), +GFP_KERNEL );if (dev->stag_arr =NULL ) goto alloc_err;
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +9 -8
@@ -879,9 +879,8 @@ static int ocrdma_build_pbl_tbl(struct ocrdma_dev *dev, struct ocrdma_hw_mr *mr)void *va;dma_addr_t pa; - mr->pbl_table =kzalloc (sizeof (struct ocrdma_pbl ) * - mr->num_pbls,GFP_KERNEL ); - + mr->pbl_table =kcalloc (mr->num_pbls,sizeof (*mr->pbl_table), +GFP_KERNEL );if (!mr->pbl_table)return -ENOMEM ;
@@ -1362,13 +1361,12 @@ static void ocrdma_set_qp_db(struct ocrdma_dev *dev, struct ocrdma_qp *qp,static int ocrdma_alloc_wr_id_tbl (struct ocrdma_qp *qp) { - qp->wqe_wr_id_tbl -kzalloc (sizeof (*(qp->wqe_wr_id_tbl)) * qp->sq.max_cnt, -GFP_KERNEL ); + qp->wqe_wr_id_tbl =kcalloc (qp->sq.max_cnt,sizeof (*qp->wqe_wr_id_tbl), +GFP_KERNEL );if (qp->wqe_wr_id_tbl =NULL )return -ENOMEM ; - qp->rqe_wr_id_tbl -kzalloc (sizeof (u64) * qp->rq.max_cnt,GFP_KERNEL ); + qp->rqe_wr_id_tbl =kcalloc (qp->rq.max_cnt,sizeof (*qp->rqe_wr_id_tbl), +GFP_KERNEL );if (qp->rqe_wr_id_tbl =NULL )return -ENOMEM ;
@@ -1903,8 +1901,9 @@ struct ib_srq *ocrdma_create_srq(struct ib_pd *ibpd, goto err;if (udata =NULL ) { - srq->rqe_wr_id_tbl =kzalloc (sizeof (u64) * srq->rq.max_cnt, -GFP_KERNEL ); + srq->rqe_wr_id_tbl =kcalloc (srq->rq.max_cnt, +sizeof (*srq->rqe_wr_id_tbl), +GFP_KERNEL );if (srq->rqe_wr_id_tbl =NULL ) goto arm_err;
Signature · 1 line
2.12.2
PATCH v2 3/12 IB/ocrdma: Improve size determinations in ten functions
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
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.
---
v2:
Changes were rebased on source files from Linux next-20170421. These were recombined as requested by Doug Ledford.
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(-)
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +1 -1
@@ -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:
drivers/infiniband/hw/ocrdma/ocrdma_main.c +1 -1
@@ -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 ;
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +2 -2
@@ -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;
Signature · 1 line
2.12.2
Re: [PATCH v2 03/12] IB/ocrdma: Improve size determinations in ten functions
Quoted 7 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 22 Apr 2017 13:26:49 +0200Replace 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.
Quoted 6 lines
Signed-off-by Markus Elfring <[email protected]>---
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
Quoted 150 lines
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(-)drivers/infiniband/hw/ocrdma/ocrdma_hw.c +12
-16@@ -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:drivers/infiniband/hw/ocrdma/ocrdma_main.c +1
-1@@ -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 ;drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +2
-3@@ -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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 03/12] IB/ocrdma: Improve size determinations in ten functions
Quoted 17 lines · Leon Romanovsky
Quoted 7 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 22 Apr 2017 13:26:49 +0200Replace 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.
Quoted 6 lines
Signed-off-by Markus Elfring <[email protected]>---
v2:
Changes were rebased on source files from Linux next-20170421. These were recombined as requested by Doug Ledford.Hi Doug,
Quoted 7 lines
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.
I agree with Leon here, and these sort of find/replace automagic clean-up patches make me nervous sometimes.
Markus, what have you done to ensure your patches don't break anything?
-Denny
Re: IB/ocrdma: Improve size determinations in ten functions
Quoted 1 line
Markus, what have you done to ensure your patches don't break anything?
I would expect that this update step will not change the run time behaviour for the OCRDMA module. I guess that it will influence the run time characteristics for compilation of three adjusted source files besides the proposed coding style improvements.
Further update steps change other source code places. I hope that their impact can be clarified according to your expectations for each shown update possibility separately. Some of them got a bit of acceptance already.
How would you like to reduce any remaining software development concerns here?
Regards,
Markus
Re: IB/ocrdma: Improve size determinations in ten functions
Quoted 7 lines · SF Markus Elfring
Quoted 1 line
Markus, what have you done to ensure your patches don't break anything?
I would expect that this update step will not change the run time behaviour for the OCRDMA module. I guess that it will influence the run time characteristics for compilation of three adjusted source files besides the proposed coding style improvements.
Quoted 6 lines
Further update steps change other source code places. I hope that their impact can be clarified according to your expectations for each shown update possibility separately. Some of them got a bit of acceptance already.
How would you like to reduce any remaining software development concerns here?
Dennis,
He didn't check it, this is why in most susbsystems his patches are ignored.
Thanks
Quoted 2 lines
Regards,
Markus
Re: IB/ocrdma: Improve size determinations in ten functions
Quoted 1 line
He didn't check it, this is why in most susbsystems his patches are ignored.
I assume that it does only partly matter how much I could check such an update suggestion when you would generally prefer to exclude some special change possibilities.
It can eventually happen a bit more software evolution, can't it there?
Regards,
Markus
Re: [PATCH v2 03/12] IB/ocrdma: Improve size determinations in ten functions
In reply to Dennis DalessandroQuoted 27 lines · Dennis Dalessandro
Quoted 26 lines · Leon Romanovsky
Quoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 22 Apr 2017 13:26:49 +0200Replace 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.Quoted 6 lines
Signed-off-by Markus Elfring <[email protected]>---
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.
Quoted 8 lines
Quoted 5 lines
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.I agree with Leon here, and these sort of find/replace automagic clean-up patches make me nervous sometimes.
OK, the easiest way to make sure that only the things you want from his patches get through is to have you pull them into a branch and submit them yourself. I'll only take the ones you submit to me, that way there is no confusion about whether or not you have checked them and approved them.
Quoted 5 lines
Markus, what have you done to ensure your patches don't break anything?
-Denny
Signature · 4 lines
Doug Ledford <[email protected]> GPG KeyID: B826A3330E572FDD Key fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD
Re: [PATCH v2 03/12] IB/ocrdma: Improve size determinations in ten functions
Quoted 34 lines · Doug Ledford
Quoted 33 lines · Dennis Dalessandro
Quoted 31 lines · Leon Romanovsky
Quoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 22 Apr 2017 13:26:49 +0200Replace 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.Quoted 6 lines
Signed-off-by Markus Elfring <[email protected]>---
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.
Quoted 8 lines
Quoted 2 lines
I agree with Leon here, and these sort of find/replace automagic clean-up patches make me nervous sometimes.
OK, the easiest way to make sure that only the things you want from his patches get through is to have you pull them into a branch and submit them yourself. I'll only take the ones you submit to me, that way there is no confusion about whether or not you have checked them and approved them.
Fine to me.
Thanks
Quoted 12 lines
Quoted 6 lines
Markus, what have you done to ensure your patches don't break anything?
-Denny
--
Doug Ledford <[email protected]>
GPG KeyID: B826A3330E572FDD
Key fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD
Re: [PATCH v2 03/12] IB/ocrdma: Improve size determinations in ten functions
In reply to Leon RomanovskyQuoted 24 lines · Leon Romanovsky
Quoted 10 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 22 Apr 2017 13:26:49 +0200Replace 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.Quoted 6 lines
Signed-off-by Markus Elfring <[email protected]>---
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.
Quoted 5 lines
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.
OK, the easiest way to make sure that only the things you want from his patches get through is to have you pull them into a branch and submit them yourself. I'll only take the ones you submit to me, that way there is no confusion about whether or not you have checked them and approved them.
Signature · 4 lines
Doug Ledford <[email protected]> GPG KeyID: B826A3330E572FDD Key fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD
PATCH v2 4/12 IB/ocrdma: Delete unnecessary variable initialisations in ocrdma_mbx_get_dcbx_config()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 22 Apr 2017 13:38:33 +0200
The local variables "req" and "rsp" will be set to appropriate pointers a bit later. Thus omit the explicit initialisations at the beginning.
--- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +2 -3
@@ -2894,9 +2894,8 @@ static int ocrdma_mbx_get_dcbx_config(struct ocrdma_dev *dev, u32 ptype,int status;dma_addr_t pa;struct ocrdma_mqe cmd; - -struct ocrdma_get_dcbx_cfg_req *req =NULL ; -struct ocrdma_get_dcbx_cfg_rsp *rsp =NULL ; +struct ocrdma_get_dcbx_cfg_req *req; +struct ocrdma_get_dcbx_cfg_rsp *rsp;struct pci_dev *pdev = dev->nic_info.pdev;struct ocrdma_mqe_sge *mqe_sge = cmd.u.nonemb_req.sge;
Signature · 1 line
2.12.2
PATCH v2 5/12 IB/ocrdma: Delete unnecessary braces
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 22 Apr 2017 13:54:28 +0200
Do not use curly brackets at some source code places where a single statement should be sufficient.
---
v2:
Changes were rebased on source files from Linux next-20170421. These were recombined as requested by Doug Ledford.
drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 17 ++++++------ drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 41 +++++++++++------------------ 2 files changed, 24 insertions(+), 34 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +8 -9
@@ -1092,14 +1092,14 @@ static int ocrdma_mbx_cmd(struct ocrdma_dev *dev, struct ocrdma_mqe *mqe)if (cqe_status || ext_status) {pr_err ("%s() cqe_status=0x%x, ext_status=0x%x," , __func__, cqe_status, ext_status); -if (rsp) { +if (rsp)/* This is for embedded cmds. */ pr_err ("opcode=0x%x, subsystem=0x%x\n" , (rsp->subsys_op &OCRDMA_MBX_RSP_OPCODE_MASK ) >>OCRDMA_MBX_RSP_OPCODE_SHIFT , (rsp->subsys_op &OCRDMA_MBX_RSP_SUBSYS_MASK ) >>OCRDMA_MBX_RSP_SUBSYS_SHIFT ); - } + status =ocrdma_get_mbx_cqe_errno (cqe_status); goto mbx_err; }
@@ -1600,10 +1600,9 @@ void ocrdma_alloc_pd_pool(struct ocrdma_dev *dev)return ; status =ocrdma_mbx_alloc_pd_range (dev); -if (status) { +if (status)pr_err ("%s(%d) Unable to initialize PD pool, using default.\n" , __func__, dev->id); - } }static void ocrdma_free_pd_pool (struct ocrdma_dev *dev)
@@ -2997,11 +2996,10 @@ static int ocrdma_parse_dcbxcfg_rsp(struct ocrdma_dev *dev, int ptype, goto out; } } -if (slindx =OCRDMA_MAX_SERVICE_LEVEL_INDEX ) { +if (slindx =OCRDMA_MAX_SERVICE_LEVEL_INDEX )pr_info ("%s ocrdma%d application priority not set for 0x%x protocol\n" ,dev_name (&dev->nic_info.pdev->dev), dev->id, proto); - } } }
@@ -3158,16 +3156,17 @@ static int ocrdma_modify_eqd(struct ocrdma_dev *dev, struct ocrdma_eq *eq, int num) {int num_eqs, i =0 ; -if (num >8 ) { + +if (num >8 )while (num) { num_eqs =min (num,8 );ocrdma_mbx_modify_eqd (dev, &eq[i], num_eqs); i += num_eqs; num -= num_eqs; } - }else { +else ocrdma_mbx_modify_eqd (dev, eq, num); - } +return 0 ; }
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +16 -25
85 lines not on this page · raw message
Signature · 1 line
2.12.2
PATCH v2 6/12 IB/ocrdma: Use kmalloc_array() in ocrdma_create_srq()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 22 Apr 2017 14:17:46 +0200
* A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus use the corresponding function "kmalloc_array".
This issue was detected by using the Coccinelle software.
* Replace the specification of a data type by a pointer dereference to make the corresponding size determination a bit safer according to the Linux coding style convention.
--- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +3 -1
@@ -1908,8 +1908,9 @@ struct ib_srq *ocrdma_create_srq(struct ib_pd *ibpd, srq->bit_fields_len = (srq->rq.max_cnt /32 ) + (srq->rq.max_cnt %32 ?1 :0 ); - srq->idx_bit_fields -kmalloc (srq->bit_fields_len *sizeof (u32),GFP_KERNEL ); + srq->idx_bit_fields =kmalloc_array (srq->bit_fields_len, +sizeof (*srq->idx_bit_fields), +GFP_KERNEL );if (srq->idx_bit_fields =NULL ) goto arm_err; memset(srq->idx_bit_fields, 0xff,
Signature · 1 line
2.12.2
PATCH v2 7/12 IB/ocrdma: Adjust 21 checks for null pointers
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 22 Apr 2017 14:20:37 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The script “checkpatch.pl” pointed information out like the following.
Comparison to NULL could be written !…
Thus fix affected source code places.
---
v2:
Changes were rebased on source files from Linux next-20170421. These were recombined as requested by Doug Ledford.
drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 20 ++++++++++---------- drivers/infiniband/hw/ocrdma/ocrdma_main.c | 2 +- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 20 ++++++++++---------- 3 files changed, 21 insertions(+), 21 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +10 -10
@@ -665,7 +665,7 @@ static void ocrdma_process_qpcat_error(struct ocrdma_dev *dev,enum ib_qp_state new_ib_qps =IB_QPS_ERR ;enum ib_qp_state old_ib_qps; -if (qp =NULL ) +if (!qp)BUG ();ocrdma_qp_state_change (qp, new_ib_qps, &old_ib_qps); }
@@ -693,7 +693,7 @@ static void ocrdma_dispatch_ibevent(struct ocrdma_dev *dev,if (cqe->qpvalid_qpid &OCRDMA_AE_MCQE_QPVALID ) {if (qpid < dev->attr.max_qp) qp = dev->qp_tbl[qpid]; -if (qp =NULL ) { +if (!qp) {pr_err ("ocrdma%d:Async event - qpid %u is not valid\n" , dev->id, qpid);return ;
@@ -703,7 +703,7 @@ static void ocrdma_dispatch_ibevent(struct ocrdma_dev *dev,if (cqe->cqvalid_cqid &OCRDMA_AE_MCQE_CQVALID ) {if (cqid < dev->attr.max_cq) cq = dev->cq_tbl[cqid]; -if (cq =NULL ) { +if (!cq) {pr_err ("ocrdma%d:Async event - cqid %u is not valid\n" , dev->id, cqid);return ;
@@ -882,7 +882,7 @@ static int ocrdma_mq_cq_handler(struct ocrdma_dev *dev, u16 cq_id)while (1 ) { cqe =ocrdma_get_mcqe (dev); -if (cqe =NULL ) +if (!cqe)break ;ocrdma_le32_to_cpu (cqe,sizeof (*cqe)); cqe_popped +=1 ;
@@ -948,7 +948,7 @@ static void ocrdma_qp_buddy_cq_handler(struct ocrdma_dev *dev,* false - Check for RQ CQ */ bcq =_ocrdma_qp_buddy_cq_handler (dev, cq, true); -if (bcq =NULL ) +if (!bcq) bcq =_ocrdma_qp_buddy_cq_handler (dev, cq, false);spin_unlock_irqrestore (&dev->flush_q_lock, flags);
@@ -969,7 +969,7 @@ static void ocrdma_qp_cq_handler(struct ocrdma_dev *dev, u16 cq_idx)BUG (); cq = dev->cq_tbl[cq_idx]; -if (cq =NULL ) +if (!cq)return ;if (cq->ibcq.comp_handler) {
@@ -1289,7 +1289,7 @@ int ocrdma_mbx_rdma_stats(struct ocrdma_dev *dev, bool reset)int status; old_stats =kmalloc (sizeof (*old_stats),GFP_KERNEL ); -if (old_stats =NULL ) +if (!old_stats)return -ENOMEM ;memset (mqe,0 ,sizeof (*mqe));
@@ -1676,12 +1676,12 @@ static int ocrdma_mbx_create_ah_tbl(struct ocrdma_dev *dev) dev->av_tbl.pbl.va =dma_alloc_coherent (&pdev->dev,PAGE_SIZE , &dev->av_tbl.pbl.pa,GFP_KERNEL ); -if (dev->av_tbl.pbl.va =NULL ) +if (!dev->av_tbl.pbl.va) goto mem_err; dev->av_tbl.va =dma_alloc_coherent (&pdev->dev, dev->av_tbl.size, &pa,GFP_KERNEL ); -if (dev->av_tbl.va =NULL ) +if (!dev->av_tbl.va) goto mem_err_ah; dev->av_tbl.pa = pa; dev->av_tbl.num_ah = max_ah;
@@ -1722,7 +1722,7 @@ static void ocrdma_mbx_delete_ah_tbl(struct ocrdma_dev *dev)struct ocrdma_delete_ah_tbl *cmd;struct pci_dev *pdev = dev->nic_info.pdev; -if (dev->av_tbl.va =NULL ) +if (!dev->av_tbl.va)return ; cmd =ocrdma_init_emb_mqe (OCRDMA_CMD_DELETE_AH_TBL ,sizeof (*cmd));
drivers/infiniband/hw/ocrdma/ocrdma_main.c +1 -1
@@ -238,7 +238,7 @@ static int ocrdma_alloc_resources(struct ocrdma_dev *dev) dev->stag_arr =kcalloc (OCRDMA_MAX_STAG ,sizeof (*dev->stag_arr),GFP_KERNEL ); -if (dev->stag_arr =NULL ) +if (!dev->stag_arr) goto alloc_err;ocrdma_alloc_pd_pool (dev);
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +10 -10
@@ -267,7 +267,7 @@ static int ocrdma_add_mmap(struct ocrdma_ucontext *uctx, u64 phy_addr,struct ocrdma_mm *mm; mm =kzalloc (sizeof (*mm),GFP_KERNEL ); -if (mm =NULL ) +if (!mm)return -ENOMEM ; mm->key.phy_addr = phy_addr; mm->key.len = len;
@@ -1194,7 +1194,7 @@ static int ocrdma_add_qpn_map(struct ocrdma_dev *dev, struct ocrdma_qp *qp) {int status = -EINVAL ; -if (qp->id <OCRDMA_MAX_QP && dev->qp_tbl[qp->id] =NULL ) { +if (qp->id <OCRDMA_MAX_QP && !dev->qp_tbl[qp->id]) { dev->qp_tbl[qp->id] = qp; status =0 ; }
@@ -1362,11 +1362,11 @@ static int ocrdma_alloc_wr_id_tbl(struct ocrdma_qp *qp) { qp->wqe_wr_id_tbl =kcalloc (qp->sq.max_cnt,sizeof (*qp->wqe_wr_id_tbl),GFP_KERNEL ); -if (qp->wqe_wr_id_tbl =NULL ) +if (!qp->wqe_wr_id_tbl)return -ENOMEM ; qp->rqe_wr_id_tbl =kcalloc (qp->rq.max_cnt,sizeof (*qp->rqe_wr_id_tbl),GFP_KERNEL ); -if (qp->rqe_wr_id_tbl =NULL ) +if (!qp->rqe_wr_id_tbl)return -ENOMEM ;return 0 ;
@@ -1426,7 +1426,7 @@ struct ib_qp *ocrdma_create_qp(struct ib_pd *ibpd, goto gen_err; }ocrdma_set_qp_init_params (qp, pd, attrs); -if (udata =NULL ) +if (!udata) qp->cap_flags |= (OCRDMA_QP_MW_BIND |OCRDMA_QP_LKEY0 |OCRDMA_QP_FAST_REG );
@@ -1438,7 +1438,7 @@ struct ib_qp *ocrdma_create_qp(struct ib_pd *ibpd, goto mbx_err;/* user space QP's wr_id table are managed in library */ -if (udata =NULL ) { +if (!udata) { status =ocrdma_alloc_wr_id_tbl (qp);if (status) goto map_err;
@@ -1899,11 +1899,11 @@ struct ib_srq *ocrdma_create_srq(struct ib_pd *ibpd,if (status) goto err; -if (udata =NULL ) { +if (!udata) { srq->rqe_wr_id_tbl =kcalloc (srq->rq.max_cnt,sizeof (*srq->rqe_wr_id_tbl),GFP_KERNEL ); -if (srq->rqe_wr_id_tbl =NULL ) +if (!srq->rqe_wr_id_tbl) goto arm_err; srq->bit_fields_len = (srq->rq.max_cnt / 32) +
@@ -1911,7 +1911,7 @@ struct ib_srq *ocrdma_create_srq(struct ib_pd *ibpd, srq->idx_bit_fields =kmalloc_array (srq->bit_fields_len,sizeof (*srq->idx_bit_fields),GFP_KERNEL ); -if (srq->idx_bit_fields =NULL ) +if (!srq->idx_bit_fields) goto arm_err;memset (srq->idx_bit_fields,0xff , srq->bit_fields_len *sizeof (*srq->idx_bit_fields));
@@ -2885,7 +2885,7 @@ static int ocrdma_poll_hwcq(struct ocrdma_cq *cq, int num_entries,if (qpn =0 ) goto skip_cqe; qp = dev->qp_tbl[qpn]; -BUG_ON (qp =NULL ); +BUG_ON (!qp); expand =is_cqe_for_sq (cqe) ? ocrdma_poll_scqe(qp, cqe, ibwc, &polled, &stop)
Signature · 1 line
2.12.2
Re: [PATCH v2 07/12] IB/ocrdma: Adjust 21 checks for null pointers
Quoted 29 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 22 Apr 2017 14:20:37 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bitThe script “checkpatch.pl” pointed information out like the following.
Comparison to NULL could be written !…
Thus fix affected source code places.
Signed-off-by Markus Elfring <[email protected]>---
v2:
Changes were rebased on source files from Linux next-20170421. These were recombined as requested by Doug Ledford.drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 20 ++++++++++---------- drivers/infiniband/hw/ocrdma/ocrdma_main.c | 2 +- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 20 ++++++++++---------- 3 files changed, 21 insertions(+), 21 deletions(-)drivers/infiniband/hw/ocrdma/ocrdma_hw.c +0
-0
drivers/infiniband/hw/ocrdma/ocrdma_hw.c static void ocrdma_process_qpcat_error(struct ocrdma_dev *dev, · line 669
Quoted 6 lines
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +1
-1@@ -665,7 +665,7 @@ static void ocrdma_process_qpcat_error(struct ocrdma_dev *dev,enum ib_qp_state new_ib_qps =IB_QPS_ERR ;enum ib_qp_state old_ib_qps; -if (qp ==NULL ) +if (!qp)BUG ();
There is a need to get rid of BUG() in driver code.
Quoted 117 lines
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +9
-9ocrdma_qp_state_change (qp, new_ib_qps, &old_ib_qps); }@@ -693,7 +693,7 @@ static void ocrdma_dispatch_ibevent(struct ocrdma_dev *dev,if (cqe->qpvalid_qpid &OCRDMA_AE_MCQE_QPVALID ) {if (qpid < dev->attr.max_qp) qp = dev->qp_tbl[qpid]; -if (qp ==NULL ) { +if (!qp) {pr_err ("ocrdma%d:Async event - qpid %u is not valid\n" , dev->id, qpid);return ;@@ -703,7 +703,7 @@ static void ocrdma_dispatch_ibevent(struct ocrdma_dev *dev,if (cqe->cqvalid_cqid &OCRDMA_AE_MCQE_CQVALID ) {if (cqid < dev->attr.max_cq) cq = dev->cq_tbl[cqid]; -if (cq ==NULL ) { +if (!cq) {pr_err ("ocrdma%d:Async event - cqid %u is not valid\n" , dev->id, cqid);return ;@@ -882,7 +882,7 @@ static int ocrdma_mq_cq_handler(struct ocrdma_dev *dev, u16 cq_id)while (1 ) { cqe =ocrdma_get_mcqe (dev); -if (cqe ==NULL ) +if (!cqe)break ;ocrdma_le32_to_cpu (cqe,sizeof (*cqe)); cqe_popped +=1 ;@@ -948,7 +948,7 @@ static void ocrdma_qp_buddy_cq_handler(struct ocrdma_dev *dev,* false - Check for RQ CQ */ bcq =_ocrdma_qp_buddy_cq_handler (dev, cq, true); -if (bcq ==NULL ) +if (!bcq) bcq =_ocrdma_qp_buddy_cq_handler (dev, cq, false);spin_unlock_irqrestore (&dev->flush_q_lock, flags);@@ -969,7 +969,7 @@ static void ocrdma_qp_cq_handler(struct ocrdma_dev *dev, u16 cq_idx)BUG (); cq = dev->cq_tbl[cq_idx]; -if (cq ==NULL ) +if (!cq)return ;if (cq->ibcq.comp_handler) {@@ -1289,7 +1289,7 @@ int ocrdma_mbx_rdma_stats(struct ocrdma_dev *dev, bool reset)int status; old_stats =kmalloc (sizeof (*old_stats),GFP_KERNEL ); -if (old_stats ==NULL ) +if (!old_stats)return -ENOMEM ;memset (mqe,0 ,sizeof (*mqe));@@ -1676,12 +1676,12 @@ static int ocrdma_mbx_create_ah_tbl(struct ocrdma_dev *dev) dev->av_tbl.pbl.va =dma_alloc_coherent (&pdev->dev,PAGE_SIZE , &dev->av_tbl.pbl.pa,GFP_KERNEL ); -if (dev->av_tbl.pbl.va ==NULL ) +if (!dev->av_tbl.pbl.va) goto mem_err; dev->av_tbl.va =dma_alloc_coherent (&pdev->dev, dev->av_tbl.size, &pa,GFP_KERNEL ); -if (dev->av_tbl.va ==NULL ) +if (!dev->av_tbl.va) goto mem_err_ah; dev->av_tbl.pa = pa; dev->av_tbl.num_ah = max_ah;@@ -1722,7 +1722,7 @@ static void ocrdma_mbx_delete_ah_tbl(struct ocrdma_dev *dev)struct ocrdma_delete_ah_tbl *cmd;struct pci_dev *pdev = dev->nic_info.pdev; -if (dev->av_tbl.va ==NULL ) +if (!dev->av_tbl.va)return ; cmd =ocrdma_init_emb_mqe (OCRDMA_CMD_DELETE_AH_TBL ,sizeof (*cmd));drivers/infiniband/hw/ocrdma/ocrdma_main.c +1
-1@@ -238,7 +238,7 @@ static int ocrdma_alloc_resources(struct ocrdma_dev *dev) dev->stag_arr =kcalloc (OCRDMA_MAX_STAG ,sizeof (*dev->stag_arr),GFP_KERNEL ); -if (dev->stag_arr ==NULL ) +if (!dev->stag_arr) goto alloc_err;ocrdma_alloc_pd_pool (dev);drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +2
-2@@ -267,7 +267,7 @@ static int ocrdma_add_mmap(struct ocrdma_ucontext *uctx, u64 phy_addr,struct ocrdma_mm *mm; mm =kzalloc (sizeof (*mm),GFP_KERNEL ); -if (mm ==NULL ) +if (!mm)return -ENOMEM ; mm->key.phy_addr = phy_addr; mm->key.len = len;@@ -1194,7 +1194,7 @@ static int ocrdma_add_qpn_map(struct ocrdma_dev *dev, struct ocrdma_qp *qp) {int status = -EINVAL ; -if (qp->id <OCRDMA_MAX_QP && dev->qp_tbl[qp->id] ==NULL ) { +if (qp->id <OCRDMA_MAX_QP && !dev->qp_tbl[qp->id]) { dev->qp_tbl[qp->id] = qp; status =0 ; }@@ -1362,11 +1362,11 @@ static int ocrdma_alloc_wr_id_tbl(struct ocrdma_qp *qp) {
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c static int ocrdma_alloc_wr_id_tbl(struct ocrdma_qp *qp) · line 1370
Quoted 10 lines
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +2
-2qp->wqe_wr_id_tbl =kcalloc (qp->sq.max_cnt,sizeof (*qp->wqe_wr_id_tbl),GFP_KERNEL ); -if (qp->wqe_wr_id_tbl ==NULL ) +if (!qp->wqe_wr_id_tbl)return -ENOMEM ; qp->rqe_wr_id_tbl =kcalloc (qp->rq.max_cnt,sizeof (*qp->rqe_wr_id_tbl),GFP_KERNEL ); -if (qp->rqe_wr_id_tbl ==NULL ) +if (!qp->rqe_wr_id_tbl)return -ENOMEM ;
Memory leak here, need to free qp->wqe_wr_id_tb here.
Quoted 44 lines
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +5
-5return 0 ;@@ -1426,7 +1426,7 @@ struct ib_qp *ocrdma_create_qp(struct ib_pd *ibpd, goto gen_err; }ocrdma_set_qp_init_params (qp, pd, attrs); -if (udata ==NULL ) +if (!udata) qp->cap_flags |= (OCRDMA_QP_MW_BIND |OCRDMA_QP_LKEY0 |OCRDMA_QP_FAST_REG );@@ -1438,7 +1438,7 @@ struct ib_qp *ocrdma_create_qp(struct ib_pd *ibpd, goto mbx_err;/* user space QP's wr_id table are managed in library */ -if (udata ==NULL ) { +if (!udata) { status =ocrdma_alloc_wr_id_tbl (qp);if (status) goto map_err;@@ -1899,11 +1899,11 @@ struct ib_srq *ocrdma_create_srq(struct ib_pd *ibpd,if (status) goto err; -if (udata ==NULL ) { +if (!udata) { srq->rqe_wr_id_tbl =kcalloc (srq->rq.max_cnt,sizeof (*srq->rqe_wr_id_tbl),GFP_KERNEL ); -if (srq->rqe_wr_id_tbl ==NULL ) +if (!srq->rqe_wr_id_tbl) goto arm_err; srq->bit_fields_len = (srq->rq.max_cnt / 32) +@@ -1911,7 +1911,7 @@ struct ib_srq *ocrdma_create_srq(struct ib_pd *ibpd, srq->idx_bit_fields =kmalloc_array (srq->bit_fields_len,sizeof (*srq->idx_bit_fields),GFP_KERNEL ); -if (srq->idx_bit_fields ==NULL ) +if (!srq->idx_bit_fields) goto arm_err;memset (srq->idx_bit_fields,0xff , srq->bit_fields_len *sizeof (*srq->idx_bit_fields));
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c static int ocrdma_poll_hwcq(struct ocrdma_cq *cq, int num_entries, · line 2888
Quoted 5 lines
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +1
-1@@ -2885,7 +2885,7 @@ static int ocrdma_poll_hwcq(struct ocrdma_cq *cq, int num_entries,if (qpn ==0 ) goto skip_cqe; qp = dev->qp_tbl[qpn]; -BUG_ON (qp ==NULL ); +BUG_ON (!qp);
Again, bug in driver can crash whole system. There is a need to get rid of it.
Quoted 6 lines
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +0
-1expand =is_cqe_for_sq (cqe) ? ocrdma_poll_scqe(qp, cqe, ibwc, &polled, &stop) --2.12.2
PATCH v2 8/12 IB/ocrdma: Delete an error message for a failed memory allocation in ocrdma_add()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 22 Apr 2017 14:36:30 +0200
Omit an extra message for a memory allocation failure in this function.
--- drivers/infiniband/hw/ocrdma/ocrdma_main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_main.c +2 -3
@@ -304,10 +304,9 @@ static struct ocrdma_dev *ocrdma_add(struct be_dev_info *dev_info)struct ocrdma_dev *dev; dev = (struct ocrdma_dev *)ib_alloc_device (sizeof (*dev)); -if (!dev) { -pr_err ("Unable to allocate ib device\n" ); +if (!dev)return NULL ; - } + dev->mbx_cmd =kzalloc (sizeof (struct ocrdma_mqe_emb_cmd ),GFP_KERNEL );if (!dev->mbx_cmd) goto idr_err;
Signature · 1 line
2.12.2
PATCH v2 9/12 IB/ocrdma: Delete an unnecessary variable assignment in ocrdma_alloc_mr()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 22 Apr 2017 15:07:41 +0200
Delete an assignment for the local variable "status" in an if branch because the desired failure indication is already specified by a constant error code at the end.
--- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +1 -3
@@ -3022,10 +3022,8 @@ struct ib_mr *ocrdma_alloc_mr(struct ib_pd *ibpd,return ERR_PTR (-ENOMEM ); mr->pages =kcalloc (max_num_sg,sizeof (*mr->pages),GFP_KERNEL ); -if (!mr->pages) { - status = -ENOMEM ; +if (!mr->pages) goto pl_err; - } status =ocrdma_get_pbl_info (dev, mr, max_num_sg);if (status)
Signature · 1 line
2.12.2
PATCH v2 10/12 IB/ocrdma: Returning only value constants in ocrdma_resize_cq()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 22 Apr 2017 15:15:09 +0200
Return constant integer values without storing them in the local variable "status".
--- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +3 -6
@@ -1122,15 +1122,12 @@ struct ib_cq *ocrdma_create_cq(struct ib_device *ibdev,int ocrdma_resize_cq (struct ib_cq *ibcq,int new_cnt,struct ib_udata *udata) { -int status =0 ;struct ocrdma_cq *cq =get_ocrdma_cq (ibcq); -if (new_cnt <1 || new_cnt > cq->max_hw_cqe) { - status = -EINVAL ; -return status; - } +if (new_cnt <1 || new_cnt > cq->max_hw_cqe) +return -EINVAL ; ibcq->cqe = new_cnt; -return status; +return 0 ; }static void ocrdma_flush_cq (struct ocrdma_cq *cq)
Signature · 1 line
2.12.2
PATCH v2 11/12 IB/ocrdma: Delete an unnecessary variable in ocrdma_dealloc_pd()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 22 Apr 2017 15:32:05 +0200
1. Return zero in one case directly.
2. Return the value from a call of the function "_ocrdma_dealloc_pd" without using an extra assignment for the local variable.
3. Remove the variable "status" in this function then.
--- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +2 -4
@@ -754,7 +754,6 @@ int ocrdma_dealloc_pd(struct ib_pd *ibpd)struct ocrdma_pd *pd =get_ocrdma_pd (ibpd);struct ocrdma_dev *dev =get_ocrdma_dev (ibpd->device);struct ocrdma_ucontext *uctx =NULL ; -int status =0 ;u64 usr_db; uctx = pd->uctx;
@@ -768,11 +767,10 @@ int ocrdma_dealloc_pd(struct ib_pd *ibpd)if (is_ucontext_pd (uctx, pd)) {ocrdma_release_ucontext_pd (uctx); -return status; +return 0 ; } } - status =_ocrdma_dealloc_pd (dev, pd); -return status; +return _ocrdma_dealloc_pd (dev, pd); } static int ocrdma_alloc_lkey(struct ocrdma_dev *dev, struct ocrdma_mr *mr,
Signature · 1 line
2.12.2
PATCH v2 12/12 IB/ocrdma: One jump label less in ocrdma_alloc_ucontext_pd()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 22 Apr 2017 15:45:21 +0200
This issue was detected by using the Coccinelle software.
1. Return directly if a call of the function "_ocrdma_alloc_pd" failed.
2. Reduce the scope for the local variable "status" to one case of an if statement.
3. Delete the jump label "err" then.
4. Return zero as a constant at the end.
--- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +4 -6
@@ -484,19 +484,17 @@ static int ocrdma_alloc_ucontext_pd(struct ocrdma_dev *dev,struct ocrdma_ucontext *uctx, struct ib_udata *udata) { - int status = 0; - uctx->cntxt_pd = _ocrdma_alloc_pd(dev, uctx, udata);if (IS_ERR (uctx->cntxt_pd)) { - status =PTR_ERR (uctx->cntxt_pd); +int status =PTR_ERR (uctx->cntxt_pd); + uctx->cntxt_pd =NULL ; - goto err; +return status; } uctx->cntxt_pd->uctx = uctx; uctx->cntxt_pd->ibpd.device = &dev->ibdev; -err: -return status; +return 0 ; }static int ocrdma_dealloc_ucontext_pd (struct ocrdma_ucontext *uctx)
Signature · 1 line
2.12.2