Il 23/11/2012 17:16, Andreas Färber ha scritto: >> > @@ -430,7 +430,7 @@ Object *object_dynamic_cast_assert(Object *obj, const >> > char *typename) >> > >> > inst = object_dynamic_cast(obj, typename); >> > >> > - 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; > > Since this function clearly has assert in the name I don't think this is > 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 = SCSI_DEVICE(some->long.expressio[n]); if (!s) { return; } with something that is more complex: DeviceState *d = some->long.expressio[n]; SCSIDevice *s; if (!d) { return; } s = SCSI_DEVICE(d); Paolo