btrfs: use BTRFS_PATH_AUTO_FREE in load_global_roots()
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:47 +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/disk-io.c

index 9c9a48aeac5f5c83de1f644e509e7eb60fd810b1..28ff9c524fba78ad52ddcc06073a26f8d0de236a 100644 (file)
@@ -2196,8 +2196,8 @@ static int load_global_roots_objectid(struct btrfs_root *tree_root,
 
 static int load_global_roots(struct btrfs_root *tree_root)
 {
-       struct btrfs_path *path;
-       int ret = 0;
+       BTRFS_PATH_AUTO_FREE(path);
+       int ret;
 
        path = btrfs_alloc_path();
        if (!path)
@@ -2206,18 +2206,17 @@ static int load_global_roots(struct btrfs_root *tree_root)
        ret = load_global_roots_objectid(tree_root, path,
                                         BTRFS_EXTENT_TREE_OBJECTID, "extent");
        if (ret)
-               goto out;
+               return ret;
        ret = load_global_roots_objectid(tree_root, path,
                                         BTRFS_CSUM_TREE_OBJECTID, "csum");
        if (ret)
-               goto out;
+               return ret;
        if (!btrfs_fs_compat_ro(tree_root->fs_info, FREE_SPACE_TREE))
-               goto out;
+               return ret;
        ret = load_global_roots_objectid(tree_root, path,
                                         BTRFS_FREE_SPACE_TREE_OBJECTID,
                                         "free space");
-out:
-       btrfs_free_path(path);
+
        return ret;
 }