From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32877) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpGKu-0002pX-Kp for qemu-devel@nongnu.org; Thu, 22 Oct 2015 09:55:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZpGKr-00068Y-Ac for qemu-devel@nongnu.org; Thu, 22 Oct 2015 09:55:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49490) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpGKr-00068M-6M for qemu-devel@nongnu.org; Thu, 22 Oct 2015 09:55:17 -0400 References: <5628167C.9020802@redhat.com> <87eggn6rl9.fsf@blackfin.pond.sub.org> From: Eric Blake Message-ID: <5628EABF.8060009@redhat.com> Date: Thu, 22 Oct 2015 07:55:11 -0600 MIME-Version: 1.0 In-Reply-To: <87eggn6rl9.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="MJfqwkLF1C5HM1AAGTQWvFspPNc2ccnJ3" Subject: Re: [Qemu-devel] DO_UPCAST confusion List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster , Peter Maydell Cc: "qemu-devel@nongnu.org" This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --MJfqwkLF1C5HM1AAGTQWvFspPNc2ccnJ3 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 10/22/2015 06:00 AM, Markus Armbruster wrote: > Peter Maydell writes: >=20 >> On 21 October 2015 at 23:49, Eric Blake wrote: >>> I much prefer the name container_of() (which is a bit more obvious th= at >>> 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 matc= h >>> what it is actually doing? >=20 > DO_UPCAST() needs deletion, not renaming. >=20 >> 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 replace= d > 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 argument= s > 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. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --MJfqwkLF1C5HM1AAGTQWvFspPNc2ccnJ3 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWKOq/AAoJEKeha0olJ0NqlTYH/RKew2TOVwziKNRa3cz62r1d 1DpUcV8QBgumheqVTO5cKHCPcxXq2KMDjLI6RhqgaDXEcrJWfGJmKp9Gskdroj/K hqeGUng/1hWf1eIDKz/uRvTeIySOzZPsK8RXvsacrd4fRDFNMBiy+tPgR7ED82Pv adaENFfJvb0w4pnSNqbTH6ehAMIqiMTkypjnPy4kAg34fKRmDpUjlZLi4lpz8VSI J9RfX+nGmimGouXQE7CbUevNL2xXtUmQ4sM7K6n1Jkg5apHA26iUegC13ij7xie/ /YfqCMX5x1ksEvAcHAF/0lPaqFCx5CYLo4e5/+PqHRYlyaDy03RNZGUwItyv9/k= =VDe+ -----END PGP SIGNATURE----- --MJfqwkLF1C5HM1AAGTQWvFspPNc2ccnJ3--