]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
btrfs: send: avoid extra calls to strlen() in gen_unique_name()
authorDmitry Antipov <dmantipov@yandex.ru>
Fri, 27 Jun 2025 08:51:17 +0000 (11:51 +0300)
committerDavid Sterba <dsterba@suse.com>
Mon, 21 Jul 2025 21:58:05 +0000 (23:58 +0200)
commit2fb5e56f524f7c0ca3ebda0069f8dd83b90876e5
treed7f5ae17f49a54e4a7464092dfea181f25452cc1
parent6633a416ed64aeb5c0a971d091d598b144739886
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>
fs/btrfs/send.c