[amir73il:fsnotify-perf 3/5] fs/notify/mark.c:198:11: warning: variable 'sb' is used uninitialized whenever 'if' condition is false

From: kernel test robot
Date: Tue Aug 03 2021 - 05:36:14 EST


tree: https://github.com/amir73il/linux fsnotify-perf
head: 7446ba772ae107ab937cd04e8800236d6235dc4c
commit: 73c769c1b2c30c19870d29f2153bbe1c1750cc88 [3/5] fsnotify: count all objects with attached connectors
config: s390-randconfig-r014-20210803 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 4f71f59bf3d9914188a11d0c41bedbb339d36ff5)
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 s390 cross compiling tool for clang build
# apt-get install binutils-s390x-linux-gnu
# https://github.com/amir73il/linux/commit/73c769c1b2c30c19870d29f2153bbe1c1750cc88
git remote add amir73il https://github.com/amir73il/linux
git fetch --no-tags amir73il fsnotify-perf
git checkout 73c769c1b2c30c19870d29f2153bbe1c1750cc88
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=s390

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/notify/mark.c:198:11: warning: variable 'sb' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
else if (conn->type == FSNOTIFY_OBJ_TYPE_SB)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/notify/mark.c:201:19: note: uninitialized use occurs here
atomic_long_inc(&sb->s_fsnotify_obj_refs);
^~
fs/notify/mark.c:198:7: note: remove the 'if' if its condition is always true
else if (conn->type == FSNOTIFY_OBJ_TYPE_SB)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/notify/mark.c:189:24: note: initialize the variable 'sb' to silence this warning
struct super_block *sb;
^
= NULL
fs/notify/mark.c:215:11: warning: variable 'sb' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
else if (conn->type == FSNOTIFY_OBJ_TYPE_SB)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/notify/mark.c:218:32: note: uninitialized use occurs here
if (atomic_long_dec_and_test(&sb->s_fsnotify_obj_refs))
^~
fs/notify/mark.c:215:7: note: remove the 'if' if its condition is always true
else if (conn->type == FSNOTIFY_OBJ_TYPE_SB)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/notify/mark.c:206:24: note: initialize the variable 'sb' to silence this warning
struct super_block *sb;
^
= NULL
fs/notify/mark.c:263:22: warning: variable 'sb' set but not used [-Wunused-but-set-variable]
struct super_block *sb;
^
3 warnings generated.


vim +198 fs/notify/mark.c

186
187 static void fsnotify_get_object_ref(struct fsnotify_mark_connector *conn)
188 {
189 struct super_block *sb;
190
191 if (conn->type == FSNOTIFY_OBJ_TYPE_DETACHED)
192 return;
193
194 if (conn->type == FSNOTIFY_OBJ_TYPE_INODE)
195 sb = fsnotify_conn_inode(conn)->i_sb;
196 else if (conn->type == FSNOTIFY_OBJ_TYPE_VFSMOUNT)
197 sb = fsnotify_conn_mount(conn)->mnt.mnt_sb;
> 198 else if (conn->type == FSNOTIFY_OBJ_TYPE_SB)
199 sb = fsnotify_conn_sb(conn);
200
201 atomic_long_inc(&sb->s_fsnotify_obj_refs);
202 }
203

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

Attachment: .config.gz
Description: application/gzip