Skip to contentSkip to conversation

fs/bcachefs/fs.c:1723:7: warning: variable 'ret' is used uninitialized whenever 'if' condition is true

PATCH kernel test robot 1 participant 1 message May 29, 2024

lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw
tree:   https://evilpiepirate.org/git/bcachefs.git master
head:   f1229fe4c8f0262d814eae41e4c55627818205fe
commit: 6223304fab6387f4fdefd0681dd88a76b06f960f [53/77] bcachefs: use new mount API
config: i386-buildonly-randconfig-001-20240529 (https://download.01.org/0day-ci/archive/20240529/[email protected]/config)
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240529/[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]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> fs/bcachefs/fs.c:1723:7: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
    1723 |                 if (opts.read_only) {
         |                     ^~~~~~~~~~~~~~
   fs/bcachefs/fs.c:1747:24: note: uninitialized use occurs here
    1747 |         return bch2_err_class(ret);
         |                               ^~~
   fs/bcachefs/fs.c:1723:3: note: remove the 'if' if its condition is always false
    1723 |                 if (opts.read_only) {
         |                 ^~~~~~~~~~~~~~~~~~~~~
    1724 |                         bch2_fs_read_only(c);
         |                         ~~~~~~~~~~~~~~~~~~~~~
    1725 | 
    1726 |                         sb->s_flags |= SB_RDONLY;
         |                         ~~~~~~~~~~~~~~~~~~~~~~~~~
    1727 |                 } else {
         |                 ~~~~~~
>> fs/bcachefs/fs.c:1720:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
    1720 |         if (opts.read_only != c->opts.read_only) {
         |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/bcachefs/fs.c:1747:24: note: uninitialized use occurs here
    1747 |         return bch2_err_class(ret);
         |                               ^~~
   fs/bcachefs/fs.c:1720:2: note: remove the 'if' if its condition is always true
    1720 |         if (opts.read_only != c->opts.read_only) {
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/bcachefs/fs.c:1716:9: note: initialize the variable 'ret' to silence this warning
    1716 |         int ret;
         |                ^
         |                 = 0

2 warnings generated.

vim +1723 fs/bcachefs/fs.c

1c6fdbd8f2465d Kent Overstreet     2017-03-16  1711  
6223304fab6387 Thomas Bertschinger 2024-05-27  1712  static int bch2_remount(struct super_block *sb, int *flags,
6223304fab6387 Thomas Bertschinger 2024-05-27  1713  			struct bch_opts opts)
1c6fdbd8f2465d Kent Overstreet     2017-03-16  1714  {
1c6fdbd8f2465d Kent Overstreet     2017-03-16  1715  	struct bch_fs *c = sb->s_fs_info;
1c6fdbd8f2465d Kent Overstreet     2017-03-16  1716  	int ret;
1c6fdbd8f2465d Kent Overstreet     2017-03-16  1717  
62719cf33c3ad6 Kent Overstreet     2023-12-23  1718  	opt_set(opts, read_only, (*flags & SB_RDONLY) != 0);
62719cf33c3ad6 Kent Overstreet     2023-12-23  1719  
1c6fdbd8f2465d Kent Overstreet     2017-03-16 @1720  	if (opts.read_only != c->opts.read_only) {
1ada160618d66b Kent Overstreet     2020-06-15  1721  		down_write(&c->state_lock);
1c6fdbd8f2465d Kent Overstreet     2017-03-16  1722  
1c6fdbd8f2465d Kent Overstreet     2017-03-16 @1723  		if (opts.read_only) {
1c6fdbd8f2465d Kent Overstreet     2017-03-16  1724  			bch2_fs_read_only(c);
1c6fdbd8f2465d Kent Overstreet     2017-03-16  1725  
1c6fdbd8f2465d Kent Overstreet     2017-03-16  1726  			sb->s_flags |= SB_RDONLY;
1c6fdbd8f2465d Kent Overstreet     2017-03-16  1727  		} else {
134915f3d38d83 Kent Overstreet     2019-03-21  1728  			ret = bch2_fs_read_write(c);
134915f3d38d83 Kent Overstreet     2019-03-21  1729  			if (ret) {
134915f3d38d83 Kent Overstreet     2019-03-21  1730  				bch_err(c, "error going rw: %i", ret);
1ada160618d66b Kent Overstreet     2020-06-15  1731  				up_write(&c->state_lock);
5c1ef830f67860 Kent Overstreet     2022-09-18  1732  				ret = -EINVAL;
5c1ef830f67860 Kent Overstreet     2022-09-18  1733  				goto err;
1c6fdbd8f2465d Kent Overstreet     2017-03-16  1734  			}
1c6fdbd8f2465d Kent Overstreet     2017-03-16  1735  
1c6fdbd8f2465d Kent Overstreet     2017-03-16  1736  			sb->s_flags &= ~SB_RDONLY;
1c6fdbd8f2465d Kent Overstreet     2017-03-16  1737  		}
1c6fdbd8f2465d Kent Overstreet     2017-03-16  1738  
1c6fdbd8f2465d Kent Overstreet     2017-03-16  1739  		c->opts.read_only = opts.read_only;
1c6fdbd8f2465d Kent Overstreet     2017-03-16  1740  
1ada160618d66b Kent Overstreet     2020-06-15  1741  		up_write(&c->state_lock);
1c6fdbd8f2465d Kent Overstreet     2017-03-16  1742  	}
1c6fdbd8f2465d Kent Overstreet     2017-03-16  1743  
96dea3d599dbc3 Kent Overstreet     2023-09-12  1744  	if (opt_defined(opts, errors))
1c6fdbd8f2465d Kent Overstreet     2017-03-16  1745  		c->opts.errors = opts.errors;
5c1ef830f67860 Kent Overstreet     2022-09-18  1746  err:
5c1ef830f67860 Kent Overstreet     2022-09-18  1747  	return bch2_err_class(ret);
1c6fdbd8f2465d Kent Overstreet     2017-03-16  1748  }
1c6fdbd8f2465d Kent Overstreet     2017-03-16  1749  

:::::: The code at line 1723 was first introduced by commit :::::: 1c6fdbd8f2465ddfb73a01ec620cbf3d14044e1a bcachefs: Initial commit

:::::: TO: Kent Overstreet <[email protected]> :::::: CC: Kent Overstreet <[email protected]>

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