Re: [PATCH v3 1/5] string: Add strprefix(), and deprecate str_has_prefix()

From: Steven Rostedt

Date: Wed Nov 11 2026 - 03:47:15 EST


On Tue, 10 Nov 2026 16:33:23 +0100
Alejandro Colomar <alx@xxxxxxxxxx> wrote:

> +/**
> + * str_has_prefix - Test if a string has a given prefix
> + * @str: The string to test
> + * @prefix: The string to see if @str starts with
> + *
> + * DEPRECATED: Use strprefix()

I'm still not convinced, so NAK on this part.

-- Steve


> + *
> + * A common way to test a prefix of a string is to do:
> + * strncmp(str, prefix, sizeof(prefix) - 1)
> + *
> + * But this can lead to bugs due to typos, or if prefix is a pointer
> + * and not a constant. Instead use strprefix().
> *