From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Jackson Subject: [PATCH 13/21] libxl: Add a gc to libxl_get_cpu_topology Date: Tue, 26 Jun 2012 18:55:10 +0100 Message-ID: <1340733318-21099-14-git-send-email-ian.jackson@eu.citrix.com> References: <1340733318-21099-1-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1340733318-21099-1-git-send-email-ian.jackson@eu.citrix.com> 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: Ian Jackson List-Id: xen-devel@lists.xenproject.org In the next patch we are going to change the definition of NOGC to require a local variable libxl__gc *gc. libxl_get_cpu_topology doesn't have one but does use NOGC. Fix this by: - introducing an `out' label - replacing the only call to `return' with a suitable assignment to ret and a `goto out'. - adding uses of GC_INIT and GC_FREE. Signed-off-by: Ian Jackson Acked-by: Ian Campbell --- tools/libxl/libxl.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 6ec7471..a259d65 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -3201,6 +3201,7 @@ int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo *physinfo) libxl_cputopology *libxl_get_cpu_topology(libxl_ctx *ctx, int *nr) { + GC_INIT(ctx); xc_topologyinfo_t tinfo; DECLARE_HYPERCALL_BUFFER(xc_cpu_to_core_t, coremap); DECLARE_HYPERCALL_BUFFER(xc_cpu_to_socket_t, socketmap); @@ -3213,7 +3214,8 @@ libxl_cputopology *libxl_get_cpu_topology(libxl_ctx *ctx, int *nr) if (max_cpus == 0) { LIBXL__LOG(ctx, XTL_ERROR, "Unable to determine number of CPUS"); - return NULL; + ret = NULL; + goto out; } coremap = xc_hypercall_buffer_alloc @@ -3258,6 +3260,8 @@ fail: if (ret) *nr = max_cpus; + out: + GC_FREE; return ret; } -- 1.7.2.5