qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] DO_UPCAST confusion


From: Markus Armbruster
Subject: Re: [Qemu-devel] DO_UPCAST confusion
Date: Thu, 22 Oct 2015 16:48:14 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Eric Blake <address@hidden> writes:

> On 10/22/2015 06:00 AM, Markus Armbruster wrote:
>> Peter Maydell <address@hidden> writes:
>> 
>>> On 21 October 2015 at 23:49, Eric Blake <address@hidden> wrote:
>>>> I much prefer the name container_of() (which is a bit more obvious that
>>>> it is finding the container or derived type that embeds the parent
>>>> type), but if we have to keep the ugly name, could we at least clean up
>>>> the comment to make sense, and fix the name to be DO_DOWNCAST to match
>>>> what it is actually doing?
>> 
>> DO_UPCAST() needs deletion, not renaming.
>> 
>>> You can't call this one container_of, because it's doing
>>> container_of plus extra checking.
>>>
>
> The only extra checking is that the derived class has the parent class
> as its first member.
>
>> Any DO_UPCAST() that have crept into other code could be simply replaced
>> by container_of().  If we want to keep the extra checking Peter
>> mentioned, we could have a container_of_checked() or something.  *Not* a
>> renamed DO_UPCAST(), because DO_UPCAST() pointlessly takes its arguments
>> in a different order than container_of().
>
> Or maybe container_of_first(), to make it obvious that the parent class
> is the first member.
>
> But how often does it really matter whether the container of the parent
> class had the parent as the first member?  I guess we'll find out as we
> try to nuke DO_UPCAST.

I don't know.  I dimly remember discussing a "parent must be first"
restriction in qdev a long time ago.  Perhaps all that's left of it by
now is this check.



reply via email to

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