qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH for-2.9] qom: Make all interface types abstract


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH for-2.9] qom: Make all interface types abstract
Date: Tue, 13 Dec 2016 13:18:56 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Eduardo Habkost <address@hidden> 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 <address@hidden>
>> > ---
>> >  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

[Prev in Thread] Current Thread [Next in Thread]