From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34620) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPpkO-00070w-A4 for qemu-devel@nongnu.org; Wed, 20 Jul 2016 07:33:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPpkM-0001n1-SF for qemu-devel@nongnu.org; Wed, 20 Jul 2016 07:33:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40261) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPpkM-0001mw-Mb for qemu-devel@nongnu.org; Wed, 20 Jul 2016 07:33:02 -0400 From: "Daniel P. Berrange" Date: Wed, 20 Jul 2016 12:32:54 +0100 Message-Id: <1469014374-6731-3-git-send-email-berrange@redhat.com> In-Reply-To: <1469014374-6731-1-git-send-email-berrange@redhat.com> References: <1469014374-6731-1-git-send-email-berrange@redhat.com> Subject: [Qemu-devel] [PULL v1 2/2] crypto: don't open-code qcrypto_hash_supports List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , "Daniel P. Berrange" Call the existing qcrypto_hash_supports method from qcrypto_hash_bytesv instead of open-coding it again. Signed-off-by: Daniel P. Berrange --- crypto/hash-gcrypt.c | 3 +-- crypto/hash-glib.c | 3 +-- crypto/hash-nettle.c | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/crypto/hash-gcrypt.c b/crypto/hash-gcrypt.c index ed6f842..7690690 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 81ef7ca..ce54a4b 100644 --- a/crypto/hash-glib.c +++ b/crypto/hash-glib.c @@ -53,8 +53,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 4c6f50b..6a206dc 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); -- 2.7.4