]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
storage: Cleanup virStorageFileBackendGlusterReadlinkCallback
authorJohn Ferlan <jferlan@redhat.com>
Tue, 12 Feb 2019 11:23:01 +0000 (06:23 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 12 Feb 2019 18:11:04 +0000 (13:11 -0500)
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@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/storage/storage_file_gluster.c

index f8bbde8cfe4ddb2998ca564337f4b339168e2cb9..41c66c5a5df33809a548e2ad404158cd6895b4ef 100644 (file)
@@ -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;
 }