Re: [PATCH RFC 04/27] Revert "storage: fix omitted slash in gluster volume URI"

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

 



On 12/16/2013 09:32 AM, Peter Krempa wrote:
> The fix for the missing slash at the beginning of the volume URI prints
> to a bad variable causing a memory leak and another one if the variable
> will be fixed. Revert the commit instead as we can just add a slash to
> the "key" attribute.
> 
> The fix also caused a regression, where the path of the volume didn't
> include the actual volume name and thus was invalid.
> 
> This reverts commit 6cd60b687acd04ea1538690b7d80f2809e0e29d4.
> ---
>  src/storage/storage_backend_gluster.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_backend_gluster.c
> index 622526b..1be9034 100644
> --- a/src/storage/storage_backend_gluster.c
> +++ b/src/storage/storage_backend_gluster.c
> @@ -227,10 +227,7 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state,
>          goto cleanup;
> 
>      tmp = state->uri->path;
> -    if (virAsprintf(&vol->key, "%s%s", state->uri->path, name) < 0) {

Uggh.  I see what I did: I swapped vol->key and state->uri->path, and
didn't run my patch through valgrind (where I would have seen the problem).

> -        state->uri->path = tmp;
> -        goto cleanup;
> -    }
> +    state->uri->path = vol->key;

Rather than reverting this patch, I'd prefer to fix the string creation
to use the intended order:

diff --git i/src/storage/storage_backend_gluster.c
w/src/storage/storage_backend_gluster.c
index 622526b..aab70ba 100644
--- i/src/storage/storage_backend_gluster.c
+++ w/src/storage/storage_backend_gluster.c
@@ -227,7 +227,7 @@
virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state,
         goto cleanup;

     tmp = state->uri->path;
-    if (virAsprintf(&vol->key, "%s%s", state->uri->path, name) < 0) {
+    if (virAsprintf(&state->uri->path, "%s%s", vol->key, name) < 0) {
         state->uri->path = tmp;
         goto cleanup;
     }


-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[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]