[Spice-devel] [PATCH spice-server 2/2] fixup! Manage lifetime of RedVmcChannel

Jonathon Jongsma jjongsma at redhat.com
Tue Nov 1 17:04:52 UTC 2016


Acked-by: Jonathon Jongsma <jjongsma at redhat.com>

I was just thinking I should do this. Now I don't have to ;)


On Tue, 2016-11-01 at 16:44 +0000, Frediano Ziglio wrote:
> Avoid to use RedCharDeviceSpiceVmcPrivate as already private inside
> C file.
> Use proper type for RedCharDeviceSpiceVmc::channel.
> 
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
>  server/spicevmc.c | 22 ++++++----------------
>  1 file changed, 6 insertions(+), 16 deletions(-)
> 
> diff --git a/server/spicevmc.c b/server/spicevmc.c
> index 8b5acf5..a77e868 100644
> --- a/server/spicevmc.c
> +++ b/server/spicevmc.c
> @@ -47,6 +47,9 @@
>  #define BUF_SIZE (64 * 1024 + 32)
>  #define COMPRESS_THRESHOLD 1000
>  
> +typedef struct RedVmcChannel RedVmcChannel;
> +typedef struct RedVmcChannelClass RedVmcChannelClass;
> +
>  typedef struct RedVmcPipeItem {
>      RedPipeItem base;
>  
> @@ -71,12 +74,11 @@ typedef struct RedVmcPipeItem {
>      (G_TYPE_INSTANCE_GET_CLASS((obj), RED_TYPE_CHAR_DEVICE_SPICEVMC,
> RedCharDeviceSpiceVmcClass))
>  
>  typedef struct RedCharDeviceSpiceVmc RedCharDeviceSpiceVmc;
> -typedef struct RedCharDeviceSpiceVmcPrivate
> RedCharDeviceSpiceVmcPrivate;
>  typedef struct RedCharDeviceSpiceVmcClass
> RedCharDeviceSpiceVmcClass;
>  
>  struct RedCharDeviceSpiceVmc {
>      RedCharDevice parent;
> -    RedCharDeviceSpiceVmcPrivate *priv;
> +    RedVmcChannel *channel;
>  };
>  
>  struct RedCharDeviceSpiceVmcClass
> @@ -84,10 +86,6 @@ struct RedCharDeviceSpiceVmcClass
>      RedCharDeviceClass parent_class;
>  };
>  
> -struct RedCharDeviceSpiceVmcPrivate {
> -    RedChannel *channel;
> -};
> -
>  static GType red_char_device_spicevmc_get_type(void) G_GNUC_CONST;
>  static RedCharDevice
> *red_char_device_spicevmc_new(SpiceCharDeviceInstance *sin,
>                                                     RedsState *reds,
> @@ -95,9 +93,6 @@ static RedCharDevice
> *red_char_device_spicevmc_new(SpiceCharDeviceInstance *sin,
>  
>  G_DEFINE_TYPE(RedCharDeviceSpiceVmc, red_char_device_spicevmc,
> RED_TYPE_CHAR_DEVICE)
>  
> -#define RED_CHAR_DEVICE_SPICEVMC_PRIVATE(o) \
> -    (G_TYPE_INSTANCE_GET_PRIVATE ((o),
> RED_TYPE_CHAR_DEVICE_SPICEVMC, RedCharDeviceSpiceVmcPrivate))
> -
>  #define RED_TYPE_VMC_CHANNEL red_vmc_channel_get_type()
>  
>  #define RED_VMC_CHANNEL(obj) \
> @@ -109,9 +104,6 @@ G_DEFINE_TYPE(RedCharDeviceSpiceVmc,
> red_char_device_spicevmc, RED_TYPE_CHAR_DEV
>  #define RED_VMC_CHANNEL_GET_CLASS(obj) \
>      (G_TYPE_INSTANCE_GET_CLASS((obj), RED_TYPE_VMC_CHANNEL,
> RedVmcChannelClass))
>  
> -typedef struct RedVmcChannel RedVmcChannel;
> -typedef struct RedVmcChannelClass RedVmcChannelClass;
> -
>  struct RedVmcChannel
>  {
>      RedChannel parent;
> @@ -865,7 +857,7 @@ RedCharDevice *spicevmc_device_connect(RedsState
> *reds,
>      RedVmcChannel *state = red_vmc_channel_new(reds, channel_type,
> sin);
>  
>      dev_state = RED_CHAR_DEVICE_SPICEVMC(state->chardev);
> -    dev_state->priv->channel = RED_CHANNEL(state);
> +    dev_state->channel = state;
>  
>      return RED_CHAR_DEVICE(dev_state);
>  }
> @@ -918,7 +910,7 @@ red_char_device_spicevmc_dispose(GObject *object)
>  {
>      RedCharDeviceSpiceVmc *self = RED_CHAR_DEVICE_SPICEVMC(object);
>  
> -    g_clear_object(&self->priv->channel);
> +    g_clear_object(&self->channel);
>  }
>  
>  static void
> @@ -927,8 +919,6 @@
> red_char_device_spicevmc_class_init(RedCharDeviceSpiceVmcClass
> *klass)
>      GObjectClass *object_class = G_OBJECT_CLASS(klass);
>      RedCharDeviceClass *char_dev_class =
> RED_CHAR_DEVICE_CLASS(klass);
>  
> -    g_type_class_add_private(klass, sizeof
> (RedCharDeviceSpiceVmcPrivate));
> -
>      object_class->dispose = red_char_device_spicevmc_dispose;
>  
>      char_dev_class->read_one_msg_from_device =
> spicevmc_chardev_read_msg_from_dev;


More information about the Spice-devel mailing list