diff options
author | Peter Maydell | 2019-08-22 18:57:09 +0200 |
---|---|---|
committer | Peter Maydell | 2019-08-22 18:57:09 +0200 |
commit | 3590b27c7a2be7a24b4b265e2e9458b3761103e1 (patch) | |
tree | c4f94fe22dc14be0929494f0c9688ab4a84c65fd /include | |
parent | Merge remote-tracking branch 'remotes/bkoppelmann2/tags/pull-tricore-20190822... (diff) | |
parent | crypto: use auto cleanup for many stack variables (diff) | |
download | qemu-3590b27c7a2be7a24b4b265e2e9458b3761103e1.tar.gz qemu-3590b27c7a2be7a24b4b265e2e9458b3761103e1.tar.xz qemu-3590b27c7a2be7a24b4b265e2e9458b3761103e1.zip |
Merge remote-tracking branch 'remotes/berrange/tags/autofree-pull-request' into staging
require newer glib2 to enable autofree'ing of stack variables exiting scope
* Bump minium glib2 version to 2.48
* Convert much of the crypto code to use automatic memory free functions
# gpg: Signature made Thu 22 Aug 2019 11:51:59 BST
# gpg: using RSA key DAF3A6FDB26B62912D0E8E3FBE86EBB415104FDF
# gpg: Good signature from "Daniel P. Berrange <dan@berrange.com>" [full]
# gpg: aka "Daniel P. Berrange <berrange@redhat.com>" [full]
# Primary key fingerprint: DAF3 A6FD B26B 6291 2D0E 8E3F BE86 EBB4 1510 4FDF
* remotes/berrange/tags/autofree-pull-request:
crypto: use auto cleanup for many stack variables
crypto: define cleanup functions for use with g_autoptr
glib: bump min required glib library version to 2.48
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/crypto/block.h | 2 | ||||
-rw-r--r-- | include/crypto/cipher.h | 2 | ||||
-rw-r--r-- | include/crypto/hmac.h | 2 | ||||
-rw-r--r-- | include/crypto/ivgen.h | 2 | ||||
-rw-r--r-- | include/crypto/tlssession.h | 2 | ||||
-rw-r--r-- | include/glib-compat.h | 42 |
6 files changed, 12 insertions, 40 deletions
diff --git a/include/crypto/block.h b/include/crypto/block.h index fe12899831..d49d2c2da9 100644 --- a/include/crypto/block.h +++ b/include/crypto/block.h @@ -268,4 +268,6 @@ uint64_t qcrypto_block_get_sector_size(QCryptoBlock *block); */ void qcrypto_block_free(QCryptoBlock *block); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(QCryptoBlock, qcrypto_block_free) + #endif /* QCRYPTO_BLOCK_H */ diff --git a/include/crypto/cipher.h b/include/crypto/cipher.h index cac90b410c..5928e5ecc7 100644 --- a/include/crypto/cipher.h +++ b/include/crypto/cipher.h @@ -170,6 +170,8 @@ QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgorithm alg, */ void qcrypto_cipher_free(QCryptoCipher *cipher); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(QCryptoCipher, qcrypto_cipher_free) + /** * qcrypto_cipher_encrypt: * @cipher: the cipher object diff --git a/include/crypto/hmac.h b/include/crypto/hmac.h index aa3c97a2ff..ad4d778416 100644 --- a/include/crypto/hmac.h +++ b/include/crypto/hmac.h @@ -65,6 +65,8 @@ QCryptoHmac *qcrypto_hmac_new(QCryptoHashAlgorithm alg, */ void qcrypto_hmac_free(QCryptoHmac *hmac); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(QCryptoHmac, qcrypto_hmac_free) + /** * qcrypto_hmac_bytesv: * @hmac: the hmac object diff --git a/include/crypto/ivgen.h b/include/crypto/ivgen.h index 9b4a62f7bb..e41521519c 100644 --- a/include/crypto/ivgen.h +++ b/include/crypto/ivgen.h @@ -203,4 +203,6 @@ QCryptoHashAlgorithm qcrypto_ivgen_get_hash(QCryptoIVGen *ivgen); */ void qcrypto_ivgen_free(QCryptoIVGen *ivgen); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(QCryptoIVGen, qcrypto_ivgen_free) + #endif /* QCRYPTO_IVGEN_H */ diff --git a/include/crypto/tlssession.h b/include/crypto/tlssession.h index 816300cdcc..e01e1a9dc2 100644 --- a/include/crypto/tlssession.h +++ b/include/crypto/tlssession.h @@ -160,6 +160,8 @@ QCryptoTLSSession *qcrypto_tls_session_new(QCryptoTLSCreds *creds, */ void qcrypto_tls_session_free(QCryptoTLSSession *sess); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(QCryptoTLSSession, qcrypto_tls_session_free) + /** * qcrypto_tls_session_check_credentials: * @sess: the TLS session object diff --git a/include/glib-compat.h b/include/glib-compat.h index 1291628e09..0b0ec76299 100644 --- a/include/glib-compat.h +++ b/include/glib-compat.h @@ -19,12 +19,12 @@ /* Ask for warnings for anything that was marked deprecated in * the defined version, or before. It is a candidate for rewrite. */ -#define GLIB_VERSION_MIN_REQUIRED GLIB_VERSION_2_40 +#define GLIB_VERSION_MIN_REQUIRED GLIB_VERSION_2_48 /* Ask for warnings if code tries to use function that did not * exist in the defined version. These risk breaking builds */ -#define GLIB_VERSION_MAX_ALLOWED GLIB_VERSION_2_40 +#define GLIB_VERSION_MAX_ALLOWED GLIB_VERSION_2_48 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" @@ -63,26 +63,6 @@ * without generating warnings. */ -static inline gboolean g_strv_contains_qemu(const gchar *const *strv, - const gchar *str) -{ -#if GLIB_CHECK_VERSION(2, 44, 0) - return g_strv_contains(strv, str); -#else - g_return_val_if_fail(strv != NULL, FALSE); - g_return_val_if_fail(str != NULL, FALSE); - - for (; *strv != NULL; strv++) { - if (g_str_equal(str, *strv)) { - return TRUE; - } - } - - return FALSE; -#endif -} -#define g_strv_contains(a, b) g_strv_contains_qemu(a, b) - #if defined(_WIN32) && !GLIB_CHECK_VERSION(2, 50, 0) /* * g_poll has a problem on Windows when using @@ -92,24 +72,6 @@ static inline gboolean g_strv_contains_qemu(const gchar *const *strv, gint g_poll_fixed(GPollFD *fds, guint nfds, gint timeout); #endif - -#ifndef g_assert_cmpmem -#define g_assert_cmpmem(m1, l1, m2, l2) \ - do { \ - gconstpointer __m1 = m1, __m2 = m2; \ - int __l1 = l1, __l2 = l2; \ - if (__l1 != __l2) { \ - g_assertion_message_cmpnum( \ - G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ - #l1 " (len(" #m1 ")) == " #l2 " (len(" #m2 "))", __l1, "==", \ - __l2, 'i'); \ - } else if (memcmp(__m1, __m2, __l1) != 0) { \ - g_assertion_message(G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ - "assertion failed (" #m1 " == " #m2 ")"); \ - } \ - } while (0) -#endif - #pragma GCC diagnostic pop #endif |