Re: [PATCH v4 2/6] string: Warn if the prefix is the empty string
From: kernel test robot
Date: Wed Nov 11 2026 - 20:23:11 EST
Hi Alejandro,
kernel test robot noticed the following build errors:
[auto build test ERROR on kees/for-next/hardening]
[also build test ERROR on driver-core/driver-core-testing driver-core/driver-core-next driver-core/driver-core-linus kees/for-next/pstore kees/for-next/kspp linus/master v7.4-rc2 next-20261110]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Alejandro-Colomar/string-Add-strprefix-and-deprecate-str_has_prefix/20261111-205515
base: https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/hardening
patch link: https://lore.kernel.org/r/cd09427148a0c4718b46029c9e806f9dc1622f9b.1794425425.git.alx%40kernel.org
patch subject: [PATCH v4 2/6] string: Warn if the prefix is the empty string
config: parisc-allyesconfig (https://download.01.org/0day-ci/archive/20261112/202611120923.khG1i6jO-lkp@xxxxxxxxx/config)
compiler: hppa-linux-gcc (GCC) 16.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261112/202611120923.khG1i6jO-lkp@xxxxxxxxx/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202611120923.khG1i6jO-lkp@xxxxxxxxx/
All errors (new ones prefixed by >>):
In file included from include/linux/uuid.h:11,
from include/linux/device-id/hv_vmbus.h:6,
from include/linux/mod_devicetable.h:31,
from scripts/mod/devicetable-offsets.c:4:
include/linux/string.h: In function 'str_has_prefix':
>> include/linux/string.h:575:9: error: implicit declaration of function 'WARN_ON_ONCE' [-Wimplicit-function-declaration]
575 | WARN_ON_ONCE(len == 0);
| ^~~~~~~~~~~~
make[3]: *** [scripts/Makefile.build:185: scripts/mod/devicetable-offsets.s] Error 1
make[3]: Target 'scripts/mod/' not remade because of errors.
make[2]: *** [Makefile:1424: prepare0] Error 2
make[2]: Target 'prepare' not remade because of errors.
make[1]: *** [Makefile:248: __sub-make] Error 2
make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:248: __sub-make] Error 2
make: Target 'prepare' not remade because of errors.
vim +/WARN_ON_ONCE +575 include/linux/string.h
555
556 /**
557 * str_has_prefix - Test if a string has a given prefix
558 * @str: The string to test
559 * @prefix: The string to see if @str starts with
560 *
561 * This is similar to strprefix(), but returns an offset instead of
562 * a pointer.
563 *
564 * Unlike for strprefix(), if the prefix is an empty string, the
565 * behavior is undefined. If you need to support arbitrary prefixes,
566 * use strprefix().
567 *
568 * Returns:
569 * * strlen(@prefix) if @str starts with @prefix
570 * * 0 if @str does not start with @prefix
571 */
572 static __always_inline size_t str_has_prefix(const char *str, const char *prefix)
573 {
574 size_t len = strlen(prefix);
> 575 WARN_ON_ONCE(len == 0);
576 return strncmp(str, prefix, len) == 0 ? len : 0;
577 }
578
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki