From 876e3f9380d373ba76f9b6d4c08ff84327956abf Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Tue, 9 Jul 2013 13:24:43 -0700 Subject: btrfs-progs: per-thread, per-call pretty buffer We don't need callers to manage string storage for each pretty_sizes() call. We can use a macro to have per-thread and per-call static storage so that pretty_sizes() can be used as many times as needed in printf() arguments without requiring a bunch of supporting variables. This lets us have a natural interface at the cost of requiring __thread and TLS from gcc and a small amount of static storage. This seems better than the current code or doing something with illegible format specifier macros. Signed-off-by: Zach Brown Acked-by: Wang Shilong Signed-off-by: David Sterba Signed-off-by: Chris Mason --- mkfs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'mkfs.c') diff --git a/mkfs.c b/mkfs.c index 95fceb34..ade85c78 100644 --- a/mkfs.c +++ b/mkfs.c @@ -1356,7 +1356,6 @@ int main(int ac, char **av) u64 num_of_meta_chunks = 0; u64 size_of_data = 0; u64 source_dir_size = 0; - char *pretty_buf; struct btrfs_super_block *super; u64 flags; int dev_cnt = 0; @@ -1629,8 +1628,7 @@ raid_groups: printf("fs created label %s on %s\n\tnodesize %u leafsize %u " "sectorsize %u size %s\n", label, first_file, nodesize, leafsize, sectorsize, - pretty_buf = pretty_sizes(btrfs_super_total_bytes(root->fs_info->super_copy))); - free(pretty_buf); + pretty_size(btrfs_super_total_bytes(root->fs_info->super_copy))); printf("%s\n", BTRFS_BUILD_VERSION); btrfs_commit_transaction(trans, root); -- cgit v1.2.3