vbox: invert condition in vboxSnapshotGetReadOnlyDisks

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>
This commit is contained in:
Ján Tomko 2020-10-04 23:18:06 +02:00
parent 4a1f4e898b
commit 5ee7714b57

View 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 */