]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: midonet: use g_auto for virCommand
authorJán Tomko <jtomko@redhat.com>
Mon, 17 Jan 2022 17:02:28 +0000 (18:02 +0100)
committerJán Tomko <jtomko@redhat.com>
Fri, 28 Jan 2022 19:38:44 +0000 (20:38 +0100)
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/util/virnetdevmidonet.c

index 9061f1516f56e947b02811fed18d9b980f2a47da..72b2fd44675e17eb383ebe1335127882005a0bcd 100644 (file)
@@ -39,8 +39,7 @@ int
 virNetDevMidonetBindPort(const char *ifname,
                          const virNetDevVPortProfile *virtualport)
 {
-    int ret = -1;
-    virCommand *cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     char virtportuuid[VIR_UUID_STRING_BUFLEN];
 
     virUUIDFormat(virtualport->interfaceID, virtportuuid);
@@ -53,13 +52,10 @@ virNetDevMidonetBindPort(const char *ifname,
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Unable to bind port %s to the virtual port %s"),
                        ifname, virtportuuid);
-        goto cleanup;
+        return -1;
     }
 
-    ret = 0;
- cleanup:
-    virCommandFree(cmd);
-    return ret;
+    return 0;
 }
 
 /**
@@ -73,8 +69,7 @@ virNetDevMidonetBindPort(const char *ifname,
 int
 virNetDevMidonetUnbindPort(const virNetDevVPortProfile *virtualport)
 {
-    int ret = -1;
-    virCommand *cmd = NULL;
+    g_autoptr(virCommand) cmd = NULL;
     char virtportuuid[VIR_UUID_STRING_BUFLEN];
 
     virUUIDFormat(virtualport->interfaceID, virtportuuid);
@@ -86,11 +81,8 @@ virNetDevMidonetUnbindPort(const virNetDevVPortProfile *virtualport)
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Unable to unbind the virtual port %s from Midonet"),
                        virtportuuid);
-        goto cleanup;
+        return -1;
     }
 
-    ret = 0;
- cleanup:
-    virCommandFree(cmd);
-    return ret;
+    return 0;
 }