diff mbox series

[v2,75/83] vdpa/ifc: remove unnecessary NULL checks

Message ID 20220124174719.14417-76-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 success coding style OK

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/vdpa/ifc/ifcvf_vdpa.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

Comments

Xia, Chenbo Jan. 27, 2022, 5:54 a.m. UTC | #1
> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Tuesday, January 25, 2022 1:47 AM
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>; Wang, Xiao W
> <xiao.w.wang@intel.com>
> Subject: [PATCH v2 75/83] vdpa/ifc: 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/vdpa/ifc/ifcvf_vdpa.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c
> index 3853c4cf7e85..9f05595b6b34 100644
> --- a/drivers/vdpa/ifc/ifcvf_vdpa.c
> +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
> @@ -226,8 +226,7 @@ ifcvf_dma_map(struct ifcvf_internal *internal, bool do_map)
>  	}
> 
>  exit:
> -	if (mem)
> -		free(mem);
> +	free(mem);
>  	return ret;
>  }
> 
> @@ -253,8 +252,7 @@ hva_to_gpa(int vid, uint64_t hva)
>  	}
> 
>  exit:
> -	if (mem)
> -		free(mem);
> +	free(mem);
>  	return gpa;
>  }
> 
> @@ -661,8 +659,7 @@ m_ifcvf_start(struct ifcvf_internal *internal)
> 
>  error:
>  	for (i = 0; i < nr_vring; i++)
> -		if (internal->m_vring[i].desc)
> -			rte_free(internal->m_vring[i].desc);
> +		rte_free(internal->m_vring[i].desc);
> 
>  	return -1;
>  }
> --
> 2.30.2

Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
diff mbox series

Patch

diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c
index 3853c4cf7e85..9f05595b6b34 100644
--- a/drivers/vdpa/ifc/ifcvf_vdpa.c
+++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
@@ -226,8 +226,7 @@  ifcvf_dma_map(struct ifcvf_internal *internal, bool do_map)
 	}
 
 exit:
-	if (mem)
-		free(mem);
+	free(mem);
 	return ret;
 }
 
@@ -253,8 +252,7 @@  hva_to_gpa(int vid, uint64_t hva)
 	}
 
 exit:
-	if (mem)
-		free(mem);
+	free(mem);
 	return gpa;
 }
 
@@ -661,8 +659,7 @@  m_ifcvf_start(struct ifcvf_internal *internal)
 
 error:
 	for (i = 0; i < nr_vring; i++)
-		if (internal->m_vring[i].desc)
-			rte_free(internal->m_vring[i].desc);
+		rte_free(internal->m_vring[i].desc);
 
 	return -1;
 }