btrfs: use BTRFS_PATH_AUTO_FREE in clear_free_space_tree()
authorDavid Sterba <dsterba@suse.com>
Mon, 24 Feb 2025 08:15:17 +0000 (09:15 +0100)
committerDavid Sterba <dsterba@suse.com>
Tue, 18 Mar 2025 19:35:48 +0000 (20:35 +0100)
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>
fs/btrfs/free-space-tree.c

index d1ec02d5e1f6a9d6c3adda2215c2b31e90dd7d80..589ff73ed13a54819e6cf98b3fadf9a1b14da6f0 100644 (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)