Re: [PATCH 09/14] char-device: Replace RedCharDeviceMsgToClient with RedPipeItem

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

 



Acked-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>

On Thu, 2016-04-07 at 17:11 -0500, Jonathon Jongsma wrote:
> From: Christophe Fergeau <cfergeau@xxxxxxxxxx>
> 
> Now that all derived classes use a type deriving from RedPipeItem for
> their RedCharDeviceMsgToClient, we can make this explicit in the
> RedCharDeviceClass vfuncs, and remove the RedCharDeviceMsgToClient
> typedef.
> ---
>  server/char-device.c | 18 +++++++++---------
>  server/char-device.h | 11 ++++-------
>  server/reds.c        | 10 +++++-----
>  server/smartcard.c   |  8 ++++----
>  server/spicevmc.c    | 10 +++++-----
>  5 files changed, 27 insertions(+), 30 deletions(-)
> 
> diff --git a/server/char-device.c b/server/char-device.c
> index e17e3be..2427de6 100644
> --- a/server/char-device.c
> +++ b/server/char-device.c
> @@ -99,10 +99,10 @@ static void red_char_device_write_retry(void *opaque);
>  
>  typedef struct RedCharDeviceMsgToClientItem {
>      RingItem link;
> -    RedCharDeviceMsgToClient *msg;
> +    RedPipeItem *msg;
>  } RedCharDeviceMsgToClientItem;
>  
> -static RedCharDeviceMsgToClient *
> +static RedPipeItem *
>  red_char_device_read_one_msg_from_device(RedCharDevice *dev)
>  {
>     RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
> @@ -110,9 +110,9 @@ red_char_device_read_one_msg_from_device(RedCharDevice
> *dev)
>     return klass->read_one_msg_from_device(dev->priv->sin, dev->priv->opaque);
>  }
>  
> -static RedCharDeviceMsgToClient *
> +static RedPipeItem *
>  red_char_device_ref_msg_to_client(RedCharDevice *dev,
> -                                  RedCharDeviceMsgToClient *msg)
> +                                    RedPipeItem *msg)
>  {
>     RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
>  
> @@ -121,7 +121,7 @@ red_char_device_ref_msg_to_client(RedCharDevice *dev,
>  
>  static void
>  red_char_device_unref_msg_to_client(RedCharDevice *dev,
> -                                    RedCharDeviceMsgToClient *msg)
> +                                      RedPipeItem *msg)
>  {
>     RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
>  
> @@ -130,7 +130,7 @@ red_char_device_unref_msg_to_client(RedCharDevice *dev,
>  
>  static void
>  red_char_device_send_msg_to_client(RedCharDevice *dev,
> -                                   RedCharDeviceMsgToClient *msg,
> +                                     RedPipeItem *msg,
>                                     RedClient *client)
>  {
>     RedCharDeviceClass *klass = RED_CHAR_DEVICE_GET_CLASS(dev);
> @@ -320,7 +320,7 @@ static uint64_t
> red_char_device_max_send_tokens(RedCharDevice *dev)
>  }
>  
>  static void red_char_device_add_msg_to_client_queue(RedCharDeviceClient
> *dev_client,
> -                                                    RedCharDeviceMsgToClient
> *msg)
> +                                                      RedPipeItem *msg)
>  {
>      RedCharDevice *dev = dev_client->dev;
>      RedCharDeviceMsgToClientItem *msg_item;
> @@ -342,7 +342,7 @@ static void
> red_char_device_add_msg_to_client_queue(RedCharDeviceClient *dev_cli
>  }
>  
>  static void red_char_device_send_msg_to_clients(RedCharDevice *dev,
> -                                                RedCharDeviceMsgToClient
> *msg)
> +                                                  RedPipeItem *msg)
>  {
>      RingItem *item, *next;
>  
> @@ -388,7 +388,7 @@ static int red_char_device_read_from_device(RedCharDevice
> *dev)
>       * All messages will be discarded if no client is attached to the device
>       */
>      while ((max_send_tokens || ring_is_empty(&dev->priv->clients)) && dev
> ->priv->running) {
> -        RedCharDeviceMsgToClient *msg;
> +        RedPipeItem *msg;
>  
>          msg = red_char_device_read_one_msg_from_device(dev);
>          if (!msg) {
> diff --git a/server/char-device.h b/server/char-device.h
> index 4c8928b..c6496cb 100644
> --- a/server/char-device.h
> +++ b/server/char-device.h
> @@ -24,8 +24,6 @@
>  #include "red-channel.h"
>  #include "migration-protocol.h"
>  
> -typedef void RedCharDeviceMsgToClient;
> -
>  #define RED_TYPE_CHAR_DEVICE red_char_device_get_type()
>  
>  #define RED_CHAR_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),
> RED_TYPE_CHAR_DEVICE, RedCharDevice))
> @@ -47,12 +45,11 @@ struct SpiceCharDeviceState
>      RedCharDevicePrivate *priv;
>  };
>  
> -typedef RedCharDeviceMsgToClient*
> (*RedCharDeviceReadOneMsgFromDevice)(SpiceCharDeviceInstance *sin,
> +typedef RedPipeItem*
> (*RedCharDeviceReadOneMsgFromDevice)(SpiceCharDeviceInstance *sin,
>                                                                           void
> *opaque);
> -typedef RedCharDeviceMsgToClient*
> (*RedCharDeviceRefMsgToClient)(RedCharDeviceMsgToClient *msg,
> -                                                                   void
> *opaque);
> -typedef void (*RedCharDeviceUnrefMsgToClient)(RedCharDeviceMsgToClient *msg,
> void *opaque);
> -typedef void (*RedCharDeviceSendMsgToClient)(RedCharDeviceMsgToClient *msg,
> RedClient *client, void *opaque);
> +typedef RedPipeItem* (*RedCharDeviceRefMsgToClient)(RedPipeItem *msg, void
> *opaque);
> +typedef void (*RedCharDeviceUnrefMsgToClient)(RedPipeItem *msg, void
> *opaque);
> +typedef void (*RedCharDeviceSendMsgToClient)(RedPipeItem *msg, RedClient
> *client, void *opaque);
>  typedef void (*RedCharDeviceSendTokensToClient)(RedClient *client, uint32_t
> tokens, void *opaque);
>  typedef void (*RedCharDeviceOnFreeSelfToken)(void *opaque);
>  typedef void (*RedCharDeviceRemoveClient)(RedClient *client, void *opaque);
> diff --git a/server/reds.c b/server/reds.c
> index bf39cf7..97aaeeb 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -774,8 +774,8 @@ static void vdi_port_read_buf_free(VDIReadBuf *buf)
>  
>  /* reads from the device till completes reading a message that is addressed
> to the client,
>   * or otherwise, when reading from the device fails */
> -static RedCharDeviceMsgToClient
> *vdi_port_read_one_msg_from_device(SpiceCharDeviceInstance *sin,
> -                                                                   void
> *opaque)
> +static RedPipeItem *vdi_port_read_one_msg_from_device(SpiceCharDeviceInstance
> *sin,
> +                                                      void *opaque)
>  {
>      RedsState *reds = opaque;
>      RedCharDeviceVDIPort *dev = reds->agent_dev;
> @@ -833,7 +833,7 @@ static RedCharDeviceMsgToClient
> *vdi_port_read_one_msg_from_device(SpiceCharDevi
>                  dev->priv->read_state = VDI_PORT_READ_STATE_GET_BUFF;
>              }
>              if (vdi_port_read_buf_process(reds->agent_dev, dispatch_buf,
> &error)) {
> -                return dispatch_buf;
> +                return (RedPipeItem *)dispatch_buf;
>              } else {
>                  if (error) {
>                      reds_agent_remove(reds);
> @@ -847,11 +847,11 @@ static RedCharDeviceMsgToClient
> *vdi_port_read_one_msg_from_device(SpiceCharDevi
>  }
>  
>  /* after calling this, we unref the message, and the ref is in the instance
> side */
> -static void vdi_port_send_msg_to_client(RedCharDeviceMsgToClient *msg,
> +static void vdi_port_send_msg_to_client(RedPipeItem *msg,
>                                          RedClient *client,
>                                          void *opaque)
>  {
> -    VDIReadBuf *agent_data_buf = msg;
> +    VDIReadBuf *agent_data_buf = (VDIReadBuf *)msg;
>  
>      red_pipe_item_ref(agent_data_buf);
>      main_channel_client_push_agent_data(red_client_get_main(client),
> diff --git a/server/smartcard.c b/server/smartcard.c
> index eab2f20..1ec67cb 100644
> --- a/server/smartcard.c
> +++ b/server/smartcard.c
> @@ -130,8 +130,8 @@ static void
> smartcard_read_buf_prepare(RedCharDeviceSmartcard *dev, VSCMsgHeader
>      }
>  }
>  
> -static RedCharDeviceMsgToClient
> *smartcard_read_msg_from_device(SpiceCharDeviceInstance *sin,
> -                                                                void *opaque)
> +static RedPipeItem *smartcard_read_msg_from_device(SpiceCharDeviceInstance
> *sin,
> +                                                   void *opaque)
>  {
>      RedCharDeviceSmartcard *dev = opaque;
>      SpiceCharDeviceInterface *sif = spice_char_device_get_interface(sin);
> @@ -161,13 +161,13 @@ static RedCharDeviceMsgToClient
> *smartcard_read_msg_from_device(SpiceCharDeviceI
>          dev->priv->buf_pos = dev->priv->buf;
>          dev->priv->buf_used = remaining;
>          if (msg_to_client) {
> -            return msg_to_client;
> +            return (RedPipeItem *)msg_to_client;
>          }
>      }
>      return NULL;
>  }
>  
> -static void smartcard_send_msg_to_client(RedCharDeviceMsgToClient *msg,
> +static void smartcard_send_msg_to_client(RedPipeItem *msg,
>                                           RedClient *client,
>                                           void *opaque)
>  {
> diff --git a/server/spicevmc.c b/server/spicevmc.c
> index 7294c2c..807cd8f 100644
> --- a/server/spicevmc.c
> +++ b/server/spicevmc.c
> @@ -105,8 +105,8 @@ enum {
>      PIPE_ITEM_TYPE_PORT_EVENT,
>  };
>  
> -static RedCharDeviceMsgToClient
> *spicevmc_chardev_read_msg_from_dev(SpiceCharDeviceInstance *sin,
> -                                                                    void
> *opaque)
> +static RedPipeItem
> *spicevmc_chardev_read_msg_from_dev(SpiceCharDeviceInstance *sin,
> +                                                       void *opaque)
>  {
>      SpiceVmcState *state = opaque;
>      SpiceCharDeviceInterface *sif;
> @@ -133,19 +133,19 @@ static RedCharDeviceMsgToClient
> *spicevmc_chardev_read_msg_from_dev(SpiceCharDev
>      if (n > 0) {
>          spice_debug("read from dev %d", n);
>          msg_item->buf_used = n;
> -        return msg_item;
> +        return (RedPipeItem *)msg_item;
>      } else {
>          state->pipe_item = msg_item;
>          return NULL;
>      }
>  }
>  
> -static void spicevmc_chardev_send_msg_to_client(RedCharDeviceMsgToClient
> *msg,
> +static void spicevmc_chardev_send_msg_to_client(RedPipeItem *msg,
>                                                  RedClient *client,
>                                                  void *opaque)
>  {
>      SpiceVmcState *state = opaque;
> -    SpiceVmcPipeItem *vmc_msg = msg;
> +    SpiceVmcPipeItem *vmc_msg = (SpiceVmcPipeItem *)msg;
>  
>      spice_assert(state->rcc->client == client);
>      red_pipe_item_ref(vmc_msg);
_______________________________________________
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]