Use g_strsplit instead of virStringSplitCount and automatically free the
temporary string list.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/openvz/openvz_conf.c | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c
index 836885af18..cf29ce30ad 100644
--- a/src/openvz/openvz_conf.c
+++ b/src/openvz/openvz_conf.c
@@ -123,26 +123,21 @@ openvzParseBarrierLimit(const char* value,
unsigned long long *barrier,
unsigned long long *limit)
{
- char **tmp = NULL;
- size_t ntmp = 0;
- int ret = -1;
+ g_auto(GStrv) tmp = NULL;
- if (!(tmp = virStringSplitCount(value, ":", 0, &ntmp)))
- goto error;
+ if (!(tmp = g_strsplit(value, ":", 0)))
+ return -1;
- if (ntmp != 2)
- goto error;
+ if (g_strv_length(tmp) != 2)
+ return -1;
if (barrier && virStrToLong_ull(tmp[0], NULL, 10, barrier) < 0)
- goto error;
+ return -1;
if (limit && virStrToLong_ull(tmp[1], NULL, 10, limit) < 0)
- goto error;
+ return -1;
- ret = 0;
- error:
- virStringListFreeCount(tmp, ntmp);
- return ret;
+ return 0;
}
--
2.29.2