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

index 94c3baf87f711f3c2140e55d851e85f9063a650a..d2acbc26067b036e1e02c013f0e444d75d59c63e 100644 (file)
@@ -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;