]> xenbits.xensource.com Git - libvirt.git/commitdiff
nodeinfo: avoid uninitialized variable on error
authorEric Blake <eblake@redhat.com>
Tue, 10 Jun 2014 22:23:09 +0000 (16:23 -0600)
committerEric Blake <eblake@redhat.com>
Tue, 10 Jun 2014 22:27:34 +0000 (16:27 -0600)
Commit 8ba0a58 introduced a compiler warning that I hit during
a run of ./autobuild.sh:

../../src/nodeinfo.c: In function 'nodeCapsInitNUMA':
../../src/nodeinfo.c:1853:43: error: 'nsiblings' may be used uninitialized in this function [-Werror=maybe-uninitialized]
         if (virCapabilitiesAddHostNUMACell(caps, n, memory,
                                           ^

Sure enough, nsiblings starts uninitialized, and is set by a call
to virNodeCapsGetSiblingInfo, but that function fails to assign
through the pointer if virNumaGetDistances fails.

* src/nodeinfo.c (nodeCapsInitNUMA): Initialize nsiblings.

Signed-off-by: Eric Blake <eblake@redhat.com>
src/nodeinfo.c

index 5eef42e20b2656acae0056e7600e2102a4ff9444..5332edec7e383f0b1b7d83010571cdfa7a2c7cc9 100644 (file)
@@ -1803,7 +1803,7 @@ nodeCapsInitNUMA(virCapsPtr caps)
     virCapsHostNUMACellCPUPtr cpus = NULL;
     virBitmapPtr cpumap = NULL;
     virCapsHostNUMACellSiblingInfoPtr siblings = NULL;
-    int nsiblings;
+    int nsiblings = 0;
     int ret = -1;
     int ncpus = 0;
     int cpu;