Check for divzero - dedup - deduplicating backup program HTML git clone git://bitreich.org/dedup/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/dedup/ DIR Log DIR Files DIR Refs DIR Tags DIR README DIR LICENSE --- DIR commit 8a5d9a252075a8eeec32c53f362746e91386ef2b DIR parent 71a2045de89e6fbe69797470ee4f0110608b0765 HTML Author: sin <sin@2f30.org> Date: Fri, 5 Apr 2019 08:26:55 +0100 Check for divzero Diffstat: M dedup.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- DIR diff --git a/dedup.c b/dedup.c @@ -69,8 +69,13 @@ print_stats(struct stats *st) (unsigned long long)st->max_blk_size); fprintf(stderr, "Number of unique blocks: %llu\n", (unsigned long long)st->nr_blks); + icache_stats(icache, &hits, &misses); - hitratio = (double)hits / (hits + misses); + if (hits == 0 && misses == 0) + hitratio = 0; + else + hitratio = (double)hits / (hits + misses); + fprintf(stderr, "Index cache hit percentage: %.2f%%\n", 100 * hitratio); }