]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tools: virsh: use automatic cleanup for vshTable
authorJán Tomko <jtomko@redhat.com>
Wed, 11 Aug 2021 13:12:02 +0000 (15:12 +0200)
committerJán Tomko <jtomko@redhat.com>
Mon, 16 Aug 2021 11:10:34 +0000 (13:10 +0200)
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
tools/virsh-domain-monitor.c
tools/virsh-domain.c
tools/virsh-interface.c
tools/virsh-network.c
tools/virsh-nwfilter.c
tools/virsh-pool.c
tools/virsh-secret.c
tools/virsh-volume.c
tools/virt-admin.c

index ee1af6145abdf3fb97f25410217377bad513872c..7410298707e7a8d2dce40369f7d37b63986a486d 100644 (file)
@@ -590,7 +590,7 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
     char *device = NULL;
     char *target = NULL;
     char *source = NULL;
-    vshTable *table = NULL;
+    g_autoptr(vshTable) table = NULL;
 
     if (vshCommandOptBool(cmd, "inactive"))
         flags |= VIR_DOMAIN_XML_INACTIVE;
@@ -674,7 +674,6 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
     ret = true;
 
  cleanup:
-    vshTableFree(table);
     VIR_FREE(source);
     VIR_FREE(target);
     VIR_FREE(device);
@@ -711,7 +710,7 @@ cmdDomiflist(vshControl *ctl, const vshCmd *cmd)
     int ninterfaces;
     xmlNodePtr *interfaces = NULL;
     size_t i;
-    vshTable *table = NULL;
+    g_autoptr(vshTable) table = NULL;
 
     if (vshCommandOptBool(cmd, "inactive"))
         flags |= VIR_DOMAIN_XML_INACTIVE;
@@ -763,7 +762,6 @@ cmdDomiflist(vshControl *ctl, const vshCmd *cmd)
     ret = true;
 
  cleanup:
-    vshTableFree(table);
     VIR_FREE(interfaces);
     return ret;
 }
@@ -1938,7 +1936,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd)
     char id_buf[VIR_INT64_STR_BUFLEN];
     unsigned int id;
     unsigned int flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE;
-    vshTable *table = NULL;
+    g_autoptr(vshTable) table = NULL;
 
     /* construct filter flags */
     if (vshCommandOptBool(cmd, "inactive") ||
@@ -2060,7 +2058,6 @@ cmdList(vshControl *ctl, const vshCmd *cmd)
 
     ret = true;
  cleanup:
-    vshTableFree(table);
     virshDomainListFree(list);
     return ret;
 }
index fe2bfdaed01e38bc6b6f7cadba87b80abe9db734..f72ec36f6fcaf0c5f7e395172e7aaff4df68b155 100644 (file)
@@ -6983,7 +6983,7 @@ virshVcpuPinQuery(vshControl *ctl,
     size_t i;
     int ncpus;
     bool ret = false;
-    vshTable *table = NULL;
+    g_autoptr(vshTable) table = NULL;
 
     if ((ncpus = virshCPUCountCollect(ctl, dom, countFlags, true)) < 0) {
         if (ncpus == -1) {
@@ -7038,7 +7038,6 @@ virshVcpuPinQuery(vshControl *ctl,
 
     ret = true;
  cleanup:
-    vshTableFree(table);
     VIR_FREE(cpumap);
     return ret;
 }
@@ -7604,7 +7603,7 @@ cmdIOThreadInfo(vshControl *ctl, const vshCmd *cmd)
     virDomainIOThreadInfoPtr *info = NULL;
     size_t i;
     unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
-    vshTable *table = NULL;
+    g_autoptr(vshTable) table = NULL;
     bool ret = false;
     int rc;
 
@@ -7655,7 +7654,6 @@ cmdIOThreadInfo(vshControl *ctl, const vshCmd *cmd)
     for (i = 0; i < niothreads; i++)
         virDomainIOThreadInfoFree(info[i]);
     VIR_FREE(info);
-    vshTableFree(table);
     return ret;
 }
 
@@ -13907,7 +13905,7 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd)
     int rc = -1;
     size_t i, j;
     virDomainFSInfoPtr *info = NULL;
-    vshTable *table = NULL;
+    g_autoptr(vshTable) table = NULL;
     size_t ninfos = 0;
     bool ret = false;
 
@@ -13962,7 +13960,6 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd)
             virDomainFSInfoFree(info[i]);
         VIR_FREE(info);
     }
-    vshTableFree(table);
     return ret;
 }
 
index 71cc265efc70527557fed75b00f0a3f5a225bcf2..f88ec188f16f0e3f961bb8ea22c576dd374c1c2f 100644 (file)
@@ -348,7 +348,7 @@ cmdInterfaceList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
     struct virshInterfaceList *list = NULL;
     size_t i;
     bool ret = false;
-    vshTable *table = NULL;
+    g_autoptr(vshTable) table = NULL;
 
     VSH_EXCLUSIVE_OPTIONS_VAR(all, inactive);
 
@@ -381,7 +381,6 @@ cmdInterfaceList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
 
     ret = true;
  cleanup:
-    vshTableFree(table);
     virshInterfaceListFree(list);
     return ret;
 }
index 152df1086b6e430682838eeb5a6a7bab432ffd4f..d641606dde0acb4bef047fc09f36fcd25df91560 100644 (file)
@@ -711,7 +711,7 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
     bool optUUID = vshCommandOptBool(cmd, "uuid");
     char uuid[VIR_UUID_STRING_BUFLEN];
     unsigned int flags = VIR_CONNECT_LIST_NETWORKS_ACTIVE;
-    vshTable *table = NULL;
+    g_autoptr(vshTable) table = NULL;
 
     if (vshCommandOptBool(cmd, "inactive"))
         flags = VIR_CONNECT_LIST_NETWORKS_INACTIVE;
@@ -782,7 +782,6 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
 
     ret = true;
  cleanup:
-    vshTableFree(table);
     virshNetworkListFree(list);
     return ret;
 }
@@ -1407,7 +1406,7 @@ cmdNetworkDHCPLeases(vshControl *ctl, const vshCmd *cmd)
     size_t i;
     unsigned int flags = 0;
     virNetworkPtr network = NULL;
-    vshTable *table = NULL;
+    g_autoptr(vshTable) table = NULL;
 
     if (vshCommandOptStringReq(ctl, cmd, "mac", &mac) < 0)
         return false;
@@ -1461,7 +1460,6 @@ cmdNetworkDHCPLeases(vshControl *ctl, const vshCmd *cmd)
     ret = true;
 
  cleanup:
-    vshTableFree(table);
     if (leases) {
         for (i = 0; i < nleases; i++)
             virNetworkDHCPLeaseFree(leases[i]);
@@ -1754,7 +1752,7 @@ cmdNetworkPortList(vshControl *ctl, const vshCmd *cmd)
     bool optUUID = vshCommandOptBool(cmd, "uuid");
     char uuid[VIR_UUID_STRING_BUFLEN];
     unsigned int flags = 0;
-    vshTable *table = NULL;
+    g_autoptr(vshTable) table = NULL;
 
     if (optTable + optUUID > 1) {
         vshError(ctl, "%s",
@@ -1795,7 +1793,6 @@ cmdNetworkPortList(vshControl *ctl, const vshCmd *cmd)
 
     ret = true;
  cleanup:
-    vshTableFree(table);
     virshNetworkPortListFree(list);
     return ret;
 }
index 640e54446e931b98f135bb1981f28079600ac165..acb35e8aa1f81ec88e2f4fc0be6e469f0b7c8f85 100644 (file)
@@ -354,7 +354,7 @@ cmdNWFilterList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
     char uuid[VIR_UUID_STRING_BUFLEN];
     bool ret = false;
     struct virshNWFilterList *list = NULL;
-    vshTable *table = NULL;
+    g_autoptr(vshTable) table = NULL;
 
     if (!(list = virshNWFilterListCollect(ctl, 0)))
         return false;
@@ -378,7 +378,6 @@ cmdNWFilterList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
 
     ret = true;
  cleanup:
-    vshTableFree(table);
     virshNWFilterListFree(list);
     return ret;
 }
@@ -717,7 +716,7 @@ cmdNWFilterBindingList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
     size_t i;
     bool ret = false;
     struct virshNWFilterBindingList *list = NULL;
-    vshTable *table = NULL;
+    g_autoptr(vshTable) table = NULL;
 
     if (!(list = virshNWFilterBindingListCollect(ctl, 0)))
         return false;
@@ -740,7 +739,6 @@ cmdNWFilterBindingList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
 
     ret = true;
  cleanup:
-    vshTableFree(table);
     virshNWFilterBindingListFree(list);
     return ret;
 }
index 18f3839a4c3ea2a9e055d20a64a185aa490bdbfd..5bce5cf06c058c8abe0af9eba94a6a5009113fae 100644 (file)
@@ -1135,7 +1135,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
     bool inactive, all;
     bool uuid = false;
     bool name = false;
-    vshTable *table = NULL;
+    g_autoptr(vshTable) table = NULL;
 
     inactive = vshCommandOptBool(cmd, "inactive");
     all = vshCommandOptBool(cmd, "all");
@@ -1390,7 +1390,6 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
     ret = true;
 
  cleanup:
-    vshTableFree(table);
     if (list && list->npools) {
         for (i = 0; i < list->npools; i++) {
             VIR_FREE(poolInfoTexts[i].state);
index cfecbb9b957295ff1c490d5c0d1245f6163c95b4..4f433fae9c47c02263edab5be7416cb3bec8ef40 100644 (file)
@@ -551,7 +551,7 @@ cmdSecretList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
     struct virshSecretList *list = NULL;
     bool ret = false;
     unsigned int flags = 0;
-    vshTable *table = NULL;
+    g_autoptr(vshTable) table = NULL;
 
     if (vshCommandOptBool(cmd, "ephemeral"))
         flags |= VIR_CONNECT_LIST_SECRETS_EPHEMERAL;
@@ -605,7 +605,6 @@ cmdSecretList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
     ret = true;
 
  cleanup:
-    vshTableFree(table);
     virshSecretListFree(list);
     return ret;
 }
index 6a1fe6785b8209bbeb3bb297fb927bafb1d3fce8..af93998d577ad2b0ed9bf951e73e7a64077520c7 100644 (file)
@@ -1415,7 +1415,7 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
     };
     struct volInfoText *volInfoTexts = NULL;
     struct virshStorageVolList *list = NULL;
-    vshTable *table = NULL;
+    g_autoptr(vshTable) table = NULL;
 
     /* Look up the pool information given to us by the user */
     if (!(pool = virshCommandOptPool(ctl, cmd, "pool", NULL)))
@@ -1513,7 +1513,6 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
     ret = true;
 
  cleanup:
-    vshTableFree(table);
 
     /* Safely free the memory allocated in this function */
     if (list && list->nvols) {
index dd17743b9d6e85cb97c87c8b858be76cca6a1306..c8e7ee794ae8fefda2ea50e979409ee54639f393 100644 (file)
@@ -332,7 +332,7 @@ cmdSrvList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
     char *uri = NULL;
     virAdmServerPtr *srvs = NULL;
     vshAdmControl *priv = ctl->privData;
-    vshTable *table = NULL;
+    g_autoptr(vshTable) table = NULL;
 
     /* Obtain a list of available servers on the daemon */
     if ((nsrvs = virAdmConnectListServers(priv->conn, &srvs, 0)) < 0) {
@@ -361,7 +361,6 @@ cmdSrvList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
 
     ret = true;
  cleanup:
-    vshTableFree(table);
     if (srvs) {
         for (i = 0; i < nsrvs; i++)
             virAdmServerFree(srvs[i]);
@@ -580,7 +579,7 @@ cmdSrvClientsList(vshControl *ctl, const vshCmd *cmd)
     virAdmServerPtr srv = NULL;
     virAdmClientPtr *clts = NULL;
     vshAdmControl *priv = ctl->privData;
-    vshTable *table = NULL;
+    g_autoptr(vshTable) table = NULL;
 
     if (vshCommandOptStringReq(ctl, cmd, "server", &srvname) < 0)
         return false;
@@ -621,7 +620,6 @@ cmdSrvClientsList(vshControl *ctl, const vshCmd *cmd)
     ret = true;
 
  cleanup:
-    vshTableFree(table);
     if (clts) {
         for (i = 0; i < nclts; i++)
             virAdmClientFree(clts[i]);