Re: Remove useless "if (foo)" before "free (foo)".

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jim Meyering <jim@xxxxxxxxxxxx> wrote:

> Jim Meyering <jim@xxxxxxxxxxxx> wrote:
>> "Daniel P. Berrange" <berrange@xxxxxxxxxx> wrote:
>>> I gave it a once-over and it looks correct to me.
>>
>> Thanks for the quick review.
>
> In relaxing the regexp, I found two more:
...
> -    if(mapstr)
> -        free(mapstr);
...

Cross-checked against the automatically transformed code,
and found two _more_ (missed initially due to space after free argument):

diff --git a/src/hash.c b/src/hash.c
index b9abf16..4e4ce60 100644
--- a/src/hash.c
+++ b/src/hash.c
@@ -809,8 +809,7 @@ __virGetDomain(virConnectPtr conn, const char *name, const un
  error:
     pthread_mutex_unlock(&conn->lock);
     if (ret != NULL) {
-        if (ret->name != NULL)
-            free(ret->name );
+        free(ret->name );
         free(ret);
     }
     return(NULL);
@@ -943,8 +942,7 @@ __virGetNetwork(virConnectPtr conn, const char *name, const u
  error:
     pthread_mutex_unlock(&conn->lock);
     if (ret != NULL) {
-        if (ret->name != NULL)
-            free(ret->name );
+        free(ret->name );
         free(ret);
     }
     return(NULL);

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]