Re: [PATCH v6 2/3] x86/cpu: Check if feature string is non-zero

From: Maciej Wieczor-Retman

Date: Fri Feb 20 2026 - 11:43:44 EST


I'll replace the sizeof(buf) with 16 for the next version.

--
Kind regards
Maciej Wieczór-Retman

On 2026-02-21 at 00:19:59 +0800, kernel test robot wrote:
>Hi Maciej,
>
>kernel test robot noticed the following build warnings:
>
>[auto build test WARNING on tip/x86/core]
>[also build test WARNING on tip/smp/core v6.19]
>[cannot apply to peterz-queue/sched/core linus/master next-20260219]
>[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/Maciej-Wieczor-Retman/x86-cpu-Clear-feature-bits-disabled-at-compile-time/20260220-204916
>base: tip/x86/core
>patch link: https://lore.kernel.org/r/bc0eebc8310acfae28a73e3780a67d721c739b89.1771590895.git.m.wieczorretman%40pm.me
>patch subject: [PATCH v6 2/3] x86/cpu: Check if feature string is non-zero
>config: x86_64-randconfig-003-20260220 (https://download.01.org/0day-ci/archive/20260221/202602210027.MJpPrtwD-lkp@xxxxxxxxx/config)
>compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
>reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260221/202602210027.MJpPrtwD-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/202602210027.MJpPrtwD-lkp@xxxxxxxxx/
>
>All warnings (new ones prefixed by >>):
>
> arch/x86/kernel/cpu/common.c: In function 'x86_cap_name':
>>> arch/x86/kernel/cpu/common.c:1987:29: warning: argument to 'sizeof' in 'snprintf' call is the same expression as the destination; did you mean to provide an explicit length? [-Wsizeof-pointer-memaccess]
> 1987 | snprintf(buf, sizeof(buf), "%u:%u", word, bit & 31);
> | ^
>>> arch/x86/kernel/cpu/common.c:1987:37: warning: '%u' directive output may be truncated writing between 1 and 9 bytes into a region of size 8 [-Wformat-truncation=]
> 1987 | snprintf(buf, sizeof(buf), "%u:%u", word, bit & 31);
> | ^~
> arch/x86/kernel/cpu/common.c:1987:36: note: directive argument in the range [0, 134217727]
> 1987 | snprintf(buf, sizeof(buf), "%u:%u", word, bit & 31);
> | ^~~~~~~
> arch/x86/kernel/cpu/common.c:1987:36: note: directive argument in the range [0, 31]
> arch/x86/kernel/cpu/common.c:1987:9: note: 'snprintf' output between 4 and 13 bytes into a destination of size 8
> 1987 | snprintf(buf, sizeof(buf), "%u:%u", word, bit & 31);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
>vim +1987 arch/x86/kernel/cpu/common.c
>
> 1973
> 1974 const char *x86_cap_name(unsigned int bit, char *buf)
> 1975 {
> 1976 unsigned int word = bit >> 5;
> 1977 const char *name = NULL;
> 1978
> 1979 if (likely(word < NCAPINTS))
> 1980 name = x86_cap_flags[bit];
> 1981 else if (likely(word < NCAPINTS + NBUGINTS))
> 1982 name = x86_bug_flags[bit - 32 * NCAPINTS];
> 1983
> 1984 if (name)
> 1985 return name;
> 1986
>> 1987 snprintf(buf, sizeof(buf), "%u:%u", word, bit & 31);
> 1988 return buf;
> 1989 }
> 1990
>
>--
>0-DAY CI Kernel Test Service
>https://github.com/intel/lkp-tests/wiki