Re: [PATCH 1/4] RISC-V: create ISA string separately - not as part of cpuinfo

From: kernel test robot
Date: Tue Apr 25 2023 - 04:48:05 EST


Hi Heiko,

kernel test robot noticed the following build warnings:

[auto build test WARNING on next-20230424]
[also build test WARNING on v6.3]
[cannot apply to soc/for-next linus/master kees/for-next/execve v6.3 v6.3-rc7 v6.3-rc6]
[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/Heiko-Stuebner/RISC-V-create-ISA-string-separately-not-as-part-of-cpuinfo/20230425-035214
base: next-20230424
patch link: https://lore.kernel.org/r/20230424194911.264850-2-heiko.stuebner%40vrull.eu
patch subject: [PATCH 1/4] RISC-V: create ISA string separately - not as part of cpuinfo
config: riscv-allnoconfig (https://download.01.org/0day-ci/archive/20230425/202304251640.IVxoyd0v-lkp@xxxxxxxxx/config)
compiler: riscv64-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/8f1a5a16616d673f2c82cdc54ff845fd8b125a21
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Heiko-Stuebner/RISC-V-create-ISA-string-separately-not-as-part-of-cpuinfo/20230425-035214
git checkout 8f1a5a16616d673f2c82cdc54ff845fd8b125a21
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=riscv olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash arch/riscv/kernel/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Link: https://lore.kernel.org/oe-kbuild-all/202304251640.IVxoyd0v-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

arch/riscv/kernel/cpu.c: In function 'riscv_create_isa_string':
>> arch/riscv/kernel/cpu.c:269:25: warning: 'strncat' output may be truncated copying 1 byte from a string of length 13 [-Wstringop-truncation]
269 | strncat(isa_str, &base_riscv_exts[i], 1);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +/strncat +269 arch/riscv/kernel/cpu.c

246
247 static char *riscv_create_isa_string(const char *isa)
248 {
249 int maxlen = 4;
250 char *isa_str;
251 int i;
252
253 /* calculate the needed string length */
254 for (i = 0; i < sizeof(base_riscv_exts); i++)
255 if (__riscv_isa_extension_available(NULL, base_riscv_exts[i] - 'a'))
256 maxlen++;
257 maxlen += strlen_isa_ext();
258
259 isa_str = kzalloc(maxlen, GFP_KERNEL);
260 if (!isa_str)
261 return ERR_PTR(-ENOMEM);
262
263 /* Print the rv[64/32] part */
264 strncat(isa_str, isa, 4);
265
266 for (i = 0; i < sizeof(base_riscv_exts); i++) {
267 if (__riscv_isa_extension_available(NULL, base_riscv_exts[i] - 'a'))
268 /* Print only enabled the base ISA extensions */
> 269 strncat(isa_str, &base_riscv_exts[i], 1);
270 }
271
272 strcat_isa_ext(isa_str);
273
274 return isa_str;
275 }
276

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests