]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
openvzParseBarrierLimit: Rework string handling
authorPeter Krempa <pkrempa@redhat.com>
Thu, 1 Apr 2021 13:34:52 +0000 (15:34 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 12 Apr 2021 13:55:10 +0000 (15:55 +0200)
Use g_strsplit instead of virStringSplitCount and automatically free the
temporary string list.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/openvz/openvz_conf.c

index 836885af18076ab3fc07d486dde5be6658ab0efa..cf29ce30ad8de825c694625e5f66a881b79d95f1 100644 (file)
@@ -123,26 +123,21 @@ openvzParseBarrierLimit(const char* value,
                         unsigned long long *barrier,
                         unsigned long long *limit)
 {
-    char **tmp = NULL;
-    size_t ntmp = 0;
-    int ret = -1;
+    g_auto(GStrv) tmp = NULL;
 
-    if (!(tmp = virStringSplitCount(value, ":", 0, &ntmp)))
-        goto error;
+    if (!(tmp = g_strsplit(value, ":", 0)))
+        return -1;
 
-    if (ntmp != 2)
-        goto error;
+    if (g_strv_length(tmp) != 2)
+        return -1;
 
     if (barrier && virStrToLong_ull(tmp[0], NULL, 10, barrier) < 0)
-        goto error;
+        return -1;
 
     if (limit && virStrToLong_ull(tmp[1], NULL, 10, limit) < 0)
-        goto error;
+        return -1;
 
-    ret = 0;
- error:
-    virStringListFreeCount(tmp, ntmp);
-    return ret;
+    return 0;
 }