[PATCH 1/9] vz: remove unnecessary labels in simple API calls

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

 



Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx>
---
 src/vz/vz_driver.c | 103 ++++++++++++++++++-----------------------------------
 1 file changed, 34 insertions(+), 69 deletions(-)

diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index e2a0d1f..0350b7d 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -528,23 +528,21 @@ static virDomainPtr
 vzDomainLookupByID(virConnectPtr conn, int id)
 {
     vzConnPtr privconn = conn->privateData;
-    virDomainPtr ret = NULL;
+    virDomainPtr ret;
     virDomainObjPtr dom;
 
     dom = virDomainObjListFindByID(privconn->driver->domains, id);
 
     if (dom == NULL) {
         virReportError(VIR_ERR_NO_DOMAIN, NULL);
-        goto cleanup;
+        return NULL;
     }
 
     ret = virGetDomain(conn, dom->def->name, dom->def->uuid);
     if (ret)
         ret->id = dom->def->id;
 
- cleanup:
-    if (dom)
-        virObjectUnlock(dom);
+    virObjectUnlock(dom);
     return ret;
 }
 
@@ -552,7 +550,7 @@ static virDomainPtr
 vzDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
 {
     vzConnPtr privconn = conn->privateData;
-    virDomainPtr ret = NULL;
+    virDomainPtr ret;
     virDomainObjPtr dom;
 
     dom = virDomainObjListFindByUUID(privconn->driver->domains, uuid);
@@ -562,16 +560,14 @@ vzDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
         virUUIDFormat(uuid, uuidstr);
         virReportError(VIR_ERR_NO_DOMAIN,
                        _("no domain with matching uuid '%s'"), uuidstr);
-        goto cleanup;
+        return NULL;
     }
 
     ret = virGetDomain(conn, dom->def->name, dom->def->uuid);
     if (ret)
         ret->id = dom->def->id;
 
- cleanup:
-    if (dom)
-        virObjectUnlock(dom);
+    virObjectUnlock(dom);
     return ret;
 }
 
@@ -579,7 +575,7 @@ static virDomainPtr
 vzDomainLookupByName(virConnectPtr conn, const char *name)
 {
     vzConnPtr privconn = conn->privateData;
-    virDomainPtr ret = NULL;
+    virDomainPtr ret;
     virDomainObjPtr dom;
 
     dom = virDomainObjListFindByName(privconn->driver->domains, name);
@@ -587,14 +583,13 @@ vzDomainLookupByName(virConnectPtr conn, const char *name)
     if (dom == NULL) {
         virReportError(VIR_ERR_NO_DOMAIN,
                        _("no domain with matching name '%s'"), name);
-        goto cleanup;
+        return NULL;
     }
 
     ret = virGetDomain(conn, dom->def->name, dom->def->uuid);
     if (ret)
         ret->id = dom->def->id;
 
- cleanup:
     virDomainObjEndAPI(&dom);
     return ret;
 }
@@ -641,17 +636,14 @@ static char *
 vzDomainGetOSType(virDomainPtr domain)
 {
     virDomainObjPtr dom;
-
     char *ret = NULL;
 
     if (!(dom = vzDomObjFromDomain(domain)))
-        goto cleanup;
+        return NULL;
 
     ignore_value(VIR_STRDUP(ret, virDomainOSTypeToString(dom->def->os.type)));
 
- cleanup:
-    if (dom)
-        virObjectUnlock(dom);
+    virObjectUnlock(dom);
     return ret;
 }
 
@@ -659,17 +651,12 @@ static int
 vzDomainIsPersistent(virDomainPtr domain)
 {
     virDomainObjPtr dom;
-    int ret = -1;
 
     if (!(dom = vzDomObjFromDomain(domain)))
-        goto cleanup;
+        return -1;
 
-    ret = 1;
-
- cleanup:
-    if (dom)
-        virObjectUnlock(dom);
-    return ret;
+    virObjectUnlock(dom);
+    return 1;
 }
 
 static int
@@ -677,19 +664,16 @@ vzDomainGetState(virDomainPtr domain,
                  int *state, int *reason, unsigned int flags)
 {
     virDomainObjPtr dom;
-    int ret = -1;
+
     virCheckFlags(0, -1);
 
     if (!(dom = vzDomObjFromDomain(domain)))
-        goto cleanup;
+        return -1;
 
     *state = virDomainObjGetState(dom, reason);
-    ret = 0;
 
- cleanup:
-    if (dom)
-        virObjectUnlock(dom);
-    return ret;
+    virObjectUnlock(dom);
+    return 0;
 }
 
 static char *
