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

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