virCgroupGetValueForBlkDev: Rewrite lookup of returned string

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@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Peter Krempa 2021-02-05 14:33:12 +01:00
parent 2b3e390674
commit 7cc3418915

View File

@ -600,21 +600,21 @@ virCgroupGetValueForBlkDev(const char *str,
char **value) char **value)
{ {
g_autofree char *prefix = NULL; g_autofree char *prefix = NULL;
char **lines = NULL; g_auto(GStrv) lines = NULL;
int ret = -1; GStrv tmp;
if (!(prefix = virCgroupGetBlockDevString(path))) if (!(prefix = virCgroupGetBlockDevString(path)))
goto error; return -1;
if (!(lines = virStringSplit(str, "\n", -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; return 0;
error:
g_strfreev(lines);
return ret;
} }