From 908bcaa452b1123eb2578ec031f5e1a103ee8084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Tue, 28 Jul 2020 20:09:40 +0200 Subject: [PATCH] util: move declarations in virStorageFileChainLookup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use g_autofree and move the declarations to the beginning of the block. Signed-off-by: Ján Tomko Reviewed-by: Michal Privoznik --- src/util/virstoragefile.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 00d8e16ef9..f529f0faf3 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -1597,7 +1597,6 @@ virStorageFileChainLookup(virStorageSourcePtr chain, { virStorageSourcePtr prev; const char *start = chain->path; - char *parentDir = NULL; bool nameIsFile = virStorageIsFile(name); if (!parent) @@ -1626,15 +1625,16 @@ virStorageFileChainLookup(virStorageSourcePtr chain, break; if (nameIsFile && virStorageSourceIsLocalStorage(chain)) { + g_autofree char *parentDir = NULL; + int result; + if (*parent && virStorageSourceIsLocalStorage(*parent)) parentDir = g_path_get_dirname((*parent)->path); else parentDir = g_strdup("."); - int result = virFileRelLinkPointsTo(parentDir, name, - chain->path); - - VIR_FREE(parentDir); + result = virFileRelLinkPointsTo(parentDir, name, + chain->path); if (result < 0) goto error;