diff mbox

kvm tools: remove unneeded checks in qcow code

Message ID 1356030701-16284-2-git-send-email-sasha.levin@oracle.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sasha Levin Dec. 20, 2012, 7:11 p.m. UTC
We already know q!=NULL at that point, no need to retest.

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 tools/kvm/disk/qcow.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Jesper Juhl Dec. 21, 2012, 10:03 p.m. UTC | #1
On Thu, 20 Dec 2012, Sasha Levin wrote:

> We already know q!=NULL at that point, no need to retest.
> 
Right, and even if it was ==NULL then 'free(NULL)' is guaranteed to be a 
NOP, so it would still be fine.

Reviewed-by: Jesper Juhl <jj@chaosbits.net>


> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
> ---
>  tools/kvm/disk/qcow.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/kvm/disk/qcow.c b/tools/kvm/disk/qcow.c
> index ee2992e..64a2550 100644
> --- a/tools/kvm/disk/qcow.c
> +++ b/tools/kvm/disk/qcow.c
> @@ -1361,8 +1361,7 @@ free_header:
>  	if (q->header)
>  		free(q->header);
>  free_qcow:
> -	if (q)
> -		free(q);
> +	free(q);
>  
>  	return NULL;
>  }
> @@ -1492,8 +1491,7 @@ free_header:
>  	if (q->header)
>  		free(q->header);
>  free_qcow:
> -	if (q)
> -		free(q);
> +	free(q);
>  
>  	return NULL;
>  }
>
diff mbox

Patch

diff --git a/tools/kvm/disk/qcow.c b/tools/kvm/disk/qcow.c
index ee2992e..64a2550 100644
--- a/tools/kvm/disk/qcow.c
+++ b/tools/kvm/disk/qcow.c
@@ -1361,8 +1361,7 @@  free_header:
 	if (q->header)
 		free(q->header);
 free_qcow:
-	if (q)
-		free(q);
+	free(q);
 
 	return NULL;
 }
@@ -1492,8 +1491,7 @@  free_header:
 	if (q->header)
 		free(q->header);
 free_qcow:
-	if (q)
-		free(q);
+	free(q);
 
 	return NULL;
 }