Re: [PATCH 09/11] reduce casts to RedPipeItem and RingItem

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

 



Acked-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>

On Fri, 2016-05-20 at 14:01 +0100, Frediano Ziglio wrote:
> Make code more type safe. This allow to move or delete structure
> fields more safely
> 
> Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
> ---
>  server/dcc.c       | 6 +++---
>  server/reds.c      | 2 +-
>  server/smartcard.c | 4 ++--
>  server/spicevmc.c  | 5 ++---
>  server/stream.c    | 2 +-
>  5 files changed, 9 insertions(+), 10 deletions(-)
> 
> diff --git a/server/dcc.c b/server/dcc.c
> index 33357cd..20a8f11 100644
> --- a/server/dcc.c
> +++ b/server/dcc.c
> @@ -78,7 +78,7 @@ int
> dcc_clear_surface_drawables_from_pipe(DisplayChannelClient *dcc, int surface
>      rcc = RED_CHANNEL_CLIENT(dcc);
>      ring = &rcc->pipe;
>      item = (RedPipeItem *) ring;
> -    while ((item = (RedPipeItem *)ring_next(ring, (RingItem *)item))) {
> +    while ((item = (RedPipeItem *)ring_next(ring, &item->link))) {
>          Drawable *drawable;
>          RedDrawablePipeItem *dpi = NULL;
>          int depend_found = FALSE;
> @@ -94,7 +94,7 @@ int
> dcc_clear_surface_drawables_from_pipe(DisplayChannelClient *dcc, int surface
>  
>          if (drawable->surface_id == surface_id) {
>              RedPipeItem *tmp_item = item;
> -            item = (RedPipeItem *)ring_prev(ring, (RingItem *)item);
> +            item = (RedPipeItem *)ring_prev(ring, &item->link);
>              red_channel_client_pipe_remove_and_release(rcc, tmp_item);
>              if (!item) {
>                  item = (RedPipeItem *)ring;
> @@ -514,7 +514,7 @@ void dcc_stream_agent_clip(DisplayChannelClient* dcc,
> StreamAgent *agent)
>      item->rects->num_rects = n_rects;
>      region_ret_rects(&agent->clip, item->rects->rects, n_rects);
>  
> -    red_channel_client_pipe_add(RED_CHANNEL_CLIENT(dcc), (RedPipeItem
> *)item);
> +    red_channel_client_pipe_add(RED_CHANNEL_CLIENT(dcc), &item->base);
>  }
>  
>  static void red_monitors_config_item_free(RedPipeItem *base)
> diff --git a/server/reds.c b/server/reds.c
> index fa9a79e..90911b4 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -888,7 +888,7 @@ static RedPipeItem
> *vdi_port_read_one_msg_from_device(SpiceCharDeviceInstance *s
>                  dev->priv->read_state = VDI_PORT_READ_STATE_GET_BUFF;
>              }
>              if (vdi_port_read_buf_process(reds->agent_dev, dispatch_buf,
> &error)) {
> -                return (RedPipeItem *)dispatch_buf;
> +                return &dispatch_buf->base;
>              } else {
>                  if (error) {
>                      reds_agent_remove(reds);
> diff --git a/server/smartcard.c b/server/smartcard.c
> index 2acddcf..9280038 100644
> --- a/server/smartcard.c
> +++ b/server/smartcard.c
> @@ -160,7 +160,7 @@ static RedPipeItem
> *smartcard_read_msg_from_device(SpiceCharDeviceInstance *sin,
>          dev->priv->buf_pos = dev->priv->buf;
>          dev->priv->buf_used = remaining;
>          if (msg_to_client) {
> -            return (RedPipeItem *)msg_to_client;
> +            return &msg_to_client->base;
>          }
>      }
>      return NULL;
> @@ -172,7 +172,7 @@ static void smartcard_send_msg_to_client(RedPipeItem *msg,
>  {
>      RedCharDeviceSmartcard *dev = opaque;
>      spice_assert(dev->priv->scc && dev->priv->scc->base.client == client);
> -    smartcard_channel_client_pipe_add_push(&dev->priv->scc->base,
> (RedPipeItem *)msg);
> +    smartcard_channel_client_pipe_add_push(&dev->priv->scc->base, msg);
>  
>  }
>  
> diff --git a/server/spicevmc.c b/server/spicevmc.c
> index f46b9e5..54c4f42 100644
> --- a/server/spicevmc.c
> +++ b/server/spicevmc.c
> @@ -133,7 +133,7 @@ static RedPipeItem
> *spicevmc_chardev_read_msg_from_dev(SpiceCharDeviceInstance *
>      if (n > 0) {
>          spice_debug("read from dev %d", n);
>          msg_item->buf_used = n;
> -        return (RedPipeItem *)msg_item;
> +        return &msg_item->base;
>      } else {
>          state->pipe_item = msg_item;
>          return NULL;
> @@ -145,11 +145,10 @@ static void
> spicevmc_chardev_send_msg_to_client(RedPipeItem *msg,
>                                                  void *opaque)
>  {
>      SpiceVmcState *state = opaque;
> -    RedVmcPipeItem *vmc_msg = SPICE_CONTAINEROF(msg, RedVmcPipeItem, base);
>  
>      spice_assert(state->rcc->client == client);
>      red_pipe_item_ref(msg);
> -    red_channel_client_pipe_add_push(state->rcc, (RedPipeItem *)vmc_msg);
> +    red_channel_client_pipe_add_push(state->rcc, msg);
>  }
>  
>  static SpiceVmcState *spicevmc_red_channel_client_get_state(RedChannelClient
> *rcc)
> diff --git a/server/stream.c b/server/stream.c
> index 74df254..be92289 100644
> --- a/server/stream.c
> +++ b/server/stream.c
> @@ -177,7 +177,7 @@ void red_stream_clip_item_free(RedPipeItem *base)
>  RedStreamClipItem *red_stream_clip_item_new(StreamAgent *agent)
>  {
>      RedStreamClipItem *item = spice_new(RedStreamClipItem, 1);
> -    red_pipe_item_init_full((RedPipeItem *)item,
> RED_PIPE_ITEM_TYPE_STREAM_CLIP,
> +    red_pipe_item_init_full(&item->base, RED_PIPE_ITEM_TYPE_STREAM_CLIP,
>                              red_stream_clip_item_free);
>  
>      item->stream_agent = agent;
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]