[Libvirt-cim] [PATCH 6/8] libxkutil: Adjust get_dominfo() logic

John Ferlan jferlan at redhat.com
Fri Mar 22 20:47:12 UTC 2013


Need to really handle the error on the get_dominfo_from_xml() call

Need to be sure to free(xml) before returning
---
 libxkutil/device_parsing.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/libxkutil/device_parsing.c b/libxkutil/device_parsing.c
index 845a953..264d4cc 100644
--- a/libxkutil/device_parsing.c
+++ b/libxkutil/device_parsing.c
@@ -1246,7 +1246,7 @@ int get_dominfo_from_xml(const char *xml, struct domain **dominfo)
 int get_dominfo(virDomainPtr dom, struct domain **dominfo)
 {
         char *xml;
-        int ret;
+        int ret = 0;
         int start;
         xml = virDomainGetXMLDesc(dom,
                 VIR_DOMAIN_XML_INACTIVE | VIR_DOMAIN_XML_SECURE);
@@ -1256,18 +1256,17 @@ int get_dominfo(virDomainPtr dom, struct domain **dominfo)
                 return 0;
         }
 
-        ret = get_dominfo_from_xml(xml, dominfo);
-        if (ret != 1) {
+        if (get_dominfo_from_xml(xml, dominfo) == 0) {
                 CU_DEBUG("Failed to translate xml into struct domain");
                 goto out;
         }
         if (virDomainGetAutostart(dom,  &start) !=  0) {
                 CU_DEBUG("Failed to get dom autostart with libvirt API.");
-                ret = 0;
                 goto out;
         }
 
         (*dominfo)->autostrt = start;
+        ret = 1;
 
  out:
         free(xml);
-- 
1.8.1.4




More information about the Libvirt-cim mailing list