[v1,2/2] qom/object.c: Allow itf cast with num_itfs = 0

Submitted by Peter Crosthwaite on Feb. 11, 2013, 7:29 a.m.

Details

Message ID 81dba157-22fc-44c9-b649-8ceba4233b51@CH1EHSMHS007.ehs.local
State New
Headers show

Commit Message

Peter Crosthwaite Feb. 11, 2013, 7:29 a.m.
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 by removing the guard altogether.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
---

 qom/object.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Patch hide | download patch | download mbox

diff --git a/qom/object.c b/qom/object.c
index 4b72a64..da442be 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -449,7 +449,7 @@  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_is_ancestor(target_type, type_interface)) {
         int found = 0;
         GSList *i;