* [koverstreet-bcachefs:bcachefs-testing 251/252] fs/bcachefs/fs.c:960:8: warning: variable 'trans' is used uninitialized whenever 'if' condition is true
@ 2025-05-20 6:32 kernel test robot
0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2025-05-20 6:32 UTC (permalink / raw)
To: Kent Overstreet; +Cc: llvm, oe-kbuild-all
tree: https://github.com/koverstreet/bcachefs bcachefs-testing
head: 0d62becef614036a50005eca81fb5bd0b0790fb0
commit: ba3508b68bd71545e1d7eb062ebb0ee33fb1345a [251/252] bcachefs: Hook up d_casefold_enable()
config: hexagon-randconfig-002-20250520 (https://download.01.org/0day-ci/archive/20250520/202505201434.jPrDJIPG-lkp@intel.com/config)
compiler: clang version 21.0.0git (https://github.com/llvm/llvm-project f819f46284f2a79790038e1f6649172789734ae8)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250520/202505201434.jPrDJIPG-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/202505201434.jPrDJIPG-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> fs/bcachefs/fs.c:960:8: warning: variable 'trans' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
960 | if (ret)
| ^~~
fs/bcachefs/fs.c:1051:17: note: uninitialized use occurs here
1051 | bch2_trans_put(trans);
| ^~~~~
fs/bcachefs/fs.c:960:4: note: remove the 'if' if its condition is always false
960 | if (ret)
| ^~~~~~~~
961 | goto err;
| ~~~~~~~~
fs/bcachefs/fs.c:953:8: warning: variable 'trans' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
953 | if (ret)
| ^~~
fs/bcachefs/fs.c:1051:17: note: uninitialized use occurs here
1051 | bch2_trans_put(trans);
| ^~~~~
fs/bcachefs/fs.c:953:4: note: remove the 'if' if its condition is always false
953 | if (ret)
| ^~~~~~~~
954 | goto err;
| ~~~~~~~~
fs/bcachefs/fs.c:926:27: note: initialize the variable 'trans' to silence this warning
926 | struct btree_trans *trans;
| ^
| = NULL
2 warnings generated.
vim +960 fs/bcachefs/fs.c
911
912 static int bch2_rename2(struct mnt_idmap *idmap,
913 struct inode *src_vdir, struct dentry *src_dentry,
914 struct inode *dst_vdir, struct dentry *dst_dentry,
915 unsigned flags)
916 {
917 struct bch_fs *c = src_vdir->i_sb->s_fs_info;
918 struct bch_inode_info *src_dir = to_bch_ei(src_vdir);
919 struct bch_inode_info *dst_dir = to_bch_ei(dst_vdir);
920 struct bch_inode_info *src_inode = to_bch_ei(src_dentry->d_inode);
921 struct bch_inode_info *dst_inode = to_bch_ei(dst_dentry->d_inode);
922 struct bch_inode_unpacked dst_dir_u, src_dir_u;
923 struct bch_inode_unpacked src_inode_u, dst_inode_u, *whiteout_inode_u;
924 struct d_casefold_enable casefold_enable_src = {};
925 struct d_casefold_enable casefold_enable_dst = {};
926 struct btree_trans *trans;
927 enum bch_rename_mode mode = flags & RENAME_EXCHANGE
928 ? BCH_RENAME_EXCHANGE
929 : dst_dentry->d_inode
930 ? BCH_RENAME_OVERWRITE : BCH_RENAME;
931 bool whiteout = !!(flags & RENAME_WHITEOUT);
932 int ret;
933
934 if (flags & ~(RENAME_NOREPLACE|RENAME_EXCHANGE|RENAME_WHITEOUT))
935 return -EINVAL;
936
937 if (mode == BCH_RENAME_OVERWRITE) {
938 ret = filemap_write_and_wait_range(src_inode->v.i_mapping,
939 0, LLONG_MAX);
940 if (ret)
941 return ret;
942 }
943
944 bch2_lock_inodes(INODE_UPDATE_LOCK,
945 src_dir,
946 dst_dir,
947 src_inode,
948 dst_inode);
949
950 if (src_dir != dst_dir) {
951 if (bch2_inode_casefold(c, &src_inode->ei_inode)) {
952 ret = d_casefold_enable(dst_dentry, &casefold_enable_dst);
953 if (ret)
954 goto err;
955 }
956
957 if (mode == BCH_RENAME_EXCHANGE &&
958 bch2_inode_casefold(c, &dst_inode->ei_inode)) {
959 ret = d_casefold_enable(src_dentry, &casefold_enable_src);
> 960 if (ret)
961 goto err;
962 }
963 }
964
965 trans = bch2_trans_get(c);
966
967 ret = bch2_subvol_is_ro_trans(trans, src_dir->ei_inum.subvol) ?:
968 bch2_subvol_is_ro_trans(trans, dst_dir->ei_inum.subvol);
969 if (ret)
970 goto err_tx_restart;
971
972 if (inode_attr_changing(dst_dir, src_inode, Inode_opt_project)) {
973 ret = bch2_fs_quota_transfer(c, src_inode,
974 dst_dir->ei_qid,
975 1 << QTYP_PRJ,
976 KEY_TYPE_QUOTA_PREALLOC);
977 if (ret)
978 goto err;
979 }
980
981 if (mode == BCH_RENAME_EXCHANGE &&
982 inode_attr_changing(src_dir, dst_inode, Inode_opt_project)) {
983 ret = bch2_fs_quota_transfer(c, dst_inode,
984 src_dir->ei_qid,
985 1 << QTYP_PRJ,
986 KEY_TYPE_QUOTA_PREALLOC);
987 if (ret)
988 goto err;
989 }
990 retry:
991 bch2_trans_begin(trans);
992
993 ret = bch2_rename_trans(trans,
994 inode_inum(src_dir), &src_dir_u,
995 inode_inum(dst_dir), &dst_dir_u,
996 &src_inode_u,
997 &dst_inode_u,
998 &src_dentry->d_name,
999 &dst_dentry->d_name,
1000 mode);
1001 if (unlikely(ret))
1002 goto err_tx_restart;
1003
1004 if (whiteout) {
1005 whiteout_inode_u = bch2_trans_kmalloc_nomemzero(trans, sizeof(*whiteout_inode_u));
1006 ret = PTR_ERR_OR_ZERO(whiteout_inode_u);
1007 if (unlikely(ret))
1008 goto err_tx_restart;
1009 bch2_inode_init_early(c, whiteout_inode_u);
1010
1011 ret = bch2_create_trans(trans,
1012 inode_inum(src_dir), &src_dir_u,
1013 whiteout_inode_u,
1014 &src_dentry->d_name,
1015 from_kuid(i_user_ns(&src_dir->v), current_fsuid()),
1016 from_kgid(i_user_ns(&src_dir->v), current_fsgid()),
1017 S_IFCHR|WHITEOUT_MODE, 0,
1018 NULL, NULL, (subvol_inum) { 0 }, 0) ?:
1019 bch2_quota_acct(c, bch_qid(whiteout_inode_u), Q_INO, 1,
1020 KEY_TYPE_QUOTA_PREALLOC);
1021 if (unlikely(ret))
1022 goto err_tx_restart;
1023 }
1024
1025 ret = bch2_trans_commit(trans, NULL, NULL, 0);
1026 if (unlikely(ret)) {
1027 err_tx_restart:
1028 if (bch2_err_matches(ret, BCH_ERR_transaction_restart))
1029 goto retry;
1030 goto err;
1031 }
1032
1033 BUG_ON(src_inode->v.i_ino != src_inode_u.bi_inum);
1034 BUG_ON(dst_inode &&
1035 dst_inode->v.i_ino != dst_inode_u.bi_inum);
1036
1037 bch2_inode_update_after_write(trans, src_dir, &src_dir_u,
1038 ATTR_MTIME|ATTR_CTIME|ATTR_SIZE);
1039
1040 if (src_dir != dst_dir)
1041 bch2_inode_update_after_write(trans, dst_dir, &dst_dir_u,
1042 ATTR_MTIME|ATTR_CTIME|ATTR_SIZE);
1043
1044 bch2_inode_update_after_write(trans, src_inode, &src_inode_u,
1045 ATTR_CTIME);
1046
1047 if (dst_inode)
1048 bch2_inode_update_after_write(trans, dst_inode, &dst_inode_u,
1049 ATTR_CTIME);
1050 err:
1051 bch2_trans_put(trans);
1052
1053 bch2_fs_quota_transfer(c, src_inode,
1054 bch_qid(&src_inode->ei_inode),
1055 1 << QTYP_PRJ,
1056 KEY_TYPE_QUOTA_NOCHECK);
1057 if (dst_inode)
1058 bch2_fs_quota_transfer(c, dst_inode,
1059 bch_qid(&dst_inode->ei_inode),
1060 1 << QTYP_PRJ,
1061 KEY_TYPE_QUOTA_NOCHECK);
1062
1063 bch2_unlock_inodes(INODE_UPDATE_LOCK,
1064 src_dir,
1065 dst_dir,
1066 src_inode,
1067 dst_inode);
1068
1069 d_casefold_enable_commit(&casefold_enable_dst, ret);
1070 d_casefold_enable_commit(&casefold_enable_src, ret);
1071
1072 return bch2_err_class(ret);
1073 }
1074
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-05-20 6:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-20 6:32 [koverstreet-bcachefs:bcachefs-testing 251/252] fs/bcachefs/fs.c:960:8: warning: variable 'trans' is used uninitialized whenever 'if' condition is true kernel test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.