@@ -703,16 +687,14 @@ vzDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
     /* Flags checked by virDomainDefFormat */
 
     if (!(dom = vzDomObjFromDomain(domain)))
-        goto cleanup;
+        return NULL;
 
     def = (flags & VIR_DOMAIN_XML_INACTIVE) &&
         dom->newDef ? dom->newDef : dom->def;
 
     ret = virDomainDefFormat(def, privconn->driver->caps, flags);
 
- cleanup:
-    if (dom)
-        virObjectUnlock(dom);
+    virObjectUnlock(dom);
     return ret;
 }
 
@@ -720,18 +702,14 @@ static int
 vzDomainGetAutostart(virDomainPtr domain, int *autostart)
 {
     virDomainObjPtr dom;
-    int ret = -1;
 
     if (!(dom = vzDomObjFromDomain(domain)))
-        goto cleanup;
+        return -1;
 
     *autostart = dom->autostart;
-    ret = 0;
 
- cleanup:
-    if (dom)
-        virObjectUnlock(dom);
-    return ret;
+    virObjectUnlock(dom);
+    return 0;
 }
 
 static virDomainPtr
@@ -882,7 +860,7 @@ vzDomainGetVcpus(virDomainPtr domain,
     int ret = -1;
 
     if (!(dom = vzDomObjFromDomainRef(domain)))
-        goto cleanup;
+        return -1;
 
     if (!virDomainObjIsActive(dom)) {
         virReportError(VIR_ERR_OPERATION_INVALID,
@@ -916,8 +894,7 @@ vzDomainGetVcpus(virDomainPtr domain,
     ret = maxinfo;
 
  cleanup:
-    if (dom)
-        virDomainObjEndAPI(&dom);
+    virDomainObjEndAPI(&dom);
     return ret;
 }
 
@@ -954,17 +931,13 @@ vzConnectDomainEventDeregisterAny(virConnectPtr conn,
                                   int callbackID)
 {
     vzConnPtr privconn = conn->privateData;
-    int ret = -1;
 
     if (virObjectEventStateDeregisterID(conn,
                                         privconn->driver->domainEventState,
                                         callbackID) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
-
- cleanup:
-    return ret;
+    return 0;
 }
 
 static int vzDomainSuspend(virDomainPtr domain)
@@ -1346,8 +1319,7 @@ vzDomainBlockStats(virDomainPtr domain, const char *path,
     ret = 0;
 
  cleanup:
-    if (dom)
-        virDomainObjEndAPI(&dom);
+    virDomainObjEndAPI(&dom);
 
     return ret;
 }
@@ -1448,24 +1420,22 @@ static int
 vzDomainGetVcpusFlags(virDomainPtr domain,
                       unsigned int flags)
 {
-    virDomainObjPtr dom = NULL;
-    int ret = -1;
+    virDomainObjPtr dom;
+    int ret;
 
     virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
                   VIR_DOMAIN_AFFECT_CONFIG |
                   VIR_DOMAIN_VCPU_MAXIMUM, -1);
 
     if (!(dom = vzDomObjFromDomain(domain)))
-        goto cleanup;
+        return -1;
 
     if (flags & VIR_DOMAIN_VCPU_MAXIMUM)
         ret = virDomainDefGetVcpusMax(dom->def);
     else
         ret = virDomainDefGetVcpus(dom->def);
 
- cleanup:
-    if (dom)
-        virObjectUnlock(dom);
+    virObjectUnlock(dom);
 
     return ret;
 }
@@ -1479,19 +1449,14 @@ static int vzDomainGetMaxVcpus(virDomainPtr domain)
 static int vzDomainIsUpdated(virDomainPtr domain)
 {
     virDomainObjPtr dom;
-    int ret = -1;
 
     /* As far as VZ domains are always updated (e.g. current==persistent),
      * we just check for domain existence */
     if (!(dom = vzDomObjFromDomain(domain)))
-        goto cleanup;
+        return -1;
 
-    ret = 0;
-
- cleanup:
-    if (dom)
-        virObjectUnlock(dom);
-    return ret;
+    virObjectUnlock(dom);
+    return 0;
 }
 
 static int vzConnectGetMaxVcpus(virConnectPtr conn ATTRIBUTE_UNUSED,
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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]