[mcgrof-next:20210708-block-fixes-v2 41/89] drivers/block/rsxx/dev.c:200:6: warning: variable 'err' is used uninitialized whenever 'if' condition is false

From: kernel test robot
Date: Thu Jul 15 2021 - 10:59:58 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux-next.git 20210708-block-fixes-v2
head: db0174e39de7dc941f158ce53ee3af95b1635b62
commit: 2903597b8e65371aac6825294c9d99c2c36c94fd [41/89] block/rsxx: add error handling support for add_disk()
config: x86_64-randconfig-a001-20210715 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 0e49c54a8cbd3e779e5526a5888c683c01cc3c50)
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 x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux-next.git/commit/?id=2903597b8e65371aac6825294c9d99c2c36c94fd
git remote add mcgrof-next https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux-next.git
git fetch --no-tags mcgrof-next 20210708-block-fixes-v2
git checkout 2903597b8e65371aac6825294c9d99c2c36c94fd
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64

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

All warnings (new ones prefixed by >>):

>> drivers/block/rsxx/dev.c:200:6: warning: variable 'err' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
if (enable_blkdev) {
^~~~~~~~~~~~~
drivers/block/rsxx/dev.c:212:6: note: uninitialized use occurs here
if (err)
^~~
drivers/block/rsxx/dev.c:200:2: note: remove the 'if' if its condition is always true
if (enable_blkdev) {
^~~~~~~~~~~~~~~~~~~
drivers/block/rsxx/dev.c:195:9: note: initialize the variable 'err' to silence this warning
int err;
^
= 0
1 warning generated.


vim +200 drivers/block/rsxx/dev.c

8722ff8cdbfac9 josh.h.morris@xxxxxxxxxx 2013-02-05 192
8722ff8cdbfac9 josh.h.morris@xxxxxxxxxx 2013-02-05 193 int rsxx_attach_dev(struct rsxx_cardinfo *card)
8722ff8cdbfac9 josh.h.morris@xxxxxxxxxx 2013-02-05 194 {
2903597b8e6537 Luis Chamberlain 2021-07-13 195 int err;
2903597b8e6537 Luis Chamberlain 2021-07-13 196
8722ff8cdbfac9 josh.h.morris@xxxxxxxxxx 2013-02-05 197 mutex_lock(&card->dev_lock);
8722ff8cdbfac9 josh.h.morris@xxxxxxxxxx 2013-02-05 198
8722ff8cdbfac9 josh.h.morris@xxxxxxxxxx 2013-02-05 199 /* The block device requires the stripe size from the config. */
8722ff8cdbfac9 josh.h.morris@xxxxxxxxxx 2013-02-05 @200 if (enable_blkdev) {
8722ff8cdbfac9 josh.h.morris@xxxxxxxxxx 2013-02-05 201 if (card->config_valid)
8722ff8cdbfac9 josh.h.morris@xxxxxxxxxx 2013-02-05 202 set_capacity(card->gendisk, card->size8 >> 9);
8722ff8cdbfac9 josh.h.morris@xxxxxxxxxx 2013-02-05 203 else
8722ff8cdbfac9 josh.h.morris@xxxxxxxxxx 2013-02-05 204 set_capacity(card->gendisk, 0);
2903597b8e6537 Luis Chamberlain 2021-07-13 205 err = device_add_disk(CARD_TO_DEV(card), card->gendisk, NULL);
2903597b8e6537 Luis Chamberlain 2021-07-13 206 if (err == 0)
8722ff8cdbfac9 josh.h.morris@xxxxxxxxxx 2013-02-05 207 card->bdev_attached = 1;
8722ff8cdbfac9 josh.h.morris@xxxxxxxxxx 2013-02-05 208 }
8722ff8cdbfac9 josh.h.morris@xxxxxxxxxx 2013-02-05 209
8722ff8cdbfac9 josh.h.morris@xxxxxxxxxx 2013-02-05 210 mutex_unlock(&card->dev_lock);
8722ff8cdbfac9 josh.h.morris@xxxxxxxxxx 2013-02-05 211
2903597b8e6537 Luis Chamberlain 2021-07-13 212 if (err)
2903597b8e6537 Luis Chamberlain 2021-07-13 213 blk_cleanup_disk(card->gendisk);
2903597b8e6537 Luis Chamberlain 2021-07-13 214
2903597b8e6537 Luis Chamberlain 2021-07-13 215 return err;
8722ff8cdbfac9 josh.h.morris@xxxxxxxxxx 2013-02-05 216 }
8722ff8cdbfac9 josh.h.morris@xxxxxxxxxx 2013-02-05 217

:::::: The code at line 200 was first introduced by commit
:::::: 8722ff8cdbfac9c1b20e67bb067b455c48cb8e93 block: IBM RamSan 70/80 device driver

:::::: TO: josh.h.morris@xxxxxxxxxx <josh.h.morris@xxxxxxxxxx>
:::::: CC: Jens Axboe <axboe@xxxxxxxxx>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip