[Libvir] [PATCH] remove useless tests before xmlFree

I've just fixed a bug in my useless-if-detecting script, committed in gnulib. Using that new script with today's change adding xmlFree to the list exposed a bunch of useless tests. This first change set removes those tests. Below it is a separate patch that updates gnulib-related files, including that script and vc-list-files. I verified that with these changes "make distcheck" passes. If no one objects, I'll push these in about 12 hours. remove useless tests before xmlFree * src/qemu_conf.c (qemudParseDiskXML, qemudParseInterfaceXML): (qemudParseInputXML, qemudParseDhcpRangesXML): * src/remote_internal.c (doRemoteOpen): * src/storage_conf.c (virStoragePoolDefParseDoc): * src/xm_internal.c (xenXMParseXMLDisk, xenXMParseXMLVif): (xenXMParseXMLToConfig, xenXMAttachInterface): * src/xml.c (virDomainParseXMLDiskDesc, virDomainParseXMLIfDesc): (virDomainXMLDevID): Signed-off-by: Jim Meyering <meyering@redhat.com> --- src/qemu_conf.c | 48 ++++++++++++++++-------------------------------- src/remote_internal.c | 8 ++++---- src/storage_conf.c | 3 +-- src/xm_internal.c | 42 ++++++++++++++---------------------------- src/xml.c | 30 ++++++++++-------------------- 5 files changed, 45 insertions(+), 86 deletions(-) diff --git a/src/qemu_conf.c b/src/qemu_conf.c index 07dfe47..a0c4a8f 100644 --- a/src/qemu_conf.c +++ b/src/qemu_conf.c @@ -680,14 +680,10 @@ static int qemudParseDiskXML(virConnectPtr conn, return 0; error: - if (type) - xmlFree(type); - if (target) - xmlFree(target); - if (source) - xmlFree(source); - if (device) - xmlFree(device); + xmlFree(type); + xmlFree(target); + xmlFree(source); + xmlFree(device); return -1; } @@ -941,18 +937,12 @@ static int qemudParseInterfaceXML(virConnectPtr conn, return 0; error: - if (network) - xmlFree(network); - if (address) - xmlFree(address); - if (port) - xmlFree(port); - if (ifname) - xmlFree(ifname); - if (script) - xmlFree(script); - if (bridge) - xmlFree(bridge); + xmlFree(network); + xmlFree(address); + xmlFree(port); + xmlFree(ifname); + xmlFree(script); + xmlFree(bridge); return -1; } @@ -1334,18 +1324,14 @@ static int qemudParseInputXML(virConnectPtr conn, input->bus = QEMU_INPUT_BUS_USB; } - if (type) - xmlFree(type); - if (bus) - xmlFree(bus); + xmlFree(type); + xmlFree(bus); return 0; error: - if (type) - xmlFree(type); - if (bus) - xmlFree(bus); + xmlFree(type); + xmlFree(bus); return -1; } @@ -2860,10 +2846,8 @@ static int qemudParseDhcpRangesXML(virConnectPtr conn, free(range); } - if (start) - xmlFree(start); - if (end) - xmlFree(end); + xmlFree(start); + xmlFree(end); cur = cur->next; } diff --git a/src/remote_internal.c b/src/remote_internal.c index ef34a3a..70aa5e9 100644 --- a/src/remote_internal.c +++ b/src/remote_internal.c @@ -434,9 +434,9 @@ doRemoteOpen (virConnectPtr conn, } #ifdef HAVE_XMLURI_QUERY_RAW - if (uri->query_raw) xmlFree (uri->query_raw); + xmlFree (uri->query_raw); #else - if (uri->query) xmlFree (uri->query); + xmlFree (uri->query); #endif if (( @@ -464,10 +464,10 @@ doRemoteOpen (virConnectPtr conn, transport_str[-1] = '\0'; } /* Remove the username, server name and port number. */ - if (uri->user) xmlFree (uri->user); + xmlFree (uri->user); uri->user = 0; - if (uri->server) xmlFree (uri->server); + xmlFree (uri->server); uri->server = 0; uri->port = 0; diff --git a/src/storage_conf.c b/src/storage_conf.c index 4499ae2..be21d3b 100644 --- a/src/storage_conf.c +++ b/src/storage_conf.c @@ -357,8 +357,7 @@ virStoragePoolDefParseDoc(virConnectPtr conn, cleanup: free(uuid); - if (type) - xmlFree(type); + xmlFree(type); virStoragePoolDefFree(ret); return NULL; } diff --git a/src/xm_internal.c b/src/xm_internal.c index a70436d..08e3e8e 100644 --- a/src/xm_internal.c +++ b/src/xm_internal.c @@ -1657,10 +1657,8 @@ static int xenXMParseXMLDisk(xmlNodePtr node, int hvm, int xendConfigVersion, ch } if (target == NULL) { - if (source != NULL) - xmlFree(source); - if (device != NULL) - xmlFree(device); + xmlFree(source); + xmlFree(device); return (-1); } @@ -1687,10 +1685,8 @@ static int xenXMParseXMLDisk(xmlNodePtr node, int hvm, int xendConfigVersion, ch } if (source == NULL && !cdrom) { - if (target != NULL) - xmlFree(target); - if (device != NULL) - xmlFree(device); + xmlFree(target); + xmlFree(device); return (-1); } @@ -1765,8 +1761,7 @@ static int xenXMParseXMLDisk(xmlNodePtr node, int hvm, int xendConfigVersion, ch xmlFree(drvName); xmlFree(device); xmlFree(target); - if(source) - xmlFree(source); + xmlFree(source); *disk = buf; return (ret); @@ -1877,14 +1872,10 @@ static char *xenXMParseXMLVif(virConnectPtr conn, xmlNodePtr node, int hvm) { cleanup: free(bridge); - if (mac != NULL) - xmlFree(mac); - if (source != NULL) - xmlFree(source); - if (script != NULL) - xmlFree(script); - if (ip != NULL) - xmlFree(ip); + xmlFree(mac); + xmlFree(source); + xmlFree(script); + xmlFree(ip); return buf; } @@ -2164,8 +2155,7 @@ virConfPtr xenXMParseXMLToConfig(virConnectPtr conn, const char *xml) { strcat(val, ",vncdisplay="); strcat(val, portstr); } - if (vncport) - xmlFree(vncport); + xmlFree(vncport); if (vnclisten) { strcat(val, ",vnclisten="); strcat(val, (const char*)vnclisten); @@ -2310,8 +2300,7 @@ virConfPtr xenXMParseXMLToConfig(virConnectPtr conn, const char *xml) { error: if (conf) virConfFree(conf); - if (prop != NULL) - xmlFree(prop); + xmlFree(prop); xmlXPathFreeObject(obj); xmlXPathFreeContext(ctxt); if (doc != NULL) @@ -2960,12 +2949,9 @@ xenXMAttachInterface(virDomainPtr domain, xmlXPathContextPtr ctxt, int hvm, goto cleanup; node_cleanup: - if (node_tmp) - xmlFree(node_tmp); - if (attr_node) - xmlFree(attr_node); - if (text_node) - xmlFree(text_node); + xmlFree(node_tmp); + xmlFree(attr_node); + xmlFree(text_node); cleanup: free(type); free(source); diff --git a/src/xml.c b/src/xml.c index e889cdd..25eba3d 100644 --- a/src/xml.c +++ b/src/xml.c @@ -1341,16 +1341,11 @@ virDomainParseXMLDiskDesc(virConnectPtr conn, xmlNodePtr node, virBufferAddLit(buf, ")"); cleanup: - if (drvType) - xmlFree(drvType); - if (drvName) - xmlFree(drvName); - if (device) - xmlFree(device); - if (target) - xmlFree(target); - if (source) - xmlFree(source); + xmlFree(drvType); + xmlFree(drvName); + xmlFree(device); + xmlFree(target); + xmlFree(source); return (ret); } @@ -1466,14 +1461,10 @@ virDomainParseXMLIfDesc(virConnectPtr conn ATTRIBUTE_UNUSED, virBufferAddLit(buf, ")"); ret = 0; error: - if (mac != NULL) - xmlFree(mac); - if (source != NULL) - xmlFree(source); - if (script != NULL) - xmlFree(script); - if (ip != NULL) - xmlFree(ip); + xmlFree(mac); + xmlFree(source); + xmlFree(script); + xmlFree(ip); return (ret); } @@ -1953,8 +1944,7 @@ virDomainXMLDevID(virDomainPtr domain, const char *xmldesc, char *class, cleanup: if (xml != NULL) xmlFreeDoc(xml); - if (attr != NULL) - xmlFree(attr); + xmlFree(attr); return ret; } #endif /* WITH_XEN */ -- 1.5.5.1.68.gbdcd8

