1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

qemuSnapshotPrepareDiskExternal: Avoid condition squashing

Separate the 'else if' branches into nested conditions so that it's more
obvious when we'll be adding additional checks later.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2021-06-16 14:57:44 +02:00
parent 006821a809
commit a96cc845d7

View File

@ -582,13 +582,16 @@ qemuSnapshotPrepareDiskExternal(virDomainObj *vm,
_("unable to stat for disk %s: %s"), _("unable to stat for disk %s: %s"),
snapdisk->name, snapdisk->src->path); snapdisk->name, snapdisk->src->path);
return -1; return -1;
} else if (reuse) { }
if (reuse) {
virReportSystemError(err, virReportSystemError(err,
_("missing existing file for disk %s: %s"), _("missing existing file for disk %s: %s"),
snapdisk->name, snapdisk->src->path); snapdisk->name, snapdisk->src->path);
return -1; return -1;
} }
} else if (!S_ISBLK(st.st_mode) && st.st_size && !reuse) { } else {
if (!S_ISBLK(st.st_mode) && st.st_size && !reuse) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("external snapshot file for disk %s already " _("external snapshot file for disk %s already "
"exists and is not a block device: %s"), "exists and is not a block device: %s"),
@ -596,6 +599,7 @@ qemuSnapshotPrepareDiskExternal(virDomainObj *vm,
return -1; return -1;
} }
} }
}
return 0; return 0;
} }