util: move declarations in virStorageFileChainLookup

Use g_autofree and move the declarations to the beginning
of the block.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Ján Tomko 2020-07-28 20:09:40 +02:00
parent d8c9584aed
commit 908bcaa452

View File

@ -1597,7 +1597,6 @@ virStorageFileChainLookup(virStorageSourcePtr chain,
{ {
virStorageSourcePtr prev; virStorageSourcePtr prev;
const char *start = chain->path; const char *start = chain->path;
char *parentDir = NULL;
bool nameIsFile = virStorageIsFile(name); bool nameIsFile = virStorageIsFile(name);
if (!parent) if (!parent)
@ -1626,15 +1625,16 @@ virStorageFileChainLookup(virStorageSourcePtr chain,
break; break;
if (nameIsFile && virStorageSourceIsLocalStorage(chain)) { if (nameIsFile && virStorageSourceIsLocalStorage(chain)) {
g_autofree char *parentDir = NULL;
int result;
if (*parent && virStorageSourceIsLocalStorage(*parent)) if (*parent && virStorageSourceIsLocalStorage(*parent))
parentDir = g_path_get_dirname((*parent)->path); parentDir = g_path_get_dirname((*parent)->path);
else else
parentDir = g_strdup("."); parentDir = g_strdup(".");
int result = virFileRelLinkPointsTo(parentDir, name, result = virFileRelLinkPointsTo(parentDir, name,
chain->path); chain->path);
VIR_FREE(parentDir);
if (result < 0) if (result < 0)
goto error; goto error;