From: Ján Tomko Date: Mon, 13 Dec 2021 17:39:29 +0000 (+0100) Subject: openvz: refactor openvzExtractVersionInfo X-Git-Tag: v8.0.0-rc1~212 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=73a716eecd1c4d89b1397434d92b8b41cb7fec8a;p=thirdparty%2Flibvirt.git openvz: refactor openvzExtractVersionInfo 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 4fb18c03ee..53170a720b 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -66,11 +66,10 @@ strtoI(const char *str) static int openvzExtractVersionInfo(const char *cmdstr, int *retversion) { - int ret = -1; unsigned long version; - char *help = NULL; + g_autofree char *help = NULL; char *tmp; - virCommand *cmd = virCommandNewArgList(cmdstr, "--help", NULL); + g_autoptr(virCommand) cmd = virCommandNewArgList(cmdstr, "--help", NULL); if (retversion) *retversion = 0; @@ -79,27 +78,21 @@ openvzExtractVersionInfo(const char *cmdstr, int *retversion) virCommandSetOutputBuffer(cmd, &help); if (virCommandRun(cmd, NULL) < 0) - goto cleanup; + return -1; tmp = help; /* expected format: vzctl version .. */ if ((tmp = STRSKIP(tmp, "vzctl version ")) == NULL) - goto cleanup; + return -1; if (virParseVersionString(tmp, &version, true) < 0) - goto cleanup; + return -1; if (retversion) *retversion = version; - ret = 0; - - cleanup: - virCommandFree(cmd); - VIR_FREE(help); - - return ret; + return 0; } int openvzExtractVersion(struct openvz_driver *driver)