[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH 09/13] virDomainSnapshotAlignDisks: Extract domain disk definition to a local variable



Extract the disk def to a local variable so that it's more obvious
what's happening and it will also allow further simplification.

Signed-off-by: Peter Krempa <pkrempa redhat com>
---
 src/conf/snapshot_conf.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index a1cee01944..aeebe2fb33 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -677,6 +677,7 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr snapdef,
     for (i = 0; i < snapdef->ndisks; i++) {
         virDomainSnapshotDiskDefPtr snapdisk = &snapdef->disks[i];
         int idx = virDomainDiskIndexByName(domdef, snapdisk->name, false);
+        virDomainDiskDefPtr domdisk = NULL;
         int disk_snapshot;

         if (idx < 0) {
@@ -685,6 +686,8 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr snapdef,
             return -1;
         }

+        domdisk = domdef->disks[idx];
+
         if (virBitmapIsBitSet(map, idx)) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                            _("disk '%s' specified twice"),
@@ -694,7 +697,7 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr snapdef,
         ignore_value(virBitmapSetBit(map, idx));
         snapdisk->idx = idx;

-        disk_snapshot = domdef->disks[idx]->snapshot;
+        disk_snapshot = domdisk->snapshot;
         if (!snapdisk->snapshot) {
             if (disk_snapshot &&
                 (!require_match ||
@@ -722,9 +725,9 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr snapdef,
                            snapdisk->src->path, snapdisk->name);
             return -1;
         }
-        if (STRNEQ(snapdisk->name, domdef->disks[idx]->dst)) {
+        if (STRNEQ(snapdisk->name, domdisk->dst)) {
             VIR_FREE(snapdisk->name);
-            snapdisk->name = g_strdup(domdef->disks[idx]->dst);
+            snapdisk->name = g_strdup(domdisk->dst);
         }
     }

-- 
2.26.2


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]