RDMA/bnxt_re: Adjustments for bnxt_qplib_alloc_dpi_tbl()
Subsystems (3)
cover RDMA/bnxt_re: Adjustments for bnxt_qplib_alloc_dpi_tbl()
From: Markus Elfring <[email protected]>
Date: Sat, 27 Jan 2018 21:10:12 +0100
Two update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Delete two error messages for a failed memory allocation Use common error handling code
drivers/infiniband/hw/bnxt_re/qplib_res.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
Signature · 1 line
2.16.1
PATCH 1/2 RDMA/bnxt_re: Delete two error messages for a failed memory allocation in bnxt_qplib_alloc_dpi_tbl()
From: Markus Elfring <[email protected]>
Date: Sat, 27 Jan 2018 20:40:11 +0100
Omit extra messages for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
--- drivers/infiniband/hw/bnxt_re/qplib_res.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/infiniband/hw/bnxt_re/qplib_res.c +0 -5
@@ -707,8 +707,6 @@ static int bnxt_qplib_alloc_dpi_tbl(struct bnxt_qplib_res *res, dpit->app_tbl =kcalloc (dpit->max,sizeof (void *),GFP_KERNEL );if (!dpit->app_tbl) {pci_iounmap (res->pdev, dpit->dbr_bar_reg_iomem); -dev_err (&res->pdev->dev, -"QPLIB: DPI app tbl allocation failed" );return -ENOMEM ; }
@@ -721,9 +719,6 @@ static int bnxt_qplib_alloc_dpi_tbl(struct bnxt_qplib_res *res,pci_iounmap (res->pdev, dpit->dbr_bar_reg_iomem);kfree (dpit->app_tbl); dpit->app_tbl =NULL ; -dev_err (&res->pdev->dev, -"QPLIB: DPI tbl allocation failed for size = %d" , - bytes);return -ENOMEM ; }
Signature · 1 line
2.16.1
PATCH 2/2 RDMA/bnxt_re: Use common error handling code in bnxt_qplib_alloc_dpi_tbl()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 27 Jan 2018 20:56:56 +0100
Add a jump target so that a bit of exception handling can be better reused at the end of this function.
--- drivers/infiniband/hw/bnxt_re/qplib_res.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/infiniband/hw/bnxt_re/qplib_res.c +7 -6
@@ -705,10 +705,8 @@ static int bnxt_qplib_alloc_dpi_tbl(struct bnxt_qplib_res *res, dpit->max = dbr_len /PAGE_SIZE ; dpit->app_tbl =kcalloc (dpit->max,sizeof (void *),GFP_KERNEL ); -if (!dpit->app_tbl) { -pci_iounmap (res->pdev, dpit->dbr_bar_reg_iomem); -return -ENOMEM ; - } +if (!dpit->app_tbl) + goto unmap_io; bytes = dpit->max >>3 ;if (!bytes)
@@ -716,15 +714,18 @@ static int bnxt_qplib_alloc_dpi_tbl(struct bnxt_qplib_res *res, dpit->tbl =kmalloc (bytes,GFP_KERNEL );if (!dpit->tbl) { -pci_iounmap (res->pdev, dpit->dbr_bar_reg_iomem);kfree (dpit->app_tbl); dpit->app_tbl =NULL ; -return -ENOMEM ; + goto unmap_io; }memset ((u8 *)dpit->tbl,0xFF , bytes);return 0 ; + +unmap_io: +pci_iounmap (res->pdev, dpit->dbr_bar_reg_iomem); +return -ENOMEM ; }/* PKEYs */
Signature · 1 line
2.16.1
Quoted 5 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 27 Jan 2018 21:10:12 +0100Two update suggestions were taken into account
from static source code analysis.
You don't need 2 patches when changing same lines of code. Could you squash both and send your changes in a single patch. The patches look good to me otherwise.
-Thanks
Quoted 8 lines
Markus Elfring (2):
Delete two error messages for a failed memory allocation Use common error handling codedrivers/infiniband/hw/bnxt_re/qplib_res.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
Quoted 7 lines
--
2.16.1--
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
--
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
Quoted 1 line
You don't need 2 patches when changing same lines of code.
Are these really the same?
Quoted 1 line
Could you squash both and send your changes in a single patch.
I prefer to keep the deletion of questionable error messages separate from the refactoring for a bit of exception handling.
Quoted 1 line
The patches look good to me otherwise.
Thanks for your constructive feedback.
Regards,
Markus
Quoted 10 lines · SF Markus Elfring
Quoted 1 line
You don't need 2 patches when changing same lines of code.
Are these really the same?
Quoted 1 line
Could you squash both and send your changes in a single patch.
I prefer to keep the deletion of questionable error messages separate from the refactoring for a bit of exception handling.
Okay fair enough
Series Acked-By: Devesh Sharma <devesh.sharma-dY08KVG/lbpWk0Htik3J/[email protected]>
Quoted 11 lines
Quoted 2 lines
The patches look good to me otherwise.
Thanks for your constructive feedback.
Regards,
Markus
--
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
--
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
Quoted 6 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 27 Jan 2018 21:10:12 +0100Two update suggestions were taken into account
from static source code analysis.
Quoted 7 lines
Markus Elfring (2):
Delete two error messages for a failed memory allocation Use common error handling codedrivers/infiniband/hw/bnxt_re/qplib_res.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
I like it.
Jason Gunthorpe
AppliedQuoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 27 Jan 2018 21:10:12 +0100Two update suggestions were taken into account
from static source code analysis.Markus Elfring (2):
Delete two error messages for a failed memory allocation Use common error handling code
Applied to for-next with Jonathan and Devesh's ack, thanks all
Jason