[libvirt] [PATCH 04/14] util: storagefile: Simplify cleanup in virStorageSourceParseBackingJSON

Peter Krempa pkrempa at redhat.com
Fri Aug 16 10:39:25 UTC 2019


Automatically free the 'root' temporary variable to get rid fo some
complexity.

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

diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index e93f6285b0..6fff013e3a 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -3622,16 +3622,12 @@ static int
 virStorageSourceParseBackingJSON(virStorageSourcePtr src,
                                  const char *json)
 {
-    virJSONValuePtr root = NULL;
-    int ret = -1;
+    VIR_AUTOPTR(virJSONValue) root = NULL;

     if (!(root = virJSONValueFromString(json)))
         return -1;

-    ret = virStorageSourceParseBackingJSONInternal(src, root);
-
-    virJSONValueFree(root);
-    return ret;
+    return virStorageSourceParseBackingJSONInternal(src, root);
 }


-- 
2.21.0




More information about the libvir-list mailing list