All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	"Daniel P. Berrange" <berrange@redhat.com>
Subject: [PATCH 40/41] crypto: use QOM macros for declaration/definition of secret types
Date: Thu, 13 Aug 2020 18:26:24 -0400	[thread overview]
Message-ID: <20200813222625.243136-41-ehabkost@redhat.com> (raw)
In-Reply-To: <20200813222625.243136-1-ehabkost@redhat.com>

From: Daniel P. Berrangé <berrange@redhat.com>

This introduces the use of the OBJECT_DEFINE and OBJECT_DECLARE macro
families in the secret types, in order to eliminate boilerplate code.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20200723181410.3145233-4-berrange@redhat.com>
[ehabkost: rebase, update to pass additional arguments to macro]
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 include/crypto/secret.h | 11 ++---------
 crypto/secret.c         | 25 +++++++------------------
 crypto/secret_common.c  | 27 +++++++++------------------
 crypto/secret_keyring.c | 29 ++++++++++++-----------------
 4 files changed, 30 insertions(+), 62 deletions(-)

diff --git a/include/crypto/secret.h b/include/crypto/secret.h
index 5d20ae6d2f..4eb4e5ffef 100644
--- a/include/crypto/secret.h
+++ b/include/crypto/secret.h
@@ -26,11 +26,9 @@
 #include "crypto/secret_common.h"
 
 #define TYPE_QCRYPTO_SECRET "secret"
-typedef struct QCryptoSecret QCryptoSecret;
-DECLARE_INSTANCE_CHECKER(QCryptoSecret, QCRYPTO_SECRET,
-                         TYPE_QCRYPTO_SECRET)
 
-typedef struct QCryptoSecretClass QCryptoSecretClass;
+OBJECT_DECLARE_SIMPLE_TYPE(QCryptoSecret, qcrypto_secret,
+                           QCRYPTO_SECRET, QCryptoSecretCommon)
 
 /**
  * QCryptoSecret:
@@ -125,9 +123,4 @@ struct QCryptoSecret {
     char *file;
 };
 
-
-struct QCryptoSecretClass {
-    QCryptoSecretCommonClass parent_class;
-};
-
 #endif /* QCRYPTO_SECRET_H */
diff --git a/crypto/secret.c b/crypto/secret.c
index c07011d388..55b406f79e 100644
--- a/crypto/secret.c
+++ b/crypto/secret.c
@@ -25,6 +25,9 @@
 #include "qemu/module.h"
 #include "trace.h"
 
+OBJECT_DEFINE_TYPE_WITH_INTERFACES(QCryptoSecret, qcrypto_secret,
+                                   QCRYPTO_SECRET, QCRYPTO_SECRET_COMMON,
+                                   { TYPE_USER_CREATABLE }, { NULL })
 
 static void
 qcrypto_secret_load_data(QCryptoSecretCommon *sec_common,
@@ -140,21 +143,7 @@ qcrypto_secret_class_init(ObjectClass *oc, void *data)
                                   qcrypto_secret_prop_set_file);
 }
 
-
-static const TypeInfo qcrypto_secret_info = {
-    .parent = TYPE_QCRYPTO_SECRET_COMMON,
-    .name = TYPE_QCRYPTO_SECRET,
-    .instance_size = sizeof(QCryptoSecret),
-    .instance_finalize = qcrypto_secret_finalize,
-    .class_size = sizeof(QCryptoSecretClass),
-    .class_init = qcrypto_secret_class_init,
-    .interfaces = (InterfaceInfo[]) {
-        { TYPE_USER_CREATABLE },
-        { }
-    }
-};
-TYPE_INFO(qcrypto_secret_info)
-
-
-
-
+static void
+qcrypto_secret_init(Object *obj)
+{
+}
diff --git a/crypto/secret_common.c b/crypto/secret_common.c
index 80d7d75b4d..9a054b90b5 100644
--- a/crypto/secret_common.c
+++ b/crypto/secret_common.c
@@ -28,6 +28,9 @@
 #include "trace.h"
 
 
