From: Ján Tomko Date: Sun, 4 Oct 2020 21:18:06 +0000 (+0200) Subject: vbox: invert condition in vboxSnapshotGetReadOnlyDisks X-Git-Tag: v6.9.0-rc1~369 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ee7714b574bee17b000e517df89f263f14b1ebd;p=thirdparty%2Flibvirt.git vbox: invert condition in vboxSnapshotGetReadOnlyDisks Error out on (impossible) failed allocation, to reduce indentation. Signed-off-by: Ján Tomko Reviewed-by: Erik Skultety --- diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 45fd670a11..f59af697ea 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -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 */