summaryrefslogtreecommitdiff
path: root/cmds-scrub.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 /cmds-scrub.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 'cmds-scrub.c')
-rw-r--r--cmds-scrub.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/cmds-scrub.c b/cmds-scrub.c
index 95dfee33..bf506508 100644
--- a/cmds-scrub.c
+++ b/cmds-scrub.c
@@ -139,7 +139,6 @@ static void print_scrub_summary(struct btrfs_scrub_progress *p)
{
u64 err_cnt;
u64 err_cnt2;
- char *bytes;
err_cnt = p->read_errors +
p->csum_errors +
@@ -151,10 +150,11 @@ static void print_scrub_summary(struct btrfs_scrub_progress *p)
if (p->malloc_errors)
printf("*** WARNING: memory allocation failed while scrubbing. "
"results may be inaccurate\n");
- bytes = pretty_sizes(p->data_bytes_scrubbed + p->tree_bytes_scrubbed);
- printf("\ttotal bytes scrubbed: %s with %llu errors\n", bytes,
+
+ printf("\ttotal bytes scrubbed: %s with %llu errors\n",
+ pretty_size(p->data_bytes_scrubbed + p->tree_bytes_scrubbed),
max(err_cnt, err_cnt2));
- free(bytes);
+
if (err_cnt || err_cnt2) {
printf("\terror details:");
PRINT_SCRUB_ERROR(p->read_errors, "read");