mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00: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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user