浏览代码

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 <xieyisheng1@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Yisheng Xie 7 年之前
父节点
当前提交
b4df86085a
共有 1 个文件被更改,包括 4 次插入7 次删除
  1. 4 7
      security/integrity/ima/ima_main.c

+ 4 - 7
security/integrity/ima/ima_main.c

@@ -59,14 +59,11 @@ static int __init hash_setup(char *str)
 		goto out;
 		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;
 		return 1;
+
+	ima_hash_algo = i;
 out:
 out:
 	hash_setup_done = 1;
 	hash_setup_done = 1;
 	return 1;
 	return 1;