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 41/41] crypto: use QOM macros for declaration/definition of TLS creds types
Date: Thu, 13 Aug 2020 18:26:25 -0400	[thread overview]
Message-ID: <20200813222625.243136-42-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 TLS creds types, in order to eliminate boilerplate code.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-Id: <20200723181410.3145233-5-berrange@redhat.com>
[ehabkost: rebase, update to pass additional arguments to macro]
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 include/crypto/tlscreds.h     | 13 ++-----------
 include/crypto/tlscredsanon.h | 14 ++------------
 include/crypto/tlscredspsk.h  | 13 ++-----------
 include/crypto/tlscredsx509.h | 13 ++-----------
 crypto/tlscreds.c             | 20 +++-----------------
 crypto/tlscredsanon.c         | 24 +++++++-----------------
 crypto/tlscredspsk.c          | 26 ++++++++------------------
 crypto/tlscredsx509.c         | 24 ++++--------------------
 8 files changed, 30 insertions(+), 117 deletions(-)

diff --git a/include/crypto/tlscreds.h b/include/crypto/tlscreds.h
index 079e376047..e9b9b8c20a 100644
--- a/include/crypto/tlscreds.h
+++ b/include/crypto/tlscreds.h
@@ -29,11 +29,8 @@
 #endif
 
 #define TYPE_QCRYPTO_TLS_CREDS "tls-creds"
-typedef struct QCryptoTLSCreds QCryptoTLSCreds;
-DECLARE_INSTANCE_CHECKER(QCryptoTLSCreds, QCRYPTO_TLS_CREDS,
-                         TYPE_QCRYPTO_TLS_CREDS)
-
-typedef struct QCryptoTLSCredsClass QCryptoTLSCredsClass;
+OBJECT_DECLARE_SIMPLE_TYPE(QCryptoTLSCreds, qcrypto_tls_creds,
+                           QCRYPTO_TLS_CREDS, Object)
 
 #define QCRYPTO_TLS_CREDS_DH_PARAMS "dh-params.pem"
 
@@ -58,10 +55,4 @@ struct QCryptoTLSCreds {
     char *priority;
 };
 
-
-struct QCryptoTLSCredsClass {
-    ObjectClass parent_class;
-};
-
-
 #endif /* QCRYPTO_TLSCREDS_H */
diff --git a/include/crypto/tlscredsanon.h b/include/crypto/tlscredsanon.h
index 3f464a3809..338b668b1d 100644
--- a/include/crypto/tlscredsanon.h
+++ b/include/crypto/tlscredsanon.h
@@ -25,12 +25,8 @@
 #include "qom/object.h"
 
 #define TYPE_QCRYPTO_TLS_CREDS_ANON "tls-creds-anon"
-typedef struct QCryptoTLSCredsAnon QCryptoTLSCredsAnon;
-DECLARE_INSTANCE_CHECKER(QCryptoTLSCredsAnon, QCRYPTO_TLS_CREDS_ANON,
-                         TYPE_QCRYPTO_TLS_CREDS_ANON)
-
-
-typedef struct QCryptoTLSCredsAnonClass QCryptoTLSCredsAnonClass;
+OBJECT_DECLARE_SIMPLE_TYPE(QCryptoTLSCredsAnon, qcrypto_tls_creds_anon,
+                           QCRYPTO_TLS_CREDS_ANON, QCryptoTLSCreds)
 
 /**
  * QCryptoTLSCredsAnon:
@@ -103,10 +99,4 @@ struct QCryptoTLSCredsAnon {
 #endif
 };
 
-
-struct QCryptoTLSCredsAnonClass {
-    QCryptoTLSCredsClass parent_class;
-};
-
-
 #endif /* QCRYPTO_TLSCREDSANON_H */
diff --git a/include/crypto/tlscredspsk.h b/include/crypto/tlscredspsk.h
index d7e6bdb5ed..16e3f84f47 100644
--- a/include/crypto/tlscredspsk.h
+++ b/include/crypto/tlscredspsk.h
@@ -25,11 +25,8 @@
 #include "qom/object.h"
 
 #define TYPE_QCRYPTO_TLS_CREDS_PSK "tls-creds-psk"
-typedef struct QCryptoTLSCredsPSK QCryptoTLSCredsPSK;
-DECLARE_INSTANCE_CHECKER(QCryptoTLSCredsPSK, QCRYPTO_TLS_CREDS_PSK,
-                         TYPE_QCRYPTO_TLS_CREDS_PSK)
-
-typedef struct QCryptoTLSCredsPSKClass QCryptoTLSCredsPSKClass;
+OBJECT_DECLARE_SIMPLE_TYPE(QCryptoTLSCredsPSK, qcrypto_tls_creds_psk,
+                           QCRYPTO_TLS_CREDS_PSK, QCryptoTLSCreds)
 
 #define QCRYPTO_TLS_CREDS_PSKFILE "keys.psk"
 
