From d5c9d168c4922807c98a395e93a08594b8ccabf5 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Thu, 1 Apr 2021 15:34:52 +0200 Subject: [PATCH] openvzParseBarrierLimit: Rework string handling MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Use g_strsplit instead of virStringSplitCount and automatically free the temporary string list. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- 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.47.2