Re: [PATCH V5 2/2] iio: proximity: aw9610x: Add support for aw9610x proximity sensor

From: Dan Carpenter
Date: Mon Jul 29 2024 - 11:28:48 EST


Hi,

kernel test robot noticed the following build warnings:

url: https://github.com/intel-lab-lkp/linux/commits/wangshuaijie-awinic-com/dt-bindings-iio-aw9610x-Add-bindings-for-aw9610x-sensor/20240726-141450
base: 1722389b0d863056d78287a120a1d6cadb8d4f7b
patch link: https://lore.kernel.org/r/20240726061312.1371450-3-wangshuaijie%40awinic.com
patch subject: [PATCH V5 2/2] iio: proximity: aw9610x: Add support for aw9610x proximity sensor
config: x86_64-randconfig-r071-20240728 (https://download.01.org/0day-ci/archive/20240728/202407282339.D0ICTGHF-lkp@xxxxxxxxx/config)
compiler: gcc-13 (Ubuntu 13.2.0-4ubuntu3) 13.2.0

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>
| Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
| Closes: https://lore.kernel.org/r/202407282339.D0ICTGHF-lkp@xxxxxxxxx/

smatch warnings:
drivers/iio/proximity/aw9610x.c:575 aw9610x_read_chipid() error: uninitialized symbol 'reg_val'.

vim +/reg_val +575 drivers/iio/proximity/aw9610x.c

1e0a5bf0d81329 shuaijie wang 2024-07-26 558 static int aw9610x_read_chipid(struct aw9610x *aw9610x)
1e0a5bf0d81329 shuaijie wang 2024-07-26 559 {
1e0a5bf0d81329 shuaijie wang 2024-07-26 560 unsigned char cnt = 0;
1e0a5bf0d81329 shuaijie wang 2024-07-26 561 u32 reg_val;
1e0a5bf0d81329 shuaijie wang 2024-07-26 562 int ret;
1e0a5bf0d81329 shuaijie wang 2024-07-26 563
1e0a5bf0d81329 shuaijie wang 2024-07-26 564 while (cnt < AW_READ_CHIPID_RETRIES) {

if cnt == AW_READ_CHIPID_RETRIES then reg_value is uninitialized

1e0a5bf0d81329 shuaijie wang 2024-07-26 565 ret = aw9610x_i2c_read(aw9610x, REG_CHIPID, &reg_val);
1e0a5bf0d81329 shuaijie wang 2024-07-26 566 if (ret < 0) {
1e0a5bf0d81329 shuaijie wang 2024-07-26 567 cnt++;
1e0a5bf0d81329 shuaijie wang 2024-07-26 568 usleep_range(2000, 3000);
1e0a5bf0d81329 shuaijie wang 2024-07-26 569 } else {
1e0a5bf0d81329 shuaijie wang 2024-07-26 570 reg_val = FIELD_GET(AW9610X_CHIPID_MASK, reg_val);
1e0a5bf0d81329 shuaijie wang 2024-07-26 571 break;
1e0a5bf0d81329 shuaijie wang 2024-07-26 572 }
1e0a5bf0d81329 shuaijie wang 2024-07-26 573 }
1e0a5bf0d81329 shuaijie wang 2024-07-26 574
1e0a5bf0d81329 shuaijie wang 2024-07-26 @575 if (reg_val == AW9610X_CHIP_ID)
^^^^^^^^^^^^^^^^^^^^^^^^^^
It's harmless but the checker is correct to warn

1e0a5bf0d81329 shuaijie wang 2024-07-26 576 return 0;
1e0a5bf0d81329 shuaijie wang 2024-07-26 577
1e0a5bf0d81329 shuaijie wang 2024-07-26 578 return -EINVAL;
1e0a5bf0d81329 shuaijie wang 2024-07-26 579 }

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