t/dedupe: avoid div-by-zero for all identical chunks
Signed-off-by: Jens Axboe <axboe@fb.com>
diff --git a/t/dedupe.c b/t/dedupe.c
index b3ab0f9..1577a69 100644
--- a/t/dedupe.c
+++ b/t/dedupe.c
@@ -478,8 +478,12 @@
double perc, ratio;
printf("Extents=%lu, Unique extents=%lu\n", (unsigned long) nextents, (unsigned long) nchunks);
- ratio = (double) nextents / (double) nchunks;
- printf("De-dupe ratio: 1:%3.2f\n", ratio - 1.0);
+
+ if (nchunks) {
+ ratio = (double) nextents / (double) nchunks;
+ printf("De-dupe ratio: 1:%3.2f\n", ratio - 1.0);
+ } else
+ printf("De-dupe ratio: 1:infinite\n");
perc = 1.00 - ((double) nchunks / (double) nextents);
perc *= 100.0;