From de48ade19586fda704d4f517ffb219960c3d6a08 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Mon, 15 May 2023 12:17:06 +0200 Subject: [PATCH] virDomainBackupDefAssignStore: Restructure control flow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Return early for errors instead of using 'else' branches. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/conf/backup_conf.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/conf/backup_conf.c b/src/conf/backup_conf.c index 4a8c05dca9..013c08cd6e 100644 --- a/src/conf/backup_conf.c +++ b/src/conf/backup_conf.c @@ -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;