]> xenbits.xensource.com Git - libvirt.git/commitdiff
vbox: Get rid of "no_memory" labels
authorFabiano Fidêncio <fidencio@redhat.com>
Fri, 20 Dec 2019 12:43:15 +0000 (13:43 +0100)
committerCole Robinson <crobinso@redhat.com>
Fri, 20 Dec 2019 22:02:40 +0000 (17:02 -0500)
As pointed out by Ján Tomko, "no_memory seems suspicious in the times of
abort()".

As libvirt decided to take the path to not report OOM and simply abort
when it happens, let's get rid of the no_memory labels and simplify the
code around them.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
src/vbox/vbox_common.c

index 4493fe858232027fe8a547b423540031f688bb2b..fc67b716da8b6a3c839db26d3fd9f8bae66b6c3e 100644 (file)
@@ -69,18 +69,18 @@ static virDomainDefParserConfig vboxDomainDefParserConfig = {
 static virCapsPtr
 vboxCapsInit(void)
 {
-    virCapsPtr caps;
-    virCapsGuestPtr guest;
+    g_autoptr(virCaps) caps = NULL;
+    virCapsGuestPtr guest = NULL;
 
     if ((caps = virCapabilitiesNew(virArchFromHost(),
                                    false, false)) == NULL)
-        goto no_memory;
+        return NULL;
 
     if (!(caps->host.numa = virCapabilitiesHostNUMANewHost()))
-        goto no_memory;
+        return NULL;
 
     if (virCapabilitiesInitCaches(caps) < 0)
-        goto no_memory;
+        return NULL;
 
     if ((guest = virCapabilitiesAddGuest(caps,
                                          VIR_DOMAIN_OSTYPE_HVM,
@@ -89,7 +89,7 @@ vboxCapsInit(void)
                                          NULL,
                                          0,
                                          NULL)) == NULL)
-        goto no_memory;
+        return NULL;
 
     if (virCapabilitiesAddGuestDomain(guest,
                                       VIR_DOMAIN_VIRT_VBOX,
@@ -97,13 +97,9 @@ vboxCapsInit(void)
                                       NULL,
                                       0,
                                       NULL) == NULL)
-        goto no_memory;
-
-    return caps;
+        return NULL;
 
- no_memory:
-    virObjectUnref(caps);
-    return NULL;
+    return g_steal_pointer(&caps);
 }
 
 static void