[libvirt] [PATCH] nodeinfo: avoid uninitialized variable on error

Eric Blake eblake at redhat.com
Tue Jun 10 22:27:00 UTC 2014


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 at redhat.com>
---

Pushing under the build-breaker rule.

 src/nodeinfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 5eef42e..5332ede 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -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;
-- 
1.9.3




More information about the libvir-list mailing list