From 0dfb73a51143b275032ce173b1c2c38cca2f3c85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Mon, 13 Dec 2021 18:47:47 +0100 Subject: [PATCH] openvz: refactor openvzGetVEID MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ján Tomko Reviewed-by: Michal Privoznik --- src/openvz/openvz_conf.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index 94c3baf87f..d2acbc2606 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -978,23 +978,18 @@ static int openvzAssignUUIDs(void) int openvzGetVEID(const char *name) { - virCommand *cmd; - char *outbuf; + g_autoptr(virCommand) cmd = NULL; + g_autofree char *outbuf = NULL; char *temp; int veid; bool ok; cmd = virCommandNewArgList(VZLIST, name, "-ovpsid", "-H", NULL); virCommandSetOutputBuffer(cmd, &outbuf); - if (virCommandRun(cmd, NULL) < 0) { - virCommandFree(cmd); - VIR_FREE(outbuf); + if (virCommandRun(cmd, NULL) < 0) return -1; - } - virCommandFree(cmd); ok = virStrToLong_i(outbuf, &temp, 10, &veid) == 0 && *temp == '\n'; - VIR_FREE(outbuf); if (ok && veid >= 0) return veid;