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

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



Jim Meyering <jim meyering net> wrote:

> Jim Meyering <jim meyering net> wrote:
>> "Daniel P. Berrange" <berrange redhat com> 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);


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