From a0eca116d01bab9f00c9629b297a9a7938862d7b Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Wed, 13 Dec 2023 10:01:36 -0500 Subject: [PATCH] MT#55283 slightly improved crypto lookup Avoids doing repeated strlen() Change-Id: I9bb45d206627184ac62a928e85f221a5316c1494 --- daemon/crypto.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/daemon/crypto.c b/daemon/crypto.c index 05e9ec345..779662ce8 100644 --- a/daemon/crypto.c +++ b/daemon/crypto.c @@ -337,22 +337,14 @@ const unsigned int num_crypto_suites = G_N_ELEMENTS(__crypto_suites); const struct crypto_suite * crypto_find_suite(const str *s) { - int i, l; + int i; const struct crypto_suite *cs; for (i = 0; i < num_crypto_suites; i++) { cs = &crypto_suites[i]; - if (!cs->name) - continue; - - l = strlen(cs->name); - if (l != s->len) - continue; - - if (strncasecmp(cs->name, s->s, s->len)) - continue; - return cs; + if (str_casecmp_str(&cs->name_str, s) == 0) + return cs; } return NULL;