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

From: Andy Shevchenko

Date: Thu Nov 12 2026 - 10:28:34 EST


On Wed, Nov 11, 2026 at 08:57:30PM +0100, Alejandro Colomar wrote:

...

> > Testing
> > ~~~~~~~
> >
> > I haven't changed the implementation of the function meaningfully, so
> > haven't re-run tests. Since the changes since v2 are only about type
> > safety and diagnostics, I have built again with 'allmodconfig', just to
> > make sure it still compiles.
>
> Ouch! It seems I had built before adding WARN_ON_ONCE(), not after.
> I just saw a compiler error in a background terminal after hitting send.
>
> $ make
> DESCEND objtool
> CC arch/x86/purgatory/sha256.o
> In file included from ./include/crypto/sha2.h:10,
> from lib/crypto/sha256.c:13:
> ./include/linux/string.h: In function ‘str_has_prefix’:
> ./include/linux/string.h:619:9: error: implicit declaration of function ‘WARN_ON_ONCE’ [-Wimplicit-function-declaration]
> 619 | WARN_ON_ONCE(len == 0);
> | ^~~~~~~~~~~~
> make[4]: *** [arch/x86/purgatory/Makefile:12: arch/x86/purgatory/sha256.o] Error 1
> make[3]: *** [scripts/Makefile.build:572: arch/x86/purgatory] Error 2
> make[2]: *** [scripts/Makefile.build:572: arch/x86] Error 2
> make[1]: *** [/srv/alx/src/linux/linux/master/Makefile:2244: .] Error 2
> make: *** [Makefile:248: __sub-make] Error 2
>
> Will fix that for v5, and fully test again.

Are you sure that it's okay to use asm/bug.h APIs in string.h?
The include/linux/string.h along with the backed C implementations is really
special in the kernel. Hint: check which stages of kernel boot use it.

--
With Best Regards,
Andy Shevchenko