[Spice-devel] [PATCH spice-server 02/12] Be consistent with opaque type
Christophe Fergeau
cfergeau at redhat.com
Tue Oct 25 16:51:50 UTC 2016
On Tue, Oct 18, 2016 at 10:09:47AM +0100, Frediano Ziglio wrote:
> vdi_port_read_buf_release is registered passing data as
> RedVDIReadBuf*, not RedPipeItem*. Cast opaque to proper
> pointer type to avoid the assumption that first field of
> RedVDIReadBuf is a RedPipeItem.
My initial objection still stands here, RedVDIReadBuf has a 'base'
field as its first member, and it's very much meant to be a RedPipeItem
as a way to get refcounting for free. So I much prefer the current
version where we have a cast from child to base type, rather than
apparently unref'ing something contained in the read_buf object.
Christophe
>
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
> server/reds.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/server/reds.c b/server/reds.c
> index 79f9c9e..a71029f 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -745,7 +745,8 @@ static void reds_agent_remove(RedsState *reds)
>
> static void vdi_port_read_buf_release(uint8_t *data, void *opaque)
> {
> - red_pipe_item_unref((RedPipeItem *)opaque);
> + RedVDIReadBuf *read_buf = (RedVDIReadBuf *)opaque;
> + red_pipe_item_unref(&read_buf->base);
> }
>
> /*
> --
> 2.7.4
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20161025/c0d24a9b/attachment.sig>
More information about the Spice-devel
mailing list