[PATCH 21/39] virshParseRateStr: Use g_strsplit instead of virStringSplitCount

Peter Krempa pkrempa at redhat.com
Thu Apr 1 13:52:20 UTC 2021


Count the elements after splitting the string.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 tools/virsh-domain.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 37be298809..532169d8d7 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -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;
     }
-- 
2.29.2




More information about the libvir-list mailing list