btrfs: use BTRFS_PATH_AUTO_FREE in clear_free_space_tree()

This is the trivial pattern for path auto free, initialize at the
beginning and free at the end with simple goto -> return conversions.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2025-02-24 09:15:17 +01:00
parent 3bfd9ead81
commit 2e70d126f9

View file

@ -1215,7 +1215,7 @@ out_clear:
static int clear_free_space_tree(struct btrfs_trans_handle *trans,
struct btrfs_root *root)
{
struct btrfs_path *path;
BTRFS_PATH_AUTO_FREE(path);
struct btrfs_key key;
int nr;
int ret;
@ -1231,7 +1231,7 @@ static int clear_free_space_tree(struct btrfs_trans_handle *trans,
while (1) {
ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
if (ret < 0)
goto out;
return ret;
nr = btrfs_header_nritems(path->nodes[0]);
if (!nr)
@ -1240,15 +1240,12 @@ static int clear_free_space_tree(struct btrfs_trans_handle *trans,
path->slots[0] = 0;
ret = btrfs_del_items(trans, root, path, 0, nr);
if (ret)
goto out;
return ret;
btrfs_release_path(path);
}
ret = 0;
out:
btrfs_free_path(path);
return ret;
return 0;
}
int btrfs_delete_free_space_tree(struct btrfs_fs_info *fs_info)