]> git.proxmox.com Git - qemu.git/commitdiff
qom/object.c: Allow itf cast with num_itfs = 0
authorPeter Crosthwaite <peter.crosthwaite@xilinx.com>
Tue, 19 Feb 2013 04:02:10 +0000 (14:02 +1000)
committerAnthony Liguori <aliguori@us.ibm.com>
Thu, 21 Feb 2013 22:34:10 +0000 (16:34 -0600)
num_interfaces only tells you how many interfaces the concrete child class has
(as defined in the TypeInfo). This means if you have a child class which defines
no interfaces of its own, but its parent has interfaces you cannot cast to those
parent interfaces.

Fixed changing the guard to check the class->interfaces list instead (which is
a complete flattened list of implemented interfaces).

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Message-id: a8c2db3b9b1f3c4bb81aca352b69e33260f36545.1361246206.git.peter.crosthwaite@xilinx.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
qom/object.c

index 4b72a643379b875edc01dec6f9bedc78bdc4457c..3d638ff273e80464ab7d06b890d92dee7a91a3c8 100644 (file)
@@ -449,7 +449,8 @@ ObjectClass *object_class_dynamic_cast(ObjectClass *class,
     TypeImpl *type = class->type;
     ObjectClass *ret = NULL;
 
-    if (type->num_interfaces && type_is_ancestor(target_type, type_interface)) {
+    if (type->class->interfaces &&
+            type_is_ancestor(target_type, type_interface)) {
         int found = 0;
         GSList *i;