archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <>
To: Alexandru Ardelean <>
Cc: linux-iio <>,
	Linux Kernel Mailing List <>,
	Jonathan Cameron <>,
	Lars-Peter Clausen <>,
	Andrew Morton <>,
	Greg Kroah-Hartman <>
Subject: Re: [PATCH v7 1/2] lib/string.c: add __sysfs_match_string_with_gaps() helper
Date: Thu, 7 Jan 2021 12:09:32 +0200	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

On Thu, Jan 7, 2021 at 10:41 AM Alexandru Ardelean
<> wrote:
> The original docstring of the __sysfs_match_string() and match_string()
> helper, implied that -1 could be used to search through NULL terminated
> arrays, and positive 'n' could be used to go through arrays that may have
> NULL elements in the middle of the array.
> This isn't true. Regardless of the value of 'n', the first NULL element in
> the array will stop the search, even if the element may be after a NULL
> element.
> To allow for a behavior where we can use the __sysfs_match_string() to
> search over arrays with NULL elements in the middle, the
> __sysfs_match_string_with_gaps() helper is added.
> If n > 0, the search will continue until the element is found or n is
> reached.


> If n < 0, the search will continue until the element is found or a NULL
> character is found.

And this is what I think is not needed.


> FWIW (from my side): I am not fully sure yet that implementing a
> new helper is the best idea. It's also not a bad idea.
> It's one of those "this could be useful for others as well later", but
> right now we would have only one user (IIO) for this.

Taking into account the failure of bitmap_set_clump() promotion, I
suggest to reduce scope to IIO for now.

> I'm also fine with just implementing it in IIO first, and the someone
> else can move it to lib/string.c if needed.

Yes, please do.


> + * If n < 0, then the search will continue until the element is found or
> + * until the first NULL element.


> +                       if (n < 0)
> +                               break;

And drop these.

With Best Regards,
Andy Shevchenko

      parent reply	other threads:[~2021-01-07 10:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-07  8:44 [PATCH v7 1/2] lib/string.c: add __sysfs_match_string_with_gaps() helper Alexandru Ardelean
2021-01-07  8:44 ` [PATCH v7 2/2] iio: Handle enumerated properties with gaps Alexandru Ardelean
2021-01-07 10:09 ` Andy Shevchenko [this message]

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \

* 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).