]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: storagefile: Simplify cleanup in virStorageSourceParseBackingJSON
authorPeter Krempa <pkrempa@redhat.com>
Thu, 15 Aug 2019 14:25:47 +0000 (16:25 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 26 Aug 2019 11:49:16 +0000 (13:49 +0200)
Automatically free the 'root' temporary variable to get rid of some
complexity.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/virstoragefile.c

index 041e03f5f0d91e9bdb864111d4d7f736a1eddfa7..86d75f44039bcf68bcd425ffbdcd0d9a6f508392 100644 (file)
@@ -3624,16 +3624,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);
 }