diff mbox series

[14/27] btrfs: use BTRFS_PATH_AUTO_FREE in btrfs_get_name()

Message ID 36c61f30ea6df6145eb92581dccff1b56b0c2139.1740562070.git.dsterba@suse.com (mailing list archive)
State New
Headers show
Series Struct btrfs_path auto cleaning conversions | expand

Commit Message

David Sterba Feb. 26, 2025, 9:51 a.m. UTC
s is the trivial pattern for path auto free, initialize at the beginning
and free at the end with some return simplifications.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/export.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

Comments

Johannes Thumshirn Feb. 27, 2025, 7:01 a.m. UTC | #1
On 26.02.25 10:52, David Sterba wrote:
> s is the trivial pattern for path auto free, initialize at the beginning
   ^~ This
diff mbox series

Patch

diff --git a/fs/btrfs/export.c b/fs/btrfs/export.c
index 0c0b8db82df6..a91eaf0ca34e 100644
--- a/fs/btrfs/export.c
+++ b/fs/btrfs/export.c
@@ -223,7 +223,7 @@  static int btrfs_get_name(struct dentry *parent, char *name,
 	struct btrfs_inode *dir = BTRFS_I(d_inode(parent));
 	struct btrfs_root *root = dir->root;
 	struct btrfs_fs_info *fs_info = root->fs_info;
-	struct btrfs_path *path;
+	BTRFS_PATH_AUTO_FREE(path);
 	struct btrfs_inode_ref *iref;
 	struct btrfs_root_ref *rref;
 	struct extent_buffer *leaf;
@@ -255,15 +255,12 @@  static int btrfs_get_name(struct dentry *parent, char *name,
 
 	ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
 	if (ret < 0) {
-		btrfs_free_path(path);
 		return ret;
 	} else if (ret > 0) {
-		if (ino == BTRFS_FIRST_FREE_OBJECTID) {
+		if (ino == BTRFS_FIRST_FREE_OBJECTID)
 			path->slots[0]--;
-		} else {
-			btrfs_free_path(path);
+		else
 			return -ENOENT;
-		}
 	}
 	leaf = path->nodes[0];
 
@@ -280,7 +277,6 @@  static int btrfs_get_name(struct dentry *parent, char *name,
 	}
 
 	read_extent_buffer(leaf, name, name_ptr, name_len);
-	btrfs_free_path(path);
 
 	/*
 	 * have to add the null termination to make sure that reconnect_path