From nobody Thu May 2 23:04:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599241944; cv=none; d=zohomail.com; s=zohoarc; b=X+v342zeTsLVbarIsTFYK3VLEG4+J5xtyZDg7GBXeU5fDW5Ir+9i66FJz1nZLt6kPeILo1tZzOH+FkEuo5w3uvIDS3YWEhgCIQoZCisz4pRvfO6V+6hwf2quRDHckASqrA4N0vq7RCFe7A88S7jWh0WAaPSifyZqedzNYmCGamg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599241944; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=FquuQCl3+2MDqTZOPKn2zfHIx42gh/jI9PA5OqnHSsg=; b=CAlSNHOPqT0Xu/RPYlOqflhOPbe47s8TCrH19ZJsjKsSHpCeeQ10TYDgLqXpVeFXjWXpX8/sKq8sBOClQwBoQoSQaRs25RVV91kGEuj9lVSiP09dEmlwwWad9SQ8RktXbHoATzSOtO4ihGiVqL/garvu1kFzbNVecDc+4TY8lhU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599241944063297.90121998242876; Fri, 4 Sep 2020 10:52:24 -0700 (PDT) Received: from localhost ([::1]:55908 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEFss-0001s1-Fj for importer@patchew.org; Fri, 04 Sep 2020 13:52:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54726) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kEFs2-0001QR-Jz for qemu-devel@nongnu.org; Fri, 04 Sep 2020 13:51:30 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:58624 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kEFrz-0008LJ-O2 for qemu-devel@nongnu.org; Fri, 04 Sep 2020 13:51:29 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-225-OnJUszeZOo2zjzIoLgT82w-1; Fri, 04 Sep 2020 13:51:22 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 14E6957054 for ; Fri, 4 Sep 2020 17:51:22 +0000 (UTC) Received: from localhost (ovpn-66-226.rdu2.redhat.com [10.10.66.226]) by smtp.corp.redhat.com (Postfix) with ESMTP id C89735D9CC; Fri, 4 Sep 2020 17:51:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599241885; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=FquuQCl3+2MDqTZOPKn2zfHIx42gh/jI9PA5OqnHSsg=; b=XB9YJGYJcxhhcyR1MOXjdbPd5LTKuaSJzNWYIBK+LqRP099OdXXMuhaYduXFXblNqBOBU7 NpW2fcKNbQ71EtBuxpjMipsAXCc83xL/avz6rO5oU+BbdC/kq2heaeLAfT3KQGgLS7tUv3 02SNY/CxKVXmxhjtztBq/z/GbAufdZQ= X-MC-Unique: OnJUszeZOo2zjzIoLgT82w-1 From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH] qom: Remove ParentClassType argument from OBJECT_DECLARE_SIMPLE_TYPE Date: Fri, 4 Sep 2020 13:51:09 -0400 Message-Id: <20200904175109.2436673-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=207.211.31.81; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/04 03:57:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H2=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S. Tsirkin" , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The requirement to specify the parent class type makes the macro harder to use and easy to misuse (by indicating the wrong parent class type). Simplify the macro by just not declaring any class struct, allowing us to remove the class_size field from the TypeInfo variables for those types. Signed-off-by: Eduardo Habkost --- This patch is based on the machine-next branch, and can be fetched from the git branch at: https://github.com/ehabkost/qemu-hacks work/qom-simplify-declare-simple-t= ype --- Cc: "Daniel P. Berrang=C3=A9" Cc: "Marc-Andr=C3=A9 Lureau" Cc: "Michael S. Tsirkin" Cc: Paolo Bonzini Cc: Eduardo Habkost Cc: Gerd Hoffmann Cc: qemu-devel@nongnu.org --- include/authz/list.h | 2 +- include/authz/listfile.h | 2 +- include/authz/pamacct.h | 2 +- include/authz/simple.h | 2 +- include/crypto/secret_keyring.h | 2 +- include/io/dns-resolver.h | 2 +- include/io/net-listener.h | 2 +- include/qom/object.h | 16 ++++++++-------- include/sysemu/vhost-user-backend.h | 2 +- authz/list.c | 1 - authz/listfile.c | 1 - authz/pamacct.c | 1 - authz/simple.c | 1 - backends/dbus-vmstate.c | 3 +-- backends/vhost-user.c | 1 - crypto/secret_keyring.c | 1 - io/dns-resolver.c | 1 - io/net-listener.c | 1 - ui/input-barrier.c | 3 +-- ui/input-linux.c | 3 +-- 20 files changed, 19 insertions(+), 30 deletions(-) diff --git a/include/authz/list.h b/include/authz/list.h index 5676bb375c..c5eda0f1bf 100644 --- a/include/authz/list.h +++ b/include/authz/list.h @@ -28,7 +28,7 @@ #define TYPE_QAUTHZ_LIST "authz-list" =20 OBJECT_DECLARE_SIMPLE_TYPE(QAuthZList, qauthz_list, - QAUTHZ_LIST, QAuthZClass) + QAUTHZ_LIST) =20 =20 =20 diff --git a/include/authz/listfile.h b/include/authz/listfile.h index b491227bbe..83d78cfa50 100644 --- a/include/authz/listfile.h +++ b/include/authz/listfile.h @@ -28,7 +28,7 @@ #define TYPE_QAUTHZ_LIST_FILE "authz-list-file" =20 OBJECT_DECLARE_SIMPLE_TYPE(QAuthZListFile, qauthz_list_file, - QAUTHZ_LIST_FILE, QAuthZClass) + QAUTHZ_LIST_FILE) =20 =20 =20 diff --git a/include/authz/pamacct.h b/include/authz/pamacct.h index 7804853ddf..18087cee20 100644 --- a/include/authz/pamacct.h +++ b/include/authz/pamacct.h @@ -28,7 +28,7 @@ #define TYPE_QAUTHZ_PAM "authz-pam" =20 OBJECT_DECLARE_SIMPLE_TYPE(QAuthZPAM, qauthz_pam, - QAUTHZ_PAM, QAuthZClass) + QAUTHZ_PAM) =20 =20 =20 diff --git a/include/authz/simple.h b/include/authz/simple.h index 346fcb0c6c..d3ed05b36f 100644 --- a/include/authz/simple.h +++ b/include/authz/simple.h @@ -27,7 +27,7 @@ #define TYPE_QAUTHZ_SIMPLE "authz-simple" =20 OBJECT_DECLARE_SIMPLE_TYPE(QAuthZSimple, qauthz_simple, - QAUTHZ_SIMPLE, QAuthZClass) + QAUTHZ_SIMPLE) =20 =20 =20 diff --git a/include/crypto/secret_keyring.h b/include/crypto/secret_keyrin= g.h index 73d2a8f501..803f3fc28b 100644 --- a/include/crypto/secret_keyring.h +++ b/include/crypto/secret_keyring.h @@ -27,7 +27,7 @@ =20 #define TYPE_QCRYPTO_SECRET_KEYRING "secret_keyring" OBJECT_DECLARE_SIMPLE_TYPE(QCryptoSecretKeyring, qcrypto_secret_keyring, - QCRYPTO_SECRET_KEYRING, QCryptoSecretCommonClas= s) + QCRYPTO_SECRET_KEYRING) =20 =20 struct QCryptoSecretKeyring { diff --git a/include/io/dns-resolver.h b/include/io/dns-resolver.h index e248fba5bd..9d14a8d98f 100644 --- a/include/io/dns-resolver.h +++ b/include/io/dns-resolver.h @@ -27,7 +27,7 @@ =20 #define TYPE_QIO_DNS_RESOLVER "qio-dns-resolver" OBJECT_DECLARE_SIMPLE_TYPE(QIODNSResolver, qio_dns_resolver, - QIO_DNS_RESOLVER, ObjectClass) + QIO_DNS_RESOLVER) =20 =20 /** diff --git a/include/io/net-listener.h b/include/io/net-listener.h index 60fad29ff4..8145962fbb 100644 --- a/include/io/net-listener.h +++ b/include/io/net-listener.h @@ -26,7 +26,7 @@ =20 #define TYPE_QIO_NET_LISTENER "qio-net-listener" OBJECT_DECLARE_SIMPLE_TYPE(QIONetListener, qio_net_listener, - QIO_NET_LISTENER, ObjectClass) + QIO_NET_LISTENER) =20 =20 typedef void (*QIONetListenerClientFunc)(QIONetListener *listener, diff --git a/include/qom/object.h b/include/qom/object.h index 056f67ab3b..4a23fed586 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -639,19 +639,19 @@ struct Object * @InstanceType: instance struct name * @module_obj_name: the object name in lowercase with underscore separato= rs * @MODULE_OBJ_NAME: the object name in uppercase with underscore separato= rs - * @ParentClassType: class struct name of parent type * - * This does the same as OBJECT_DECLARE_TYPE(), but also declares - * the class struct, thus only the object struct needs to be declare - * manually. + * This does the same as OBJECT_DECLARE_TYPE(), but with no class struct + * declared. * * This macro should be used unless the class struct needs to have * virtual methods declared. */ -#define OBJECT_DECLARE_SIMPLE_TYPE(InstanceType, module_obj_name, \ - MODULE_OBJ_NAME, ParentClassType) \ - OBJECT_DECLARE_TYPE(InstanceType, InstanceType##Class, module_obj_name= , MODULE_OBJ_NAME) \ - struct InstanceType##Class { ParentClassType parent_class; }; +#define OBJECT_DECLARE_SIMPLE_TYPE(InstanceType, module_obj_name, MODULE_O= BJ_NAME) \ + typedef struct InstanceType InstanceType; \ + \ + G_DEFINE_AUTOPTR_CLEANUP_FUNC(InstanceType, object_unref) \ + \ + DECLARE_INSTANCE_CHECKER(InstanceType, MODULE_OBJ_NAME, TYPE_##MODULE_= OBJ_NAME) =20 =20 /** diff --git a/include/sysemu/vhost-user-backend.h b/include/sysemu/vhost-use= r-backend.h index 23205edeb8..41d5ff43bd 100644 --- a/include/sysemu/vhost-user-backend.h +++ b/include/sysemu/vhost-user-backend.h @@ -23,7 +23,7 @@ =20 #define TYPE_VHOST_USER_BACKEND "vhost-user-backend" OBJECT_DECLARE_SIMPLE_TYPE(VhostUserBackend, vhost_user_backend, - VHOST_USER_BACKEND, ObjectClass) + VHOST_USER_BACKEND) =20 =20 =20 diff --git a/authz/list.c b/authz/list.c index 8e904bfc93..28b990931a 100644 --- a/authz/list.c +++ b/authz/list.c @@ -252,7 +252,6 @@ static const TypeInfo qauthz_list_info =3D { .name =3D TYPE_QAUTHZ_LIST, .instance_size =3D sizeof(QAuthZList), .instance_finalize =3D qauthz_list_finalize, - .class_size =3D sizeof(QAuthZListClass), .class_init =3D qauthz_list_class_init, .interfaces =3D (InterfaceInfo[]) { { TYPE_USER_CREATABLE }, diff --git a/authz/listfile.c b/authz/listfile.c index 666df872ad..cd6163aa40 100644 --- a/authz/listfile.c +++ b/authz/listfile.c @@ -263,7 +263,6 @@ static const TypeInfo qauthz_list_file_info =3D { .instance_init =3D qauthz_list_file_init, .instance_size =3D sizeof(QAuthZListFile), .instance_finalize =3D qauthz_list_file_finalize, - .class_size =3D sizeof(QAuthZListFileClass), .class_init =3D qauthz_list_file_class_init, .interfaces =3D (InterfaceInfo[]) { { TYPE_USER_CREATABLE }, diff --git a/authz/pamacct.c b/authz/pamacct.c index 3c6be43916..c91593bbd8 100644 --- a/authz/pamacct.c +++ b/authz/pamacct.c @@ -129,7 +129,6 @@ static const TypeInfo qauthz_pam_info =3D { .name =3D TYPE_QAUTHZ_PAM, .instance_size =3D sizeof(QAuthZPAM), .instance_finalize =3D qauthz_pam_finalize, - .class_size =3D sizeof(QAuthZPAMClass), .class_init =3D qauthz_pam_class_init, .interfaces =3D (InterfaceInfo[]) { { TYPE_USER_CREATABLE }, diff --git a/authz/simple.c b/authz/simple.c index 84954b80a5..ee061e980d 100644 --- a/authz/simple.c +++ b/authz/simple.c @@ -96,7 +96,6 @@ static const TypeInfo qauthz_simple_info =3D { .name =3D TYPE_QAUTHZ_SIMPLE, .instance_size =3D sizeof(QAuthZSimple), .instance_finalize =3D qauthz_simple_finalize, - .class_size =3D sizeof(QAuthZSimpleClass), .class_init =3D qauthz_simple_class_init, .interfaces =3D (InterfaceInfo[]) { { TYPE_USER_CREATABLE }, diff --git a/backends/dbus-vmstate.c b/backends/dbus-vmstate.c index a13461edea..5bffbc4906 100644 --- a/backends/dbus-vmstate.c +++ b/backends/dbus-vmstate.c @@ -24,7 +24,7 @@ =20 #define TYPE_DBUS_VMSTATE "dbus-vmstate" OBJECT_DECLARE_SIMPLE_TYPE(DBusVMState, dbus_vmstate, - DBUS_VMSTATE, ObjectClass) + DBUS_VMSTATE) =20 =20 struct DBusVMState { @@ -483,7 +483,6 @@ static const TypeInfo dbus_vmstate_info =3D { .parent =3D TYPE_OBJECT, .instance_size =3D sizeof(DBusVMState), .instance_finalize =3D dbus_vmstate_finalize, - .class_size =3D sizeof(DBusVMStateClass), .class_init =3D dbus_vmstate_class_init, .interfaces =3D (InterfaceInfo[]) { { TYPE_USER_CREATABLE }, diff --git a/backends/vhost-user.c b/backends/vhost-user.c index 9e6e198546..ae8362d721 100644 --- a/backends/vhost-user.c +++ b/backends/vhost-user.c @@ -197,7 +197,6 @@ static const TypeInfo vhost_user_backend_info =3D { .instance_size =3D sizeof(VhostUserBackend), .instance_init =3D vhost_user_backend_init, .instance_finalize =3D vhost_user_backend_finalize, - .class_size =3D sizeof(VhostUserBackendClass), }; =20 static void register_types(void) diff --git a/crypto/secret_keyring.c b/crypto/secret_keyring.c index 8bfc58ebf4..10d8bc48a0 100644 --- a/crypto/secret_keyring.c +++ b/crypto/secret_keyring.c @@ -129,7 +129,6 @@ static const TypeInfo qcrypto_secret_info =3D { .parent =3D TYPE_QCRYPTO_SECRET_COMMON, .name =3D TYPE_QCRYPTO_SECRET_KEYRING, .instance_size =3D sizeof(QCryptoSecretKeyring), - .class_size =3D sizeof(QCryptoSecretKeyringClass), .class_init =3D qcrypto_secret_keyring_class_init, .interfaces =3D (InterfaceInfo[]) { { TYPE_USER_CREATABLE }, diff --git a/io/dns-resolver.c b/io/dns-resolver.c index 6ebe2a5650..b55d8cc3fe 100644 --- a/io/dns-resolver.c +++ b/io/dns-resolver.c @@ -267,7 +267,6 @@ static const TypeInfo qio_dns_resolver_info =3D { .parent =3D TYPE_OBJECT, .name =3D TYPE_QIO_DNS_RESOLVER, .instance_size =3D sizeof(QIODNSResolver), - .class_size =3D sizeof(QIODNSResolverClass), }; =20 =20 diff --git a/io/net-listener.c b/io/net-listener.c index 5d8a226872..46c2643d00 100644 --- a/io/net-listener.c +++ b/io/net-listener.c @@ -307,7 +307,6 @@ static const TypeInfo qio_net_listener_info =3D { .name =3D TYPE_QIO_NET_LISTENER, .instance_size =3D sizeof(QIONetListener), .instance_finalize =3D qio_net_listener_finalize, - .class_size =3D sizeof(QIONetListenerClass), }; =20 =20 diff --git a/ui/input-barrier.c b/ui/input-barrier.c index 87543a3399..b76697be93 100644 --- a/ui/input-barrier.c +++ b/ui/input-barrier.c @@ -21,7 +21,7 @@ =20 #define TYPE_INPUT_BARRIER "input-barrier" OBJECT_DECLARE_SIMPLE_TYPE(InputBarrier, input_barrier, - INPUT_BARRIER, ObjectClass) + INPUT_BARRIER) =20 =20 #define MAX_HELLO_LENGTH 1024 @@ -723,7 +723,6 @@ static void input_barrier_class_init(ObjectClass *oc, v= oid *data) static const TypeInfo input_barrier_info =3D { .name =3D TYPE_INPUT_BARRIER, .parent =3D TYPE_OBJECT, - .class_size =3D sizeof(InputBarrierClass), .class_init =3D input_barrier_class_init, .instance_size =3D sizeof(InputBarrier), .instance_init =3D input_barrier_instance_init, diff --git a/ui/input-linux.c b/ui/input-linux.c index 5d501c8360..f02557b012 100644 --- a/ui/input-linux.c +++ b/ui/input-linux.c @@ -32,7 +32,7 @@ static bool linux_is_button(unsigned int lnx) =20 #define TYPE_INPUT_LINUX "input-linux" OBJECT_DECLARE_SIMPLE_TYPE(InputLinux, input_linux, - INPUT_LINUX, ObjectClass) + INPUT_LINUX) =20 =20 struct InputLinux { @@ -514,7 +514,6 @@ static void input_linux_class_init(ObjectClass *oc, voi= d *data) static const TypeInfo input_linux_info =3D { .name =3D TYPE_INPUT_LINUX, .parent =3D TYPE_OBJECT, - .class_size =3D sizeof(InputLinuxClass), .class_init =3D input_linux_class_init, .instance_size =3D sizeof(InputLinux), .instance_init =3D input_linux_instance_init, --=20 2.26.2