* [PATCH] selinux: ss: use match_string() helper to simplify the code
@ 2018-09-14 14:54 zhong jiang
0 siblings, 0 replies; only message in thread
From: zhong jiang @ 2018-09-14 14:54 UTC (permalink / raw)
To: paul, sds, eparis
Cc: james.morris, sgrover, kyeongdon.kim, selinux, linux-kernel
match_string() returns the index of an array for a matching string,
which can be used intead of open coded implementation.
Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
security/selinux/ss/services.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c
index 12e4143..aa9fc35 100644
--- a/security/selinux/ss/services.c
+++ b/security/selinux/ss/services.c
@@ -1461,14 +1461,14 @@ static int security_context_to_sid_core(struct selinux_state *state,
return -ENOMEM;
if (!state->initialized) {
- int i;
+ int index;
- for (i = 1; i < SECINITSID_NUM; i++) {
- if (!strcmp(initial_sid_to_string[i], scontext2)) {
- *sid = i;
- goto out;
- }
+ index = match_string(initial_sid_to_string, SECINITSID_NUM, scontext2);
+ if (index >= 0) {
+ *sid = index;
+ goto out;
}
+
*sid = SECINITSID_KERNEL;
goto out;
}
--
1.7.12.4
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2018-09-14 15:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-14 14:54 [PATCH] selinux: ss: use match_string() helper to simplify the code zhong jiang
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).