From: Daniel Henrique Barboza Date: Fri, 26 Jun 2020 22:10:40 +0000 (-0300) Subject: virsh-domain.c: modernize virshVcpuinfoInactive() X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=a3a628f54cf682abe0fe10270dc51b12df1a620f;p=libvirt.git virsh-domain.c: modernize virshVcpuinfoInactive() Use g_auto* in the string and in the bitmap. Remove the cleanup label since it's now unneeded. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 085b88b097..23d41a4ddf 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -6886,16 +6886,15 @@ virshVcpuinfoInactive(vshControl *ctl, int maxcpu, bool pretty) { - unsigned char *cpumaps = NULL; + g_autofree unsigned char *cpumaps = NULL; size_t cpumaplen; int ncpus; - virBitmapPtr vcpus = NULL; + g_autoptr(virBitmap) vcpus = NULL; ssize_t nextvcpu = -1; - bool ret = false; bool first = true; if (!(vcpus = virshDomainGetVcpuBitmap(ctl, dom, true))) - goto cleanup; + return false; cpumaplen = VIR_CPU_MAPLEN(maxcpu); cpumaps = vshMalloc(ctl, virBitmapSize(vcpus) * cpumaplen); @@ -6903,7 +6902,7 @@ virshVcpuinfoInactive(vshControl *ctl, if ((ncpus = virDomainGetVcpuPinInfo(dom, virBitmapSize(vcpus), cpumaps, cpumaplen, VIR_DOMAIN_AFFECT_CONFIG)) < 0) - goto cleanup; + return false; while ((nextvcpu = virBitmapNextSetBit(vcpus, nextvcpu)) >= 0) { if (!first) @@ -6918,15 +6917,10 @@ virshVcpuinfoInactive(vshControl *ctl, if (virshVcpuinfoPrintAffinity(ctl, VIR_GET_CPUMAP(cpumaps, cpumaplen, nextvcpu), maxcpu, pretty) < 0) - goto cleanup; + return false; } - ret = true; - - cleanup: - virBitmapFree(vcpus); - VIR_FREE(cpumaps); - return ret; + return true; }