libvirt/SOURCES/libvirt-qemuBlockGetBacking...

68 lines
2.3 KiB
Diff

From 11ec875ccebe3035bb4b6e38406f22d52ed4b7fe Mon Sep 17 00:00:00 2001
Message-Id: <11ec875ccebe3035bb4b6e38406f22d52ed4b7fe@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Tue, 24 Mar 2020 16:26:03 +0100
Subject: [PATCH] qemuBlockGetBackingStoreString: Remove 'ret' variable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
We can return the appropriate string directly.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit c60fe3106e8b91478e54129b4b1b81cc0543399e)
https://bugzilla.redhat.com/show_bug.cgi?id=1804617
Message-Id: <b3cb9b35035b7e2d3de21de3f067966de5e6765b.1585063415.git.pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/qemu/qemu_block.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index 279b4a38b8..20579ec7b3 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -2030,13 +2030,10 @@ qemuBlockGetBackingStoreString(virStorageSourcePtr src,
virJSONValuePtr props = NULL;
g_autoptr(virURI) uri = NULL;
g_autofree char *backingJSON = NULL;
- char *ret = NULL;
if (!src->sliceStorage) {
- if (virStorageSourceIsLocalStorage(src)) {
- ret = g_strdup(src->path);
- return ret;
- }
+ if (virStorageSourceIsLocalStorage(src))
+ return g_strdup(src->path);
/* generate simplified URIs for the easy cases */
if (actualType == VIR_STORAGE_TYPE_NETWORK &&
@@ -2055,10 +2052,7 @@ qemuBlockGetBackingStoreString(virStorageSourcePtr src,
if (!(uri = qemuBlockStorageSourceGetURI(src)))
return NULL;
- if (!(ret = virURIFormat(uri)))
- return NULL;
-
- return ret;
+ return virURIFormat(uri);
case VIR_STORAGE_NET_PROTOCOL_SHEEPDOG:
case VIR_STORAGE_NET_PROTOCOL_RBD:
@@ -2092,9 +2086,7 @@ qemuBlockGetBackingStoreString(virStorageSourcePtr src,
if (!(backingJSON = virJSONValueToString(props, pretty)))
return NULL;
- ret = g_strdup_printf("json:%s", backingJSON);
-
- return ret;
+ return g_strdup_printf("json:%s", backingJSON);
}
--
2.26.0