From 977c736f80c232de7c6476d793ed575359c049d8 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Thu, 24 Aug 2017 10:46:08 +0200 Subject: qapi: Mechanically convert FOO_lookup[...] to FOO_str(...) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Markus Armbruster Message-Id: <1503564371-26090-14-git-send-email-armbru@redhat.com> Reviewed-by: Marc-André Lureau --- crypto/block-luks.c | 12 ++++++------ crypto/block.c | 4 ++-- crypto/cipher-afalg.c | 2 +- crypto/cipher-builtin.c | 8 ++++---- crypto/cipher-gcrypt.c | 4 ++-- crypto/cipher-nettle.c | 8 ++++---- crypto/hmac-gcrypt.c | 2 +- crypto/hmac-glib.c | 2 +- crypto/hmac-nettle.c | 2 +- crypto/pbkdf-gcrypt.c | 2 +- crypto/pbkdf-nettle.c | 2 +- 11 files changed, 24 insertions(+), 24 deletions(-) (limited to 'crypto') diff --git a/crypto/block-luks.c b/crypto/block-luks.c index 84d189a..4e82895 100644 --- a/crypto/block-luks.c +++ b/crypto/block-luks.c @@ -257,7 +257,7 @@ qcrypto_block_luks_cipher_alg_lookup(QCryptoCipherAlgorithm alg, } error_setg(errp, "Algorithm '%s' not supported", - QCryptoCipherAlgorithm_lookup[alg]); + QCryptoCipherAlgorithm_str(alg)); return NULL; } @@ -392,7 +392,7 @@ qcrypto_block_luks_essiv_cipher(QCryptoCipherAlgorithm cipher, break; default: error_setg(errp, "Cipher %s not supported with essiv", - QCryptoCipherAlgorithm_lookup[cipher]); + QCryptoCipherAlgorithm_str(cipher)); return 0; } } @@ -962,16 +962,16 @@ qcrypto_block_luks_create(QCryptoBlock *block, goto error; } - cipher_mode = QCryptoCipherMode_lookup[luks_opts.cipher_mode]; - ivgen_alg = QCryptoIVGenAlgorithm_lookup[luks_opts.ivgen_alg]; + cipher_mode = QCryptoCipherMode_str(luks_opts.cipher_mode); + ivgen_alg = QCryptoIVGenAlgorithm_str(luks_opts.ivgen_alg); if (luks_opts.has_ivgen_hash_alg) { - ivgen_hash_alg = QCryptoHashAlgorithm_lookup[luks_opts.ivgen_hash_alg]; + ivgen_hash_alg = QCryptoHashAlgorithm_str(luks_opts.ivgen_hash_alg); cipher_mode_spec = g_strdup_printf("%s-%s:%s", cipher_mode, ivgen_alg, ivgen_hash_alg); } else { cipher_mode_spec = g_strdup_printf("%s-%s", cipher_mode, ivgen_alg); } - hash_alg = QCryptoHashAlgorithm_lookup[luks_opts.hash_alg]; + hash_alg = QCryptoHashAlgorithm_str(luks_opts.hash_alg); if (strlen(cipher_alg) >= QCRYPTO_BLOCK_LUKS_CIPHER_NAME_LEN) { diff --git a/crypto/block.c b/crypto/block.c index b097d45..c382393 100644 --- a/crypto/block.c +++ b/crypto/block.c @@ -61,7 +61,7 @@ QCryptoBlock *qcrypto_block_open(QCryptoBlockOpenOptions *options, if (options->format >= G_N_ELEMENTS(qcrypto_block_drivers) || !qcrypto_block_drivers[options->format]) { error_setg(errp, "Unsupported block driver %s", - QCryptoBlockFormat_lookup[options->format]); + QCryptoBlockFormat_str(options->format)); g_free(block); return NULL; } @@ -92,7 +92,7 @@ QCryptoBlock *qcrypto_block_create(QCryptoBlockCreateOptions *options, if (options->format >= G_N_ELEMENTS(qcrypto_block_drivers) || !qcrypto_block_drivers[options->format]) { error_setg(errp, "Unsupported block driver %s", - QCryptoBlockFormat_lookup[options->format]); + QCryptoBlockFormat_str(options->format)); g_free(block); return NULL; } diff --git a/crypto/cipher-afalg.c b/crypto/cipher-afalg.c index 01343b2..cd72284 100644 --- a/crypto/cipher-afalg.c +++ b/crypto/cipher-afalg.c @@ -52,7 +52,7 @@ qcrypto_afalg_cipher_format_name(QCryptoCipherAlgorithm alg, return NULL; } - mode_name = QCryptoCipherMode_lookup[mode]; + mode_name = QCryptoCipherMode_str(mode); name = g_strdup_printf("%s(%s)", mode_name, alg_name); return name; diff --git a/crypto/cipher-builtin.c b/crypto/cipher-builtin.c index 16a36d4..d8c811f 100644 --- a/crypto/cipher-builtin.c +++ b/crypto/cipher-builtin.c @@ -247,7 +247,7 @@ qcrypto_cipher_init_aes(QCryptoCipherMode mode, mode != QCRYPTO_CIPHER_MODE_ECB && mode != QCRYPTO_CIPHER_MODE_XTS) { error_setg(errp, "Unsupported cipher mode %s", - QCryptoCipherMode_lookup[mode]); + QCryptoCipherMode_str(mode)); return NULL; } @@ -379,7 +379,7 @@ qcrypto_cipher_init_des_rfb(QCryptoCipherMode mode, if (mode != QCRYPTO_CIPHER_MODE_ECB) { error_setg(errp, "Unsupported cipher mode %s", - QCryptoCipherMode_lookup[mode]); + QCryptoCipherMode_str(mode)); return NULL; } @@ -440,7 +440,7 @@ static QCryptoCipherBuiltin *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg, break; default: error_setg(errp, "Unsupported cipher mode %s", - QCryptoCipherMode_lookup[mode]); + QCryptoCipherMode_str(mode)); return NULL; } @@ -460,7 +460,7 @@ static QCryptoCipherBuiltin *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg, default: error_setg(errp, "Unsupported cipher algorithm %s", - QCryptoCipherAlgorithm_lookup[alg]); + QCryptoCipherAlgorithm_str(alg)); return NULL; } diff --git a/crypto/cipher-gcrypt.c b/crypto/cipher-gcrypt.c index 0489147..10d75da 100644 --- a/crypto/cipher-gcrypt.c +++ b/crypto/cipher-gcrypt.c @@ -105,7 +105,7 @@ static QCryptoCipherGcrypt *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg, break; default: error_setg(errp, "Unsupported cipher mode %s", - QCryptoCipherMode_lookup[mode]); + QCryptoCipherMode_str(mode)); return NULL; } @@ -160,7 +160,7 @@ static QCryptoCipherGcrypt *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg, default: error_setg(errp, "Unsupported cipher algorithm %s", - QCryptoCipherAlgorithm_lookup[alg]); + QCryptoCipherAlgorithm_str(alg)); return NULL; } diff --git a/crypto/cipher-nettle.c b/crypto/cipher-nettle.c index c51f119..3848cb3 100644 --- a/crypto/cipher-nettle.c +++ b/crypto/cipher-nettle.c @@ -281,7 +281,7 @@ static QCryptoCipherNettle *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg, break; default: error_setg(errp, "Unsupported cipher mode %s", - QCryptoCipherMode_lookup[mode]); + QCryptoCipherMode_str(mode)); return NULL; } @@ -420,7 +420,7 @@ static QCryptoCipherNettle *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg, default: error_setg(errp, "Unsupported cipher algorithm %s", - QCryptoCipherAlgorithm_lookup[alg]); + QCryptoCipherAlgorithm_str(alg)); goto error; } @@ -491,7 +491,7 @@ qcrypto_nettle_cipher_encrypt(QCryptoCipher *cipher, default: error_setg(errp, "Unsupported cipher mode %s", - QCryptoCipherMode_lookup[cipher->mode]); + QCryptoCipherMode_str(cipher->mode)); return -1; } return 0; @@ -537,7 +537,7 @@ qcrypto_nettle_cipher_decrypt(QCryptoCipher *cipher, default: error_setg(errp, "Unsupported cipher mode %s", - QCryptoCipherMode_lookup[cipher->mode]); + QCryptoCipherMode_str(cipher->mode)); return -1; } return 0; diff --git a/crypto/hmac-gcrypt.c b/crypto/hmac-gcrypt.c index 76ca61b..0c6f979 100644 --- a/crypto/hmac-gcrypt.c +++ b/crypto/hmac-gcrypt.c @@ -52,7 +52,7 @@ void *qcrypto_hmac_ctx_new(QCryptoHashAlgorithm alg, if (!qcrypto_hmac_supports(alg)) { error_setg(errp, "Unsupported hmac algorithm %s", - QCryptoHashAlgorithm_lookup[alg]); + QCryptoHashAlgorithm_str(alg)); return NULL; } diff --git a/crypto/hmac-glib.c b/crypto/hmac-glib.c index 8cf6b22..a6c1730 100644 --- a/crypto/hmac-glib.c +++ b/crypto/hmac-glib.c @@ -58,7 +58,7 @@ void *qcrypto_hmac_ctx_new(QCryptoHashAlgorithm alg, if (!qcrypto_hmac_supports(alg)) { error_setg(errp, "Unsupported hmac algorithm %s", - QCryptoHashAlgorithm_lookup[alg]); + QCryptoHashAlgorithm_str(alg)); return NULL; } diff --git a/crypto/hmac-nettle.c b/crypto/hmac-nettle.c index 1d5a915..ec2d61b 100644 --- a/crypto/hmac-nettle.c +++ b/crypto/hmac-nettle.c @@ -106,7 +106,7 @@ void *qcrypto_hmac_ctx_new(QCryptoHashAlgorithm alg, if (!qcrypto_hmac_supports(alg)) { error_setg(errp, "Unsupported hmac algorithm %s", - QCryptoHashAlgorithm_lookup[alg]); + QCryptoHashAlgorithm_str(alg)); return NULL; } diff --git a/crypto/pbkdf-gcrypt.c b/crypto/pbkdf-gcrypt.c index 4028985..54ca0d9 100644 --- a/crypto/pbkdf-gcrypt.c +++ b/crypto/pbkdf-gcrypt.c @@ -68,7 +68,7 @@ int qcrypto_pbkdf2(QCryptoHashAlgorithm hash, hash_map[hash] == GCRY_MD_NONE) { error_setg_errno(errp, ENOSYS, "PBKDF does not support hash algorithm %s", - QCryptoHashAlgorithm_lookup[hash]); + QCryptoHashAlgorithm_str(hash)); return -1; } diff --git a/crypto/pbkdf-nettle.c b/crypto/pbkdf-nettle.c index 6fb2671..212b3e8 100644 --- a/crypto/pbkdf-nettle.c +++ b/crypto/pbkdf-nettle.c @@ -110,7 +110,7 @@ int qcrypto_pbkdf2(QCryptoHashAlgorithm hash, default: error_setg_errno(errp, ENOSYS, "PBKDF does not support hash algorithm %s", - QCryptoHashAlgorithm_lookup[hash]); + QCryptoHashAlgorithm_str(hash)); return -1; } return 0; -- cgit v1.1