]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuSnapshotPrepareDiskExternal: Avoid condition squashing
authorPeter Krempa <pkrempa@redhat.com>
Wed, 16 Jun 2021 12:57:44 +0000 (14:57 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 18 Jun 2021 07:16:16 +0000 (09:16 +0200)
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>
src/qemu/qemu_snapshot.c

index 67180a2b10b7278e1e237e551ea103ae265fde52..81085bf4bdc88cd650b5fb070e1b4f2c746e4129 100644 (file)
@@ -582,18 +582,22 @@ qemuSnapshotPrepareDiskExternal(virDomainObj *vm,
                                      _("unable to stat for disk %s: %s"),
                                      snapdisk->name, snapdisk->src->path);
                 return -1;
-            } else if (reuse) {
+            }
+
+            if (reuse) {
                 virReportSystemError(err,
                                      _("missing existing file for disk %s: %s"),
                                      snapdisk->name, snapdisk->src->path);
                 return -1;
             }
-        } else if (!S_ISBLK(st.st_mode) && st.st_size && !reuse) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                           _("external snapshot file for disk %s already "
-                             "exists and is not a block device: %s"),
-                           snapdisk->name, snapdisk->src->path);
-            return -1;
+        } else {
+            if (!S_ISBLK(st.st_mode) && st.st_size && !reuse) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                               _("external snapshot file for disk %s already "
+                                 "exists and is not a block device: %s"),
+                               snapdisk->name, snapdisk->src->path);
+                return -1;
+            }
         }
     }