* [PATCH 25/33] ima: use match_string() helper
[not found] <1526903890-35761-1-git-send-email-xieyisheng1@huawei.com>
@ 2018-05-21 11:58 ` Yisheng Xie
2018-05-23 14:42 ` Mimi Zohar
0 siblings, 1 reply; 2+ messages in thread
From: Yisheng Xie @ 2018-05-21 11:58 UTC (permalink / raw)
To: linux-kernel
Cc: Yisheng Xie, Mimi Zohar, Dmitry Kasatkin, James Morris,
Serge E. Hallyn, linux-integrity, linux-security-module
match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.
Cc: Mimi Zohar <zohar@linux.vnet.ibm.com>
Cc: Dmitry Kasatkin <dmitry.kasatkin@gmail.com>
Cc: James Morris <jmorris@namei.org>
Cc: "Serge E. Hallyn" <serge@hallyn.com>
Cc: linux-integrity@vger.kernel.org
Cc: linux-security-module@vger.kernel.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 25/33] ima: use match_string() helper
2018-05-21 11:58 ` [PATCH 25/33] ima: use match_string() helper Yisheng Xie
@ 2018-05-23 14:42 ` Mimi Zohar
0 siblings, 0 replies; 2+ messages in thread
From: Mimi Zohar @ 2018-05-23 14:42 UTC (permalink / raw)
To: Yisheng Xie, linux-kernel
Cc: Dmitry Kasatkin, James Morris, Serge E. Hallyn, linux-integrity,
linux-security-module
On Mon, 2018-05-21 at 19:58 +0800, Yisheng Xie wrote:
> match_string() returns the index of an array for a matching string,
> which can be used intead of open coded variant.
>
> Cc: Mimi Zohar <zohar@linux.vnet.ibm.com>
> Cc: Dmitry Kasatkin <dmitry.kasatkin@gmail.com>
> Cc: James Morris <jmorris@namei.org>
> Cc: "Serge E. Hallyn" <serge@hallyn.com>
> Cc: linux-integrity@vger.kernel.org
> Cc: linux-security-module@vger.kernel.org
> Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
Reviewed-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
> ---
> 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;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-05-23 14:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1526903890-35761-1-git-send-email-xieyisheng1@huawei.com>
2018-05-21 11:58 ` [PATCH 25/33] ima: use match_string() helper Yisheng Xie
2018-05-23 14:42 ` Mimi Zohar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).