diff mbox series

[v2,06/30] btrfs: send: implement fs_path_add_path() using fs_path_add()

Message ID ff39cbb59348ce36b4fe6fe32d3696f17f0e0920.1740049233.git.fdmanana@suse.com (mailing list archive)
State New
Headers show
Series btrfs: avoid repeated path computations and allocations for send | expand

Commit Message

Filipe Manana Feb. 20, 2025, 11:04 a.m. UTC
From: Filipe Manana <fdmanana@suse.com>

The helper fs_path_add_path() is basically a copy of fs_path_add() and it
can be made a wrapper around fs_path_add(). So do that and also make it
inline and constify its second argument.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 fs/btrfs/send.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 2203745569e0..7a75f1d963f9 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -566,19 +566,9 @@  static int fs_path_add(struct fs_path *p, const char *name, int name_len)
 	return 0;
 }
 
-static int fs_path_add_path(struct fs_path *p, struct fs_path *p2)
+static inline int fs_path_add_path(struct fs_path *p, const struct fs_path *p2)
 {
-	int ret;
-	const int p2_len = fs_path_len(p2);
-	char *prepared;
-
-	ret = fs_path_prepare_for_add(p, p2_len, &prepared);
-	if (ret < 0)
-		goto out;
-	memcpy(prepared, p2->start, p2_len);
-
-out:
-	return ret;
+	return fs_path_add(p, p2->start, fs_path_len(p2));
 }
 
 static int fs_path_add_from_extent_buffer(struct fs_path *p,