[PATCH 22/40] virCgroupGetValueForBlkDev: Rewrite lookup of returned string

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Lookup the string with prefix locally so that we can remove the helper
which isn't universal at all.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/util/vircgroup.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index b5c74e94de..2c418cd84d 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -568,21 +568,21 @@ virCgroupGetValueForBlkDev(const char *str,
                            char **value)
 {
     g_autofree char *prefix = NULL;
-    char **lines = NULL;
-    int ret = -1;
+    g_auto(GStrv) lines = NULL;
+    GStrv tmp;

     if (!(prefix = virCgroupGetBlockDevString(path)))
-        goto error;
+        return -1;

     if (!(lines = virStringSplit(str, "\n", -1)))
-        goto error;
+        return -1;

-    *value = g_strdup(virStringListGetFirstWithPrefix(lines, prefix));
+    for (tmp = lines; *tmp; tmp++) {
+        if ((*value = g_strdup(STRSKIP(*tmp, prefix))))
+            break;
+    }

-    ret = 0;
- error:
-    g_strfreev(lines);
-    return ret;
+    return 0;
 }


-- 
2.29.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux