btrfs: get fs_info from eb in btrfs_print_leaf, remove argument
Hello David Sterba,
This is a semi-automatic email about new static checker warnings.
The patch c042dd070450: "btrfs: get fs_info from eb in btrfs_print_leaf, remove argument" from Jun 29, 2017, leads to the following Smatch complaint:
fs/btrfs/print-tree.c:181 btrfs_print_leaf()
warn: variable dereferenced before check 'l' (see line 166)
fs/btrfs/print-tree.c
165 {
166 struct btrfs_fs_info *fs_info = l->fs_info;
^^^^^^^^^^New dereference.
167 int i;
168 u32 type, nr;
169 struct btrfs_item *item;
170 struct btrfs_root_item *ri;
171 struct btrfs_dir_item *di;
172 struct btrfs_inode_item *ii;
173 struct btrfs_block_group_item *bi;
174 struct btrfs_file_extent_item *fi;
175 struct btrfs_extent_data_ref *dref;
176 struct btrfs_shared_data_ref *sref;
177 struct btrfs_dev_extent *dev_extent;
178 struct btrfs_key key;
179 struct btrfs_key found_key;
180
181 if (!l)
^^
Checked too late.
182 return;
183
regards,
dan carpenter
Quoted 33 lines · Dan Carpenter
Hello David Sterba,
This is a semi-automatic email about new static checker warnings.
The patch
c042dd070450: "btrfs: getfs_infofrom eb inbtrfs_print_leaf, remove argument" from Jun 29, 2017, leads to the following Smatch complaint:
fs/btrfs/print-tree.c:181btrfs_print_leaf()
warn: variable dereferenced before check 'l' (see line 166)
fs/btrfs/print-tree.c165 { 166 struct btrfs_fs_info *fs_info = l->fs_info; ^^^^^^^^^^New dereference.
167 int i; 168 u32 type, nr; 169 struct btrfs_item *item; 170 struct btrfs_root_item *ri; 171 struct btrfs_dir_item *di; 172 struct btrfs_inode_item *ii; 173 struct btrfs_block_group_item *bi; 174 struct btrfs_file_extent_item *fi; 175 struct btrfs_extent_data_ref *dref; 176 struct btrfs_shared_data_ref *sref; 177 struct btrfs_dev_extent *dev_extent; 178 struct btrfs_key key; 179 struct btrfs_key found_key; 180 181 if (!l) ^^
Quoted 1 line
Checked too late.
Thanks, I've moved the fs_info initialization after this check. In both patches (btrfs_print_leaf and btrfs_print_tree).