mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-04-10 19:28:49 -04:00
btrfs: send: avoid extra calls to strlen() in gen_unique_name()
Since 'snprintf()' returns the number of characters which would
be emitted and output truncation is handled by 'ASSERT()', it
should be safe to use that return value instead of the subsequent
calls to 'strlen()' in 'gen_unique_name()'.
This also reduces the module's text size.
Before:
$ size fs/btrfs/btrfs.ko
text data bss dec hex filename
1897006 161571 16136 2074713 1fa859 fs/btrfs/btrfs.ko
After:
$ size fs/btrfs/btrfs.ko
text data bss dec hex filename
1896848 161571 16136 2074555 1fa7bb fs/btrfs/btrfs.ko
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
committed by
David Sterba
parent
6633a416ed
commit
2fb5e56f52
@@ -1804,7 +1804,7 @@ static int gen_unique_name(struct send_ctx *sctx,
|
||||
ino, gen, idx);
|
||||
ASSERT(len < sizeof(tmp));
|
||||
tmp_name.name = tmp;
|
||||
tmp_name.len = strlen(tmp);
|
||||
tmp_name.len = len;
|
||||
|
||||
di = btrfs_lookup_dir_item(NULL, sctx->send_root,
|
||||
path, BTRFS_FIRST_FREE_OBJECTID,
|
||||
@@ -1843,7 +1843,7 @@ static int gen_unique_name(struct send_ctx *sctx,
|
||||
break;
|
||||
}
|
||||
|
||||
ret = fs_path_add(dest, tmp, strlen(tmp));
|
||||
ret = fs_path_add(dest, tmp, len);
|
||||
|
||||
out:
|
||||
btrfs_free_path(path);
|
||||
|
||||
Reference in New Issue
Block a user