+OBJECT_DEFINE_ABSTRACT_TYPE(QCryptoSecretCommon, qcrypto_secret_common,
+                            QCRYPTO_SECRET_COMMON, OBJECT)
+
 static void qcrypto_secret_decrypt(QCryptoSecretCommon *secret,
                                    const uint8_t *input,
                                    size_t inputlen,
@@ -269,7 +272,7 @@ qcrypto_secret_prop_get_keyid(Object *obj,
 
 
 static void
-qcrypto_secret_finalize(Object *obj)
+qcrypto_secret_common_finalize(Object *obj)
 {
     QCryptoSecretCommon *secret = QCRYPTO_SECRET_COMMON(obj);
 
@@ -279,7 +282,7 @@ qcrypto_secret_finalize(Object *obj)
 }
 
 static void
-qcrypto_secret_class_init(ObjectClass *oc, void *data)
+qcrypto_secret_common_class_init(ObjectClass *oc, void *data)
 {
     object_class_property_add_bool(oc, "loaded",
                                    qcrypto_secret_prop_get_loaded,
@@ -297,6 +300,10 @@ qcrypto_secret_class_init(ObjectClass *oc, void *data)
                                   qcrypto_secret_prop_set_iv);
 }
 
+static void
+qcrypto_secret_common_init(Object *obj)
+{
+}
 
 int qcrypto_secret_lookup(const char *secretid,
                           uint8_t **data,
@@ -380,19 +387,3 @@ char *qcrypto_secret_lookup_as_base64(const char *secretid,
     g_free(data);
     return ret;
 }
-
-
-static const TypeInfo qcrypto_secret_info = {
-    .parent = TYPE_OBJECT,
-    .name = TYPE_QCRYPTO_SECRET_COMMON,
-    .instance_size = sizeof(QCryptoSecretCommon),
-    .instance_finalize = qcrypto_secret_finalize,
-    .class_size = sizeof(QCryptoSecretCommonClass),
-    .class_init = qcrypto_secret_class_init,
-    .abstract = true,
-};
-TYPE_INFO(qcrypto_secret_info)
-
-
-
-
diff --git a/crypto/secret_keyring.c b/crypto/secret_keyring.c
index 821d2e421b..463aefe5dc 100644
--- a/crypto/secret_keyring.c
+++ b/crypto/secret_keyring.c
@@ -26,6 +26,9 @@
 #include "trace.h"
 #include "crypto/secret_keyring.h"
 
+OBJECT_DEFINE_TYPE_WITH_INTERFACES(QCryptoSecretKeyring, qcrypto_secret_keyring,
+                                   QCRYPTO_SECRET_KEYRING, QCRYPTO_SECRET_COMMON,
+                                   { TYPE_USER_CREATABLE }, { NULL })
 
 static inline
 long keyctl_read(int32_t key, uint8_t *buffer, size_t buflen)
@@ -109,6 +112,11 @@ qcrypto_secret_keyring_complete(UserCreatable *uc, Error **errp)
 }
 
 
+static void
+qcrypto_secret_keyring_finalize(Object *obj)
+{
+}
+
 static void
 qcrypto_secret_keyring_class_init(ObjectClass *oc, void *data)
 {
@@ -124,20 +132,7 @@ qcrypto_secret_keyring_class_init(ObjectClass *oc, void *data)
                                   NULL, NULL);
 }
 
-
-static const TypeInfo qcrypto_secret_info = {
-    .parent = TYPE_QCRYPTO_SECRET_COMMON,
-    .name = TYPE_QCRYPTO_SECRET_KEYRING,
-    .instance_size = sizeof(QCryptoSecretKeyring),
-    .class_size = sizeof(QCryptoSecretKeyringClass),
-    .class_init = qcrypto_secret_keyring_class_init,
-    .interfaces = (InterfaceInfo[]) {
-        { TYPE_USER_CREATABLE },
-        { }
-    }
-};
-TYPE_INFO(qcrypto_secret_info)
-
-
-
-
+static void
+qcrypto_secret_keyring_init(Object *obj)
+{
+}
-- 
2.26.2



  parent reply	other threads:[~2020-08-13 22:47 UTC|newest]

Thread overview: 103+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-13 22:25 [PATCH 00/41] qom: Automated conversion of type checking boilerplate Eduardo Habkost
2020-08-13 22:25 ` [PATCH 01/41] pl1110: Rename PL1110 enum Eduardo Habkost
2020-08-14 17:45   ` Philippe Mathieu-Daudé
2020-08-18 21:30     ` Eduardo Habkost
2020-08-19  2:45       ` Philippe Mathieu-Daudé
2020-08-13 22:25 ` [PATCH 02/41] e1000: Rename QOM class cast macros Eduardo Habkost
2020-08-17 15:49   ` Daniel P. Berrangé
2020-08-13 22:25 ` [PATCH 03/41] megasas: " Eduardo Habkost
2020-08-17 15:53   ` Daniel P. Berrangé
2020-08-13 22:25 ` [PATCH 04/41] vmw_pvscsi: " Eduardo Habkost
2020-08-17 15:54   ` Daniel P. Berrangé
2020-08-13 22:25 ` [PATCH 05/41] aspeed_timer: Fix ASPEED_TIMER macro definition Eduardo Habkost
2020-08-14 17:47   ` Philippe Mathieu-Daudé
2020-08-17 15:54   ` Daniel P. Berrangé
2020-08-13 22:25 ` [PATCH 06/41] allwinner-h3: Rename memmap enum constants Eduardo Habkost
2020-08-14 17:54   ` Philippe Mathieu-Daudé
2020-08-17 19:07     ` Niek Linnenbank
2020-08-18 21:43       ` Eduardo Habkost
2020-08-13 22:25 ` [PATCH 07/41] aspeed_soc: Rename memmap/irqmap " Eduardo Habkost
2020-08-13 22:25 ` [PATCH 08/41] opentitan: Rename memmap " Eduardo Habkost
2020-08-14 15:06   ` Alistair Francis
2020-08-14 17:56   ` Philippe Mathieu-Daudé
2020-08-17  9:52     ` Bin Meng
2020-08-21 18:53       ` Alistair Francis
2020-08-25 12:38         ` Bin Meng
2020-08-13 22:25 ` [PATCH 09/41] sifive_e: " Eduardo Habkost
2020-08-14 15:07   ` Alistair Francis
2020-08-13 22:25 ` [PATCH 10/41] sifive_u: " Eduardo Habkost
2020-08-14 15:09   ` Alistair Francis
2020-08-13 22:25 ` [PATCH 11/41] versatile: Fix typo in PCI_VPB_HOST definition Eduardo Habkost
2020-08-14 17:59   ` Philippe Mathieu-Daudé
2020-08-17 15:56   ` Daniel P. Berrangé
2020-08-13 22:25 ` [PATCH 12/41] virtio-ccw: Fix definition of VIRTIO_CCW_BUS_GET_CLASS Eduardo Habkost
2020-08-17  7:25   ` Cornelia Huck
2020-08-17 15:57   ` Daniel P. Berrangé
2020-08-13 22:25 ` [PATCH 13/41] hvf: Add missing include Eduardo Habkost
2020-08-17 15:58   ` Daniel P. Berrangé
2020-08-18  7:12   ` Philippe Mathieu-Daudé
2020-08-18 10:29   ` Roman Bolshakov
2020-08-13 22:25 ` [PATCH 14/41] hcd-dwc2: Rename USB_*CLASS macros for consistency Eduardo Habkost
2020-08-14 18:00   ` Philippe Mathieu-Daudé
2020-08-17 15:58   ` Daniel P. Berrangé
2020-08-13 22:25 ` [PATCH 15/41] tulip: Move TulipState typedef to header Eduardo Habkost
2020-08-14 18:01   ` Philippe Mathieu-Daudé
2020-08-17 15:59   ` Daniel P. Berrangé
2020-08-13 22:26 ` [PATCH 16/41] throttle-groups: Move ThrottleGroup " Eduardo Habkost
2020-08-14 18:01   ` Philippe Mathieu-Daudé
2020-08-17 15:59   ` Daniel P. Berrangé
2020-08-13 22:26 ` [PATCH 17/41] pci: Move PCIBusClass typedef to pci.h Eduardo Habkost
2020-08-17 16:00   ` Daniel P. Berrangé
2020-08-13 22:26 ` [PATCH 18/41] i8254: Move PITCommonState/PITCommonClass typedefs to i8254.h Eduardo Habkost
2020-08-14 18:02   ` Philippe Mathieu-Daudé
2020-08-17 16:00   ` Daniel P. Berrangé
2020-08-13 22:26 ` [PATCH 19/41] hvf: Move HVFState typedef to hvf.h Eduardo Habkost
2020-08-17 16:01   ` Daniel P. Berrangé
2020-08-13 22:26 ` [PATCH 20/41] mcf_fec: Move mcf_fec_state typedef to header Eduardo Habkost
2020-08-17 16:02   ` Daniel P. Berrangé
2020-08-13 22:26 ` [PATCH 21/41] s390_flic: Move KVMS390FLICState " Eduardo Habkost
2020-08-17  7:26   ` Cornelia Huck
2020-08-17 16:02   ` Daniel P. Berrangé
2020-08-13 22:26 ` [PATCH 22/41] can_emu: Delete macros for non-existing typedef Eduardo Habkost
2020-08-14 18:03   ` Philippe Mathieu-Daudé
2020-08-17 16:02   ` Daniel P. Berrangé
2020-08-13 22:26 ` [PATCH 23/41] nubus: Delete unused NUBUS_BRIDGE macro Eduardo Habkost
2020-08-14 18:03   ` Philippe Mathieu-Daudé
2020-08-17 16:03   ` Daniel P. Berrangé
2020-08-13 22:26 ` [PATCH 24/41] platform-bus: Delete macros for non-existing typedef Eduardo Habkost
2020-08-17 16:03   ` Daniel P. Berrangé
2020-08-13 22:26 ` [PATCH 25/41] qom: make object_ref/unref use a void * instead of Object * Eduardo Habkost
2020-08-13 22:26 ` [PATCH 26/41] qom: provide convenient macros for declaring and defining types Eduardo Habkost
2020-08-13 22:26 ` [PATCH 27/41] qom: Fix G_DEFINE_AUTOPTR_CLEANUP_FUNC Eduardo Habkost
2020-08-17 16:04   ` Daniel P. Berrangé
2020-08-13 22:26 ` [PATCH 28/41] qom: Allow class type name to be specified in OBJECT_DECLARE* Eduardo Habkost
2020-08-17 16:06   ` Daniel P. Berrangé
2020-08-13 22:26 ` [PATCH 29/41] qom: DECLARE_*_CHECKERS macros Eduardo Habkost
2020-08-17 16:06   ` Daniel P. Berrangé
2020-08-13 22:26 ` [PATCH 30/41] qom: Make type checker functions accept const pointers Eduardo Habkost
2020-08-14 18:05   ` Philippe Mathieu-Daudé
2020-08-17 16:08   ` Daniel P. Berrangé
2020-08-18 20:56     ` Eduardo Habkost
2020-08-13 22:26 ` [PATCH 31/41] qom: TYPE_INFO macro Eduardo Habkost
2020-08-17 16:09   ` Daniel P. Berrangé
2020-08-13 22:26 ` [PATCH 32/41] codeconverter: script for automating QOM code cleanups Eduardo Habkost
2020-08-13 22:26 ` [PATCH 33/41] [automated] Delete duplicate QOM typedefs Eduardo Habkost
2020-08-17 16:11   ` Daniel P. Berrangé
2020-08-13 22:26 ` [PATCH 34/41] [automated] Use TYPE_INFO macro Eduardo Habkost
2020-08-17 16:14   ` Daniel P. Berrangé
2020-08-13 22:26 ` [PATCH 35/41] [automated] Move QOM typedefs and add missing includes Eduardo Habkost
2020-08-17 16:16   ` Daniel P. Berrangé
2020-08-13 22:26 ` [PATCH 36/41] [automated] Use DECLARE_*CHECKER* macros Eduardo Habkost
2020-08-17 16:17   ` Daniel P. Berrangé
2020-08-13 22:26 ` [PATCH 37/41] [automated] Use DECLARE_*CHECKER* when possible (--force mode) Eduardo Habkost
2020-08-17 16:29   ` Daniel P. Berrangé
2020-08-17 17:14     ` Eduardo Habkost
2020-08-13 22:26 ` [PATCH 38/41] [automated] Use OBJECT_DECLARE_TYPE where possible Eduardo Habkost
2020-08-13 22:26 ` [PATCH 39/41] [automated] Use OBJECT_DECLARE_SIMPLE_TYPE when possible Eduardo Habkost
2020-08-13 22:26 ` Eduardo Habkost [this message]
2020-08-13 22:26 ` [PATCH 41/41] crypto: use QOM macros for declaration/definition of TLS creds types Eduardo Habkost
2020-08-13 23:01 ` [PATCH 00/41] qom: Automated conversion of type checking boilerplate no-reply
2020-08-13 23:03 ` no-reply
2020-08-13 23:07 ` no-reply
2020-08-18  9:59 ` Roman Bolshakov
2020-08-18 13:19   ` Eduardo Habkost

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200813222625.243136-41-ehabkost@redhat.com \
    --to=ehabkost@redhat.com \
    --cc=berrange@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.