Error out on (impossible) failed allocation, to reduce indentation. Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx> --- src/vbox/vbox_common.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) 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 */ -- 2.26.2