diff options
author | 2025-02-05 11:14:09 +0000 | |
---|---|---|
committer | 2025-03-18 20:35:45 +0100 | |
commit | 1f63d4b610181c1f6add492c9c23f27818aff361 (patch) | |
tree | 4dbe64bb98fdfe2bedf651f95875f6716e88b57f | |
parent | btrfs: send: make fs_path_len() inline and constify its argument (diff) | |
download | wireguard-linux-1f63d4b610181c1f6add492c9c23f27818aff361.tar.xz wireguard-linux-1f63d4b610181c1f6add492c9c23f27818aff361.zip |
btrfs: send: always use fs_path_len() to determine a path's length
Several places are hardcoding the path length calculation instead of using
the helper fs_path_len() for that. Update all those places to instead use
fs_path_len().
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | fs/btrfs/send.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 4e998bf8d379..9f9885dc1e10 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -489,7 +489,7 @@ static int fs_path_ensure_buf(struct fs_path *p, int len) return -ENOMEM; } - path_len = p->end - p->start; + path_len = fs_path_len(p); old_buf_len = p->buf_len; /* @@ -530,7 +530,7 @@ static int fs_path_prepare_for_add(struct fs_path *p, int name_len, int ret; int new_len; - new_len = p->end - p->start + name_len; + new_len = fs_path_len(p) + name_len; if (p->start != p->end) new_len++; ret = fs_path_ensure_buf(p, new_len); @@ -571,12 +571,13 @@ out: static int fs_path_add_path(struct fs_path *p, struct fs_path *p2) { int ret; + const int p2_len = fs_path_len(p2); char *prepared; - ret = fs_path_prepare_for_add(p, p2->end - p2->start, &prepared); + ret = fs_path_prepare_for_add(p, p2_len, &prepared); if (ret < 0) goto out; - memcpy(prepared, p2->start, p2->end - p2->start); + memcpy(prepared, p2->start, p2_len); out: return ret; @@ -616,7 +617,7 @@ static void fs_path_unreverse(struct fs_path *p) return; tmp = p->start; - len = p->end - p->start; + len = fs_path_len(p); p->start = p->buf; p->end = p->start + len; memmove(p->start, tmp, len + 1); @@ -737,7 +738,7 @@ static int tlv_put_btrfs_timespec(struct send_ctx *sctx, u16 attr, #define TLV_PUT_PATH(sctx, attrtype, p) \ do { \ ret = tlv_put_string(sctx, attrtype, p->start, \ - p->end - p->start); \ + fs_path_len((p))); \ if (ret < 0) \ goto tlv_put_failure; \ } while(0) @@ -2364,7 +2365,7 @@ static int __get_cur_name_and_parent(struct send_ctx *sctx, * earlier. If yes, treat as orphan and return 1. */ ret = did_overwrite_ref(sctx, *parent_ino, *parent_gen, ino, gen, - dest->start, dest->end - dest->start); + dest->start, fs_path_len(dest)); if (ret < 0) goto out; if (ret) { |