From ec32413b5e15f5583c4c45f2d956e381140ad41a Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Wed, 8 Feb 2023 16:23:10 +0100 Subject: [PATCH] hashindex: always have at least 1 empty bucket avoid rounding / integer conversion issues bringing this down to 0. --- src/borg/_hashindex.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/borg/_hashindex.c b/src/borg/_hashindex.c index 31473051a..aff440974 100644 --- a/src/borg/_hashindex.c +++ b/src/borg/_hashindex.c @@ -241,8 +241,10 @@ int get_upper_limit(int num_buckets){ } int get_min_empty(int num_buckets){ - /* Differently from load, the effective load also considers tombstones (deleted buckets). */ - return (int)(num_buckets * (1.0 - HASH_MAX_EFF_LOAD)); + /* Differently from load, the effective load also considers tombstones (deleted buckets). + * We always add 1, so this never can return 0 (0 empty buckets would be a bad HT state). + */ + return 1 + (int)(num_buckets * (1.0 - HASH_MAX_EFF_LOAD)); } int size_idx(int size){