From nobody Sat Nov 23 20:19:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1730204844; cv=none; d=zohomail.com; s=zohoarc; b=gQ53kPfLle1jto2OWbGi6gpoCBeLrpQiUlQgtBdR3Qh+7wfn8hLlZ/oD7rDJzQHp+W71LkQ+vUdjbJWxnsj4z4UbmR68trexVeGWR/goq6w6aY6862Mpdp+N+Zwk6VBePz5rNoIe/2WUW97UP+KMjBNTzJiJy8dP30Rj14vcyvw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730204844; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=45MBX6aNgqsN2wiv/WXqRIpWZQdipkdsz1mMqox8E0Q=; b=OxLQli//8zt4hURHxtR/y6K0zgepmW41zGbVHLSlZ9nLJRuqlp3oiTq5ClKICwLbVtZ87b1ZTYMHe7jnhMZWhSg+Ynr9MIqdy9n4JcqxibxuKwczl3yKqRzvofGqjTNBCEr0NVGsTIeq3a28fmHCj2l4hRdOApCNyKHZh5ps19Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1730204844745128.13993071775644; Tue, 29 Oct 2024 05:27:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5lJB-0006Ap-7I; Tue, 29 Oct 2024 08:26:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5lIm-00067s-FJ for qemu-devel@nongnu.org; Tue, 29 Oct 2024 08:26:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5lIj-0000Ta-Ss for qemu-devel@nongnu.org; Tue, 29 Oct 2024 08:26:23 -0400 Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-622-QlWBdyfOOpCEbDQUWjGgzA-1; Tue, 29 Oct 2024 08:26:19 -0400 Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-539e03bfd4aso4297215e87.1 for ; Tue, 29 Oct 2024 05:26:18 -0700 (PDT) Received: from [192.168.10.3] ([151.49.226.83]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b57b051sm176900505e9.42.2024.10.29.05.26.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 05:26:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730204781; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=45MBX6aNgqsN2wiv/WXqRIpWZQdipkdsz1mMqox8E0Q=; b=RN9nhNFfaFIhY+TjzaM5XY6UgYCo8PAPNC6hjcVy2P+vB9AYlFa93XKbOqZ1jYuCdvNa/k taXUThM8lmEgMBi6u+6jJHhmuAuMUHQW6b6/KS1A/Cwm6yNUWDi/mGTN4VWtoQBYtyF9JB fgcwjgzdBtCgprAX5hM8h8mLabJhSwQ= X-MC-Unique: QlWBdyfOOpCEbDQUWjGgzA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730204776; x=1730809576; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=45MBX6aNgqsN2wiv/WXqRIpWZQdipkdsz1mMqox8E0Q=; b=Lm1WTuQyJh/HEHfLu06lK3ichMaWqYrjEb80bVJSB8lCK9ObDdqCSCtNz49IJgQ+42 ZDxUr3w7D0+sQdYeTc1+hKWZ1RRG/r7lF3B7i3t8gTT/boK3m4+DR9PWf6LavffXJFpz Vjpv/uTFMX7JljSS1AEDJggzSMp6KQCZfO04prnoSSyGR6uKFxNJpXmNLDnyGdykmgq2 s00Osb6wi0D27Js5afjo01WZuNxdfrfxIMBXFa+dU2YyCa30YJdV6JOZFDfTgn7abPWA cBzd4QIlUCChBLHn6xd3spiliJzzDmkROQv/Fd7Qj9odeiqrhE3Xqz0g0Pxig89l1CbL H/MQ== X-Gm-Message-State: AOJu0YwWM0T+i6ydIv8gwap0POvEK6OyMmGj+1Syqj6CNjlo9eKZ2zyM 9zMyI0RbEGcz9M0EF5p6j7R9HiiDbxkr5zDd3zQFpgQHMz+IdgVmuyyh5F72hzTJyYtk8jFo1Dj Wxpr88yzIg1pRqbgsL5e5bf54yYEiA4PGKwFQmmOJsdkFE5oi9tHxJHgjSFYHBeO3mPnxtPQ9I9 uFITwRGUCvuk+bSryQDpou2RVfse9qilx0ElPxxKs= X-Received: by 2002:a05:6512:ba2:b0:539:968a:9196 with SMTP id 2adb3069b0e04-53b34a2d6e3mr4928774e87.48.1730204776198; Tue, 29 Oct 2024 05:26:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE1vsDurwYa4Uy/mtUm3yRQiII7PrCndzfPuDQG7Dtn7vMEkeTE6OxRtmKJDnL87risDM8mbA== X-Received: by 2002:a05:6512:ba2:b0:539:968a:9196 with SMTP id 2adb3069b0e04-53b34a2d6e3mr4928756e87.48.1730204775709; Tue, 29 Oct 2024 05:26:15 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: armbru@redhat.com Subject: [PATCH 2/5] qom: use object_new_with_class when possible Date: Tue, 29 Oct 2024 13:26:06 +0100 Message-ID: <20241029122609.514347-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241029122609.514347-1-pbonzini@redhat.com> References: <20241029122609.514347-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.302, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1730204845966116600 Content-Type: text/plain; charset="utf-8" A small optimization/code simplification, that also makes it clear that we won't look for a type in a not-loaded-yet module---the module will have been loaded by a call to module_object_class_by_name(), if present. Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/core/qdev.c | 5 +++-- qom/object_interfaces.c | 2 +- qom/qom-qmp-cmds.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 17c454334c6..5f13111b77c 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -151,10 +151,11 @@ DeviceState *qdev_new(const char *name) =20 DeviceState *qdev_try_new(const char *name) { - if (!module_object_class_by_name(name)) { + ObjectClass *oc =3D module_object_class_by_name(name); + if (!oc) { return NULL; } - return DEVICE(object_new(name)); + return DEVICE(object_new_with_class(oc)); } =20 static QTAILQ_HEAD(, DeviceListener) device_listeners diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c index e0833c8bfe4..1f2aa133066 100644 --- a/qom/object_interfaces.c +++ b/qom/object_interfaces.c @@ -108,7 +108,7 @@ Object *user_creatable_add_type(const char *type, const= char *id, } =20 assert(qdict); - obj =3D object_new(type); + obj =3D object_new_with_class(klass); object_set_properties_from_qdict(obj, qdict, v, &local_err); if (local_err) { goto out; diff --git a/qom/qom-qmp-cmds.c b/qom/qom-qmp-cmds.c index e91a2353472..69a8e17aa80 100644 --- a/qom/qom-qmp-cmds.c +++ b/qom/qom-qmp-cmds.c @@ -141,7 +141,7 @@ ObjectPropertyInfoList *qmp_device_list_properties(cons= t char *typename, return NULL; } =20 - obj =3D object_new(typename); + obj =3D object_new_with_class(klass); =20 object_property_iter_init(&iter, obj); while ((prop =3D object_property_iter_next(&iter))) { --=20 2.47.0