From ad80bba90a3d783d03559de7184a90ef6414942d Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Mon, 22 Mar 2021 18:10:54 +0100 Subject: [PATCH] bhyveParsePCIFbuf: Use g_strsplit instead of virStringSplitCount MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/bhyve/bhyve_parse_command.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/bhyve/bhyve_parse_command.c b/src/bhyve/bhyve_parse_command.c index 70f5ac42a0..d86d37b697 100644 --- a/src/bhyve/bhyve_parse_command.c +++ b/src/bhyve/bhyve_parse_command.c @@ -558,10 +558,8 @@ bhyveParsePCIFbuf(virDomainDefPtr def, virDomainVideoDefPtr video = NULL; virDomainGraphicsDefPtr graphics = NULL; - char **params = NULL; - char *param = NULL, *separator = NULL; - size_t nparams = 0; - size_t i = 0; + g_auto(GStrv) **params = NULL; + GStrv next; if (!(video = virDomainVideoDefNew(xmlopt))) goto cleanup; @@ -579,11 +577,11 @@ bhyveParsePCIFbuf(virDomainDefPtr def, if (!config) goto error; - if (!(params = virStringSplitCount(config, ",", 0, &nparams))) + if (!(params = g_strsplit(config, ",", 0))) goto error; - for (i = 0; i < nparams; i++) { - param = params[i]; + for (next = params; *next; next++) { + char *param = *next; if (!video->driver) video->driver = g_new0(virDomainVideoDriverDef, 1); @@ -649,13 +647,11 @@ bhyveParsePCIFbuf(virDomainDefPtr def, if (VIR_APPEND_ELEMENT(def->graphics, def->ngraphics, graphics) < 0) goto error; - g_strfreev(params); return 0; error: virDomainVideoDefFree(video); virDomainGraphicsDefFree(graphics); - g_strfreev(params); return -1; }