From patchwork Fri May 10 12:16:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 242972 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 410F52C009D for ; Fri, 10 May 2013 22:19:11 +1000 (EST) Received: from localhost ([::1]:58381 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UamI1-0006yk-C9 for incoming@patchwork.ozlabs.org; Fri, 10 May 2013 08:19:09 -0400 Received: from eggs.gnu.org ([208.118.235.92]:40010) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UamG2-00046v-KH for qemu-devel@nongnu.org; Fri, 10 May 2013 08:17:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UamG1-0007mM-2y for qemu-devel@nongnu.org; Fri, 10 May 2013 08:17:06 -0400 Received: from mail-wg0-x22e.google.com ([2a00:1450:400c:c00::22e]:35867) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UamG0-0007lh-Sj for qemu-devel@nongnu.org; Fri, 10 May 2013 08:17:04 -0400 Received: by mail-wg0-f46.google.com with SMTP id n12so3897209wgh.1 for ; Fri, 10 May 2013 05:17:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=NnMaZhDqjJic2PCJU7UW5jbckRLo/QwP4ZQaWI3z9/8=; b=dLaNXF8sH3EL0yjRaB4+ipXA6DyAt2t3JM+s4ul0TFy6Ot1Fztvw27NedPiuywqlMZ q2m02+WYV3aSxwUlxy6r6kjf9eIR4oIZZo4pJ1keKUqxSzyXohJGpKGDMSrzNwYcaArP I+IriAboMBOAx4pzDrBAoJ7aEbAJ4opQDR4a98vxWhiUEp+D4X2EdnhagSRULC60iB5T yq1QfhsYKVCze5TTAqRBarjB8y6rDOE8qexcFi9NDnX+mxOBarB3wodgu0JzTGvkz3ti 7JxPkmWJ1FRRTt58B5EQH36RxeBZocpn1nv8clgaSAdEmnz9pqZwdND+zaFt3gjCi5pj FoAg== X-Received: by 10.194.93.68 with SMTP id cs4mr24471340wjb.17.1368188224097; Fri, 10 May 2013 05:17:04 -0700 (PDT) Received: from playground.lan (93-34-176-20.ip50.fastwebnet.it. [93.34.176.20]) by mx.google.com with ESMTPSA id er17sm3529771wic.0.2013.05.10.05.17.02 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 10 May 2013 05:17:03 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 10 May 2013 14:16:42 +0200 Message-Id: <1368188203-3407-9-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1368188203-3407-1-git-send-email-pbonzini@redhat.com> References: <1368188203-3407-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c00::22e Cc: Anthony Liguori , Andreas Faerber , Aurelien Jarno , mst@redhat.com Subject: [Qemu-devel] [PATCH for-1.5 8/9] qom: simplify object_class_dynamic_cast, part 1 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 Access everything from the class. Signed-off-by: Paolo Bonzini --- qom/object.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/qom/object.c b/qom/object.c index f5f416b..f82f12c 100644 --- a/qom/object.c +++ b/qom/object.c @@ -457,15 +457,13 @@ ObjectClass *object_class_dynamic_cast(ObjectClass *class, { ObjectClass *ret = NULL; TypeImpl *target_type; - TypeImpl *type; if (!class) { return NULL; } /* A simple fast path that can trigger a lot for leaf classes. */ - type = class->type; - if (type->name == typename) { + if (class->type->name == typename) { return class; } @@ -475,7 +473,7 @@ ObjectClass *object_class_dynamic_cast(ObjectClass *class, return NULL; } - if (type->class->interfaces && + if (class->interfaces && type_is_ancestor(target_type, type_interface)) { int found = 0; GSList *i; @@ -493,7 +491,7 @@ ObjectClass *object_class_dynamic_cast(ObjectClass *class, if (found > 1) { ret = NULL; } - } else if (type_is_ancestor(type, target_type)) { + } else if (type_is_ancestor(class->type, target_type)) { ret = class; }