[libvirt] [libvirt-glib 03/37] Add gobject boilerplate for GVirConfigClock and GVirConfigTimer

Christophe Fergeau cfergeau at redhat.com
Tue Nov 15 11:23:55 UTC 2011


On Fri, Nov 11, 2011 at 03:33:51PM +0100, Marc-André Lureau wrote:
> On Thu, Nov 10, 2011 at 9:33 PM, Christophe Fergeau <cfergeau at redhat.com> wrote:
> > +struct _GVirConfigClockPrivate
> > +{
> > +    gboolean unused;
> > +};
> 
> (does it really matter if the struct is empty?)

Yes, there's a runtime warning if sizeof(GVirConfigClockPrivate) == 0 when
associating the private structure with the class. Imo these "empty" private
structures should be removed at some point, they are here in all classes
because of copy/paste.

> 
> > +G_DEFINE_TYPE(GVirConfigClock, gvir_config_clock, GVIR_TYPE_CONFIG_OBJECT);
> > +
> > +
> > +static void gvir_config_clock_class_init(GVirConfigClockClass *klass)
> > +{
> > +
> > +    g_type_class_add_private(klass, sizeof(GVirConfigClockPrivate));
> > +}
> > +
> > +
> > +static void gvir_config_clock_init(GVirConfigClock *klock)
> > +{
> > +    GVirConfigClockPrivate *priv;
> > +
> > +    DEBUG("Init GVirConfigClock=%p", klock);
> > +
> > +    priv = klock->priv = GVIR_CONFIG_CLOCK_GET_PRIVATE(klock);
> > +
> > +    memset(priv, 0, sizeof(*priv));
> 
> in fact, memset is useless here, GObject are always initialized with
> 0's including private data (from what I understand of gobject code). I
> am going to send a patch to remove it on the whole code base.

Yep, this memset is present in the libvirt-gconfig file I used as a copy
and paste source, that's why it got everywhere.

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20111115/9fe58dc2/attachment-0001.sig>


More information about the libvir-list mailing list