From e0c86b78dc5587263aeb10ae0fc8fbb5975135ee Mon Sep 17 00:00:00 2001 Message-Id: From: Peter Krempa Date: Fri, 28 Feb 2020 10:24:30 +0100 Subject: [PATCH] virStorageFileGetMetadataRecurse: Shuffle around assignment of backing chain depth MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Eric Blake (cherry picked from commit b347e5c7dd69e3381b073c640ece2460632830cc) https://bugzilla.redhat.com/show_bug.cgi?id=1798148 Message-Id: <0432e2bd0f224cd1c55104e33699cb1602013a5d.1582881363.git.pkrempa@redhat.com> Reviewed-by: Ján Tomko --- 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 1f18320756..911f811ace 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.25.1