[PATCH 3/9] virStorageFileGetMetadataRecurse: Shuffle around assignment of backing chain depth

Peter Krempa pkrempa at redhat.com
Mon Feb 17 17:13:53 UTC 2020


Move the assignment to a place where we know that the backing store is
present rather than having to check in the cleanup section.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/util/virstoragefile.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 7aeeab0739..f8e4102588 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -5053,14 +5053,15 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
             ret = 0;
             goto cleanup;
         }
+
+        backingStore->id = depth;
+        src->backingStore = g_steal_pointer(&backingStore);
     } else {
         /* add terminator */
-        if (!(backingStore = virStorageSourceNew()))
+        if (!(src->backingStore = virStorageSourceNew()))
             goto cleanup;
     }

-    src->backingStore = g_steal_pointer(&backingStore);
-
     if (src->externalDataStoreRaw) {
         g_autoptr(virStorageSource) externalDataStore = NULL;

@@ -5080,8 +5081,6 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
     ret = 0;

  cleanup:
-    if (virStorageSourceHasBacking(src))
-        src->backingStore->id = depth;
     virStorageFileDeinit(src);
     return ret;
 }
-- 
2.24.1




More information about the libvir-list mailing list