[Libvir] Remove useless "if (foo)" before "free (foo)".
Jim Meyering
jim at meyering.net
Wed Jan 23 11:20:07 UTC 2008
Jim Meyering <jim at meyering.net> wrote:
> Jim Meyering <jim at meyering.net> wrote:
>> "Daniel P. Berrange" <berrange at 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);
More information about the libvir-list
mailing list