From: Daniel P. Berrange Date: Tue, 5 Jul 2016 16:41:45 +0000 (+0100) Subject: crypto: don't open-code qcrypto_hash_supports X-Git-Tag: v2.7.0-rc0~4^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=760328971218bace4ab14b01f619825607fab9c3;p=thirdparty%2Fqemu.git crypto: don't open-code qcrypto_hash_supports Call the existing qcrypto_hash_supports method from qcrypto_hash_bytesv instead of open-coding it again. Signed-off-by: Daniel P. Berrange --- diff --git a/crypto/hash-gcrypt.c b/crypto/hash-gcrypt.c index ed6f842461a..7690690f705 100644 --- a/crypto/hash-gcrypt.c +++ b/crypto/hash-gcrypt.c @@ -55,8 +55,7 @@ int qcrypto_hash_bytesv(QCryptoHashAlgorithm alg, gcry_md_hd_t md; unsigned char *digest; - if (alg >= G_N_ELEMENTS(qcrypto_hash_alg_map) || - qcrypto_hash_alg_map[alg] == GCRY_MD_NONE) { + if (!qcrypto_hash_supports(alg)) { error_setg(errp, "Unknown hash algorithm %d", alg); diff --git a/crypto/hash-glib.c b/crypto/hash-glib.c index cb68a3b0d74..ec99ac9df99 100644 --- a/crypto/hash-glib.c +++ b/crypto/hash-glib.c @@ -57,8 +57,7 @@ int qcrypto_hash_bytesv(QCryptoHashAlgorithm alg, int i, ret; GChecksum *cs; - if (alg >= G_N_ELEMENTS(qcrypto_hash_alg_map) || - qcrypto_hash_alg_map[alg] == -1) { + if (!qcrypto_hash_supports(alg)) { error_setg(errp, "Unknown hash algorithm %d", alg); diff --git a/crypto/hash-nettle.c b/crypto/hash-nettle.c index 4c6f50b65d8..6a206dcb18c 100644 --- a/crypto/hash-nettle.c +++ b/crypto/hash-nettle.c @@ -113,8 +113,7 @@ int qcrypto_hash_bytesv(QCryptoHashAlgorithm alg, int i; union qcrypto_hash_ctx ctx; - if (alg >= G_N_ELEMENTS(qcrypto_hash_alg_map) || - qcrypto_hash_alg_map[alg].init == NULL) { + if (!qcrypto_hash_supports(alg)) { error_setg(errp, "Unknown hash algorithm %d", alg);