diff options
author | Jussi Kivilinna <jussi.kivilinna@iki.fi> | 2013-06-13 10:37:40 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2013-06-21 02:44:29 -0400 |
commit | 5714758b5c23dcca8d29a43590397e58d245732f (patch) | |
tree | 2cc1a4d487e425a6ad1b5ac30bbe0609177a8e05 /crypto | |
parent | 99f42f937a080995b34e1ed75ed6934b5f96f9ca (diff) |
crypto: testmgr - check that entries in alg_test_descs are in correct order
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>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/testmgr.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/crypto/testmgr.c b/crypto/testmgr.c index b2bc5334c170..a81c154e5d85 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c | |||
@@ -3054,6 +3054,35 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
3054 | } | 3054 | } |
3055 | }; | 3055 | }; |
3056 | 3056 | ||
3057 | static bool alg_test_descs_checked; | ||
3058 | |||
3059 | static void alg_test_descs_check_order(void) | ||
3060 | { | ||
3061 | int i; | ||
3062 | |||
3063 | /* only check once */ | ||
3064 | if (alg_test_descs_checked) | ||
3065 | return; | ||
3066 | |||
3067 | alg_test_descs_checked = true; | ||
3068 | |||
3069 | for (i = 1; i < ARRAY_SIZE(alg_test_descs); i++) { | ||
3070 | int diff = strcmp(alg_test_descs[i - 1].alg, | ||
3071 | alg_test_descs[i].alg); | ||
3072 | |||
3073 | if (WARN_ON(diff > 0)) { | ||
3074 | pr_warn("testmgr: alg_test_descs entries in wrong order: '%s' before '%s'\n", | ||
3075 | alg_test_descs[i - 1].alg, | ||
3076 | alg_test_descs[i].alg); | ||
3077 | } | ||
3078 | |||
3079 | if (WARN_ON(diff == 0)) { | ||
3080 | pr_warn("testmgr: duplicate alg_test_descs entry: '%s'\n", | ||
3081 | alg_test_descs[i].alg); | ||
3082 | } | ||
3083 | } | ||
3084 | } | ||
3085 | |||
3057 | static int alg_find_test(const char *alg) | 3086 | static int alg_find_test(const char *alg) |
3058 | { | 3087 | { |
3059 | int start = 0; | 3088 | int start = 0; |
@@ -3085,6 +3114,8 @@ int alg_test(const char *driver, const char *alg, u32 type, u32 mask) | |||
3085 | int j; | 3114 | int j; |
3086 | int rc; | 3115 | int rc; |
3087 | 3116 | ||
3117 | alg_test_descs_check_order(); | ||
3118 | |||
3088 | if ((type & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_CIPHER) { | 3119 | if ((type & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_CIPHER) { |
3089 | char nalg[CRYPTO_MAX_ALG_NAME]; | 3120 | char nalg[CRYPTO_MAX_ALG_NAME]; |
3090 | 3121 | ||