rdmacg: Convert to use match_string() helper
PATCH v2 1/1 rdmacg: Convert to use match_string() helper
The new helper returns index of the matching string in an array. We are going to use it here.
Signed-off-by Andy Shevchenko <[email protected]>
---
- fix compile error
kernel/cgroup/rdma.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-)
kernel/cgroup/rdma.c +16 -19
@@ -362,35 +362,32 @@ EXPORT_SYMBOL(rdmacg_unregister_device);static int parse_resource (char *c,int *intval) {substring_t argstr; -const char **table = &rdmacg_resource_names[0 ];char *name, *value = c;size_t len; -int ret, i =0 ; +int ret, i; name =strsep (&value,"=" );if (!name || !value)return -EINVAL ; - len =strlen (value); + i =match_string (rdmacg_resource_names,RDMACG_RESOURCE_MAX , name); +if (i <0 ) +return i; -for (i =0 ; i <RDMACG_RESOURCE_MAX ; i++) { -if (strcmp (table[i], name)) -continue ; + len =strlen (value); - argstr.from = value; - argstr.to = value + len; + argstr.from = value; + argstr.to = value + len; - ret =match_int (&argstr, intval); -if (ret >=0 ) { -if (*intval <0 ) -break ; -return i; - } -if (strncmp (value,RDMACG_MAX_STR , len) ==0 ) { - *intval =S32_MAX ; -return i; - } -break ; + ret =match_int (&argstr, intval); +if (ret >=0 ) { +if (*intval <0 ) +return -EINVAL ; +return i; + } +if (strncmp (value,RDMACG_MAX_STR , len) ==0 ) { + *intval =S32_MAX ; +return i; }return -EINVAL ; }
Signature · 1 line
2.17.0
Quoted 4 lines · Andy Shevchenko
The new helper returns index of the matching string in an array. We are going to use it here.
Signed-off-by Andy Shevchenko <[email protected]>
Applied to cgroup/for-4.18.
Thanks.
Signature · 1 line
tejun