Skip to contentSkip to conversation

net: qed: Remove unneeded cast from memory allocation

PATCH Applied Aishwarya Ramakrishnan 3 participants 3 messages Apr 19, 2020 – Apr 20, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: qed: Remove unneeded cast from memory allocation

Remove casting the values returned by memory allocation function.

Coccinelle emits WARNING: casting value returned by memory allocation function to struct pointer is useless.

This issue was detected by using the Coccinelle.

---
 drivers/net/ethernet/qlogic/qed/qed_roce.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/net/ethernet/qlogic/qed/qed_roce.c +8 -9
index 37e70562a964..475b89903f46 100644
@@ -736,9 +736,9 @@ static int qed_roce_sp_destroy_qp_responder(struct qed_hwfn *p_hwfn,
 
 	p_ramrod = &p_ent->ramrod.roce_destroy_qp_resp;
 
-	p_ramrod_res = (struct roce_destroy_qp_resp_output_params *)
-	    dma_alloc_coherent(&p_hwfn->cdev->pdev->dev, sizeof(*p_ramrod_res),
-			       &ramrod_res_phys, GFP_KERNEL);
+	p_ramrod_res = dma_alloc_coherent(&p_hwfn->cdev->pdev->dev,
+					  sizeof(*p_ramrod_res),
+					  &ramrod_res_phys, GFP_KERNEL);
 
 	if (!p_ramrod_res) {
 		rc = -ENOMEM;
@@ -872,10 +872,10 @@ int qed_roce_query_qp(struct qed_hwfn *p_hwfn,
 	}
 
 	/* Send a query responder ramrod to FW to get RQ-PSN and state */
-	p_resp_ramrod_res = (struct roce_query_qp_resp_output_params *)
-	    dma_alloc_coherent(&p_hwfn->cdev->pdev->dev,
-			       sizeof(*p_resp_ramrod_res),
-			       &resp_ramrod_res_phys, GFP_KERNEL);
+	p_resp_ramrod_res =
+		dma_alloc_coherent(&p_hwfn->cdev->pdev->dev,
+				   sizeof(*p_resp_ramrod_res),
+				   &resp_ramrod_res_phys, GFP_KERNEL);
 	if (!p_resp_ramrod_res) {
 		DP_NOTICE(p_hwfn,
 			  "qed query qp failed: cannot allocate memory (ramrod)\n");
@@ -920,8 +920,7 @@ int qed_roce_query_qp(struct qed_hwfn *p_hwfn,
 	}
 
 	/* Send a query requester ramrod to FW to get SQ-PSN and state */
-	p_req_ramrod_res = (struct roce_query_qp_req_output_params *)
-			   dma_alloc_coherent(&p_hwfn->cdev->pdev->dev,
+	p_req_ramrod_res = dma_alloc_coherent(&p_hwfn->cdev->pdev->dev,
 					      sizeof(*p_req_ramrod_res),
 					      &req_ramrod_res_phys,
 					      GFP_KERNEL);
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw
Quoted 66 lines

From: Aishwarya Ramakrishnan <[email protected]>
Sent: Sunday, April 19, 2020 7:29 PM

----------------------------------------------------------------------
Remove casting the values returned by memory allocation function.

Coccinelle emits WARNING: casting value returned by memory allocation function to struct pointer is useless.

This issue was detected by using the Coccinelle.

---
 drivers/net/ethernet/qlogic/qed/qed_roce.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/net/ethernet/qlogic/qed/qed_roce.c +3 -3
index 37e70562a964..475b89903f46 100644
@@ -736,9 +736,9 @@ static int qed_roce_sp_destroy_qp_responder(struct
 qed_hwfn *p_hwfn,
 
 	p_ramrod = &p_ent->ramrod.roce_destroy_qp_resp;
 
-	p_ramrod_res = (struct roce_destroy_qp_resp_output_params *)
-	    dma_alloc_coherent(&p_hwfn->cdev->pdev->dev,
 sizeof(*p_ramrod_res),
-			       &ramrod_res_phys, GFP_KERNEL);
+	p_ramrod_res = dma_alloc_coherent(&p_hwfn->cdev->pdev->dev,
+					  sizeof(*p_ramrod_res),
+					  &ramrod_res_phys, GFP_KERNEL);
 
drivers/net/ethernet/qlogic/qed/qed_roce.c +4 -4
 	if (!p_ramrod_res) {
 		rc = -ENOMEM;
@@ -872,10 +872,10 @@ int qed_roce_query_qp(struct qed_hwfn
 *p_hwfn,
 	}
 
 	/* Send a query responder ramrod to FW to get RQ-PSN and state */
-	p_resp_ramrod_res = (struct roce_query_qp_resp_output_params
 *)
-	    dma_alloc_coherent(&p_hwfn->cdev->pdev->dev,
-			       sizeof(*p_resp_ramrod_res),
-			       &resp_ramrod_res_phys, GFP_KERNEL);
+	p_resp_ramrod_res =
+		dma_alloc_coherent(&p_hwfn->cdev->pdev->dev,
+				   sizeof(*p_resp_ramrod_res),
+				   &resp_ramrod_res_phys, GFP_KERNEL);
 	if (!p_resp_ramrod_res) {
drivers/net/ethernet/qlogic/qed/qed_roce.c +0 -0
 		DP_NOTICE(p_hwfn,
 			  "qed query qp failed: cannot allocate memory

(ramrod)\n"); @@ -920,8 +920,7 @@ int qed_roce_query_qp(struct qed_hwfn *p_hwfn,

drivers/net/ethernet/qlogic/qed/qed_roce.c +1 -2
 	}
 
 	/* Send a query requester ramrod to FW to get SQ-PSN and state */
-	p_req_ramrod_res = (struct roce_query_qp_req_output_params *)
-			   dma_alloc_coherent(&p_hwfn->cdev->pdev->dev,
+	p_req_ramrod_res = dma_alloc_coherent(&p_hwfn->cdev->pdev-
Quoted 1 line

dev,

drivers/net/ethernet/qlogic/qed/qed_roce.c +0 -1
 					      sizeof(*p_req_ramrod_res),
 					      &req_ramrod_res_phys,
 					      GFP_KERNEL);
--
Quoted 1 line

2.17.1

Thanks,

maintainer Applied
#2 lore raw
In reply to Aishwarya Ramakrishnan

From: Aishwarya Ramakrishnan <[email protected]>
Date: Sun, 19 Apr 2020 21:59:17 +0530

Quoted 8 lines

Remove casting the values returned by memory allocation function.

Coccinelle emits WARNING: casting value returned by memory allocation function to struct pointer is useless.

This issue was detected by using the Coccinelle.

Applied to net-next, thanks.