lkml.org 
[lkml]   [2018]   [May]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 27/33] sched/debug: use match_string() helper
Date
match_string() returns the index of an array for a matching string,
which can be used intead of open coded variant.

Cc: Ingo Molnar <mingo@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
kernel/sched/debug.c | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 15b10e2..9e34499 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -111,16 +111,14 @@ static int sched_feat_set(char *cmp)
cmp += 3;
}

- for (i = 0; i < __SCHED_FEAT_NR; i++) {
- if (strcmp(cmp, sched_feat_names[i]) == 0) {
- if (neg) {
- sysctl_sched_features &= ~(1UL << i);
- sched_feat_disable(i);
- } else {
- sysctl_sched_features |= (1UL << i);
- sched_feat_enable(i);
- }
- break;
+ i = match_string(sched_feat_names, __SCHED_FEAT_NR, cmp);
+ if (i >= 0) {
+ if (neg) {
+ sysctl_sched_features &= ~(1UL << i);
+ sched_feat_disable(i);
+ } else {
+ sysctl_sched_features |= (1UL << i);
+ sched_feat_enable(i);
}
}

@@ -150,7 +148,7 @@ static int sched_feat_set(char *cmp)
inode_lock(inode);
i = sched_feat_set(cmp);
inode_unlock(inode);
- if (i == __SCHED_FEAT_NR)
+ if (i < 0)
return -EINVAL;

*ppos += cnt;
--
1.7.12.4
\
 
 \ /
  Last update: 2018-05-21 14:13    [W:0.451 / U:0.848 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site