From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32796) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V6wli-0002Ec-GE for qemu-devel@nongnu.org; Wed, 07 Aug 2013 01:58:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V6wlb-0005eI-75 for qemu-devel@nongnu.org; Wed, 07 Aug 2013 01:58:46 -0400 Received: from cantor2.suse.de ([195.135.220.15]:41513 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V6wlb-0005e4-0p for qemu-devel@nongnu.org; Wed, 07 Aug 2013 01:58:39 -0400 Message-ID: <5201E205.8060702@suse.de> Date: Wed, 07 Aug 2013 07:58:29 +0200 From: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= MIME-Version: 1.0 References: <1375323463-32747-1-git-send-email-afaerber@suse.de> <1375323463-32747-2-git-send-email-afaerber@suse.de> <52008FAE.8060709@ozlabs.ru> <5200B4C1.9010008@suse.de> <5201C0CA.2070808@ozlabs.ru> In-Reply-To: <5201C0CA.2070808@ozlabs.ru> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH for-next v2 01/22] object: Add OBJECT_GET_PARENT_CLASS() macro List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexey Kardashevskiy Cc: Peter Crosthwaite , qemu-devel@nongnu.org, Anthony Liguori Am 07.08.2013 05:36, schrieb Alexey Kardashevskiy: > This what I would suggest: >=20 > #define OBJECT_GET_PARENT_CLASS(obj, name) \ > object_class_get_parent(OBJECT_GET_CLASS(ObjectClass, (obj), (name)= )) >=20 > @name here is just to make sure we are at the right level of the class > hierarchy. >=20 > And use it like this: >=20 > static void xics_kvm_cpu_setup(XICSState *icp, PowerPCCPU *cpu) > { > XICSStateClass *xsc =3D XICS_COMMON_CLASS( > OBJECT_GET_PARENT_CLASS(OBJECT(icp), TYPE_KVM_XICS)); > ... >=20 > Here both source and destination classes are checked, everyone must be = happy :) In addition to what Peter has explained, I recommend against using my macro inline, just like we don't use OBJECT_CHECK() inline. Doing so keeps the uses of TYPE_KVM_XICS together and lets us exchange the implementation more easily should the need arise. Btw COMMON_XICS_CLASS() would be a more specific name. (Yes, ARM GIC is a counter-example.) Andreas --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=C3=BCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=C3=B6rffer; HRB 16746 AG N=C3=BC= rnberg