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(a)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