From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46753) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpEXh-0001Sv-O2 for qemu-devel@nongnu.org; Thu, 22 Oct 2015 08:00:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZpEXd-0005oa-Ll for qemu-devel@nongnu.org; Thu, 22 Oct 2015 08:00:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39204) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpEXd-0005o4-Gd for qemu-devel@nongnu.org; Thu, 22 Oct 2015 08:00:21 -0400 From: Markus Armbruster References: <5628167C.9020802@redhat.com> Date: Thu, 22 Oct 2015 14:00:18 +0200 In-Reply-To: (Peter Maydell's message of "Thu, 22 Oct 2015 10:58:09 +0100") Message-ID: <87eggn6rl9.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] DO_UPCAST confusion List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: "qemu-devel@nongnu.org" Peter Maydell writes: > On 21 October 2015 at 23:49, Eric Blake 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. > > As Gerd says, most of these uses should probably go away, but > ideally by conversion to the QOM cast macros rather than > just dropping down to use of container_of. Yes, any DO_UPCAST() of QOM objects should be converted to the proper QOM casts. DO_UPCAST() of something that should be a QOM object... well, ideally the something should be converted to QOM, but that's hardly simple cleanup. 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().