Re: [PATCH v1 0/2] Add strprefix() and fix a bug with it

From: Alejandro Colomar

Date: Thu Nov 05 2026 - 07:55:45 EST


Hi Bartosz,

> Date: 2026-11-05 13:30:08+0100
> From: Bartosz Golaszewski <brgl@xxxxxxxxxx>
>
> On Thu, Nov 05, 2026 at 12:12:55PM +0100, Alejandro Colomar wrote:
> > Hi!
> >
> > str_has_prefix() is based on sizes and lengths, which means it must
> > overload the valid length 0 to mean not found. This is a typical
> > consequence of choosing to design an API around sizes and lengths, and
> > vanishes when moving to pointer-based similar APIs.
> >
> > This patch set adds strprefix(), deprecates str_has_prefix(), and uses
> > strprefix() in one place to fix a bug reported by Bartosz.
> >
> > We can later work on replacing the other uses of str_has_prefix(), which
> > might hide similar bugs.
> >
>
> Thanks. As Andy said, we'd need kunit tests for that.

Agree. v2 (sent a few seconds ago) contains kunit tests.

> I can also fold it
> into my series that actually triggered the problem if you like.

Sounds good. Thanks!


Have a lovely day!
Alex

>
> Bart
>

--
<https://www.alejandro-colomar.es>

Attachment: signature.asc
Description: PGP signature