[libvirt PATCH 1/6] util: midonet: use g_auto for virCommand

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx>
---
 src/util/virnetdevmidonet.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/src/util/virnetdevmidonet.c b/src/util/virnetdevmidonet.c
index 9061f1516f..72b2fd4467 100644
--- a/src/util/virnetdevmidonet.c
+++ b/src/util/virnetdevmidonet.c
@@ -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;
 }
-- 
2.31.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux