[djwong-xfs:vectorized-scrub 242/312] fs/xfs/scrub/rtrmap_repair.c:350:6: warning: variable 'error' is used uninitialized whenever 'if' condition is false

From: kernel test robot
Date: Mon Oct 25 2021 - 17:02:26 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux.git vectorized-scrub
head: 1804f4671b76293a8a792e5be4e514cefc0f012f
commit: 28686c6c3ab632596568e0dbb4c56f955b0c3930 [242/312] xfs: online repair of the realtime rmap btree
config: hexagon-randconfig-r031-20211025 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project a461fa64bb37cffd73f683c74f6b0780379fc2ca)
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
# https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux.git/commit/?id=28686c6c3ab632596568e0dbb4c56f955b0c3930
git remote add djwong-xfs https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux.git
git fetch --no-tags djwong-xfs vectorized-scrub
git checkout 28686c6c3ab632596568e0dbb4c56f955b0c3930
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=hexagon

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

All warnings (new ones prefixed by >>):

>> fs/xfs/scrub/rtrmap_repair.c:350:6: warning: variable 'error' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
if (XFS_IS_REALTIME_INODE(ip)) {
^~~~~~~~~~~~~~~~~~~~~~~~~
fs/xfs/xfs_linux.h:241:2: note: expanded from macro 'XFS_IS_REALTIME_INODE'
(((ip)->i_diflags & XFS_DIFLAG_REALTIME) && \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/xfs/scrub/rtrmap_repair.c:359:9: note: uninitialized use occurs here
return error;
^~~~~
fs/xfs/scrub/rtrmap_repair.c:350:2: note: remove the 'if' if its condition is always true
if (XFS_IS_REALTIME_INODE(ip)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> fs/xfs/scrub/rtrmap_repair.c:350:6: warning: variable 'error' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized]
if (XFS_IS_REALTIME_INODE(ip)) {
^~~~~~~~~~~~~~~~~~~~~~~~~
fs/xfs/xfs_linux.h:241:3: note: expanded from macro 'XFS_IS_REALTIME_INODE'
(((ip)->i_diflags & XFS_DIFLAG_REALTIME) && \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/xfs/scrub/rtrmap_repair.c:359:9: note: uninitialized use occurs here
return error;
^~~~~
fs/xfs/scrub/rtrmap_repair.c:350:6: note: remove the '&&' if its condition is always true
if (XFS_IS_REALTIME_INODE(ip)) {
^
fs/xfs/xfs_linux.h:241:3: note: expanded from macro 'XFS_IS_REALTIME_INODE'
(((ip)->i_diflags & XFS_DIFLAG_REALTIME) && \
^
fs/xfs/scrub/rtrmap_repair.c:344:13: note: initialize the variable 'error' to silence this warning
int error;
^
= 0
2 warnings generated.


vim +350 fs/xfs/scrub/rtrmap_repair.c

336
337 /* Record reverse mappings for a file. */
338 STATIC int
339 xrep_rtrmap_scan_inode(
340 struct xrep_rtrmap *rr,
341 struct xfs_inode *ip)
342 {
343 unsigned int lock_mode;
344 int error;
345
346 xfs_ilock(ip, XFS_IOLOCK_SHARED | XFS_MMAPLOCK_SHARED);
347 lock_mode = xfs_ilock_data_map_shared(ip);
348
349 /* Check the data fork if it's on the realtime device. */
> 350 if (XFS_IS_REALTIME_INODE(ip)) {
351 error = xrep_rtrmap_scan_dfork(rr, ip);
352 if (error)
353 goto out_unlock;
354 }
355
356 xchk_iscan_mark_visited(&rr->iscan, ip);
357 out_unlock:
358 xfs_iunlock(ip, XFS_IOLOCK_SHARED | XFS_MMAPLOCK_SHARED | lock_mode);
359 return error;
360 }
361

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

Attachment: .config.gz
Description: application/gzip