]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virshParseRateStr: Use g_strsplit instead of virStringSplitCount
authorPeter Krempa <pkrempa@redhat.com>
Tue, 23 Mar 2021 08:10:18 +0000 (09:10 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 12 Apr 2021 13:55:09 +0000 (15:55 +0200)
Count the elements after splitting the string.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tools/virsh-domain.c

index 37be298809292e1e1d3101d444ecfdaa190b501c..532169d8d74de717deb3ed7f8cf8100e9b349aa5 100644 (file)
@@ -860,10 +860,10 @@ virshParseRateStr(vshControl *ctl,
     g_auto(GStrv) tok = NULL;
     size_t ntok;
 
-    if (!(tok = virStringSplitCount(rateStr, ",", 0, &ntok)))
+    if (!(tok = g_strsplit(rateStr, ",", 0)))
         return -1;
 
-    if (ntok > 4) {
+    if ((ntok = g_strv_length(tok)) > 4) {
         vshError(ctl, _("Rate string '%s' has too many fields"), rateStr);
         return -1;
     }