From: Ján Tomko Date: Mon, 13 Dec 2021 17:47:47 +0000 (+0100) Subject: openvz: refactor openvzGetVEID X-Git-Tag: v8.0.0-rc1~210 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0dfb73a51143b275032ce173b1c2c38cca2f3c85;p=thirdparty%2Flibvirt.git openvz: refactor openvzGetVEID Signed-off-by: Ján Tomko Reviewed-by: Michal Privoznik --- 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;