On 06/13/2012 01:41 PM, Paolo Bonzini wrote: > > However, something that _is_ bad indeed happens; we try to ref/unref an > interface > object. This patch fixes it while keeping things efficient (and in fact > fixes one > TODO). Can add a link to an image on http://wiki.qemu.org/Testing and/or > test it? > > Anthony, is this above your disgust level? > > Paolo > > > ------------------------ 8< ----------------------- > > diff --git a/qom/object.c b/qom/object.c > index c3a7a47..bd60838 100644 > --- a/qom/object.c > +++ b/qom/object.c > @@ -63,7 +63,7 @@ struct TypeImpl > InterfaceImpl interfaces[MAX_INTERFACES]; > }; > > -#define INTERFACE(obj) INTERFACE_CHECK(obj, TYPE_INTERFACE) > +#define INTERFACE(obj) ((Interface *)(obj)) > > static Type type_interface; > > @@ -239,13 +239,21 @@ static void type_initialize(TypeImpl *ti) > } > } > > +#define INTERFACE_MAGIC ((GSList *) (intptr_t)0xBAD0BAD) > + > +static inline bool object_is_interface(Object *obj) { > + return obj->interfaces == INTERFACE_MAGIC; > +}
Why play games? static GSList interface_magic; static inline bool object_is_interface(Object *obj) { return obj->interfaces == &interface_magic; } though I think we can spare a bool (and developer's sanity) in Object. -- error compiling committee.c: too many arguments to function