Commit 3cf5068f authored by Liu Bo's avatar Liu Bo Committed by David Sterba

Btrfs: unify error handling of btrfs_lookup_dir_item

Unify the error handling of directory item lookups using IS_ERR_OR_NULL.
No functional changes.
Signed-off-by: default avatarLiu Bo <bo.liu@linux.alibaba.com>
Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 3b2fd801
...@@ -3907,12 +3907,8 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans, ...@@ -3907,12 +3907,8 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans,
path->leave_spinning = 1; path->leave_spinning = 1;
di = btrfs_lookup_dir_item(trans, root, path, dir_ino, di = btrfs_lookup_dir_item(trans, root, path, dir_ino,
name, name_len, -1); name, name_len, -1);
if (IS_ERR(di)) { if (IS_ERR_OR_NULL(di)) {
ret = PTR_ERR(di); ret = di ? PTR_ERR(di) : -ENOENT;
goto err;
}
if (!di) {
ret = -ENOENT;
goto err; goto err;
} }
leaf = path->nodes[0]; leaf = path->nodes[0];
...@@ -4072,10 +4068,7 @@ static int btrfs_unlink_subvol(struct btrfs_trans_handle *trans, ...@@ -4072,10 +4068,7 @@ static int btrfs_unlink_subvol(struct btrfs_trans_handle *trans,
di = btrfs_lookup_dir_item(trans, root, path, dir_ino, di = btrfs_lookup_dir_item(trans, root, path, dir_ino,
name, name_len, -1); name, name_len, -1);
if (IS_ERR_OR_NULL(di)) { if (IS_ERR_OR_NULL(di)) {
if (!di) ret = di ? PTR_ERR(di) : -ENOENT;
ret = -ENOENT;
else
ret = PTR_ERR(di);
goto out; goto out;
} }
...@@ -5467,12 +5460,8 @@ static int btrfs_inode_by_name(struct inode *dir, struct dentry *dentry, ...@@ -5467,12 +5460,8 @@ static int btrfs_inode_by_name(struct inode *dir, struct dentry *dentry,
di = btrfs_lookup_dir_item(NULL, root, path, btrfs_ino(BTRFS_I(dir)), di = btrfs_lookup_dir_item(NULL, root, path, btrfs_ino(BTRFS_I(dir)),
name, namelen, 0); name, namelen, 0);
if (!di) { if (IS_ERR_OR_NULL(di)) {
ret = -ENOENT; ret = di ? PTR_ERR(di) : -ENOENT;
goto out;
}
if (IS_ERR(di)) {
ret = PTR_ERR(di);
goto out; goto out;
} }
......
...@@ -1693,12 +1693,8 @@ static int lookup_dir_item_inode(struct btrfs_root *root, ...@@ -1693,12 +1693,8 @@ static int lookup_dir_item_inode(struct btrfs_root *root,
di = btrfs_lookup_dir_item(NULL, root, path, di = btrfs_lookup_dir_item(NULL, root, path,
dir, name, name_len, 0); dir, name, name_len, 0);
if (!di) { if (IS_ERR_OR_NULL(di)) {
ret = -ENOENT; ret = di ? PTR_ERR(di) : -ENOENT;
goto out;
}
if (IS_ERR(di)) {
ret = PTR_ERR(di);
goto out; goto out;
} }
btrfs_dir_item_key_to_cpu(path->nodes[0], di, &key); btrfs_dir_item_key_to_cpu(path->nodes[0], di, &key);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment