From: Ján Tomko Date: Tue, 28 Jul 2020 18:09:40 +0000 (+0200) Subject: util: move declarations in virStorageFileChainLookup X-Git-Tag: v6.7.0-rc1~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=908bcaa452b1123eb2578ec031f5e1a103ee8084;p=thirdparty%2Flibvirt.git util: move declarations in virStorageFileChainLookup Use g_autofree and move the declarations to the beginning of the block. Signed-off-by: Ján Tomko Reviewed-by: Michal Privoznik --- 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;