From: Dario Faggioli Subject: [PATCH v2 7/7] xl: use libxl_cpupoolinfo_list_free() in main_cpupoolnumasplit Date: Fri, 13 Mar 2015 12:09:59 +0100 Message-ID: <20150313110959.32539.20026.stgit@Solace.station> References: <20150313110535.32539.77102.stgit@Solace.station> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20150313110535.32539.77102.stgit@Solace.station> 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 Cc: Juergen Gross , Wei Liu , Ian Jackson , Ian Campbell , Stefano Stabellini List-Id: xen-devel@lists.xenproject.org instead of manually freeing the elements of the list, which is exactly the purpose of the said function. Trade also a couple of 'return'-s with 'goto out'-s, which is more in line with libxl usage paradigm. Signed-off-by: Dario Faggioli Cc: Ian Campbell Cc: Ian Jackson Cc: Stefano Stabellini Cc: Wei Liu Cc: Juergen Gross Acked-by: Wei Liu --- Changes from v1: * grammar fixes in the changelog, as requested during review. --- tools/libxl/xl_cmdimpl.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 8587cc2..efb6024 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -7460,9 +7460,8 @@ int main_cpupoolnumasplit(int argc, char **argv) } poolid = poolinfo[0].poolid; sched = poolinfo[0].sched; - for (p = 0; p < n_pools; p++) { - libxl_cpupoolinfo_dispose(poolinfo + p); - } + libxl_cpupoolinfo_list_free(poolinfo, n_pools); + if (n_pools > 1) { fprintf(stderr, "splitting not possible, already cpupools in use\n"); return 1; @@ -7476,8 +7475,7 @@ int main_cpupoolnumasplit(int argc, char **argv) if (libxl_cpu_bitmap_alloc(ctx, &cpumap, 0)) { fprintf(stderr, "Failed to allocate cpumap\n"); - libxl_cputopology_list_free(topology, n_cpus); - return 1; + goto out; } /* Reset Pool-0 to 1st node: first add cpus, then remove cpus to avoid @@ -7486,7 +7484,7 @@ int main_cpupoolnumasplit(int argc, char **argv) node = topology[0].node; if (libxl_cpupool_cpuadd_node(ctx, 0, node, &n)) { fprintf(stderr, "error on adding cpu to Pool 0\n"); - return 1; + goto out; } snprintf(name, 15, "Pool-node%d", node);