[libvirt] [PATCH v3 1/8] storage: Cleanup virStorageFileBackendGlusterReadlinkCallback

John Ferlan jferlan at redhat.com
Tue Feb 12 14:18:59 UTC 2019


Rather than having two exit paths, let's use a @retval value
and VIR_STEAL_PTR in order to unite the exit path through the
error label.

Signed-off-by: John Ferlan <jferlan at redhat.com>
---
 src/storage/storage_file_gluster.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/storage/storage_file_gluster.c b/src/storage/storage_file_gluster.c
index f8bbde8cfe..41c66c5a5d 100644
--- a/src/storage/storage_file_gluster.c
+++ b/src/storage/storage_file_gluster.c
@@ -262,6 +262,7 @@ virStorageFileBackendGlusterReadlinkCallback(const char *path,
     size_t bufsiz = 0;
     ssize_t ret;
     struct stat st;
+    int retval = -1;
 
     *linkpath = NULL;
 
@@ -291,13 +292,13 @@ virStorageFileBackendGlusterReadlinkCallback(const char *path,
 
     buf[ret] = '\0';
 
-    *linkpath = buf;
+    VIR_STEAL_PTR(*linkpath, buf);
 
-    return 0;
+    retval = 0;
 
  error:
     VIR_FREE(buf);
-    return -1;
+    return retval;
 }
 
 
-- 
2.20.1




More information about the libvir-list mailing list