On Tue, Apr 29, 2008 at 09:30:39PM +0200, Jim Meyering wrote:
I've just fixed a bug in my useless-if-detecting script, committed in gnulib. Using that new script with today's change adding xmlFree to the list exposed a bunch of useless tests. This first change set removes those tests.
Below it is a separate patch that updates gnulib-related files, including that script and vc-list-files. I verified that with these changes "make distcheck" passes.
If no one objects, I'll push these in about 12 hours.
remove useless tests before xmlFree * src/qemu_conf.c (qemudParseDiskXML, qemudParseInterfaceXML): (qemudParseInputXML, qemudParseDhcpRangesXML): * src/remote_internal.c (doRemoteOpen): * src/storage_conf.c (virStoragePoolDefParseDoc): * src/xm_internal.c (xenXMParseXMLDisk, xenXMParseXMLVif): (xenXMParseXMLToConfig, xenXMAttachInterface): * src/xml.c (virDomainParseXMLDiskDesc, virDomainParseXMLIfDesc): (virDomainXMLDevID):
Signed-off-by: Jim Meyering <meyering@redhat.com>
ACK, please commit . Dan. -- |: Red Hat, Engineering, Boston -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

"Daniel P. Berrange" <berrange@redhat.com> wrote:
On Tue, Apr 29, 2008 at 09:30:39PM +0200, Jim Meyering wrote:
I've just fixed a bug in my useless-if-detecting script, committed in gnulib. Using that new script with today's change adding xmlFree to the list exposed a bunch of useless tests. This first change set removes those tests.
Below it is a separate patch that updates gnulib-related files, including that script and vc-list-files. I verified that with these changes "make distcheck" passes.
If no one objects, I'll push these in about 12 hours.
remove useless tests before xmlFree ... ACK, please commit .
Ok. I've just done that one. The gnulib one will take a couple more minutes.

On Tue, Apr 29, 2008 at 09:44:50PM +0200, Jim Meyering wrote:
"Daniel P. Berrange" <berrange@redhat.com> wrote:
On Tue, Apr 29, 2008 at 09:30:39PM +0200, Jim Meyering wrote:
I've just fixed a bug in my useless-if-detecting script, committed in gnulib. Using that new script with today's change adding xmlFree to the list exposed a bunch of useless tests. This first change set removes those tests.
Below it is a separate patch that updates gnulib-related files, including that script and vc-list-files. I verified that with these changes "make distcheck" passes.
If no one objects, I'll push these in about 12 hours.
remove useless tests before xmlFree ... ACK, please commit .
Ok. I've just done that one. The gnulib one will take a couple more minutes.
I think one of the files from the gnulib refresh got missed from the commit [berrange@t60wlan libvirt-new]$ make make all-recursive make[1]: Entering directory `/home/berrange/src/xen/libvirt-new' Making all in gnulib/lib make[2]: Entering directory `/home/berrange/src/xen/libvirt-new/gnulib/lib' { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ cat ./alloca.in.h; \ } > alloca.h-t mv -f alloca.h-t alloca.h /bin/mkdir -p arpa rm -f arpa/inet.h-t arpa/inet.h { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's/@''INCLUDE_NEXT''@/include_next/g' \ -e 's|@''NEXT_ARPA_INET_H''@|<arpa/inet.h>|g' \ -e 's|@''HAVE_ARPA_INET_H''@|1|g' \ -e 's|@''GNULIB_INET_NTOP''@|1|g' \ -e 's|@''GNULIB_INET_PTON''@|0|g' \ -e 's|@''HAVE_DECL_INET_NTOP''@|1|g' \ -e 's|@''HAVE_DECL_INET_PTON''@|1|g' \ < ./arpa_inet.in.h; \ } > arpa/inet.h-t /bin/sh: line 1: ./arpa_inet.in.h: No such file or directory make[2]: *** [arpa/inet.h] Error 1 make[2]: Leaving directory `/home/berrange/src/xen/libvirt-new/gnulib/lib' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/home/berrange/src/xen/libvirt-new' make: *** [all] Error 2 Regards, Dan. -- |: Red Hat, Engineering, Boston -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

"Daniel P. Berrange" <berrange@redhat.com> wrote:
On Tue, Apr 29, 2008 at 09:44:50PM +0200, Jim Meyering wrote:
"Daniel P. Berrange" <berrange@redhat.com> wrote:
On Tue, Apr 29, 2008 at 09:30:39PM +0200, Jim Meyering wrote:
I've just fixed a bug in my useless-if-detecting script, committed in gnulib. Using that new script with today's change adding xmlFree to the list exposed a bunch of useless tests. This first change set removes those tests.
Below it is a separate patch that updates gnulib-related files, including that script and vc-list-files. I verified that with these changes "make distcheck" passes.
If no one objects, I'll push these in about 12 hours.
remove useless tests before xmlFree ... ACK, please commit .
Ok. I've just done that one. The gnulib one will take a couple more minutes.
I think one of the files from the gnulib refresh got missed from the commit ... /bin/sh: line 1: ./arpa_inet.in.h: No such file or directory
Thanks for the heads-up. It did indeed. I've just committed the fix to add that. Also, there was a new link error on rawhide, due to libvirt_proxy's use of the now-gnulib-replaced sprintf function. Here's the patch:
participants (2)
-
Daniel P. Berrange
-
Jim Meyering