]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
openvz: refactor openvzGetVEStatus
authorJán Tomko <jtomko@redhat.com>
Mon, 13 Dec 2021 18:26:06 +0000 (19:26 +0100)
committerJán Tomko <jtomko@redhat.com>
Tue, 14 Dec 2021 15:41:06 +0000 (16:41 +0100)
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/openvz/openvz_driver.c

index 3cd655e5a76a20358cf95c8208d5f73c21cf0014..d4c65dbc267c02bc55a8bfcc53a1239ecd241999 100644 (file)
@@ -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