linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gioh Kim <gi-oh.kim@ionos.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH] lib/string: sysfs_streq works case insensitively
Date: Wed, 28 Apr 2021 09:31:55 +0200	[thread overview]
Message-ID: <CAJX1YtYRK=_X8+mvva2S35-K4kpwXSAGctUJ01TEDFRhS0y5LA@mail.gmail.com> (raw)
In-Reply-To: <CAHp75Vf2yJ5=zdxRcPKmKGCKeF8As=Nv2S9fm0ciVXL5HGbWDg@mail.gmail.com>

On Wed, Apr 28, 2021 at 8:42 AM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
>
>
>
> On Wednesday, April 28, 2021, Gioh Kim <gi-oh.kim@ionos.com> wrote:
>>
>> On Mon, Apr 12, 2021 at 1:33 PM Gioh Kim <gi-oh.kim@ionos.com> wrote:
>> >
>> > As the name shows, it checks the strings inputed from sysfs.
>> > It should work for both case-sensitive filesystem and
>> > case-insensitive filesystem. Therefore sysfs_streq should work
>> > case-insensitively.
>> >
>> > Signed-off-by: Gioh Kim <gi-oh.kim@ionos.com>
>> > ---
>> >  lib/string.c | 6 ++++--
>> >  1 file changed, 4 insertions(+), 2 deletions(-)
>> >
>> > diff --git a/lib/string.c b/lib/string.c
>> > index 7548eb715ddb..d0914dffdaae 100644
>> > --- a/lib/string.c
>> > +++ b/lib/string.c
>> > @@ -688,7 +688,8 @@ EXPORT_SYMBOL(strsep);
>> >  #endif
>> >
>> >  /**
>> > - * sysfs_streq - return true if strings are equal, modulo trailing newline
>> > + * sysfs_streq - return true if strings are equal case-insentively,
>> > + *               modulo trailing newline
>> >   * @s1: one string
>> >   * @s2: another string
>> >   *
>> > @@ -696,10 +697,11 @@ EXPORT_SYMBOL(strsep);
>> >   * NUL and newline-then-NUL as equivalent string terminations.  It's
>> >   * geared for use with sysfs input strings, which generally terminate
>> >   * with newlines but are compared against values without newlines.
>> > + * And case does not matter for the sysfs input strings comparison.
>> >   */
>> >  bool sysfs_streq(const char *s1, const char *s2)
>> >  {
>> > -       while (*s1 && *s1 == *s2) {
>> > +       while (*s1 && tolower(*s1) == tolower(*s2)) {
>> >                 s1++;
>> >                 s2++;
>> >         }
>> > --
>> > 2.25.1
>> >
>>
>> Hi Andrew,
>>
>
> Are you sure it’s good change? Sysfs is used for an ABI and you are opening a can of worms. From me NAK to this change without a very good background description that tells why it is safe to do.

https://www.spinics.net/lists/kernel/msg3898123.html
My initial idea was making a new function: sysfs_streqcase.
Andrew and Greg suggested making sysfs_streq to be case-insensitive.
I would like to have a discussion about it.

>
>
>>
>> I changed sysfs_streq to be case-insensitive as you requested.
>> Is there any progress?
>
>
>
> --
> With Best Regards,
> Andy Shevchenko
>
>

  parent reply	other threads:[~2021-04-28  7:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-12 11:33 [PATCH] lib/string: sysfs_streq works case insensitively Gioh Kim
2021-04-28  5:41 ` Gioh Kim
     [not found]   ` <CAHp75Vf2yJ5=zdxRcPKmKGCKeF8As=Nv2S9fm0ciVXL5HGbWDg@mail.gmail.com>
2021-04-28  7:31     ` Gioh Kim [this message]
2021-04-28  7:46       ` Andy Shevchenko
2021-04-28  7:47       ` Rasmus Villemoes
2021-04-28  8:31         ` Gioh Kim
2021-04-28  9:13           ` Rasmus Villemoes
2021-04-28  6:37 ` Rasmus Villemoes

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to='CAJX1YtYRK=_X8+mvva2S35-K4kpwXSAGctUJ01TEDFRhS0y5LA@mail.gmail.com' \
    --to=gi-oh.kim@ionos.com \
    --cc=akpm@linux-foundation.org \
    --cc=andy.shevchenko@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ndesaulniers@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

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