Re: [PATCH v3 5/5] string: Make strprefix() const-qualifier-generic
From: Alejandro Colomar
Date: Tue Nov 10 2026 - 18:28:01 EST
Hi Joe,
> Date: 2026-11-10 08:32:41-0800
> From: Joe Perches <joe@xxxxxxxxxxx>
>
> On Tue, 2026-11-10 at 16:33 +0100, Alejandro Colomar wrote:
>
> no commit description on proposed patch
There isn't much to say, but I'll add something (the explanation of why
the parentheses are needed around the function name, for example).
> > Suggested-by: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
> > Signed-off-by: Alejandro Colomar <alx@xxxxxxxxxx>
> > ---
> > include/linux/string.h | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/include/linux/string.h b/include/linux/string.h
> > index 9e59f9697c9e..55ca4cb5122c 100644
> > --- a/include/linux/string.h
> > +++ b/include/linux/string.h
> > @@ -590,7 +590,9 @@ void memcpy_and_pad(void *dest, size_t dest_len, const void *src, size_t count,
> > * * @s+strlen(@prefix) if @s starts with @prefix
> > * * NULL if @s does not start with @prefix
> > */
> > -static inline char *strprefix(const char *s, const char *prefix)
> > +#define strprefix(s, pfx) const_cast(CQChar_of(s) *, strprefix(s, pfx))
> > +
> > +static inline char *(strprefix)(const char *s, const char *prefix)
>
> Why introduce a new coding style?
It's not style; the parentheses are technically needed to avoid macro
expansion, since the macro has the same name as the function.
Alternatively, I could rename the function to __strprefix().
Have a lovely night!
Alex
--
<https://www.alejandro-colomar.es>
Attachment:
signature.asc
Description: PGP signature