[Spice-devel] [PATCH 10/10] Move RedCharDeviceCallbacks into RedCharDeviceClass

Jonathon Jongsma jjongsma at redhat.com
Thu Apr 7 16:58:05 UTC 2016


On Thu, 2016-04-07 at 11:54 +0200, Christophe Fergeau wrote:
> On Fri, Apr 01, 2016 at 03:51:44PM -0500, Jonathon Jongsma wrote:
> > diff --git a/server/smartcard.c b/server/smartcard.c
> > index 52d56ea..0238efe 100644
> > --- a/server/smartcard.c
> > +++ b/server/smartcard.c
> > @@ -272,14 +272,6 @@ static SpiceCharDeviceInstance
> > *smartcard_readers_get_unattached(void)
> >  static RedCharDeviceSmartcard *smartcard_device_new(RedsState *reds,
> > SpiceCharDeviceInstance *sin)
> >  {
> >      RedCharDevice *char_dev;
> > -    RedCharDeviceCallbacks char_dev_cbs = {
> > -        .read_one_msg_from_device = smartcard_read_msg_from_device,
> > -        .ref_msg_to_client = smartcard_ref_msg_to_client,
> > -        .unref_msg_to_client = smartcard_unref_msg_to_client,
> > -        .send_msg_to_client = smartcard_send_msg_to_client,
> > -        .send_tokens_to_client = smartcard_send_tokens_to_client,
> > -        .remove_client = smartcard_remove_client,
> > -    };
> >  
> >      char_dev = g_object_new(RED_TYPE_CHAR_DEVICE_SMARTCARD,
> >                              "sin", sin,
> > @@ -288,8 +280,8 @@ static RedCharDeviceSmartcard
> > *smartcard_device_new(RedsState *reds, SpiceCharDe
> >                              "self-tokens", ~0ULL,
> >                              NULL);
> >  
> > -    red_char_device_set_callbacks(RED_CHAR_DEVICE(char_dev),
> > -                                  &char_dev_cbs, char_dev);
> > +    g_object_set(char_dev, "opaque", char_dev, NULL);
> > +
> 
> I'm not sure why this is done in a separate call here rather than being
> added to the g_object_new call just before as for the other
> RedCharDevice children.

It's done this way because it's setting 'opaque' to the result of g_object_new.
Which is a little bit odd -- the functions should really be passed a 'self'
argument instead of having to set  self as the 'opaque' data argument. But
that's how it's done at the moment.

> 
> Looks good otherwise.
> 
> Christophe


More information about the Spice-devel mailing list