[PATCH 33/39] xenParsePCI: Replace virStringSplitCount by g_strsplit

Peter Krempa posted 39 patches 4 years, 10 months ago
[PATCH 33/39] xenParsePCI: Replace virStringSplitCount by g_strsplit
Posted by Peter Krempa 4 years, 10 months ago
Count the number of elements in place just for the check.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/libxl/xen_common.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c
index 835f48ec42..49a816add2 100644
--- a/src/libxl/xen_common.c
+++ b/src/libxl/xen_common.c
@@ -372,7 +372,6 @@ xenParsePCI(char *entry)
     virDomainHostdevDefPtr hostdev = NULL;
     g_auto(GStrv) tokens = NULL;
     g_auto(GStrv) options = NULL;
-    size_t ntokens = 0;
     size_t nexttoken = 0;
     char *str;
     char *nextstr;
@@ -383,11 +382,11 @@ xenParsePCI(char *entry)
     virTristateBool filtered = VIR_TRISTATE_BOOL_ABSENT;

     /* pci=['00:1b.0','0000:00:13.0,permissive=1'] */
-    if (!(tokens = virStringSplitCount(entry, ":", 3, &ntokens)))
+    if (!(tokens = g_strsplit(entry, ":", 3)))
         return NULL;

     /* domain */
-    if (ntokens == 3) {
+    if (g_strv_length(tokens) == 3) {
         if (virStrToLong_i(tokens[nexttoken], NULL, 16, &domain) < 0)
             return NULL;
         nexttoken++;
-- 
2.29.2

Re: [PATCH 33/39] xenParsePCI: Replace virStringSplitCount by g_strsplit
Posted by Ján Tomko 4 years, 10 months ago
On a Thursday in 2021, Peter Krempa wrote:
>Count the number of elements in place just for the check.
>
>Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>---
> src/libxl/xen_common.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano