]> xenbits.xensource.com Git - libvirt.git/commitdiff
virsh-domain.c: modernize virshVcpuinfoInactive()
authorDaniel Henrique Barboza <danielhb413@gmail.com>
Fri, 26 Jun 2020 22:10:40 +0000 (19:10 -0300)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 8 Jul 2020 17:39:31 +0000 (19:39 +0200)
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 <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tools/virsh-domain.c

index 085b88b097749c811fe1abbb243aa9eccb7ab09a..23d41a4ddfdae16dd70a53768040da5991512272 100644 (file)
@@ -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;
 }