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

Re: [Libguestfs] [PATCH] upload: improve file write callback



On Wed, Nov 09, 2016 at 10:52:25PM +0200, Matteo Cafasso wrote:
> As noted by Pino in another patch, the logic passes the first member of
> the struct which happens to be the right address to the callback
> function.
> 
> This will break the callback if order of the members of the struct will
> change.
> 
> As the callback is using the entire struct, better to pass the pointer
> to the struct itself.
> 
> Signed-off-by: Matteo Cafasso <noxdafox gmail com>
> ---
>  daemon/upload.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/daemon/upload.c b/daemon/upload.c
> index f034627..8b4f600 100644
> --- a/daemon/upload.c
> +++ b/daemon/upload.c
> @@ -84,7 +84,7 @@ upload (const char *filename, int flags, int64_t offset)
>      }
>    }
> 
> -  r = receive_file (write_cb, &data.fd);
> +  r = receive_file (write_cb, &data);
>    if (r == -1) {		/* write error */
>      err = errno;
>      r = cancel_receive ();

Obvious fix - applied.

Thanks,

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html


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