From 10c10f4380aaf7c0e01cd5430bfe623d79883498 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Tue, 10 Jun 2014 16:23:09 -0600 Subject: [PATCH] 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 --- src/nodeinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; -- 2.39.5