Skip to contentSkip to conversation

drivers/clk/uniphier/clk-uniphier-mux.c:47 uniphier_clk_mux_get_parent() warn: signedness bug returning '(-22)'

DISCUSSION Dan Carpenter 1 participant 1 message Dec 4, 2023

lore
Share & tools
lore
#0 lore raw

Hi Dragos,

First bad commit (maybe != root cause):

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   33cc938e65a98f1d29d0a18403dbbee050dcad9a
commit: f26e433185cb2830b933df3a4d378558fe2fccd9 arch: nios2: Enable the common clk subsystem on Nios2
config: nios2-randconfig-r081-20231120 (https://download.01.org/0day-ci/archive/20231204/[email protected]/config)
compiler: nios2-linux-gcc (GCC) 13.2.0
reproduce: (https://download.01.org/0day-ci/archive/20231204/[email protected]/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 <[email protected]>
| Reported-by: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

smatch warnings:
drivers/clk/uniphier/clk-uniphier-mux.c:47 uniphier_clk_mux_get_parent() warn: signedness bug returning '(-22)'

vim +47 drivers/clk/uniphier/clk-uniphier-mux.c

734d82f4a678e8 Masahiro Yamada 2016-09-16  31  static u8 uniphier_clk_mux_get_parent(struct clk_hw *hw)
734d82f4a678e8 Masahiro Yamada 2016-09-16  32  {
734d82f4a678e8 Masahiro Yamada 2016-09-16  33  	struct uniphier_clk_mux *mux = to_uniphier_clk_mux(hw);
734d82f4a678e8 Masahiro Yamada 2016-09-16  34  	int num_parents = clk_hw_get_num_parents(hw);
734d82f4a678e8 Masahiro Yamada 2016-09-16  35  	int ret;
c0ce317f0c8863 Masahiro Yamada 2016-10-17  36  	unsigned int val;
734d82f4a678e8 Masahiro Yamada 2016-09-16  37  	u8 i;
734d82f4a678e8 Masahiro Yamada 2016-09-16  38  
734d82f4a678e8 Masahiro Yamada 2016-09-16  39  	ret = regmap_read(mux->regmap, mux->reg, &val);
734d82f4a678e8 Masahiro Yamada 2016-09-16  40  	if (ret)
734d82f4a678e8 Masahiro Yamada 2016-09-16  41  		return ret;
734d82f4a678e8 Masahiro Yamada 2016-09-16  42  
734d82f4a678e8 Masahiro Yamada 2016-09-16  43  	for (i = 0; i < num_parents; i++)
734d82f4a678e8 Masahiro Yamada 2016-09-16  44  		if ((mux->masks[i] & val) == mux->vals[i])
734d82f4a678e8 Masahiro Yamada 2016-09-16  45  			return i;
734d82f4a678e8 Masahiro Yamada 2016-09-16  46  

734d82f4a678e8 Masahiro Yamada 2016-09-16 @47 return -EINVAL;

kbuild has decided to dig through ancient warnings today. This function is type u8 so returning -EINVAL doesn't work.

734d82f4a678e8 Masahiro Yamada 2016-09-16 48 }

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki