Re: [PATCH v2 19/21] bcache: use match_string() helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
> Cc: linux-bcache@xxxxxxxxxxxxxxx 
> Signed-off-by: Yisheng Xie <xieyisheng1@xxxxxxxxxx>

Hi Yishenng,

Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> 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;
>  }
>  
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-bcache" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux ARM Kernel]     [Linux Filesystem Development]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux