]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
bhyveParsePCIFbuf: Use g_strsplit instead of virStringSplitCount
authorPeter Krempa <pkrempa@redhat.com>
Mon, 22 Mar 2021 17:10:54 +0000 (18:10 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 12 Apr 2021 13:55:09 +0000 (15:55 +0200)
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/bhyve/bhyve_parse_command.c

index 70f5ac42a02d944229f9226db8768744ab084e55..d86d37b697fad5853ac607f1409f3d13d4d32cc8 100644 (file)
@@ -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;
 }