Fix window size initialization and div-by-zero

This commit is contained in:
Marcus Holland-Moritz 2021-03-08 18:19:49 +01:00
parent 3a78ab9ce4
commit ebe92f9540
2 changed files with 2 additions and 2 deletions

View File

@ -279,7 +279,7 @@ class block_manager_ final : public block_manager::impl {
, window_size_{cfg.blockhash_window_size > 0
? static_cast<size_t>(1) << cfg.blockhash_window_size
: 0}
, window_step_{window_size_ >> cfg.window_increment_shift}
, window_step_{std::max<size_t>(1, window_size_ >> cfg.window_increment_shift)}
, block_size_{static_cast<size_t>(1) << cfg.block_size_bits}
, filter_{bloom_filter_size()} {
LOG_INFO << "bloom filter size: " << size_with_unit(filter_.size() / 8);

View File

@ -549,7 +549,7 @@ int mkdwarfs(int argc, char** argv) {
metadata_compression = defaults.metadata_compression;
}
if (!vm.count("blockhash-window-size")) {
if (!vm.count("window-size")) {
cfg.blockhash_window_size = defaults.window_size;
}