tools: virsh: use automatic cleanup for vshTable

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Ján Tomko 2021-08-11 15:12:02 +02:00
parent 5f7cdb0efc
commit 4b72960b4e
9 changed files with 17 additions and 34 deletions

View 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;
}

View 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;
}

View 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;
}

View 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;
}

View 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;
}

View 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);

View 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;
}

View 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) {

View 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]);