Skip to content

Commit b4df860

Browse files
Yisheng XieMimi Zohar
authored andcommitted
ima: use match_string() helper
match_string() returns the index of an array for a matching string, which can be used intead of open coded variant. Signed-off-by: Yisheng Xie <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Mimi Zohar <[email protected]>
1 parent 6f0911a commit b4df860

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

security/integrity/ima/ima_main.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,11 @@ static int __init hash_setup(char *str)
5959
goto out;
6060
}
6161

62-
for (i = 0; i < HASH_ALGO__LAST; i++) {
63-
if (strcmp(str, hash_algo_name[i]) == 0) {
64-
ima_hash_algo = i;
65-
break;
66-
}
67-
}
68-
if (i == HASH_ALGO__LAST)
62+
i = match_string(hash_algo_name, HASH_ALGO__LAST, str);
63+
if (i < 0)
6964
return 1;
65+
66+
ima_hash_algo = i;
7067
out:
7168
hash_setup_done = 1;
7269
return 1;

0 commit comments

Comments
 (0)