1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

tools: virsh: use automatic cleanup for char **

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:45:02 +02:00
parent 851e66e05d
commit 07b40abe0f
4 changed files with 7 additions and 17 deletions

View File

@ -4002,7 +4002,7 @@ cmdStartGetFDs(vshControl *ctl,
int **fdsret)
{
const char *fdopt;
char **fdlist = NULL;
g_auto(GStrv) fdlist = NULL;
int *fds = NULL;
size_t nfds = 0;
size_t i;
@ -4028,14 +4028,11 @@ cmdStartGetFDs(vshControl *ctl,
fds[nfds - 1] = fd;
}
g_strfreev(fdlist);
*fdsret = fds;
*nfdsret = nfds;
return 0;
error:
g_strfreev(fdlist);
VIR_FREE(fds);
return -1;
}
@ -5859,7 +5856,7 @@ cmdShutdown(vshControl *ctl, const vshCmd *cmd)
const char *mode = NULL;
int flags = 0;
int rv;
char **modes = NULL;
g_auto(GStrv) modes = NULL;
char **tmp;
if (vshCommandOptStringReq(ctl, cmd, "mode", &mode) < 0)
@ -5908,7 +5905,6 @@ cmdShutdown(vshControl *ctl, const vshCmd *cmd)
ret = true;
cleanup:
g_strfreev(modes);
return ret;
}
@ -5943,7 +5939,7 @@ cmdReboot(vshControl *ctl, const vshCmd *cmd)
const char *name;
const char *mode = NULL;
int flags = 0;
char **modes = NULL;
g_auto(GStrv) modes = NULL;
char **tmp;
if (vshCommandOptStringReq(ctl, cmd, "mode", &mode) < 0)
@ -5988,7 +5984,6 @@ cmdReboot(vshControl *ctl, const vshCmd *cmd)
ret = true;
cleanup:
g_strfreev(modes);
return ret;
}

View File

@ -1301,7 +1301,7 @@ cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd)
const char *from = NULL;
bool ret = false;
char *result = NULL;
char **list = NULL;
g_auto(GStrv) list = NULL;
unsigned int flags = 0;
virshControl *priv = ctl->privData;
@ -1326,7 +1326,6 @@ cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd)
}
VIR_FREE(result);
g_strfreev(list);
return ret;
}

View File

@ -115,7 +115,7 @@ static virNodeDevice*
vshFindNodeDevice(vshControl *ctl, const char *value)
{
virNodeDevicePtr dev = NULL;
char **arr = NULL;
g_auto(GStrv) arr = NULL;
int narr;
virshControl *priv = ctl->privData;
@ -140,7 +140,6 @@ vshFindNodeDevice(vshControl *ctl, const char *value)
}
cleanup:
g_strfreev(arr);
return dev;
}
@ -409,7 +408,7 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
bool tree = vshCommandOptBool(cmd, "tree");
bool ret = true;
unsigned int flags = 0;
char **caps = NULL;
g_auto(GStrv) caps = NULL;
int ncaps = 0;
struct virshNodeDeviceList *list = NULL;
int cap_type = -1;
@ -555,7 +554,6 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
}
cleanup:
g_strfreev(caps);
virshNodeDeviceListFree(list);
return ret;
}

View File

@ -1175,7 +1175,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
if (type) {
int poolType = -1;
char **poolTypes = NULL;
g_auto(GStrv) poolTypes = NULL;
int npoolTypes = 0;
if ((npoolTypes = vshStringToArray(type, &poolTypes)) < 0)
@ -1184,7 +1184,6 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
for (i = 0; i < npoolTypes; i++) {
if ((poolType = virStoragePoolTypeFromString(poolTypes[i])) < 0) {
vshError(ctl, _("Invalid pool type '%s'"), poolTypes[i]);
g_strfreev(poolTypes);
return false;
}
@ -1235,7 +1234,6 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
break;
}
}
g_strfreev(poolTypes);
}
if (!(list = virshStoragePoolListCollect(ctl, flags)))