@@ -98,10 +95,4 @@ struct QCryptoTLSCredsPSK {
 #endif
 };
 
-
-struct QCryptoTLSCredsPSKClass {
-    QCryptoTLSCredsClass parent_class;
-};
-
-
 #endif /* QCRYPTO_TLSCREDSPSK_H */
diff --git a/include/crypto/tlscredsx509.h b/include/crypto/tlscredsx509.h
index c6d89b7881..1197f33663 100644
--- a/include/crypto/tlscredsx509.h
+++ b/include/crypto/tlscredsx509.h
@@ -25,11 +25,8 @@
 #include "qom/object.h"
 
 #define TYPE_QCRYPTO_TLS_CREDS_X509 "tls-creds-x509"
-typedef struct QCryptoTLSCredsX509 QCryptoTLSCredsX509;
-DECLARE_INSTANCE_CHECKER(QCryptoTLSCredsX509, QCRYPTO_TLS_CREDS_X509,
-                         TYPE_QCRYPTO_TLS_CREDS_X509)
-
-typedef struct QCryptoTLSCredsX509Class QCryptoTLSCredsX509Class;
+OBJECT_DECLARE_SIMPLE_TYPE(QCryptoTLSCredsX509, qcrypto_tls_creds_x509,
+                           QCRYPTO_TLS_CREDS_X509, QCryptoTLSCreds)
 
 #define QCRYPTO_TLS_CREDS_X509_CA_CERT "ca-cert.pem"
 #define QCRYPTO_TLS_CREDS_X509_CA_CRL "ca-crl.pem"
@@ -105,10 +102,4 @@ struct QCryptoTLSCredsX509 {
     char *passwordid;
 };
 
-
-struct QCryptoTLSCredsX509Class {
-    QCryptoTLSCredsClass parent_class;
-};
-
-
 #endif /* QCRYPTO_TLSCREDSX509_H */
diff --git a/crypto/tlscreds.c b/crypto/tlscreds.c
index bb3e6667b9..c238ff7d4b 100644
--- a/crypto/tlscreds.c
+++ b/crypto/tlscreds.c
@@ -24,6 +24,9 @@
 #include "tlscredspriv.h"
 #include "trace.h"
 
+OBJECT_DEFINE_ABSTRACT_TYPE(QCryptoTLSCreds, qcrypto_tls_creds,
+                            QCRYPTO_TLS_CREDS, OBJECT)
+
 #define DH_BITS 2048
 
 #ifdef CONFIG_GNUTLS
@@ -258,20 +261,3 @@ qcrypto_tls_creds_finalize(Object *obj)
     g_free(creds->dir);
     g_free(creds->priority);
 }
-
-
-static const TypeInfo qcrypto_tls_creds_info = {
-    .parent = TYPE_OBJECT,
-    .name = TYPE_QCRYPTO_TLS_CREDS,
-    .instance_size = sizeof(QCryptoTLSCreds),
-    .instance_init = qcrypto_tls_creds_init,
-    .instance_finalize = qcrypto_tls_creds_finalize,
-    .class_init = qcrypto_tls_creds_class_init,
-    .class_size = sizeof(QCryptoTLSCredsClass),
-    .abstract = true,
-};
-TYPE_INFO(qcrypto_tls_creds_info)
-
-
-
-
diff --git a/crypto/tlscredsanon.c b/crypto/tlscredsanon.c
index 16162e60b6..dc1b77e37c 100644
--- a/crypto/tlscredsanon.c
+++ b/crypto/tlscredsanon.c
@@ -26,6 +26,9 @@
 #include "qom/object_interfaces.h"
 #include "trace.h"
 
+OBJECT_DEFINE_TYPE_WITH_INTERFACES(QCryptoTLSCredsAnon, qcrypto_tls_creds_anon,
+                                   QCRYPTO_TLS_CREDS_ANON, QCRYPTO_TLS_CREDS,
+                                   { TYPE_USER_CREATABLE }, { NULL })
 
 #ifdef CONFIG_GNUTLS
 
@@ -191,20 +194,7 @@ qcrypto_tls_creds_anon_class_init(ObjectClass *oc, void *data)
 }
 
 
