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

From: Bartosz Golaszewski

Date: Thu Nov 05 2026 - 07:44:26 EST


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. I can also fold it
into my series that actually triggered the problem if you like.

Bart