Blame SOURCES/libvirt-virStorageFileGetMetadataRecurse-Shuffle-around-assignment-of-backing-chain-depth.patch

fbe740
From e0c86b78dc5587263aeb10ae0fc8fbb5975135ee Mon Sep 17 00:00:00 2001
fbe740
Message-Id: <e0c86b78dc5587263aeb10ae0fc8fbb5975135ee@dist-git>
fbe740
From: Peter Krempa <pkrempa@redhat.com>
fbe740
Date: Fri, 28 Feb 2020 10:24:30 +0100
fbe740
Subject: [PATCH] virStorageFileGetMetadataRecurse: Shuffle around assignment
fbe740
 of backing chain depth
fbe740
MIME-Version: 1.0
fbe740
Content-Type: text/plain; charset=UTF-8
fbe740
Content-Transfer-Encoding: 8bit
fbe740
fbe740
Move the assignment to a place where we know that the backing store is
fbe740
present rather than having to check in the cleanup section.
fbe740
fbe740
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
fbe740
Reviewed-by: Eric Blake <eblake@redhat.com>
fbe740
(cherry picked from commit b347e5c7dd69e3381b073c640ece2460632830cc)
fbe740
fbe740
https://bugzilla.redhat.com/show_bug.cgi?id=1798148
fbe740
Message-Id: <0432e2bd0f224cd1c55104e33699cb1602013a5d.1582881363.git.pkrempa@redhat.com>
fbe740
Reviewed-by: Ján Tomko <jtomko@redhat.com>
fbe740
---
fbe740
 src/util/virstoragefile.c | 9 ++++-----
fbe740
 1 file changed, 4 insertions(+), 5 deletions(-)
fbe740
fbe740
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
fbe740
index 1f18320756..911f811ace 100644
fbe740
--- a/src/util/virstoragefile.c
fbe740
+++ b/src/util/virstoragefile.c
fbe740
@@ -5053,14 +5053,15 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
fbe740
             ret = 0;
fbe740
             goto cleanup;
fbe740
         }
fbe740
+
fbe740
+        backingStore->id = depth;
fbe740
+        src->backingStore = g_steal_pointer(&backingStore);
fbe740
     } else {
fbe740
         /* add terminator */
fbe740
-        if (!(backingStore = virStorageSourceNew()))
fbe740
+        if (!(src->backingStore = virStorageSourceNew()))
fbe740
             goto cleanup;
fbe740
     }
fbe740
 
fbe740
-    src->backingStore = g_steal_pointer(&backingStore);
fbe740
-
fbe740
     if (src->externalDataStoreRaw) {
fbe740
         g_autoptr(virStorageSource) externalDataStore = NULL;
fbe740
 
fbe740
@@ -5080,8 +5081,6 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
fbe740
     ret = 0;
fbe740
 
fbe740
  cleanup:
fbe740
-    if (virStorageSourceHasBacking(src))
fbe740
-        src->backingStore->id = depth;
fbe740
     virStorageFileDeinit(src);
fbe740
     return ret;
fbe740
 }
fbe740
-- 
fbe740
2.25.1
fbe740