From fe434a0ceb72e0689f6be6b8fef42b74ea2ac278 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Thu, 15 Aug 2019 16:25:47 +0200 Subject: [PATCH] util: storagefile: Simplify cleanup in virStorageSourceParseBackingJSON MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Automatically free the 'root' temporary variable to get rid of some complexity. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- 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 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); } -- GitLab