Eduardo Habkost <[email protected]> writes:

> On Mon, Dec 12, 2016 at 03:04:25PM +0100, Andreas Färber wrote:
>> Am 09.12.2016 um 19:06 schrieb Eduardo Habkost:
>> > "qom-list-types abstract=false" currently returns all interface
>> > types, as if they were not abstract. Fix this by making sure all
>> > interface types are abstract.
>> > 
>> > All interface types have instance_size == 0, so we can use
>> > it to set abstract=true on
>> > 
>> > Signed-off-by: Eduardo Habkost <[email protected]>
>> > ---
>> >  qom/object.c                   |  4 +++
>> >  tests/device-introspect-test.c | 61 
>> > +++++++++++++++++++++++++++++++++++++++---
>> >  2 files changed, 62 insertions(+), 3 deletions(-)
>> > 
>> > diff --git a/qom/object.c b/qom/object.c
>> > index 7a05e35..3870c1b 100644
>> > --- a/qom/object.c
>> > +++ b/qom/object.c
>> > @@ -272,6 +272,10 @@ static void type_initialize(TypeImpl *ti)
>> >  
>> >      ti->class_size = type_class_get_size(ti);
>> >      ti->instance_size = type_object_get_size(ti);
>> > +    /* Any type with zero instance_size is implicitly abstract.
>> > +     * This means interface types are all abstract.
>> > +     */
>> > +    ti->abstract |= ti->instance_size == 0;
>> 
>> IIRC this is a bool field, so I would prefer to avoid |= by using an
>> old-fashioned if statement.
>
> I was going to use an if statement, but then I tried to make it
> simpler using "|=". I will add it back in v2.

Operator | is perfectly fine for boolean operands, and so is your |=
line.  Doesn't mean a conditional would be worse.

[...]

Reply via email to