Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
tools/virsh-domain.c | 23 ++++++++++-------------
1 file changed, 10 insertions(+), 13 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index a778421b66..86de4255fa 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -9342,24 +9342,21 @@ virshParseEventStr(const char *event,
int *nparams,
int *maxparams)
{
- char **tok = NULL;
- size_t i, ntok;
- int ret = -1;
+ g_auto(GStrv) tok = NULL;
+ GStrv next;
- if (!(tok = virStringSplitCount(event, ",", 0, &ntok)))
+ if (!(tok = g_strsplit(event, ",", 0)))
return -1;
- for (i = 0; i < ntok; i++) {
- if ((*tok[i] != '\0') &&
- virTypedParamsAddBoolean(params, nparams,
- maxparams, tok[i], state) < 0)
- goto cleanup;
+ for (next = tok; *next; next++) {
+ if (*next[0] == '\0')
+ continue;
+
+ if (virTypedParamsAddBoolean(params, nparams, maxparams, *next, state) < 0)
+ return -1;
}
- ret = 0;
- cleanup:
- g_strfreev(tok);
- return ret;
+ return 0;
}
static void
--
2.29.2