[avpatel:riscv_sbi_dbcn_v1 9/42] arch/riscv/mm/cacheflush.c:123:6: warning: variable 'cbom_hartid' is uninitialized when used here

From: kernel test robot
Date: Tue Aug 30 2022 - 06:45:25 EST


tree: https://github.com/avpatel/linux.git riscv_sbi_dbcn_v1
head: 74814d446b33fc095867181d8953a92ede0b042c
commit: 9a1ab381c3ec9717a3b694fc72fed88b4dde6b91 [9/42] RISC-V: Move riscv_init_cbom_blocksize() to cacheflush.c
config: riscv-randconfig-r042-20220830 (https://download.01.org/0day-ci/archive/20220830/202208301804.6NyqVVPU-lkp@xxxxxxxxx/config)
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project c7df82e4693c19e3fd2e25c83eb04d9deb7b7b59)
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
# install riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://github.com/avpatel/linux/commit/9a1ab381c3ec9717a3b694fc72fed88b4dde6b91
git remote add avpatel https://github.com/avpatel/linux.git
git fetch --no-tags avpatel riscv_sbi_dbcn_v1
git checkout 9a1ab381c3ec9717a3b694fc72fed88b4dde6b91
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash arch/riscv/mm/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

>> arch/riscv/mm/cacheflush.c:123:6: warning: variable 'cbom_hartid' is uninitialized when used here [-Wuninitialized]
cbom_hartid, hartid);
^~~~~~~~~~~
include/linux/printk.h:517:37: note: expanded from macro 'pr_warn'
printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
^~~~~~~~~~~
include/linux/printk.h:464:60: note: expanded from macro 'printk'
#define printk(fmt, ...) printk_index_wrap(_printk, fmt, ##__VA_ARGS__)
^~~~~~~~~~~
include/linux/printk.h:436:19: note: expanded from macro 'printk_index_wrap'
_p_func(_fmt, ##__VA_ARGS__); \
^~~~~~~~~~~
arch/riscv/mm/cacheflush.c:103:18: note: initialize the variable 'cbom_hartid' to silence this warning
int cbom_hartid;
^
= 0
1 warning generated.


vim +/cbom_hartid +123 arch/riscv/mm/cacheflush.c

93
94 #ifdef CONFIG_RISCV_ISA_ZICBOM
95 void riscv_init_cbom_blocksize(void)
96 {
97 struct device_node *node;
98 int ret;
99 u32 val;
100
101 for_each_of_cpu_node(node) {
102 unsigned long hartid;
103 int cbom_hartid;
104
105 ret = riscv_of_processor_hartid(node, &hartid);
106 if (ret)
107 continue;
108
109 if (hartid < 0)
110 continue;
111
112 /* set block-size for cbom extension if available */
113 ret = of_property_read_u32(node, "riscv,cbom-block-size", &val);
114 if (ret)
115 continue;
116
117 if (!riscv_cbom_block_size) {
118 riscv_cbom_block_size = val;
119 cbom_hartid = hartid;
120 } else {
121 if (riscv_cbom_block_size != val)
122 pr_warn("cbom-block-size mismatched between harts %d and %lu\n",
> 123 cbom_hartid, hartid);

--
0-DAY CI Kernel Test Service
https://01.org/lkp