From: kernel test robot <lkp@intel.com>
To: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev
Subject: [jic23-iio:sparse-friendly-direct-mode 52/166] drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c:1850:7: warning: variable 'err' is used uninitialized whenever 'if' condition is false
Date: Mon, 3 Feb 2025 08:15:29 +0800 [thread overview]
Message-ID: <202502030800.FBFCF1CE-lkp@intel.com> (raw)
tree: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git sparse-friendly-direct-mode
head: bada9cd0235b288b74ee2bd65fd4223d71f62b02
commit: 3e53e337047467484ef3689555b5fe392679790b [52/166] iio: imu: st_lsm6dsx: Switch to sparse friendly claim/release_direct()
config: hexagon-randconfig-002-20250203 (https://download.01.org/0day-ci/archive/20250203/202502030800.FBFCF1CE-lkp@intel.com/config)
compiler: clang version 21.0.0git (https://github.com/llvm/llvm-project 355d0b186f178668b103068537e517f3d52ad639)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250203/202502030800.FBFCF1CE-lkp@intel.com/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@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202502030800.FBFCF1CE-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c:1850:7: warning: variable 'err' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
1850 | if (val < 0)
| ^~~~~~~
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c:1863:9: note: uninitialized use occurs here
1863 | return err;
| ^~~
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c:1850:3: note: remove the 'if' if its condition is always true
1850 | if (val < 0)
| ^~~~~~~~~~~~
1851 | err = val;
| ~
1852 | else
| ~~~~
1853 | sensor->odr = val;
| ~~~~~~~~~~~~~~~~~
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c:1836:9: note: initialize the variable 'err' to silence this warning
1836 | int err;
| ^
| = 0
1 warning generated.
vim +1850 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
290a6ce11d938b Lorenzo Bianconi 2017-01-10 1830
290a6ce11d938b Lorenzo Bianconi 2017-01-10 1831 static int st_lsm6dsx_write_raw(struct iio_dev *iio_dev,
290a6ce11d938b Lorenzo Bianconi 2017-01-10 1832 struct iio_chan_spec const *chan,
290a6ce11d938b Lorenzo Bianconi 2017-01-10 1833 int val, int val2, long mask)
290a6ce11d938b Lorenzo Bianconi 2017-01-10 1834 {
290a6ce11d938b Lorenzo Bianconi 2017-01-10 1835 struct st_lsm6dsx_sensor *sensor = iio_priv(iio_dev);
290a6ce11d938b Lorenzo Bianconi 2017-01-10 1836 int err;
290a6ce11d938b Lorenzo Bianconi 2017-01-10 1837
3e53e337047467 Jonathan Cameron 2025-01-05 1838 if (!iio_device_claim_direct(iio_dev))
3e53e337047467 Jonathan Cameron 2025-01-05 1839 return -EBUSY;
290a6ce11d938b Lorenzo Bianconi 2017-01-10 1840
290a6ce11d938b Lorenzo Bianconi 2017-01-10 1841 switch (mask) {
290a6ce11d938b Lorenzo Bianconi 2017-01-10 1842 case IIO_CHAN_INFO_SCALE:
290a6ce11d938b Lorenzo Bianconi 2017-01-10 1843 err = st_lsm6dsx_set_full_scale(sensor, val2);
290a6ce11d938b Lorenzo Bianconi 2017-01-10 1844 break;
2ccc15036d812e Lorenzo Bianconi 2017-04-02 1845 case IIO_CHAN_INFO_SAMP_FREQ: {
2ccc15036d812e Lorenzo Bianconi 2017-04-02 1846 u8 data;
2ccc15036d812e Lorenzo Bianconi 2017-04-02 1847
f8710f0357bc36 Lorenzo Bianconi 2019-11-03 1848 val = val * 1000 + val2 / 1000;
fc3f6ad7f5dc6c Lorenzo Bianconi 2019-10-27 1849 val = st_lsm6dsx_check_odr(sensor, val, &data);
fc3f6ad7f5dc6c Lorenzo Bianconi 2019-10-27 @1850 if (val < 0)
fc3f6ad7f5dc6c Lorenzo Bianconi 2019-10-27 1851 err = val;
fc3f6ad7f5dc6c Lorenzo Bianconi 2019-10-27 1852 else
5e3c3e3382e87a Lorenzo Bianconi 2017-09-18 1853 sensor->odr = val;
290a6ce11d938b Lorenzo Bianconi 2017-01-10 1854 break;
2ccc15036d812e Lorenzo Bianconi 2017-04-02 1855 }
290a6ce11d938b Lorenzo Bianconi 2017-01-10 1856 default:
290a6ce11d938b Lorenzo Bianconi 2017-01-10 1857 err = -EINVAL;
290a6ce11d938b Lorenzo Bianconi 2017-01-10 1858 break;
290a6ce11d938b Lorenzo Bianconi 2017-01-10 1859 }
290a6ce11d938b Lorenzo Bianconi 2017-01-10 1860
3e53e337047467 Jonathan Cameron 2025-01-05 1861 iio_device_release_direct(iio_dev);
290a6ce11d938b Lorenzo Bianconi 2017-01-10 1862
290a6ce11d938b Lorenzo Bianconi 2017-01-10 1863 return err;
290a6ce11d938b Lorenzo Bianconi 2017-01-10 1864 }
290a6ce11d938b Lorenzo Bianconi 2017-01-10 1865
:::::: The code at line 1850 was first introduced by commit
:::::: fc3f6ad7f5dc6c899fbda0255865737bac88c2e0 iio: imu: st_lsm6dsx: fix ODR check in st_lsm6dsx_write_raw
:::::: TO: Lorenzo Bianconi <lorenzo@kernel.org>
:::::: CC: Jonathan Cameron <Jonathan.Cameron@huawei.com>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
reply other threads:[~2025-02-03 0:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202502030800.FBFCF1CE-lkp@intel.com \
--to=lkp@intel.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=llvm@lists.linux.dev \
--cc=oe-kbuild-all@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox