From c5ae8135df997ccce8963e5e3e5876feb0bbfdb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Mon, 13 Dec 2021 19:26:06 +0100 Subject: [PATCH] openvz: refactor openvzGetVEStatus 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_driver.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 3cd655e5a7..d4c65dbc26 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -1697,21 +1697,20 @@ openvzDomainSetMemoryParameters(virDomainPtr domain, static int openvzGetVEStatus(virDomainObj *vm, int *status, int *reason) { - virCommand *cmd; - char *outbuf; + g_autoptr(virCommand) cmd = NULL; + g_autofree char *outbuf = NULL; char *line; int state; - int ret = -1; cmd = virCommandNewArgList(VZLIST, vm->def->name, "-ostatus", "-H", NULL); virCommandSetOutputBuffer(cmd, &outbuf); if (virCommandRun(cmd, NULL) < 0) - goto cleanup; + return -1; if ((line = strchr(outbuf, '\n')) == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Failed to parse vzlist output")); - goto cleanup; + return -1; } *line++ = '\0'; @@ -1728,12 +1727,7 @@ openvzGetVEStatus(virDomainObj *vm, int *status, int *reason) *status = VIR_DOMAIN_SHUTOFF; } - ret = 0; - - cleanup: - virCommandFree(cmd); - VIR_FREE(outbuf); - return ret; + return 0; } static int