Linux cryptographic layer development
 help / color / mirror / Atom feed
* [PATCH 1/4] crypto: testmgr - check that entries in alg_test_descs are in correct order
@ 2013-06-13 14:37 Jussi Kivilinna
  2013-06-13 14:37 ` [PATCH 2/4] crypto: testmgr - test skciphers with unaligned buffers Jussi Kivilinna
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Jussi Kivilinna @ 2013-06-13 14:37 UTC (permalink / raw)
  To: linux-crypto; +Cc: Herbert Xu, David S. Miller

Patch adds check for alg_test_descs list order, so that accidentically
misplaced entries are found quicker. Duplicate entries are also checked for.

Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
---
 crypto/testmgr.c |   31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index b2bc533..a81c154 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -3054,6 +3054,35 @@ static const struct alg_test_desc alg_test_descs[] = {
 	}
 };
 
+static bool alg_test_descs_checked;
+
+static void alg_test_descs_check_order(void)
+{
+	int i;
+
+	/* only check once */
+	if (alg_test_descs_checked)
+		return;
+
+	alg_test_descs_checked = true;
+
+	for (i = 1; i < ARRAY_SIZE(alg_test_descs); i++) {
+		int diff = strcmp(alg_test_descs[i - 1].alg,
+				  alg_test_descs[i].alg);
+
+		if (WARN_ON(diff > 0)) {
+			pr_warn("testmgr: alg_test_descs entries in wrong order: '%s' before '%s'\n",
+				alg_test_descs[i - 1].alg,
+				alg_test_descs[i].alg);
+		}
+
+		if (WARN_ON(diff == 0)) {
+			pr_warn("testmgr: duplicate alg_test_descs entry: '%s'\n",
+				alg_test_descs[i].alg);
+		}
+	}
+}
+
 static int alg_find_test(const char *alg)
 {
 	int start = 0;
@@ -3085,6 +3114,8 @@ int alg_test(const char *driver, const char *alg, u32 type, u32 mask)
 	int j;
 	int rc;
 
+	alg_test_descs_check_order();
+
 	if ((type & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_CIPHER) {
 		char nalg[CRYPTO_MAX_ALG_NAME];
 

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-06-21  7:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-13 14:37 [PATCH 1/4] crypto: testmgr - check that entries in alg_test_descs are in correct order Jussi Kivilinna
2013-06-13 14:37 ` [PATCH 2/4] crypto: testmgr - test skciphers with unaligned buffers Jussi Kivilinna
2013-06-13 14:37 ` [PATCH 3/4] crypto: testmgr - test AEADs " Jussi Kivilinna
2013-06-13 14:37 ` [PATCH 4/4] crypto: testmgr - test hash implementations " Jussi Kivilinna
2013-06-21  7:17 ` [PATCH 1/4] crypto: testmgr - check that entries in alg_test_descs are in correct order Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox