diff --git a/src/dwarfs/block_cache.cpp b/src/dwarfs/block_cache.cpp index 60466b5a..f9c08e6e 100644 --- a/src/dwarfs/block_cache.cpp +++ b/src/dwarfs/block_cache.cpp @@ -609,7 +609,7 @@ class block_cache_ final : public block_cache::impl { // Check if another worker is already processing this block { - std::lock_guard lock(mx_dec_); + std::lock_guard lock_dec(mx_dec_); auto di = decompressing_.find(block_no); diff --git a/src/dwarfs/categorizer.cpp b/src/dwarfs/categorizer.cpp index 5a83c7ff..cfb115cc 100644 --- a/src/dwarfs/categorizer.cpp +++ b/src/dwarfs/categorizer.cpp @@ -282,8 +282,8 @@ fragment_category categorizer_manager::default_category() { template void categorizer_manager_::add(std::shared_ptr c) { - for (auto const& c : c->categories()) { - add_category(c, categorizers_.size()); + for (auto const& cat : c->categories()) { + add_category(cat, categorizers_.size()); } categorizers_.emplace_back(std::move(c)); diff --git a/src/dwarfs/inode_reader_v2.cpp b/src/dwarfs/inode_reader_v2.cpp index 4c6449b6..8d0d5ab4 100644 --- a/src/dwarfs/inode_reader_v2.cpp +++ b/src/dwarfs/inode_reader_v2.cpp @@ -195,9 +195,8 @@ void inode_reader_::do_readahead(uint32_t inode, std::lock_guard lock(readahead_cache_mutex_); if (read_offset > 0) { - if (auto it = readahead_cache_.find(inode); - it != readahead_cache_.end()) { - readahead_pos = it->second; + if (auto i = readahead_cache_.find(inode); i != readahead_cache_.end()) { + readahead_pos = i->second; } if (readahead_until <= readahead_pos) { diff --git a/src/dwarfs/scanner.cpp b/src/dwarfs/scanner.cpp index 65e03526..00e4f0ec 100644 --- a/src/dwarfs/scanner.cpp +++ b/src/dwarfs/scanner.cpp @@ -491,10 +491,10 @@ scanner_::scan_tree(std::filesystem::path const& path, DWARFS_CHECK(parent, "expected directory"); queue.pop_front(); - auto path = parent->fs_path(); + auto ppath = parent->fs_path(); try { - auto d = os_->opendir(path); + auto d = os_->opendir(ppath); std::filesystem::path name; std::vector> subdirs; @@ -510,7 +510,7 @@ scanner_::scan_tree(std::filesystem::path const& path, prog.dirs_scanned++; } catch (const std::system_error& e) { - LOG_ERROR << "cannot read directory `" << path + LOG_ERROR << "cannot read directory `" << ppath << "`: " << folly::exceptionStr(e); prog.errors++; } diff --git a/src/dwarfs/util.cpp b/src/dwarfs/util.cpp index 66055731..4c46a639 100644 --- a/src/dwarfs/util.cpp +++ b/src/dwarfs/util.cpp @@ -272,9 +272,7 @@ void utf8_sanitize(std::string& str) { } void shorten_path_string(std::string& path, char separator, size_t max_len) { - auto len = utf8_display_width(path); - - if (len > max_len) { + if (utf8_display_width(path) > max_len) { if (max_len < 3) { path.clear(); return; @@ -293,7 +291,7 @@ void shorten_path_string(std::string& path, char separator, size_t max_len) { path.replace(0, start, "..."); - if (auto len = utf8_display_width(path); len > max_len) { + if (utf8_display_width(path) > max_len) { if (max_len >= 7) { utf8_truncate(path, max_len - 3); path += "..."; diff --git a/src/mkdwarfs_main.cpp b/src/mkdwarfs_main.cpp index 4f1653c2..8e4a35d3 100644 --- a/src/mkdwarfs_main.cpp +++ b/src/mkdwarfs_main.cpp @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include @@ -334,8 +335,8 @@ class categorize_optval { void add_implicit_defaults(T& cop) const { if (is_implicit_default()) { if (auto it = defaults_.find(cop.name()); it != defaults_.end()) { - for (auto const& value : it->second) { - cop.parse_fallback(value); + for (auto const& v : it->second) { + cop.parse_fallback(v); } } } @@ -713,16 +714,14 @@ int mkdwarfs_main(int argc, sys_char** argv, iolayer const& iol) { metadata_hdr, l_mc, "Size/Step Order") << " " << sep << "\n"; - int level = 0; - for (auto const& l : levels) { + for (auto const& [i, l] : folly::enumerate(levels)) { iol.out << fmt::format(" {:1d} {:2d} {:{}s} {:{}s} {:{}s}" " {:2d} / {:1d} {:{}s}", - level, l.block_size_bits, l.data_compression, l_dc, + i, l.block_size_bits, l.data_compression, l_dc, l.schema_history_compression, l_sc, l.metadata_compression, l_mc, l.window_size, l.window_step, l.order, l_or) << "\n"; - ++level; } iol.out << " " << sep << "\n"; diff --git a/test/block_cache_test.cpp b/test/block_cache_test.cpp index cd691d64..030a5947 100644 --- a/test/block_cache_test.cpp +++ b/test/block_cache_test.cpp @@ -138,7 +138,6 @@ TEST_P(options_test, cache_stress) { auto const& cache_opts = GetParam(); - std::mt19937_64 rng{42}; auto os = std::make_shared(); { @@ -222,6 +221,7 @@ TEST_P(options_test, cache_stress) { }; std::vector> data(num_threads); + std::mt19937_64 rng{42}; for (auto& reqs : data) { while (reqs.size() < num_read_reqs) {