From patchwork Mon Feb 11 07:29:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Crosthwaite X-Patchwork-Id: 219543 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 952CD2C02AD for ; Mon, 11 Feb 2013 18:29:38 +1100 (EST) Received: from localhost ([::1]:44882 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U4npY-00031L-Mg for incoming@patchwork.ozlabs.org; Mon, 11 Feb 2013 02:29:36 -0500 Received: from eggs.gnu.org ([208.118.235.92]:52351) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U4npL-00031B-GO for qemu-devel@nongnu.org; Mon, 11 Feb 2013 02:29:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U4npJ-0000b8-To for qemu-devel@nongnu.org; Mon, 11 Feb 2013 02:29:23 -0500 Received: from ch1ehsobe001.messaging.microsoft.com ([216.32.181.181]:41321 helo=ch1outboundpool.messaging.microsoft.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U4npJ-0000au-Ok for qemu-devel@nongnu.org; Mon, 11 Feb 2013 02:29:21 -0500 Received: from mail16-ch1-R.bigfish.com (10.43.68.226) by CH1EHSOBE008.bigfish.com (10.43.70.58) with Microsoft SMTP Server id 14.1.225.23; Mon, 11 Feb 2013 07:29:20 +0000 Received: from mail16-ch1 (localhost [127.0.0.1]) by mail16-ch1-R.bigfish.com (Postfix) with ESMTP id 1F1DF2C0153; Mon, 11 Feb 2013 07:29:20 +0000 (UTC) X-Forefront-Antispam-Report: CIP:149.199.60.83; KIP:(null); UIP:(null); IPV:NLI; H:xsj-gw1; RD:unknown-60-83.xilinx.com; EFVD:NLI X-SpamScore: 1 X-BigFish: VPS1(zzzz1f42h1ee6h1de0h1202h1e76h1d1ah1d2ahzz8275bhz2fh95h668h839hd24hf0ah119dh1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h14ddh1504h1537h162dh1631h1758h1898h18e1h1946h19b5h906i1155h) Received-SPF: pass (mail16-ch1: domain of xilinx.com designates 149.199.60.83 as permitted sender) client-ip=149.199.60.83; envelope-from=peter.crosthwaite@xilinx.com; helo=xsj-gw1 ; helo=xsj-gw1 ; Received: from mail16-ch1 (localhost.localdomain [127.0.0.1]) by mail16-ch1 (MessageSwitch) id 13605677596584_4314; Mon, 11 Feb 2013 07:29:19 +0000 (UTC) Received: from CH1EHSMHS007.bigfish.com (snatpool1.int.messaging.microsoft.com [10.43.68.241]) by mail16-ch1.bigfish.com (Postfix) with ESMTP id F3065C0049; Mon, 11 Feb 2013 07:29:18 +0000 (UTC) Received: from xsj-gw1 (149.199.60.83) by CH1EHSMHS007.bigfish.com (10.43.70.7) with Microsoft SMTP Server id 14.1.225.23; Mon, 11 Feb 2013 07:29:18 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66] helo=xsj-smtp1.xilinx.com) by xsj-gw1 with esmtp (Exim 4.63) (envelope-from ) id 1U4npG-0002I0-Dk; Sun, 10 Feb 2013 23:29:18 -0800 From: Peter Crosthwaite To: Date: Mon, 11 Feb 2013 17:29:08 +1000 X-Mailer: git-send-email 1.7.0.4 In-Reply-To: References: X-RCIS-Action: ALLOW MIME-Version: 1.0 Message-ID: <81dba157-22fc-44c9-b649-8ceba4233b51@CH1EHSMHS007.ehs.local> X-OriginatorOrg: xilinx.com X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 X-Received-From: 216.32.181.181 Cc: pbonzini@redhat.com, aliguori@us.ibm.com, Peter Crosthwaite Subject: [Qemu-devel] [PATCH v1 2/2] qom/object.c: Allow itf cast with num_itfs = 0 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- qom/object.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) 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;