-static const TypeInfo qcrypto_tls_creds_anon_info = {
-    .parent = TYPE_QCRYPTO_TLS_CREDS,
-    .name = TYPE_QCRYPTO_TLS_CREDS_ANON,
-    .instance_size = sizeof(QCryptoTLSCredsAnon),
-    .instance_finalize = qcrypto_tls_creds_anon_finalize,
-    .class_size = sizeof(QCryptoTLSCredsAnonClass),
-    .class_init = qcrypto_tls_creds_anon_class_init,
-    .interfaces = (InterfaceInfo[]) {
-        { TYPE_USER_CREATABLE },
-        { }
-    }
-};
-TYPE_INFO(qcrypto_tls_creds_anon_info)
-
-
-
-
+static void
+qcrypto_tls_creds_anon_init(Object *obj)
+{
+}
diff --git a/crypto/tlscredspsk.c b/crypto/tlscredspsk.c
index ea890f5837..0c66be3647 100644
--- a/crypto/tlscredspsk.c
+++ b/crypto/tlscredspsk.c
@@ -27,6 +27,10 @@
 #include "trace.h"
 
 
+OBJECT_DEFINE_TYPE_WITH_INTERFACES(QCryptoTLSCredsPSK, qcrypto_tls_creds_psk,
+                                   QCRYPTO_TLS_CREDS_PSK, QCRYPTO_TLS_CREDS,
+                                   { TYPE_USER_CREATABLE }, { NULL })
+
 #ifdef CONFIG_GNUTLS
 
 static int
@@ -281,21 +285,7 @@ qcrypto_tls_creds_psk_class_init(ObjectClass *oc, void *data)
                                   qcrypto_tls_creds_psk_prop_set_username);
 }
 
-
-static const TypeInfo qcrypto_tls_creds_psk_info = {
-    .parent = TYPE_QCRYPTO_TLS_CREDS,
-    .name = TYPE_QCRYPTO_TLS_CREDS_PSK,
-    .instance_size = sizeof(QCryptoTLSCredsPSK),
-    .instance_finalize = qcrypto_tls_creds_psk_finalize,
-    .class_size = sizeof(QCryptoTLSCredsPSKClass),
-    .class_init = qcrypto_tls_creds_psk_class_init,
-    .interfaces = (InterfaceInfo[]) {
-        { TYPE_USER_CREATABLE },
-        { }
-    }
-};
-TYPE_INFO(qcrypto_tls_creds_psk_info)
-
-
-
-
+static void
+qcrypto_tls_creds_psk_init(Object *obj)
+{
+}
diff --git a/crypto/tlscredsx509.c b/crypto/tlscredsx509.c
index 77f1beaf8b..a39555e5e6 100644
--- a/crypto/tlscredsx509.c
+++ b/crypto/tlscredsx509.c
@@ -28,6 +28,10 @@
 #include "trace.h"
 
 
+OBJECT_DEFINE_TYPE_WITH_INTERFACES(QCryptoTLSCredsX509, qcrypto_tls_creds_x509,
+                                   QCRYPTO_TLS_CREDS_X509, QCRYPTO_TLS_CREDS,
+                                   { TYPE_USER_CREATABLE }, { NULL })
+
 #ifdef CONFIG_GNUTLS
 
 #include <gnutls/x509.h>
@@ -814,23 +818,3 @@ qcrypto_tls_creds_x509_class_init(ObjectClass *oc, void *data)
                                   qcrypto_tls_creds_x509_prop_get_passwordid,
                                   qcrypto_tls_creds_x509_prop_set_passwordid);
 }
-
-
-static const TypeInfo qcrypto_tls_creds_x509_info = {
-    .parent = TYPE_QCRYPTO_TLS_CREDS,
-    .name = TYPE_QCRYPTO_TLS_CREDS_X509,
-    .instance_size = sizeof(QCryptoTLSCredsX509),
-    .instance_init = qcrypto_tls_creds_x509_init,
-    .instance_finalize = qcrypto_tls_creds_x509_finalize,
-    .class_size = sizeof(QCryptoTLSCredsX509Class),
-    .class_init = qcrypto_tls_creds_x509_class_init,
-    .interfaces = (InterfaceInfo[]) {
-        { TYPE_USER_CREATABLE },
-        { }
-    }
-};
-TYPE_INFO(qcrypto_tls_creds_x509_info)
-
-
-
-
-- 
2.26.2



  parent reply	other threads:[~2020-08-13 22:46 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 ` [PATCH 40/41] crypto: use QOM macros for declaration/definition of secret types Eduardo Habkost
2020-08-13 22:26 ` Eduardo Habkost [this message]
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-42-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.