[Spice-devel] [PATCH] Introduce SPICE_UPCAST macro

Christophe Fergeau cfergeau at redhat.com
Tue May 24 12:20:48 UTC 2016


On Tue, May 24, 2016 at 10:52:59AM +0100, Frediano Ziglio wrote:
> This was proposed by Christophe as improvement over some typesafe
> patches.
> 
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  server/char-device.c         |  2 +-
>  server/cursor-channel.c      |  6 +++---
>  server/dcc-encoders.c        |  2 +-
>  server/dcc-send.c            | 14 +++++++-------
>  server/dcc.c                 |  2 +-
>  server/display-channel.c     |  4 ++--
>  server/display-channel.h     |  2 +-
>  server/image-cache.c         |  4 ++--
>  server/inputs-channel.c      |  6 +++---
>  server/main-channel-client.c | 22 +++++++++++-----------
>  server/pixmap-cache.c        |  2 +-
>  server/red-channel.c         |  4 ++--
>  server/red-common.h          |  4 ++++
>  server/red-record-qxl.c      |  2 +-
>  server/reds.c                |  2 +-
>  server/smartcard.c           |  6 +++---
>  server/spicevmc.c            |  6 +++---
>  server/stream.c              |  6 +++---
>  server/tree.h                |  6 +++---
>  19 files changed, 53 insertions(+), 49 deletions(-)
> 
> diff --git a/server/char-device.c b/server/char-device.c
> index 4a6e4c8..cb35aa2 100644
> --- a/server/char-device.c
> +++ b/server/char-device.c
> @@ -1002,7 +1002,7 @@ SpiceServer* red_char_device_get_server(RedCharDevice *dev)
>  
>  SpiceCharDeviceInterface *spice_char_device_get_interface(SpiceCharDeviceInstance *instance)
>  {
> -   return SPICE_CONTAINEROF(instance->base.sif, SpiceCharDeviceInterface, base);
> +   return SPICE_UPCAST(SpiceCharDeviceInterface, instance->base.sif);
>  }
>  
>  
> diff --git a/server/cursor-channel.c b/server/cursor-channel.c
> index 23a8cb8..2869b11 100644
> --- a/server/cursor-channel.c
> +++ b/server/cursor-channel.c
> @@ -208,7 +208,7 @@ static void cursor_pipe_item_free(RedPipeItem *base)
>  {
>      spice_return_if_fail(base);
>  
> -    RedCursorPipeItem *pipe_item = SPICE_CONTAINEROF(base, RedCursorPipeItem, base);
> +    RedCursorPipeItem *pipe_item = SPICE_UPCAST(RedCursorPipeItem, base);

Totally unrelated to this patch, and no need to send patches to change
this now, but in general, I think RedPipeItem *pipe_item; and
RedCursorPipeItem *cursor_item; are slightly more descriptive.

>  
>      spice_assert(!red_pipe_item_is_linked(&pipe_item->base));
>  
> @@ -318,13 +318,13 @@ static void cursor_channel_send_item(RedChannelClient *rcc, RedPipeItem *pipe_it
>  
>      switch (pipe_item->type) {
>      case RED_PIPE_ITEM_TYPE_CURSOR:
> -        cursor_marshall(rcc, m, SPICE_CONTAINEROF(pipe_item, RedCursorPipeItem, base));
> +        cursor_marshall(rcc, m, SPICE_UPCAST(RedCursorPipeItem, pipe_item));
>          break;
>      case RED_PIPE_ITEM_TYPE_INVAL_ONE:
>          red_marshall_inval(rcc, m, SPICE_CONTAINEROF(pipe_item, RedCacheItem, u.pipe_data));

I think this one could be changed too?


Acked-by: Christophe Fergeau <cfergeau at redhat.com>
assuming others are good with SPICE_UPCAST too.

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20160524/218c1658/attachment.sig>


More information about the Spice-devel mailing list