[PATCH 16/39] virLogParseOutput: Replace virStringSplitCount by g_strsplit

Peter Krempa posted 39 patches 4 years, 10 months ago
[PATCH 16/39] virLogParseOutput: Replace virStringSplitCount by g_strsplit
Posted by Peter Krempa 4 years, 10 months ago
Unfortunately here we do need the count of elements. Use g_strv_length
to calculate it so that virStringSplitCount can be removed later.

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

diff --git a/src/util/virlog.c b/src/util/virlog.c
index 8a4cfbfdc2..3fb27fcb25 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -1470,7 +1470,8 @@ virLogParseOutput(const char *src)
     /* split our format prio:destination:additional_data to tokens and parse
      * them individually
      */
-    if (!(tokens = virStringSplitCount(src, ":", 0, &count)) || count < 2) {
+    if (!(tokens = g_strsplit(src, ":", 0)) ||
+        (count = g_strv_length(tokens))< 2) {
         virReportError(VIR_ERR_INVALID_ARG,
                        _("Malformed format for output '%s'"), src);
         return NULL;
-- 
2.29.2

Re: [PATCH 16/39] virLogParseOutput: Replace virStringSplitCount by g_strsplit
Posted by Ján Tomko 4 years, 10 months ago
On a Thursday in 2021, Peter Krempa wrote:
>Unfortunately here we do need the count of elements. Use g_strv_length
>to calculate it so that virStringSplitCount can be removed later.
>
>Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>---
> src/util/virlog.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
>diff --git a/src/util/virlog.c b/src/util/virlog.c
>index 8a4cfbfdc2..3fb27fcb25 100644
>--- a/src/util/virlog.c
>+++ b/src/util/virlog.c
>@@ -1470,7 +1470,8 @@ virLogParseOutput(const char *src)
>     /* split our format prio:destination:additional_data to tokens and parse
>      * them individually
>      */
>-    if (!(tokens = virStringSplitCount(src, ":", 0, &count)) || count < 2) {
>+    if (!(tokens = g_strsplit(src, ":", 0)) ||
>+        (count = g_strv_length(tokens))< 2) {

Missing space before <

>         virReportError(VIR_ERR_INVALID_ARG,
>                        _("Malformed format for output '%s'"), src);
>         return NULL;

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

Jano