Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
tools/virsh-domain.c | 11 +++--------
tools/virsh-host.c | 3 +--
tools/virsh-nodedev.c | 6 ++----
tools/virsh-pool.c | 4 +---
4 files changed, 7 insertions(+), 17 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 542e2a1736..0636bbfa31 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -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;
}
diff --git a/tools/virsh-host.c b/tools/virsh-host.c
index a07f5adbfa..df1fe49e09 100644
--- a/tools/virsh-host.c
+++ b/tools/virsh-host.c
@@ -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;
}
diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c
index 5b1afe4601..c6c7d97d50 100644
--- a/tools/virsh-nodedev.c
+++ b/tools/virsh-nodedev.c
@@ -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;
}
diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c
index 5bce5cf06c..03987770f6 100644
--- a/tools/virsh-pool.c
+++ b/tools/virsh-pool.c
@@ -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)))
--
2.31.1