Re: [PATCH v2 02/15] Rename SpiceCharDeviceWriteBuffer to RedCharDeviceWriteBuffer

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

 



> Internal types should use 'Red' namespace for consistency
> ---
>  server/char-device.c  | 72
>  +++++++++++++++++++++++++--------------------------
>  server/char-device.h  | 16 ++++++------
>  server/reds-private.h |  2 +-
>  server/reds.c         |  4 +--
>  server/smartcard.c    | 12 ++++-----
>  server/spicevmc.c     |  2 +-
>  6 files changed, 54 insertions(+), 54 deletions(-)
> 
> diff --git a/server/char-device.c b/server/char-device.c
> index 25fcbba..ea1fb17 100644
> --- a/server/char-device.c
> +++ b/server/char-device.c
> @@ -55,7 +55,7 @@ struct RedCharDevicePrivate {
>      Ring write_queue;
>      Ring write_bufs_pool;
>      uint64_t cur_pool_size;
> -    SpiceCharDeviceWriteBuffer *cur_write_buf;
> +    RedCharDeviceWriteBuffer *cur_write_buf;
>      uint8_t *cur_write_buf_pos;
>      SpiceTimer *write_to_dev_timer;
>      uint64_t num_self_tokens;
> @@ -89,7 +89,7 @@ enum {
>   * destroyed during a callback */
>  static void spice_char_device_state_ref(SpiceCharDeviceState *char_dev);
>  static void spice_char_device_state_unref(SpiceCharDeviceState *char_dev);
> -static void spice_char_device_write_buffer_unref(SpiceCharDeviceWriteBuffer
> *write_buf);
> +static void red_char_device_write_buffer_unref(RedCharDeviceWriteBuffer
> *write_buf);
>  
>  static void spice_char_dev_write_retry(void *opaque);
>  
> @@ -148,7 +148,7 @@ spice_char_device_remove_client(SpiceCharDeviceState
> *dev, RedClient *client)
>     dev->priv->cbs.remove_client(client, dev->priv->opaque);
>  }
>  
> -static void spice_char_device_write_buffer_free(SpiceCharDeviceWriteBuffer
> *buf)
> +static void red_char_device_write_buffer_free(RedCharDeviceWriteBuffer *buf)
>  {
>      if (buf == NULL)
>          return;
> @@ -161,16 +161,16 @@ static void write_buffers_queue_free(Ring *write_queue)
>  {
>      while (!ring_is_empty(write_queue)) {
>          RingItem *item = ring_get_tail(write_queue);
> -        SpiceCharDeviceWriteBuffer *buf;
> +        RedCharDeviceWriteBuffer *buf;
>  
>          ring_remove(item);
> -        buf = SPICE_CONTAINEROF(item, SpiceCharDeviceWriteBuffer, link);
> -        spice_char_device_write_buffer_free(buf);
> +        buf = SPICE_CONTAINEROF(item, RedCharDeviceWriteBuffer, link);
> +        red_char_device_write_buffer_free(buf);
>      }
>  }
>  
>  static void spice_char_device_write_buffer_pool_add(SpiceCharDeviceState
>  *dev,
> -
> SpiceCharDeviceWriteBuffer
> *buf)
> +                                                    RedCharDeviceWriteBuffer
> *buf)
>  {
>      if (buf->refs == 1 &&
>          dev->priv->cur_pool_size < MAX_POOL_SIZE) {
> @@ -183,7 +183,7 @@ static void
> spice_char_device_write_buffer_pool_add(SpiceCharDeviceState *dev,
>      }
>  
>      /* Buffer still being used - just unref for the caller */
> -    spice_char_device_write_buffer_unref(buf);
> +    red_char_device_write_buffer_unref(buf);
>  }
>  
>  static void spice_char_device_client_send_queue_free(SpiceCharDeviceState
>  *dev,
> @@ -218,9 +218,9 @@ static void
> spice_char_device_client_free(SpiceCharDeviceState *dev,
>      /* remove write buffers that are associated with the client */
>      spice_debug("write_queue_is_empty %d",
>      ring_is_empty(&dev->priv->write_queue) && !dev->priv->cur_write_buf);
>      RING_FOREACH_SAFE(item, next, &dev->priv->write_queue) {
> -        SpiceCharDeviceWriteBuffer *write_buf;
> +        RedCharDeviceWriteBuffer *write_buf;
>  
> -        write_buf = SPICE_CONTAINEROF(item, SpiceCharDeviceWriteBuffer,
> link);
> +        write_buf = SPICE_CONTAINEROF(item, RedCharDeviceWriteBuffer, link);
>          if (write_buf->origin == WRITE_BUFFER_ORIGIN_CLIENT &&
>              write_buf->client == dev_client->client) {
>              ring_remove(item);
> @@ -521,7 +521,7 @@ static int
> spice_char_device_write_to_device(SpiceCharDeviceState *dev)
>              if (!item) {
>                  break;
>              }
> -            dev->priv->cur_write_buf = SPICE_CONTAINEROF(item,
> SpiceCharDeviceWriteBuffer, link);
> +            dev->priv->cur_write_buf = SPICE_CONTAINEROF(item,
> RedCharDeviceWriteBuffer, link);
>              dev->priv->cur_write_buf_pos = dev->priv->cur_write_buf->buf;
>              ring_remove(item);
>          }
> @@ -540,7 +540,7 @@ static int
> spice_char_device_write_to_device(SpiceCharDeviceState *dev)
>          total += n;
>          write_len -= n;
>          if (!write_len) {
> -            SpiceCharDeviceWriteBuffer *release_buf =
> dev->priv->cur_write_buf;
> +            RedCharDeviceWriteBuffer *release_buf =
> dev->priv->cur_write_buf;
>              dev->priv->cur_write_buf = NULL;
>              spice_char_device_write_buffer_release(dev, release_buf);
>              continue;
> @@ -574,23 +574,23 @@ static void spice_char_dev_write_retry(void *opaque)
>      spice_char_device_write_to_device(dev);
>  }
>  
> -static SpiceCharDeviceWriteBuffer *__spice_char_device_write_buffer_get(
> +static RedCharDeviceWriteBuffer *__spice_char_device_write_buffer_get(
>      SpiceCharDeviceState *dev, RedClient *client,
>      int size, int origin, int migrated_data_tokens)
>  {
>      RingItem *item;
> -    SpiceCharDeviceWriteBuffer *ret;
> +    RedCharDeviceWriteBuffer *ret;
>  
>      if (origin == WRITE_BUFFER_ORIGIN_SERVER && !dev->priv->num_self_tokens)
>      {
>          return NULL;
>      }
>  
>      if ((item = ring_get_tail(&dev->priv->write_bufs_pool))) {
> -        ret = SPICE_CONTAINEROF(item, SpiceCharDeviceWriteBuffer, link);
> +        ret = SPICE_CONTAINEROF(item, RedCharDeviceWriteBuffer, link);
>          ring_remove(item);
>          dev->priv->cur_pool_size -= ret->buf_size;
>      } else {
> -        ret = spice_new0(SpiceCharDeviceWriteBuffer, 1);
> +        ret = spice_new0(RedCharDeviceWriteBuffer, 1);
>      }
>  
>      spice_assert(!ret->buf_used);
> @@ -634,23 +634,23 @@ error:
>      return NULL;
>  }
>  
> -SpiceCharDeviceWriteBuffer
> *spice_char_device_write_buffer_get(SpiceCharDeviceState *dev,
> -                                                               RedClient
> *client,
> -                                                               int size)
> +RedCharDeviceWriteBuffer
> *spice_char_device_write_buffer_get(SpiceCharDeviceState *dev,
> +                                                             RedClient
> *client,
> +                                                             int size)
>  {
>     return  __spice_char_device_write_buffer_get(dev, client, size,
>               client ? WRITE_BUFFER_ORIGIN_CLIENT :
>               WRITE_BUFFER_ORIGIN_SERVER,
>               0);
>  }
>  
> -SpiceCharDeviceWriteBuffer
> *spice_char_device_write_buffer_get_server_no_token(
> +RedCharDeviceWriteBuffer
> *spice_char_device_write_buffer_get_server_no_token(
>      SpiceCharDeviceState *dev, int size)
>  {
>     return  __spice_char_device_write_buffer_get(dev, NULL, size,
>               WRITE_BUFFER_ORIGIN_SERVER_NO_TOKEN, 0);
>  }
>  
> -static SpiceCharDeviceWriteBuffer
> *spice_char_device_write_buffer_ref(SpiceCharDeviceWriteBuffer *write_buf)
> +static RedCharDeviceWriteBuffer
> *red_char_device_write_buffer_ref(RedCharDeviceWriteBuffer *write_buf)
>  {
>      spice_assert(write_buf);
>  
> @@ -658,17 +658,17 @@ static SpiceCharDeviceWriteBuffer
> *spice_char_device_write_buffer_ref(SpiceCharD
>      return write_buf;
>  }
>  
> -static void spice_char_device_write_buffer_unref(SpiceCharDeviceWriteBuffer
> *write_buf)
> +static void red_char_device_write_buffer_unref(RedCharDeviceWriteBuffer
> *write_buf)
>  {
>      spice_assert(write_buf);
>  
>      write_buf->refs--;
>      if (write_buf->refs == 0)
> -        spice_char_device_write_buffer_free(write_buf);
> +        red_char_device_write_buffer_free(write_buf);
>  }
>  
>  void spice_char_device_write_buffer_add(SpiceCharDeviceState *dev,
> -                                        SpiceCharDeviceWriteBuffer
> *write_buf)
> +                                        RedCharDeviceWriteBuffer *write_buf)
>  {
>      spice_assert(dev);
>      /* caller shouldn't add buffers for client that was removed */
> @@ -684,7 +684,7 @@ void
> spice_char_device_write_buffer_add(SpiceCharDeviceState *dev,
>  }
>  
>  void spice_char_device_write_buffer_release(SpiceCharDeviceState *dev,
> -                                            SpiceCharDeviceWriteBuffer
> *write_buf)
> +                                            RedCharDeviceWriteBuffer
> *write_buf)
>  {
>      int buf_origin = write_buf->origin;
>      uint32_t buf_token_price = write_buf->token_price;
> @@ -693,7 +693,7 @@ void
> spice_char_device_write_buffer_release(SpiceCharDeviceState *dev,
>      spice_assert(!ring_item_is_linked(&write_buf->link));
>      if (!dev) {
>          spice_printerr("no device. write buffer is freed");
> -        spice_char_device_write_buffer_free(write_buf);
> +        red_char_device_write_buffer_free(write_buf);
>          return;
>      }
>  
> @@ -802,7 +802,7 @@ void spice_char_device_state_destroy(SpiceCharDeviceState
> *char_dev)
>      write_buffers_queue_free(&char_dev->priv->write_queue);
>      write_buffers_queue_free(&char_dev->priv->write_bufs_pool);
>      char_dev->priv->cur_pool_size = 0;
> -    spice_char_device_write_buffer_free(char_dev->priv->cur_write_buf);
> +    red_char_device_write_buffer_free(char_dev->priv->cur_write_buf);
>      char_dev->priv->cur_write_buf = NULL;
>  
>      while (!ring_is_empty(&char_dev->priv->clients)) {
> @@ -943,15 +943,15 @@ void spice_char_device_reset(SpiceCharDeviceState *dev)
>      spice_debug("dev_state %p", dev);
>      while (!ring_is_empty(&dev->priv->write_queue)) {
>          RingItem *item = ring_get_tail(&dev->priv->write_queue);
> -        SpiceCharDeviceWriteBuffer *buf;
> +        RedCharDeviceWriteBuffer *buf;
>  
>          ring_remove(item);
> -        buf = SPICE_CONTAINEROF(item, SpiceCharDeviceWriteBuffer, link);
> +        buf = SPICE_CONTAINEROF(item, RedCharDeviceWriteBuffer, link);
>          /* tracking the tokens */
>          spice_char_device_write_buffer_release(dev, buf);
>      }
>      if (dev->priv->cur_write_buf) {
> -        SpiceCharDeviceWriteBuffer *release_buf = dev->priv->cur_write_buf;
> +        RedCharDeviceWriteBuffer *release_buf = dev->priv->cur_write_buf;
>  
>          dev->priv->cur_write_buf = NULL;
>          spice_char_device_write_buffer_release(dev, release_buf);
> @@ -990,9 +990,9 @@ void
> spice_char_device_state_migrate_data_marshall_empty(SpiceMarshaller *m)
>  
>  static void migrate_data_marshaller_write_buffer_free(uint8_t *data, void
>  *opaque)
>  {
> -    SpiceCharDeviceWriteBuffer *write_buf = (SpiceCharDeviceWriteBuffer
> *)opaque;
> +    RedCharDeviceWriteBuffer *write_buf = (RedCharDeviceWriteBuffer
> *)opaque;
>  
> -    spice_char_device_write_buffer_unref(write_buf);
> +    red_char_device_write_buffer_unref(write_buf);
>  }
>  
>  void spice_char_device_state_migrate_data_marshall(SpiceCharDeviceState
>  *dev,
> @@ -1028,7 +1028,7 @@ void
> spice_char_device_state_migrate_data_marshall(SpiceCharDeviceState *dev,
>                                   dev->priv->cur_write_buf_pos;
>          spice_marshaller_add_ref_full(m2, dev->priv->cur_write_buf_pos,
>          buf_remaining,
>                                        migrate_data_marshaller_write_buffer_free,
> -
> spice_char_device_write_buffer_ref(dev->priv->cur_write_buf)
> +
> red_char_device_write_buffer_ref(dev->priv->cur_write_buf)
>                                        );
>          *write_to_dev_size_ptr += buf_remaining;
>          if (dev->priv->cur_write_buf->origin == WRITE_BUFFER_ORIGIN_CLIENT)
>          {
> @@ -1038,12 +1038,12 @@ void
> spice_char_device_state_migrate_data_marshall(SpiceCharDeviceState *dev,
>      }
>  
>      RING_FOREACH_REVERSED(item, &dev->priv->write_queue) {
> -        SpiceCharDeviceWriteBuffer *write_buf;
> +        RedCharDeviceWriteBuffer *write_buf;
>  
> -        write_buf = SPICE_CONTAINEROF(item, SpiceCharDeviceWriteBuffer,
> link);
> +        write_buf = SPICE_CONTAINEROF(item, RedCharDeviceWriteBuffer, link);
>          spice_marshaller_add_ref_full(m2, write_buf->buf,
>          write_buf->buf_used,
>                                        migrate_data_marshaller_write_buffer_free,
> -
> spice_char_device_write_buffer_ref(write_buf)
> +
> red_char_device_write_buffer_ref(write_buf)
>                                        );
>          *write_to_dev_size_ptr += write_buf->buf_used;
>          if (write_buf->origin == WRITE_BUFFER_ORIGIN_CLIENT) {
> diff --git a/server/char-device.h b/server/char-device.h
> index f352396..1076e07 100644
> --- a/server/char-device.h
> +++ b/server/char-device.h
> @@ -35,7 +35,7 @@
>   *
>   * Writing to the device
>   * ---------------------
> - * Write the data into SpiceCharDeviceWriteBuffer:
> + * Write the data into RedCharDeviceWriteBuffer:
>   * call spice_char_device_write_buffer_get in order to get an appropriate
>   buffer.
>   * call spice_char_device_write_buffer_add in order to push the buffer to
>   the write queue.
>   * If you choose not to push the buffer to the device, call
> @@ -82,7 +82,7 @@
>  struct RedsState;
>  
>  /* buffer that is used for writing to the device */
> -typedef struct SpiceCharDeviceWriteBuffer {
> +typedef struct RedCharDeviceWriteBuffer {
>      RingItem link;
>      int origin;
>      RedClient *client; /* The client that sent the message to the device.
> @@ -93,7 +93,7 @@ typedef struct SpiceCharDeviceWriteBuffer {
>      uint32_t buf_used;
>      uint32_t token_price;
>      uint32_t refs;
> -} SpiceCharDeviceWriteBuffer;
> +} RedCharDeviceWriteBuffer;
>  
>  typedef void RedCharDeviceMsgToClient;
>  
> @@ -200,16 +200,16 @@ void
> spice_char_device_send_to_client_tokens_set(SpiceCharDeviceState *dev,
>                                                   uint32_t tokens);
>  /** Write to device **/
>  
> -SpiceCharDeviceWriteBuffer
> *spice_char_device_write_buffer_get(SpiceCharDeviceState *dev,
> -                                                               RedClient
> *client, int size);
> -SpiceCharDeviceWriteBuffer
> *spice_char_device_write_buffer_get_server_no_token(
> +RedCharDeviceWriteBuffer
> *spice_char_device_write_buffer_get(SpiceCharDeviceState *dev,
> +                                                             RedClient
> *client, int size);
> +RedCharDeviceWriteBuffer
> *spice_char_device_write_buffer_get_server_no_token(
>      SpiceCharDeviceState *dev, int size);
>  
>  /* Either add the buffer to the write queue or release it */
>  void spice_char_device_write_buffer_add(SpiceCharDeviceState *dev,
> -                                        SpiceCharDeviceWriteBuffer
> *write_buf);
> +                                        RedCharDeviceWriteBuffer
> *write_buf);
>  void spice_char_device_write_buffer_release(SpiceCharDeviceState *dev,
> -                                            SpiceCharDeviceWriteBuffer
> *write_buf);
> +                                            RedCharDeviceWriteBuffer
> *write_buf);
>  
>  /* api for specific char devices */
>  
> diff --git a/server/reds-private.h b/server/reds-private.h
> index 3001990..560a21b 100644
> --- a/server/reds-private.h
> +++ b/server/reds-private.h
> @@ -63,7 +63,7 @@ struct VDIPortState {
>      int client_agent_started;
>  
>      /* write to agent */
> -    SpiceCharDeviceWriteBuffer *recv_from_client_buf;
> +    RedCharDeviceWriteBuffer *recv_from_client_buf;
>      int recv_from_client_buf_pushed;
>      AgentMsgFilter write_filter;
>  
> diff --git a/server/reds.c b/server/reds.c
> index eb13cd3..1776186 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -502,7 +502,7 @@ void reds_client_disconnect(RedsState *reds, RedClient
> *client)
>      if (reds->num_clients == 0) {
>          /* Let the agent know the client is disconnected */
>          if (reds->agent_state.base) {
> -            SpiceCharDeviceWriteBuffer *char_dev_buf;
> +            RedCharDeviceWriteBuffer *char_dev_buf;
>              VDInternalBuf *internal_buf;
>              uint32_t total_msg_size;
>  
> @@ -835,7 +835,7 @@ int reds_has_vdagent(RedsState *reds)
>  
>  void reds_handle_agent_mouse_event(RedsState *reds, const VDAgentMouseState
>  *mouse_state)
>  {
> -    SpiceCharDeviceWriteBuffer *char_dev_buf;
> +    RedCharDeviceWriteBuffer *char_dev_buf;
>      VDInternalBuf *internal_buf;
>      uint32_t total_msg_size;
>  
> diff --git a/server/smartcard.c b/server/smartcard.c
> index 20d7261..af282a1 100644
> --- a/server/smartcard.c
> +++ b/server/smartcard.c
> @@ -57,8 +57,8 @@ typedef struct SmartCardChannelClient {
>  
>      /* read_from_client/write_to_device buffer.
>       * The beginning of the buffer should always be VSCMsgHeader*/
> -    SpiceCharDeviceWriteBuffer *write_buf;
> -    int msg_in_write_buf; /* was the client msg received into a
> SpiceCharDeviceWriteBuffer
> +    RedCharDeviceWriteBuffer *write_buf;
> +    int msg_in_write_buf; /* was the client msg received into a
> RedCharDeviceWriteBuffer
>                             * or was it explicitly malloced */
>  } SmartCardChannelClient;
>  
> @@ -117,7 +117,7 @@ static SpiceCharDeviceInstance*
> smartcard_readers_get(uint32_t reader_id);
>  static int smartcard_char_device_add_to_readers(RedsState *reds,
>  SpiceCharDeviceInstance *sin);
>  static void smartcard_char_device_attach_client(
>      SpiceCharDeviceInstance *char_device, SmartCardChannelClient *scc);
> -static void smartcard_channel_write_to_reader(SpiceCharDeviceWriteBuffer
> *write_buf);
> +static void smartcard_channel_write_to_reader(RedCharDeviceWriteBuffer
> *write_buf);
>  
>  static MsgItem *smartcard_char_device_on_message_from_device(
>      SmartCardDeviceState *state, VSCMsgHeader *header);
> @@ -333,7 +333,7 @@ SpiceCharDeviceState *smartcard_device_connect(RedsState
> *reds, SpiceCharDeviceI
>  
>  static void smartcard_char_device_notify_reader_add(SmartCardDeviceState
>  *st)
>  {
> -    SpiceCharDeviceWriteBuffer *write_buf;
> +    RedCharDeviceWriteBuffer *write_buf;
>      VSCMsgHeader *vheader;
>  
>      write_buf = spice_char_device_write_buffer_get(st->priv->chardev_st,
>      NULL, sizeof(vheader));
> @@ -376,7 +376,7 @@ static void
> smartcard_char_device_attach_client(SpiceCharDeviceInstance *char_de
>  
>  static void smartcard_char_device_notify_reader_remove(SmartCardDeviceState
>  *st)
>  {
> -    SpiceCharDeviceWriteBuffer *write_buf;
> +    RedCharDeviceWriteBuffer *write_buf;
>      VSCMsgHeader *vheader;
>  
>      if (!st->priv->reader_added) {
> @@ -657,7 +657,7 @@ static void smartcard_add_reader(SmartCardChannelClient
> *scc, uint8_t *name)
>      // our SmartCardDeviceState.
>  }
>  
> -static void smartcard_channel_write_to_reader(SpiceCharDeviceWriteBuffer
> *write_buf)
> +static void smartcard_channel_write_to_reader(RedCharDeviceWriteBuffer
> *write_buf)
>  {
>      SpiceCharDeviceInstance *sin;
>      SmartCardDeviceState *st;
> diff --git a/server/spicevmc.c b/server/spicevmc.c
> index c67b408..f263a3d 100644
> --- a/server/spicevmc.c
> +++ b/server/spicevmc.c
> @@ -57,7 +57,7 @@ typedef struct SpiceVmcState {
>      SpiceCharDeviceState *chardev_st;
>      SpiceCharDeviceInstance *chardev_sin;
>      SpiceVmcPipeItem *pipe_item;
> -    SpiceCharDeviceWriteBuffer *recv_from_client_buf;
> +    RedCharDeviceWriteBuffer *recv_from_client_buf;
>      uint8_t port_opened;
>  } SpiceVmcState;
>  

Acked-by: Frediano Ziglio <fziglio@xxxxxxxxxx>

Frediano
_______________________________________________
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]