From: zhong jiang <zhongjiang@huawei.com>
To: <paul@paul-moore.com>, <sds@tycho.nsa.gov>, <eparis@parisplace.org>
Cc: <james.morris@microsoft.com>, <sgrover@codeaurora.org>,
<kyeongdon.kim@lge.com>, <selinux@tycho.nsa.gov>,
<linux-kernel@vger.kernel.org>
Subject: [PATCH] selinux: ss: use match_string() helper to simplify the code
Date: Fri, 14 Sep 2018 22:54:12 +0800 [thread overview]
Message-ID: <1536936852-30893-1-git-send-email-zhongjiang@huawei.com> (raw)
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
reply other threads:[~2018-09-14 15:06 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1536936852-30893-1-git-send-email-zhongjiang@huawei.com \
--to=zhongjiang@huawei.com \
--cc=eparis@parisplace.org \
--cc=james.morris@microsoft.com \
--cc=kyeongdon.kim@lge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=paul@paul-moore.com \
--cc=sds@tycho.nsa.gov \
--cc=selinux@tycho.nsa.gov \
--cc=sgrover@codeaurora.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).