summaryrefslogtreecommitdiff
path: root/btrfs-calc-size.c
diff options
context:
space:
mode:
authorZach Brown <zab@redhat.com>2013-07-09 13:24:43 -0700
committerDavid Sterba <dsterba@suse.cz>2013-08-09 14:32:33 +0200
commit876e3f9380d373ba76f9b6d4c08ff84327956abf (patch)
treea5cf9f31f77249dadbd35b57f9a0025876db2e27 /btrfs-calc-size.c
parent8e6b7ce746d668d7f2c2b6e0b2075dccf55df01a (diff)
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 <zab@redhat.com> Acked-by: Wang Shilong <wangs.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'btrfs-calc-size.c')
-rw-r--r--btrfs-calc-size.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/btrfs-calc-size.c b/btrfs-calc-size.c
index c4adfb0c..5aa0b702 100644
--- a/btrfs-calc-size.c
+++ b/btrfs-calc-size.c
@@ -162,18 +162,11 @@ out_print:
stat.total_inline, stat.total_nodes, stat.total_leaves,
level + 1);
} else {
- char *total_size;
- char *inline_size;
-
- total_size = pretty_sizes(stat.total_bytes);
- inline_size = pretty_sizes(stat.total_inline);
-
printf("\t%s total size, %s inline data, %Lu nodes, "
"%Lu leaves, %d levels\n",
- total_size, inline_size, stat.total_nodes,
- stat.total_leaves, level + 1);
- free(total_size);
- free(inline_size);
+ pretty_size(stat.total_bytes),
+ pretty_size(stat.total_inline),
+ stat.total_nodes, stat.total_leaves, level + 1);
}
out:
btrfs_free_path(path);