From e45b8acdc11c95e34c10d3c145120ab5c3e3ccec Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Wed, 19 Dec 2018 15:42:18 -0500 Subject: [PATCH] Fix a divide by zero --- libbcachefs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libbcachefs.c b/libbcachefs.c index ea52ce48..f84a34ca 100644 --- a/libbcachefs.c +++ b/libbcachefs.c @@ -927,7 +927,9 @@ int bchu_data(struct bchfs_handle fs, struct bch_ioctl_data cmd) printf("\33[2K\r"); printf("%llu%% complete: current position %s", - e.p.sectors_done * 100 / e.p.sectors_total, + e.p.sectors_total + ? e.p.sectors_done * 100 / e.p.sectors_total + : 0, bch2_data_types[e.p.data_type]); switch (e.p.data_type) {