We don't need the index that virDomainDiskIndexByName returns.

Signed-off-by: Peter Krempa <pkre...@redhat.com>
---
 src/conf/snapshot_conf.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index 8ef9708c72..f896fd1cf2 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -663,17 +663,14 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr 
snapdef,
     /* Double check requested disks.  */
     for (i = 0; i < snapdef->ndisks; i++) {
         virDomainSnapshotDiskDefPtr snapdisk = &snapdef->disks[i];
-        int idx = virDomainDiskIndexByName(domdef, snapdisk->name, false);
-        virDomainDiskDefPtr domdisk = NULL;
+        virDomainDiskDefPtr domdisk = virDomainDiskByName(domdef, 
snapdisk->name, false);

-        if (idx < 0) {
+        if (!domdisk) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                            _("no disk named '%s'"), snapdisk->name);
             return -1;
         }

-        domdisk = domdef->disks[idx];
-
         if (virHashHasEntry(map, domdisk->dst)) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                            _("disk '%s' specified twice"),
-- 
2.28.0

Reply via email to