From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:43310) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tbw4C-0001K2-Hs for qemu-devel@nongnu.org; Fri, 23 Nov 2012 11:25:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tbw4B-0001cB-5a for qemu-devel@nongnu.org; Fri, 23 Nov 2012 11:25:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51057) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tbw4A-0001c4-Ua for qemu-devel@nongnu.org; Fri, 23 Nov 2012 11:25:23 -0500 Message-ID: <50AFA36D.7030502@redhat.com> Date: Fri, 23 Nov 2012 17:25:17 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1353686178-27520-1-git-send-email-pbonzini@redhat.com> <1353686178-27520-2-git-send-email-pbonzini@redhat.com> <50AFA158.4020502@suse.de> In-Reply-To: <50AFA158.4020502@suse.de> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 1.3 1/2] qom: dynamic_cast of NULL is always NULL List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?ISO-8859-15?Q?Andreas_F=E4rber?= Cc: aliguori@us.ibm.com, lcapitulino@redhat.com, qemu-devel@nongnu.org, armbru@redhat.com Il 23/11/2012 17:16, Andreas F=E4rber ha scritto: >> > @@ -430,7 +430,7 @@ Object *object_dynamic_cast_assert(Object *obj, = const char *typename) >> > =20 >> > inst =3D object_dynamic_cast(obj, typename); >> > =20 >> > - if (!inst) { >> > + if (!inst && obj) { >> > fprintf(stderr, "Object %p is not an instance of type %s\n"= , >> > obj, typename); >> > abort(); > This is followed by return inst; >=20 > Since this function clearly has assert in the name I don't think this i= s > right. I would expect %p to print 0x0 and the function to abort. I think it's okay to segfault in this case. Otherwise you need to replace this simple cast+check pair: SCSIDevice *s =3D SCSI_DEVICE(some->long.expressio[n]); if (!s) { return; } with something that is more complex: DeviceState *d =3D some->long.expressio[n]; SCSIDevice *s; if (!d) { return; } s =3D SCSI_DEVICE(d); Paolo