[PATCH] tests: Fix build with -Werror

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

 



---
Pushed as build-breaker.

Use of uninitialized "n" after the former "error" label was the issue
(gcc didn't get it right though). I forgot to mention this in the
commit message :-(

 tests/cputest.c |   17 +++++++----------
 1 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/tests/cputest.c b/tests/cputest.c
index 15614a7..870f99f 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -126,17 +126,17 @@ cpuTestLoadMultiXML(const char *arch,
         goto cleanup;
 
     if (!(doc = virXMLParseFileCtxt(xml, &ctxt)))
-        goto error;
+        goto cleanup;
 
     n = virXPathNodeSet("/cpuTest/cpu", ctxt, &nodes);
     if (n <= 0 || (VIR_ALLOC_N(cpus, n) < 0))
-        goto error;
+        goto cleanup;
 
     for (i = 0; i < n; i++) {
         ctxt->node = nodes[i];
         cpus[i] = virCPUDefParseXML(nodes[i], ctxt, VIR_CPU_TYPE_HOST);
         if (!cpus[i])
-            goto error;
+            goto cleanup_cpus;
     }
 
     *count = n;
@@ -148,13 +148,10 @@ cleanup:
     xmlFreeDoc(doc);
     return cpus;
 
-error:
-    if (cpus) {
-        for (i = 0; i < n; i++)
-            virCPUDefFree(cpus[i]);
-        VIR_FREE(cpus);
-        cpus = NULL;
-    }
+cleanup_cpus:
+    for (i = 0; i < n; i++)
+        virCPUDefFree(cpus[i]);
+    VIR_FREE(cpus);
     goto cleanup;
 }
 
-- 
1.7.8.4

--
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]