From: Jens Axboe Date: Tue, 7 Oct 2014 03:07:25 +0000 (-0600) Subject: t/dedupe: avoid div-by-zero for all identical chunks X-Git-Tag: fio-2.1.14~96 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=15e3ca5b72b03f485abdda06bee9a9458dbd26a5;ds=sidebyside t/dedupe: avoid div-by-zero for all identical chunks Signed-off-by: Jens Axboe --- diff --git a/t/dedupe.c b/t/dedupe.c index b3ab0f9b..1577a691 100644 --- a/t/dedupe.c +++ b/t/dedupe.c @@ -478,8 +478,12 @@ static void show_stat(uint64_t nextents, uint64_t nchunks) 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;