]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
vbox: invert condition in vboxSnapshotGetReadOnlyDisks
authorJán Tomko <jtomko@redhat.com>
Sun, 4 Oct 2020 21:18:06 +0000 (23:18 +0200)
committerJán Tomko <jtomko@redhat.com>
Mon, 5 Oct 2020 12:29:41 +0000 (14:29 +0200)
Error out on (impossible) failed allocation, to reduce
indentation.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
src/vbox/vbox_common.c

index 45fd670a11bf909b81cb29605568e7ebac2a54ed..f59af697eaaab6a75b7167701732c629c18331c3 100644 (file)
@@ -5971,15 +5971,14 @@ vboxSnapshotGetReadOnlyDisks(virDomainSnapshotDefPtr def,
     }
 
     /* Allocate mem, if fails return error */
-    if (VIR_ALLOC_N(defdom->disks, defdom->ndisks) >= 0) {
-        for (i = 0; i < defdom->ndisks; i++) {
-            virDomainDiskDefPtr diskDef = virDomainDiskDefNew(NULL);
-            if (!diskDef)
-                goto cleanup;
-            defdom->disks[i] = diskDef;
-        }
-    } else {
+    if (VIR_ALLOC_N(defdom->disks, defdom->ndisks) < 0)
         goto cleanup;
+
+    for (i = 0; i < defdom->ndisks; i++) {
+        virDomainDiskDefPtr diskDef = virDomainDiskDefNew(NULL);
+        if (!diskDef)
+            goto cleanup;
+        defdom->disks[i] = diskDef;
     }
 
     /* get the attachment details here */