qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 07/18] qom: add link properties


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH 07/18] qom: add link properties
Date: Thu, 1 Dec 2011 11:35:40 +0000

On Thu, Dec 1, 2011 at 11:21 AM, Avi Kivity <address@hidden> wrote:
> On 11/30/2011 11:03 PM, Anthony Liguori wrote:
>> Links represent an ephemeral relationship between devices.  They are meant to
>> replace the qdev concept of busses by allowing more informal relationships
>> between devices.
>
> So, links are equivalent to pointers?
>
>> Links are fairly limited in their usefulness without implementing QOM-style
>> subclassing and interfaces.
>>
>>
>> +static void qdev_get_link_property(DeviceState *dev, Visitor *v, void 
>> *opaque,
>> +                                   const char *name, Error **errp)
>> +{
>> +    DeviceState **child = opaque;
>> +    gchar *path;
>> +
>> +    if (*child) {
>> +        path = qdev_get_canonical_path(*child);
>> +        visit_type_str(v, &path, name, errp);
>> +        g_free(path);
>> +    } else {
>> +        path = (gchar *)"";
>
> If gchar != char, this is wrong.  Also, you're converting a const
> pointer into a non-const pointer, discarding type safety.

This looked weird to me too but the cast has to do with the fact that
the visitor function works both for input and output visitors.  The
output visitor needs to write to gchar** while the input visitor does
not.

When this function is called with the correct visitor type we are
guaranteed that path will not be modified.

Stefan



reply via email to

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