* [PATCH v2 19/21] bcache: use match_string() helper
[not found] <1527765086-19873-1-git-send-email-xieyisheng1@huawei.com>
@ 2018-05-31 11:11 ` Yisheng Xie
2018-06-01 3:45 ` Coly Li
0 siblings, 1 reply; 4+ messages in thread
From: Yisheng Xie @ 2018-05-31 11:11 UTC (permalink / raw)
To: linux-kernel; +Cc: andy.shevchenko, Yisheng Xie, Kent Overstreet, linux-bcache
match_string() returns the index of an array for a matching string,
which can be used instead of open coded variant.
Cc: Kent Overstreet <kent.overstreet@gmail.com>
Cc: linux-bcache@vger.kernel.org
Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
drivers/md/bcache/util.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/md/bcache/util.c b/drivers/md/bcache/util.c
index 74febd5..cd1f4fd 100644
--- a/drivers/md/bcache/util.c
+++ b/drivers/md/bcache/util.c
@@ -136,22 +136,17 @@ ssize_t bch_snprint_string_list(char *buf, size_t size, const char * const list[
ssize_t bch_read_string_list(const char *buf, const char * const list[])
{
- size_t i;
+ ssize_t i;
char *s, *d = kstrndup(buf, PAGE_SIZE - 1, GFP_KERNEL);
if (!d)
return -ENOMEM;
s = strim(d);
- for (i = 0; list[i]; i++)
- if (!strcmp(list[i], s))
- break;
+ i = match_string(list, -1, s);
kfree(d);
- if (!list[i])
- return -EINVAL;
-
return i;
}
--
1.7.12.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 19/21] bcache: use match_string() helper
2018-05-31 11:11 ` [PATCH v2 19/21] bcache: use match_string() helper Yisheng Xie
@ 2018-06-01 3:45 ` Coly Li
2018-06-01 4:32 ` Yisheng Xie
0 siblings, 1 reply; 4+ messages in thread
From: Coly Li @ 2018-06-01 3:45 UTC (permalink / raw)
To: Yisheng Xie, linux-kernel; +Cc: andy.shevchenko, Kent Overstreet, linux-bcache
On 2018/5/31 7:11 PM, Yisheng Xie wrote:
> match_string() returns the index of an array for a matching string,
> which can be used instead of open coded variant.
>
> Cc: Kent Overstreet <kent.overstreet@gmail.com>
> Cc: linux-bcache@vger.kernel.org
> Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
Hi Yishenng,
Andy Shevchenko <andriy.shevchenko@linux.intel.com> submitted a patch to
replace the whole bch_read_string_list() with __sysfs_match_string().
And this patch is applied in Jens' block tree, will go into mainline
kernel in v4.18.
If you search bcache mailing list, you may find a patch named with
"bcache: Replace bch_read_string_list() by __sysfs_match_string()".
That means this patch will conflict with existing changes.
Thanks.
Coly Li
> ---
> drivers/md/bcache/util.c | 9 ++-------
> 1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/md/bcache/util.c b/drivers/md/bcache/util.c
> index 74febd5..cd1f4fd 100644
> --- a/drivers/md/bcache/util.c
> +++ b/drivers/md/bcache/util.c
> @@ -136,22 +136,17 @@ ssize_t bch_snprint_string_list(char *buf, size_t size, const char * const list[
>
> ssize_t bch_read_string_list(const char *buf, const char * const list[])
> {
> - size_t i;
> + ssize_t i;
> char *s, *d = kstrndup(buf, PAGE_SIZE - 1, GFP_KERNEL);
> if (!d)
> return -ENOMEM;
>
> s = strim(d);
>
> - for (i = 0; list[i]; i++)
> - if (!strcmp(list[i], s))
> - break;
> + i = match_string(list, -1, s);
>
> kfree(d);
>
> - if (!list[i])
> - return -EINVAL;
> -
> return i;
> }
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 19/21] bcache: use match_string() helper
2018-06-01 3:45 ` Coly Li
@ 2018-06-01 4:32 ` Yisheng Xie
2018-06-01 5:04 ` Coly Li
0 siblings, 1 reply; 4+ messages in thread
From: Yisheng Xie @ 2018-06-01 4:32 UTC (permalink / raw)
To: Coly Li, linux-kernel; +Cc: andy.shevchenko, Kent Overstreet, linux-bcache
Hi Coly,
On 2018/6/1 11:45, Coly Li wrote:
> On 2018/5/31 7:11 PM, Yisheng Xie wrote:
>> match_string() returns the index of an array for a matching string,
>> which can be used instead of open coded variant.
>>
>> Cc: Kent Overstreet <kent.overstreet@gmail.com>
>> Cc: linux-bcache@vger.kernel.org
>> Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
>
> Hi Yishenng,
>
> Andy Shevchenko <andriy.shevchenko@linux.intel.com> submitted a patch to
> replace the whole bch_read_string_list() with __sysfs_match_string().
> And this patch is applied in Jens' block tree, will go into mainline
> kernel in v4.18.
>
> If you search bcache mailing list, you may find a patch named with
> "bcache: Replace bch_read_string_list() by __sysfs_match_string()".
>
> That means this patch will conflict with existing changes.
Get it, and thanks for this information.
Sorry Andy, for doing this once more.
Thanks
Yisheng
>
> Thanks.
>
> Coly Li
>
>> ---
>> drivers/md/bcache/util.c | 9 ++-------
>> 1 file changed, 2 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/md/bcache/util.c b/drivers/md/bcache/util.c
>> index 74febd5..cd1f4fd 100644
>> --- a/drivers/md/bcache/util.c
>> +++ b/drivers/md/bcache/util.c
>> @@ -136,22 +136,17 @@ ssize_t bch_snprint_string_list(char *buf, size_t size, const char * const list[
>>
>> ssize_t bch_read_string_list(const char *buf, const char * const list[])
>> {
>> - size_t i;
>> + ssize_t i;
>> char *s, *d = kstrndup(buf, PAGE_SIZE - 1, GFP_KERNEL);
>> if (!d)
>> return -ENOMEM;
>>
>> s = strim(d);
>>
>> - for (i = 0; list[i]; i++)
>> - if (!strcmp(list[i], s))
>> - break;
>> + i = match_string(list, -1, s);
>>
>> kfree(d);
>>
>> - if (!list[i])
>> - return -EINVAL;
>> -
>> return i;
>> }
>>
>>
>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 19/21] bcache: use match_string() helper
2018-06-01 4:32 ` Yisheng Xie
@ 2018-06-01 5:04 ` Coly Li
0 siblings, 0 replies; 4+ messages in thread
From: Coly Li @ 2018-06-01 5:04 UTC (permalink / raw)
To: Yisheng Xie, linux-kernel; +Cc: andy.shevchenko, Kent Overstreet, linux-bcache
On 2018/6/1 12:32 PM, Yisheng Xie wrote:
> Hi Coly,
>
> On 2018/6/1 11:45, Coly Li wrote:
>> On 2018/5/31 7:11 PM, Yisheng Xie wrote:
>>> match_string() returns the index of an array for a matching string,
>>> which can be used instead of open coded variant.
>>>
>>> Cc: Kent Overstreet <kent.overstreet@gmail.com>
>>> Cc: linux-bcache@vger.kernel.org
>>> Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
>>
>> Hi Yishenng,
>>
>> Andy Shevchenko <andriy.shevchenko@linux.intel.com> submitted a patch to
>> replace the whole bch_read_string_list() with __sysfs_match_string().
>> And this patch is applied in Jens' block tree, will go into mainline
>> kernel in v4.18.
>>
>> If you search bcache mailing list, you may find a patch named with
>> "bcache: Replace bch_read_string_list() by __sysfs_match_string()".
>>
>> That means this patch will conflict with existing changes.
>
> Get it, and thanks for this information.
>
> Sorry Andy, for doing this once more.
>
Hi Yisheng,
Thank you for the effort, hope to see more bcache patches from you :-)
Coly Li
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-06-01 5:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1527765086-19873-1-git-send-email-xieyisheng1@huawei.com>
2018-05-31 11:11 ` [PATCH v2 19/21] bcache: use match_string() helper Yisheng Xie
2018-06-01 3:45 ` Coly Li
2018-06-01 4:32 ` Yisheng Xie
2018-06-01 5:04 ` Coly Li
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).