From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matthew Daley Subject: [PATCH v2] libxl: correctly handle libxl_get_cpu_topology failure in libxl_{cpu, node}map_to_{node, cpu}map Date: Sun, 29 Sep 2013 18:47:37 +1300 Message-ID: <1380433657-16824-1-git-send-email-mattjd@gmail.com> References: <1379492310.18543.54.camel@Abyss> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1379492310.18543.54.camel@Abyss> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: Dario Faggioli , Matthew Daley , Ian Jackson , Ian Campbell , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org Initialize nr_cpus to 0 so that if it is unchanged by a failing libxl_get_cpu_topology, libxl_cputopology_list_free still works OK afterward. Coverity-ID: 1055294 Coverity-ID: 1055295 Signed-off-by: Matthew Daley --- tools/libxl/libxl_utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c index 1927383..bb5ae31 100644 --- a/tools/libxl/libxl_utils.c +++ b/tools/libxl/libxl_utils.c @@ -650,7 +650,7 @@ int libxl_nodemap_to_cpumap(libxl_ctx *ctx, libxl_bitmap *cpumap) { libxl_cputopology *tinfo = NULL; - int nr_cpus, i, rc = 0; + int nr_cpus = 0, i, rc = 0; tinfo = libxl_get_cpu_topology(ctx, &nr_cpus); if (tinfo == NULL) { @@ -673,7 +673,7 @@ int libxl_cpumap_to_nodemap(libxl_ctx *ctx, libxl_bitmap *nodemap) { libxl_cputopology *tinfo = NULL; - int nr_cpus, i, rc = 0; + int nr_cpus = 0, i, rc = 0; tinfo = libxl_get_cpu_topology(ctx, &nr_cpus); if (tinfo == NULL) { -- 1.7.10.4