From: Eric Blake Date: Tue, 10 Jun 2014 22:23:09 +0000 (-0600) Subject: nodeinfo: avoid uninitialized variable on error X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=10c10f4380aaf7c0e01cd5430bfe623d79883498;p=libvirt.git nodeinfo: avoid uninitialized variable on error 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 --- diff --git a/src/nodeinfo.c b/src/nodeinfo.c index 5eef42e20b..5332edec7e 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;