diff mbox series

[v2,70/83] raw/dpaa2_qdma: remove unnecessary NULL checks

Message ID 20220124174719.14417-71-stephen@networkplumber.org (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers show
Series remove unnecessary null checks | expand

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Stephen Hemminger Jan. 24, 2022, 5:47 p.m. UTC
Remove redundant NULL pointer checks before free functions
found by nullfree.cocci

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/raw/dpaa2_qdma/dpaa2_qdma.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

Comments

Nipun Gupta Jan. 24, 2022, 6:09 p.m. UTC | #1
Acked-by: Nipun Gupta <nipun.gupta@nxp.com>

> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: 24 January 2022 23:17
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Nipun Gupta
> <nipun.gupta@nxp.com>
> Subject: [PATCH v2 70/83] raw/dpaa2_qdma: remove unnecessary NULL checks
> 
> Remove redundant NULL pointer checks before free functions
> found by nullfree.cocci
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  drivers/raw/dpaa2_qdma/dpaa2_qdma.c | 15 +++++----------
>  1 file changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
> b/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
> index ebc2cd5d0ddc..b2260439a4ef 100644
> --- a/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
> +++ b/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
> @@ -1115,11 +1115,9 @@ dpaa2_qdma_reset(struct rte_rawdev *rawdev)
> 
>  	/* Reset and free virtual queues */
>  	for (i = 0; i < qdma_dev->max_vqs; i++) {
> -		if (qdma_dev->vqs[i].status_ring)
> -			rte_ring_free(qdma_dev->vqs[i].status_ring);
> +		rte_ring_free(qdma_dev->vqs[i].status_ring);
>  	}
> -	if (qdma_dev->vqs)
> -		rte_free(qdma_dev->vqs);
> +	rte_free(qdma_dev->vqs);
>  	qdma_dev->vqs = NULL;
> 
>  	/* Reset per core info */
> @@ -1314,8 +1312,7 @@ dpaa2_qdma_queue_setup(struct rte_rawdev
> *rawdev,
> 
>  	if (qdma_dev->vqs[i].hw_queue == NULL) {
>  		DPAA2_QDMA_ERR("No H/W queue available for VQ");
> -		if (qdma_dev->vqs[i].status_ring)
> -			rte_ring_free(qdma_dev->vqs[i].status_ring);
> +		rte_ring_free(qdma_dev->vqs[i].status_ring);
>  		qdma_dev->vqs[i].status_ring = NULL;
>  		rte_spinlock_unlock(&qdma_dev->lock);
>  		return -ENODEV;
> @@ -1516,14 +1513,12 @@ dpaa2_qdma_queue_release(struct rte_rawdev
> *rawdev,
>  	if (qdma_vq->exclusive_hw_queue)
>  		free_hw_queue(qdma_vq->hw_queue);
>  	else {
> -		if (qdma_vq->status_ring)
> -			rte_ring_free(qdma_vq->status_ring);
> +		rte_ring_free(qdma_vq->status_ring);
> 
>  		put_hw_queue(qdma_vq->hw_queue);
>  	}
> 
> -	if (qdma_vq->fle_pool)
> -		rte_mempool_free(qdma_vq->fle_pool);
> +	rte_mempool_free(qdma_vq->fle_pool);
> 
>  	memset(qdma_vq, 0, sizeof(struct qdma_virt_queue));
> 
> --
> 2.30.2
diff mbox series

Patch

diff --git a/drivers/raw/dpaa2_qdma/dpaa2_qdma.c b/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
index ebc2cd5d0ddc..b2260439a4ef 100644
--- a/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
+++ b/drivers/raw/dpaa2_qdma/dpaa2_qdma.c
@@ -1115,11 +1115,9 @@  dpaa2_qdma_reset(struct rte_rawdev *rawdev)
 
 	/* Reset and free virtual queues */
 	for (i = 0; i < qdma_dev->max_vqs; i++) {
-		if (qdma_dev->vqs[i].status_ring)
-			rte_ring_free(qdma_dev->vqs[i].status_ring);
+		rte_ring_free(qdma_dev->vqs[i].status_ring);
 	}
-	if (qdma_dev->vqs)
-		rte_free(qdma_dev->vqs);
+	rte_free(qdma_dev->vqs);
 	qdma_dev->vqs = NULL;
 
 	/* Reset per core info */
@@ -1314,8 +1312,7 @@  dpaa2_qdma_queue_setup(struct rte_rawdev *rawdev,
 
 	if (qdma_dev->vqs[i].hw_queue == NULL) {
 		DPAA2_QDMA_ERR("No H/W queue available for VQ");
-		if (qdma_dev->vqs[i].status_ring)
-			rte_ring_free(qdma_dev->vqs[i].status_ring);
+		rte_ring_free(qdma_dev->vqs[i].status_ring);
 		qdma_dev->vqs[i].status_ring = NULL;
 		rte_spinlock_unlock(&qdma_dev->lock);
 		return -ENODEV;
@@ -1516,14 +1513,12 @@  dpaa2_qdma_queue_release(struct rte_rawdev *rawdev,
 	if (qdma_vq->exclusive_hw_queue)
 		free_hw_queue(qdma_vq->hw_queue);
 	else {
-		if (qdma_vq->status_ring)
-			rte_ring_free(qdma_vq->status_ring);
+		rte_ring_free(qdma_vq->status_ring);
 
 		put_hw_queue(qdma_vq->hw_queue);
 	}
 
-	if (qdma_vq->fle_pool)
-		rte_mempool_free(qdma_vq->fle_pool);
+	rte_mempool_free(qdma_vq->fle_pool);
 
 	memset(qdma_vq, 0, sizeof(struct qdma_virt_queue));