From: Peter Krempa Date: Thu, 15 Aug 2019 14:25:47 +0000 (+0200) Subject: util: storagefile: Simplify cleanup in virStorageSourceParseBackingJSON X-Git-Tag: v5.7.0-rc1~72 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fe434a0ceb72e0689f6be6b8fef42b74ea2ac278;p=thirdparty%2Flibvirt.git util: storagefile: Simplify cleanup in virStorageSourceParseBackingJSON Automatically free the 'root' temporary variable to get rid of some complexity. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 041e03f5f0..86d75f4403 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -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); }