From: Gioh Kim <gi-oh.kim@ionos.com>
To: Nick Desaulniers <ndesaulniers@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
LKML <linux-kernel@vger.kernel.org>,
Dan Williams <dan.j.williams@intel.com>,
Andrey Konovalov <andreyknvl@google.com>,
laniel_francis@privacyrequired.com,
Kees Cook <keescook@chromium.org>, Daniel Axtens <dja@axtens.net>
Subject: Re: [PATCH] lib/string: Introduce sysfs_streqcase
Date: Thu, 8 Apr 2021 09:25:29 +0200 [thread overview]
Message-ID: <CAJX1YtaiPSVfUn6bVCGo+9S77LGN4TAf5PyxeOGxJYZuxgvUSQ@mail.gmail.com> (raw)
In-Reply-To: <CAKwvOdnaLT8sn4e3PQoASjKaNP4gUKQikhxtJM5G94-7CMUKTw@mail.gmail.com>
On Wed, Apr 7, 2021 at 10:07 PM Nick Desaulniers
<ndesaulniers@google.com> wrote:
>
> On Tue, Apr 6, 2021 at 11:15 PM Gioh Kim <gi-oh.kim@ionos.com> wrote:
> >
> > As the name shows, it checks if strings are equal in case insensitive
> > manner.
> >
> > For example, drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c uses
> > strncasecmp to check that the input via sysfs is "mi". But it would
> > work even-if the input is "min-wrongcommand".
> >
> > I found some more cases using strncasecmp to check the entire string
> > such as rtrs-clt-sysfs.c does. drivers/pnp/interface.c checks
> > "disable" command with strncasecmp but it would also work if the
> > command is "disable-wrong".
>
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
>
> I do wonder if these (sysfs_streqcase and sysfs_streq) could or should
> be conditionally available on CONFIG_SYSFS=y; don't pay for what you
> don't use (without needing CONFIG_LD_DEAD_CODE_DATA_ELIMINATION=y)?
Good idea.
Thank you.
>
> Also, it might be nice to share the second half of the function with
> sysfs_streq via a new static function. Though it will just get
> inlined in both for CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y, it might
> help the compiler if CONFIG_CC_OPTIMIZE_FOR_SIZE=y was instead chosen
> if the compiler cannot outline/deduplicate the shared code. At the
> least, there's less duplication between two very similar functions; if
> one changes then authors may need to be careful to update both.
Yes, they are exactly the same.
I will make an inline function for the common code.
>
> Are either of those concerns worth a v3? ¯\_(ツ)_/¯
Sure, I will not forget to add 'V2'.
Thank you for kind review.
next prev parent reply other threads:[~2021-04-08 7:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-07 6:14 Gioh Kim
2021-04-07 20:06 ` Nick Desaulniers
2021-04-08 7:25 ` Gioh Kim [this message]
-- strict thread matches above, loose matches on Subject: below --
2021-04-02 9:40 Gioh Kim
2021-04-02 17:59 ` kernel test robot
2021-04-02 18:17 ` Nick Desaulniers
2021-04-02 18:23 ` Kees Cook
2021-04-02 19:43 ` Gioh Kim
2021-04-02 19:41 ` Gioh Kim
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=CAJX1YtaiPSVfUn6bVCGo+9S77LGN4TAf5PyxeOGxJYZuxgvUSQ@mail.gmail.com \
--to=gi-oh.kim@ionos.com \
--cc=akpm@linux-foundation.org \
--cc=andreyknvl@google.com \
--cc=dan.j.williams@intel.com \
--cc=dja@axtens.net \
--cc=keescook@chromium.org \
--cc=laniel_francis@privacyrequired.com \
--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
all inboxes | Powered by JetHome®