btrfs: use BTRFS_PATH_AUTO_FREE in btrfs_del_inode_extref()
authorDavid Sterba <dsterba@suse.com>
Tue, 1 Apr 2025 23:18:11 +0000 (01:18 +0200)
committerDavid Sterba <dsterba@suse.com>
Thu, 15 May 2025 12:30:42 +0000 (14:30 +0200)
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: Daniel Vacek <neelx@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/inode-item.c

index 3530de0618c8be40381ac159ea259b13bf6d7266..b920250e9e8ff7c323ed388c168ca63abc405a32 100644 (file)
@@ -109,7 +109,7 @@ static int btrfs_del_inode_extref(struct btrfs_trans_handle *trans,
                                  u64 inode_objectid, u64 ref_objectid,
                                  u64 *index)
 {
-       struct btrfs_path *path;
+       BTRFS_PATH_AUTO_FREE(path);
        struct btrfs_key key;
        struct btrfs_inode_extref *extref;
        struct extent_buffer *leaf;
@@ -129,9 +129,9 @@ static int btrfs_del_inode_extref(struct btrfs_trans_handle *trans,
 
        ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
        if (ret > 0)
-               ret = -ENOENT;
+               return -ENOENT;
        if (ret < 0)
-               goto out;
+               return ret;
 
        /*
         * Sanity check - did we find the right item for this name?
@@ -142,8 +142,7 @@ static int btrfs_del_inode_extref(struct btrfs_trans_handle *trans,
                                                ref_objectid, name);
        if (!extref) {
                btrfs_abort_transaction(trans, -ENOENT);
-               ret = -ENOENT;
-               goto out;
+               return -ENOENT;
        }
 
        leaf = path->nodes[0];
@@ -152,12 +151,8 @@ static int btrfs_del_inode_extref(struct btrfs_trans_handle *trans,
                *index = btrfs_inode_extref_index(leaf, extref);
 
        if (del_len == item_size) {
-               /*
-                * Common case only one ref in the item, remove the
-                * whole item.
-                */
-               ret = btrfs_del_item(trans, root, path);
-               goto out;
+               /* Common case only one ref in the item, remove the whole item. */
+               return btrfs_del_item(trans, root, path);
        }
 
        ptr = (unsigned long)extref;
@@ -168,9 +163,6 @@ static int btrfs_del_inode_extref(struct btrfs_trans_handle *trans,
 
        btrfs_truncate_item(trans, path, item_size - del_len, 1);
 
-out:
-       btrfs_free_path(path);
-
        return ret;
 }