]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: move declarations in virStorageFileChainLookup
authorJán Tomko <jtomko@redhat.com>
Tue, 28 Jul 2020 18:09:40 +0000 (20:09 +0200)
committerJán Tomko <jtomko@redhat.com>
Tue, 25 Aug 2020 17:03:11 +0000 (19:03 +0200)
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>
src/util/virstoragefile.c

index 00d8e16ef99d6b095bfc0bc2bd603b5f3c866a13..f529f0faf3d85a1b885cb1e0fef50451e37fbb61 100644 (file)
@@ -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;