[libvirt PATCH 04/19] util: move declarations in virStorageFileChainLookup

Ján Tomko jtomko at redhat.com
Mon Aug 3 16:56:41 UTC 2020


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

Signed-off-by: Ján Tomko <jtomko at redhat.com>
---
 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;
-- 
2.26.2




More information about the libvir-list mailing list