libxl: Add a gc to libxl_get_cpu_topology
authorIan Jackson <ian.jackson@eu.citrix.com>
Thu, 28 Jun 2012 17:43:25 +0000 (18:43 +0100)
committerIan Jackson <ian.jackson@eu.citrix.com>
Thu, 28 Jun 2012 17:43:25 +0000 (18:43 +0100)
In the next-but-one 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 <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
tools/libxl/libxl.c

index 4d09b953bf51d1c13d0449452027cd06faca7c5a..4e831427e871b84578eeaa2776cca2ced0100434 100644 (file)
@@ -3202,6 +3202,7 @@ int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo *physinfo)
 
 libxl_cputopology *libxl_get_cpu_topology(libxl_ctx *ctx, int *nb_cpu_out)
 {
+    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);
@@ -3214,7 +3215,8 @@ libxl_cputopology *libxl_get_cpu_topology(libxl_ctx *ctx, int *nb_cpu_out)
     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
@@ -3259,6 +3261,8 @@ fail:
 
     if (ret)
         *nb_cpu_out = max_cpus;
+ out:
+    GC_FREE;
     return ret;
 }