[PATCH 09/14] qemuBlockGetBackingStoreString: Remove 'ret' variable

Peter Krempa pkrempa at redhat.com
Mon Mar 23 18:11:59 UTC 2020


We can return the appropriate string directly.

Signed-off-by: Peter Krempa <pkrempa at 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 d6cc999a43..b7c3ba7530 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -2043,13 +2043,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 &&
@@ -2068,10 +2065,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:
@@ -2105,9 +2099,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.24.1




More information about the libvir-list mailing list