Skip to content

Commit b7b74b3

Browse files
loemrawkdave
authored andcommitted
btrfs: BTRFS_PATH_AUTO_FREE in orphan.c
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>
1 parent a1d1701 commit b7b74b3

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

fs/btrfs/orphan.c

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
int btrfs_insert_orphan_item(struct btrfs_trans_handle *trans,
1010
struct btrfs_root *root, u64 offset)
1111
{
12-
struct btrfs_path *path;
12+
BTRFS_PATH_AUTO_FREE(path);
1313
struct btrfs_key key;
14-
int ret = 0;
1514

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

24-
ret = btrfs_insert_empty_item(trans, root, path, &key, 0);
25-
26-
btrfs_free_path(path);
27-
return ret;
23+
return btrfs_insert_empty_item(trans, root, path, &key, 0);
2824
}
2925

3026
int btrfs_del_orphan_item(struct btrfs_trans_handle *trans,
3127
struct btrfs_root *root, u64 offset)
3228
{
33-
struct btrfs_path *path;
29+
BTRFS_PATH_AUTO_FREE(path);
3430
struct btrfs_key key;
3531
int ret = 0;
3632

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

4541
ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
4642
if (ret < 0)
47-
goto out;
48-
if (ret) { /* JDM: Really? */
49-
ret = -ENOENT;
50-
goto out;
51-
}
52-
53-
ret = btrfs_del_item(trans, root, path);
43+
return ret;
44+
if (ret)
45+
return -ENOENT;
5446

55-
out:
56-
btrfs_free_path(path);
57-
return ret;
47+
return btrfs_del_item(trans, root, path);
5848
}

0 commit comments

Comments
 (0)