Skip to content

Commit

Permalink
btrfs: BTRFS_PATH_AUTO_FREE in orphan.c
Browse files Browse the repository at this point in the history
All cleanup paths lead to btrfs_path_free so path can be defined with
the automatic freeing callback in the following functions:

- btrfs_insert_orphan_item()
- btrfs_del_orphan_item()

Signed-off-by: Leo Martins <loemra.dev@gmail.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
  • Loading branch information
Leo Martins authored and David Sterba committed Sep 10, 2024
1 parent 45763a0 commit 68f32b9
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions fs/btrfs/orphan.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
int btrfs_insert_orphan_item(struct btrfs_trans_handle *trans,
struct btrfs_root *root, u64 offset)
{
struct btrfs_path *path;
BTRFS_PATH_AUTO_FREE(path);
struct btrfs_key key;
int ret = 0;

key.objectid = BTRFS_ORPHAN_OBJECTID;
key.type = BTRFS_ORPHAN_ITEM_KEY;
Expand All @@ -21,16 +20,13 @@ int btrfs_insert_orphan_item(struct btrfs_trans_handle *trans,
if (!path)
return -ENOMEM;

ret = btrfs_insert_empty_item(trans, root, path, &key, 0);

btrfs_free_path(path);
return ret;
return btrfs_insert_empty_item(trans, root, path, &key, 0);
}

int btrfs_del_orphan_item(struct btrfs_trans_handle *trans,
struct btrfs_root *root, u64 offset)
{
struct btrfs_path *path;
BTRFS_PATH_AUTO_FREE(path);
struct btrfs_key key;
int ret = 0;

Expand All @@ -44,15 +40,9 @@ int btrfs_del_orphan_item(struct btrfs_trans_handle *trans,

ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
if (ret < 0)
goto out;
if (ret) { /* JDM: Really? */
ret = -ENOENT;
goto out;
}

ret = btrfs_del_item(trans, root, path);
return ret;
if (ret)
return -ENOENT;

out:
btrfs_free_path(path);
return ret;
return btrfs_del_item(trans, root, path);
}

0 comments on commit 68f32b9

Please sign in to comment.