virStorageFileParseBackingStoreStr: use g_strsplit instead of virStringSplitCount

The presence of the second element can be checked by looking at it
directly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2021-03-22 17:00:41 +01:00
parent e49eb0aaa7
commit b18527134b

View File

@ -192,17 +192,16 @@ virStorageFileParseBackingStoreStr(const char *str,
char **target,
unsigned int *chainIndex)
{
size_t nstrings;
unsigned int idx = 0;
char *suffix;
g_auto(GStrv) strings = NULL;
*chainIndex = 0;
if (!(strings = virStringSplitCount(str, "[", 2, &nstrings)))
if (!(strings = g_strsplit(str, "[", 2)))
return -1;
if (nstrings == 2) {
if (strings[0] && strings[1]) {
if (virStrToLong_uip(strings[1], &suffix, 10, &idx) < 0 ||
STRNEQ(suffix, "]"))
return -1;