[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMRc=MeXQgkO80i3wnC1ogs6U8ZV8FzH13n8emaG63eznwey6g@mail.gmail.com>
Date: Tue, 18 Nov 2025 11:43:03 +0100
From: Bartosz Golaszewski <brgl@...ev.pl>
To: Andy Shevchenko <andy.shevchenko@...il.com>
Cc: Kees Cook <kees@...nel.org>, Andy Shevchenko <andy@...nel.org>,
Linus Walleij <linus.walleij@...aro.org>, linux-hardening@...r.kernel.org,
linux-kernel@...r.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@...aro.org>, Stephen Rothwell <sfr@...b.auug.org.au>
Subject: Re: [PATCH 0/2] string: strends() follow-ups
On Tue, Nov 18, 2025 at 11:32 AM Andy Shevchenko
<andy.shevchenko@...il.com> wrote:
>
> On Tue, Nov 18, 2025 at 12:14 PM Bartosz Golaszewski <brgl@...ev.pl> wrote:
> > On Tue, Nov 18, 2025 at 11:09 AM Andy Shevchenko
> > <andy.shevchenko@...il.com> wrote:
> > > On Tue, Nov 18, 2025 at 12:04 PM Bartosz Golaszewski <brgl@...ev.pl> wrote:
>
> ...
>
> > > > A couple follow-up changes to the new strends() string helper. This
> > > > needs to go through the GPIO tree as this is where the strends()
> > > > currently is.
>
> > > For the
> > > strends() I proposed to get rid of strlen() calls by
> > >
> > > char *p;
> > >
> > > p = strrchr(str, suffix[0[);
> > > if (!p)
> > > return false;
> > >
> > > return strcmp(p, suffix) == 0;
> >
> > IMO that's a bit less readable. Unless you benchmark it and show it's
> > faster than the current version, I'd say: let's keep the current
> > implementation.
>
> For the static suffixes the second strlen() becomes a hardcoded value,
> and I expect the benchmark will be closer to the variant I propose.
> Otherwise it will be definitely faster as the strrchr() implies
> partial strlen() and strcmp() is the same or even faster in my case as
> here we don't do the additional calculations with the pointers. Do you
> really need a benchmark for this?
>
Ok, I don't want to load too much string-related stuff into my tree.
I'm adding it to my TODO list for the next release where I already
have an item to replace the OF-specific implementation of suffix
comparator with strends().
Bart
Powered by blists - more mailing lists