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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx>
---
 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




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux