From 33eb88cdc9e30b8946ea1e76ca6c4342fe64dc44 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Tue, 7 Dec 2021 17:22:26 +0100 Subject: [PATCH] virshParseCPUList: Refactor cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use automatic memory freeing for the temporary bitmap and remove the pointless 'cleanup' section. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- tools/virsh-domain.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 8379f9f135..2338d6522a 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -6983,7 +6983,7 @@ virshParseCPUList(vshControl *ctl, int *cpumaplen, const char *cpulist, int maxcpu) { unsigned char *cpumap = NULL; - virBitmap *map = NULL; + g_autoptr(virBitmap) map = NULL; if (cpulist[0] == 'r') { map = virBitmapNew(maxcpu); @@ -6994,21 +6994,19 @@ virshParseCPUList(vshControl *ctl, int *cpumaplen, if (virBitmapParse(cpulist, &map, 1024) < 0 || virBitmapIsAllClear(map)) { vshError(ctl, _("Invalid cpulist '%s'"), cpulist); - goto cleanup; + return NULL; } lastcpu = virBitmapLastSetBit(map); if (lastcpu >= maxcpu) { vshError(ctl, _("CPU %d in cpulist '%s' exceed the maxcpu %d"), lastcpu, cpulist, maxcpu); - goto cleanup; + return NULL; } } if (virBitmapToData(map, &cpumap, cpumaplen) < 0) - goto cleanup; + return NULL; - cleanup: - virBitmapFree(map); return cpumap; }