mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
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:
parent
2b3e390674
commit
7cc3418915
@ -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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user