[PATCH v2 13/21] ima: use match_string() helper
Yisheng Xie
xieyisheng1 at huawei.com
Thu May 31 11:11:18 UTC 2018
match_string() returns the index of an array for a matching string,
which can be used instead of open coded variant.
Reviewed-by: Mimi Zohar <zohar at linux.vnet.ibm.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko at gmail.com>
Cc: Mimi Zohar <zohar at linux.vnet.ibm.com>
Cc: Dmitry Kasatkin <dmitry.kasatkin at gmail.com>
Cc: James Morris <jmorris at namei.org>
Cc: "Serge E. Hallyn" <serge at hallyn.com>
Cc: linux-integrity at vger.kernel.org
Cc: linux-security-module at vger.kernel.org
Signed-off-by: Yisheng Xie <xieyisheng1 at huawei.com>
---
v2:
- add Reviewed-by tag.
security/integrity/ima/ima_main.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
index 74d0bd7..f807093 100644
--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@ -61,14 +61,11 @@ static int __init hash_setup(char *str)
goto out;
}
- for (i = 0; i < HASH_ALGO__LAST; i++) {
- if (strcmp(str, hash_algo_name[i]) == 0) {
- ima_hash_algo = i;
- break;
- }
- }
- if (i == HASH_ALGO__LAST)
+ i = match_string(hash_algo_name, HASH_ALGO__LAST, str);
+ if (i < 0)
return 1;
+
+ ima_hash_algo = i;
out:
hash_setup_done = 1;
return 1;
--
1.7.12.4
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
More information about the Linux-security-module-archive
mailing list