]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virDomainBackupDefAssignStore: Restructure control flow
authorPeter Krempa <pkrempa@redhat.com>
Mon, 15 May 2023 10:17:06 +0000 (12:17 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 16 May 2023 08:26:33 +0000 (10:26 +0200)
Return early for errors instead of using 'else' branches.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/conf/backup_conf.c

index 4a8c05dca9c6a33c6cdf6a841d230633eb3c82a0..013c08cd6ece05d0c03795309484b5f989a0d9ed 100644 (file)
@@ -422,17 +422,19 @@ virDomainBackupDefAssignStore(virDomainBackupDiskDef *disk,
                            _("disk '%1$s' has no media"), disk->name);
             return -1;
         }
-    } else if (!disk->store) {
-        if (virStorageSourceGetActualType(src) == VIR_STORAGE_TYPE_FILE) {
-            disk->store = virStorageSourceNew();
-            disk->store->type = VIR_STORAGE_TYPE_FILE;
-            disk->store->path = g_strdup_printf("%s.%s", src->path, suffix);
-        } else {
+    }
+
+    if (!disk->store) {
+        if (virStorageSourceGetActualType(src) != VIR_STORAGE_TYPE_FILE) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                            _("refusing to generate file name for disk '%1$s'"),
                            disk->name);
             return -1;
         }
+
+        disk->store = virStorageSourceNew();
+        disk->store->type = VIR_STORAGE_TYPE_FILE;
+        disk->store->path = g_strdup_printf("%s.%s", src->path, suffix);
     }
 
     return 0;