mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-18 08:49:29 -04:00
chore: reformat code using new .clang-format
This commit is contained in:
parent
71064e6613
commit
45098e7913
@ -52,9 +52,9 @@ class block_compressor {
|
||||
public:
|
||||
block_compressor() = default;
|
||||
|
||||
explicit block_compressor(const std::string& spec);
|
||||
explicit block_compressor(std::string const& spec);
|
||||
|
||||
block_compressor(const block_compressor& bc)
|
||||
block_compressor(block_compressor const& bc)
|
||||
: impl_(bc.impl_->clone()) {}
|
||||
|
||||
block_compressor(block_compressor&& bc) = default;
|
||||
@ -100,7 +100,7 @@ class block_compressor {
|
||||
virtual std::unique_ptr<impl> clone() const = 0;
|
||||
|
||||
virtual std::vector<uint8_t>
|
||||
compress(const std::vector<uint8_t>& data,
|
||||
compress(std::vector<uint8_t> const& data,
|
||||
std::string const* metadata) const = 0;
|
||||
virtual std::vector<uint8_t>
|
||||
compress(std::vector<uint8_t>&& data,
|
||||
@ -121,7 +121,7 @@ class block_compressor {
|
||||
|
||||
class block_decompressor {
|
||||
public:
|
||||
block_decompressor(compression_type type, const uint8_t* data, size_t size,
|
||||
block_decompressor(compression_type type, uint8_t const* data, size_t size,
|
||||
std::vector<uint8_t>& target);
|
||||
|
||||
bool decompress_frame(size_t frame_size = BUFSIZ) {
|
||||
@ -135,7 +135,7 @@ class block_decompressor {
|
||||
std::optional<std::string> metadata() const { return impl_->metadata(); }
|
||||
|
||||
static std::vector<uint8_t>
|
||||
decompress(compression_type type, const uint8_t* data, size_t size) {
|
||||
decompress(compression_type type, uint8_t const* data, size_t size) {
|
||||
std::vector<uint8_t> target;
|
||||
block_decompressor bd(type, data, size, target);
|
||||
bd.decompress_frame(bd.uncompressed_size());
|
||||
|
@ -58,7 +58,7 @@ class worker_group {
|
||||
* \param num_workers Number of worker threads.
|
||||
*/
|
||||
explicit worker_group(
|
||||
logger& lgr, os_access const& os, const char* group_name,
|
||||
logger& lgr, os_access const& os, char const* group_name,
|
||||
size_t num_workers = 1,
|
||||
size_t max_queue_len = std::numeric_limits<size_t>::max(),
|
||||
int niceness = 0);
|
||||
|
@ -187,7 +187,7 @@ class no_log_entry {
|
||||
no_log_entry(logger&, logger::level_type, std::source_location) {}
|
||||
|
||||
template <typename T>
|
||||
no_log_entry& operator<<(const T&) {
|
||||
no_log_entry& operator<<(T const&) {
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
@ -34,12 +34,12 @@ class option_map {
|
||||
public:
|
||||
explicit option_map(std::string_view spec);
|
||||
|
||||
const std::string& choice() const { return choice_; }
|
||||
std::string const& choice() const { return choice_; }
|
||||
|
||||
bool has_options() const { return !opt_.empty(); }
|
||||
|
||||
template <typename T>
|
||||
T get(const std::string& key, const T& default_value = T()) {
|
||||
T get(std::string const& key, T const& default_value = T()) {
|
||||
auto i = opt_.find(key);
|
||||
|
||||
if (i != opt_.end()) {
|
||||
@ -52,7 +52,7 @@ class option_map {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::optional<T> get_optional(const std::string& key) {
|
||||
std::optional<T> get_optional(std::string const& key) {
|
||||
auto i = opt_.find(key);
|
||||
|
||||
if (i != opt_.end()) {
|
||||
@ -64,7 +64,7 @@ class option_map {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
size_t get_size(const std::string& key, size_t default_value = 0);
|
||||
size_t get_size(std::string const& key, size_t default_value = 0);
|
||||
|
||||
void report();
|
||||
|
||||
|
@ -42,7 +42,7 @@ class performance_monitor {
|
||||
public:
|
||||
using timer_id = size_t;
|
||||
using time_type = uint64_t;
|
||||
static inline constexpr size_t kNumInlineContext{3};
|
||||
static constexpr inline size_t kNumInlineContext{3};
|
||||
|
||||
static std::unique_ptr<performance_monitor>
|
||||
create(std::unordered_set<std::string> enabled_namespaces,
|
||||
|
@ -54,7 +54,7 @@ namespace internal {
|
||||
class block_cache {
|
||||
public:
|
||||
block_cache(logger& lgr, os_access const& os, std::shared_ptr<mmif> mm,
|
||||
const block_cache_options& options,
|
||||
block_cache_options const& options,
|
||||
std::shared_ptr<performance_monitor const> const& perfmon);
|
||||
|
||||
size_t block_count() const { return impl_->block_count(); }
|
||||
|
@ -48,7 +48,7 @@ class cached_block {
|
||||
virtual ~cached_block() = default;
|
||||
|
||||
virtual size_t range_end() const = 0;
|
||||
virtual const uint8_t* data() const = 0;
|
||||
virtual uint8_t const* data() const = 0;
|
||||
virtual void decompress_until(size_t end) = 0;
|
||||
virtual size_t uncompressed_size() const = 0;
|
||||
virtual void touch() = 0;
|
||||
|
@ -40,7 +40,7 @@ namespace reader::internal {
|
||||
|
||||
class filesystem_parser {
|
||||
private:
|
||||
static uint64_t constexpr section_offset_mask{(UINT64_C(1) << 48) - 1};
|
||||
static constexpr uint64_t section_offset_mask{(UINT64_C(1) << 48) - 1};
|
||||
|
||||
public:
|
||||
static file_off_t find_image_offset(mmif& mm, file_off_t image_offset);
|
||||
|
@ -81,7 +81,7 @@ class inode_reader_v2 {
|
||||
}
|
||||
|
||||
void
|
||||
dump(std::ostream& os, const std::string& indent, chunk_range chunks) const {
|
||||
dump(std::ostream& os, std::string const& indent, chunk_range chunks) const {
|
||||
impl_->dump(os, indent, chunks);
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ class inode_reader_v2 {
|
||||
virtual std::vector<std::future<block_range>>
|
||||
readv(uint32_t inode, size_t size, file_off_t offset, size_t maxiov,
|
||||
chunk_range chunks, std::error_code& ec) const = 0;
|
||||
virtual void dump(std::ostream& os, const std::string& indent,
|
||||
virtual void dump(std::ostream& os, std::string const& indent,
|
||||
chunk_range chunks) const = 0;
|
||||
virtual void set_num_workers(size_t num) = 0;
|
||||
virtual void set_cache_tidy_config(cache_tidy_config const& cfg) = 0;
|
||||
|
@ -76,7 +76,7 @@ class metadata_v2 {
|
||||
void
|
||||
dump(std::ostream& os, fsinfo_options const& opts,
|
||||
filesystem_info const* fsinfo,
|
||||
std::function<void(const std::string&, uint32_t)> const& icb) const {
|
||||
std::function<void(std::string const&, uint32_t)> const& icb) const {
|
||||
impl_->dump(os, opts, fsinfo, icb);
|
||||
}
|
||||
|
||||
@ -186,7 +186,7 @@ class metadata_v2 {
|
||||
virtual void dump(
|
||||
std::ostream& os, fsinfo_options const& opts,
|
||||
filesystem_info const* fsinfo,
|
||||
std::function<void(const std::string&, uint32_t)> const& icb) const = 0;
|
||||
std::function<void(std::string const&, uint32_t)> const& icb) const = 0;
|
||||
|
||||
virtual nlohmann::json
|
||||
info_as_json(fsinfo_options const& opts,
|
||||
|
@ -122,7 +122,7 @@ class sorted_array_map {
|
||||
}
|
||||
|
||||
private:
|
||||
constexpr static std::array<value_type, N>
|
||||
static constexpr std::array<value_type, N>
|
||||
sort(std::array<value_type, N> arr) {
|
||||
if (!std::ranges::is_sorted(arr, std::less{}, &value_type::first)) {
|
||||
std::ranges::sort(arr, std::less{}, &value_type::first);
|
||||
|
@ -50,7 +50,7 @@ class thread_pool {
|
||||
using job_type = std::function<void()>;
|
||||
|
||||
thread_pool();
|
||||
thread_pool(logger& lgr, os_access const& os, const char* group_name,
|
||||
thread_pool(logger& lgr, os_access const& os, char const* group_name,
|
||||
size_t num_workers = 1,
|
||||
size_t max_queue_len = std::numeric_limits<size_t>::max(),
|
||||
int niceness = 0);
|
||||
|
@ -79,9 +79,9 @@ class multi_queue_block_merger_impl : public block_merger_base,
|
||||
multi_queue_block_merger_impl(multi_queue_block_merger_impl&&) = default;
|
||||
multi_queue_block_merger_impl&
|
||||
operator=(multi_queue_block_merger_impl&&) = default;
|
||||
multi_queue_block_merger_impl(const multi_queue_block_merger_impl&) = delete;
|
||||
multi_queue_block_merger_impl(multi_queue_block_merger_impl const&) = delete;
|
||||
multi_queue_block_merger_impl&
|
||||
operator=(const multi_queue_block_merger_impl&) = delete;
|
||||
operator=(multi_queue_block_merger_impl const&) = delete;
|
||||
|
||||
void add(source_type src, block_type blk) override {
|
||||
auto const block_size = this->block_size(blk);
|
||||
|
@ -88,7 +88,7 @@ class entry : public entry_interface {
|
||||
virtual type_t type() const = 0;
|
||||
bool is_directory() const override;
|
||||
virtual void walk(std::function<void(entry*)> const& f);
|
||||
virtual void walk(std::function<void(const entry*)> const& f) const;
|
||||
virtual void walk(std::function<void(entry const*)> const& f) const;
|
||||
void pack(thrift::metadata::inode_data& entry_v2,
|
||||
global_entry_data const& data) const;
|
||||
void update(global_entry_data& data) const;
|
||||
@ -174,7 +174,7 @@ class dir : public entry {
|
||||
type_t type() const override;
|
||||
void add(std::shared_ptr<entry> e);
|
||||
void walk(std::function<void(entry*)> const& f) override;
|
||||
void walk(std::function<void(const entry*)> const& f) const override;
|
||||
void walk(std::function<void(entry const*)> const& f) const override;
|
||||
void accept(entry_visitor& v, bool preorder) override;
|
||||
void sort();
|
||||
void
|
||||
@ -208,7 +208,7 @@ class link : public entry {
|
||||
using entry::entry;
|
||||
|
||||
type_t type() const override;
|
||||
const std::string& linkname() const;
|
||||
std::string const& linkname() const;
|
||||
void accept(entry_visitor& v, bool preorder) override;
|
||||
void scan(os_access const& os, progress& prog) override;
|
||||
|
||||
|
@ -36,7 +36,7 @@ namespace writer::internal {
|
||||
class metadata_freezer {
|
||||
public:
|
||||
static std::pair<std::vector<uint8_t>, std::vector<uint8_t>>
|
||||
freeze(const thrift::metadata::metadata& data);
|
||||
freeze(thrift::metadata::metadata const& data);
|
||||
};
|
||||
|
||||
} // namespace writer::internal
|
||||
|
@ -49,7 +49,7 @@ class scanner {
|
||||
public:
|
||||
scanner(logger& lgr, thread_pool& pool, segmenter_factory& sf,
|
||||
entry_factory& ef, os_access const& os,
|
||||
const scanner_options& options);
|
||||
scanner_options const& options);
|
||||
|
||||
void add_filter(std::unique_ptr<entry_filter>&& filter) {
|
||||
impl_->add_filter(std::move(filter));
|
||||
@ -60,7 +60,7 @@ class scanner {
|
||||
}
|
||||
|
||||
void scan(
|
||||
filesystem_writer& fsw, const std::filesystem::path& path,
|
||||
filesystem_writer& fsw, std::filesystem::path const& path,
|
||||
writer_progress& prog,
|
||||
std::optional<std::span<std::filesystem::path const>> list = std::nullopt,
|
||||
std::shared_ptr<file_access const> fa = nullptr) {
|
||||
@ -77,7 +77,7 @@ class scanner {
|
||||
add_transformer(std::unique_ptr<entry_transformer>&& transformer) = 0;
|
||||
|
||||
virtual void
|
||||
scan(filesystem_writer& fsw, const std::filesystem::path& path,
|
||||
scan(filesystem_writer& fsw, std::filesystem::path const& path,
|
||||
writer_progress& prog,
|
||||
std::optional<std::span<std::filesystem::path const>> list,
|
||||
std::shared_ptr<file_access const> fa) = 0;
|
||||
|
@ -45,8 +45,8 @@ class writer_progress {
|
||||
writer_progress(update_function_type func,
|
||||
std::chrono::microseconds interval);
|
||||
|
||||
writer_progress(const writer_progress&) = delete;
|
||||
writer_progress& operator=(const writer_progress&) = delete;
|
||||
writer_progress(writer_progress const&) = delete;
|
||||
writer_progress& operator=(writer_progress const&) = delete;
|
||||
writer_progress(writer_progress&&) = delete;
|
||||
writer_progress& operator=(writer_progress&&) = delete;
|
||||
|
||||
|
@ -36,12 +36,12 @@
|
||||
|
||||
namespace dwarfs {
|
||||
|
||||
block_compressor::block_compressor(const std::string& spec) {
|
||||
block_compressor::block_compressor(std::string const& spec) {
|
||||
impl_ = compression_registry::instance().make_compressor(spec);
|
||||
}
|
||||
|
||||
block_decompressor::block_decompressor(compression_type type,
|
||||
const uint8_t* data, size_t size,
|
||||
uint8_t const* data, size_t size,
|
||||
std::vector<uint8_t>& target) {
|
||||
impl_ = compression_registry::instance().make_decompressor(
|
||||
type, std::span<uint8_t const>(data, size), target);
|
||||
|
@ -109,7 +109,7 @@ class checksum_evp : public checksum::impl {
|
||||
static std::vector<std::string> available_algorithms() {
|
||||
std::vector<std::string> available;
|
||||
::EVP_MD_do_all(
|
||||
[](const ::EVP_MD*, const char* from, const char* to, void* vec) {
|
||||
[](::EVP_MD const*, char const* from, char const* to, void* vec) {
|
||||
// TODO: C++23: use std::ranges::contains
|
||||
if (!to && std::ranges::find(unsupported_algorithms, from) ==
|
||||
unsupported_algorithms.end()) {
|
||||
@ -198,7 +198,7 @@ using checksum_xxh3_64 = checksum_xxh3<xxh3_64_policy>;
|
||||
using checksum_xxh3_128 = checksum_xxh3<xxh3_128_policy>;
|
||||
|
||||
template <typename T>
|
||||
bool verify_impl(T&& alg, void const* data, size_t size, const void* digest,
|
||||
bool verify_impl(T&& alg, void const* data, size_t size, void const* digest,
|
||||
size_t digest_size) {
|
||||
std::array<char, EVP_MAX_MD_SIZE> tmp;
|
||||
checksum cs(std::forward<T>(alg));
|
||||
@ -228,12 +228,12 @@ std::vector<std::string> checksum::available_algorithms() {
|
||||
}
|
||||
|
||||
bool checksum::verify(algorithm alg, void const* data, size_t size,
|
||||
const void* digest, size_t digest_size) {
|
||||
void const* digest, size_t digest_size) {
|
||||
return verify_impl(alg, data, size, digest, digest_size);
|
||||
}
|
||||
|
||||
bool checksum::verify(std::string const& alg, void const* data, size_t size,
|
||||
const void* digest, size_t digest_size) {
|
||||
void const* digest, size_t digest_size) {
|
||||
return verify_impl(alg, data, size, digest, digest_size);
|
||||
}
|
||||
|
||||
|
@ -43,14 +43,14 @@ class brotli_block_compressor final : public block_compressor::impl {
|
||||
: quality_{quality}
|
||||
, window_bits_{window_bits} {}
|
||||
|
||||
brotli_block_compressor(const brotli_block_compressor& rhs) = default;
|
||||
brotli_block_compressor(brotli_block_compressor const& rhs) = default;
|
||||
|
||||
std::unique_ptr<block_compressor::impl> clone() const override {
|
||||
return std::make_unique<brotli_block_compressor>(*this);
|
||||
}
|
||||
|
||||
std::vector<uint8_t>
|
||||
compress(const std::vector<uint8_t>& data,
|
||||
compress(std::vector<uint8_t> const& data,
|
||||
std::string const* /*metadata*/) const override {
|
||||
std::vector<uint8_t> compressed;
|
||||
compressed.resize(folly::kMaxVarintLength64 +
|
||||
@ -96,7 +96,7 @@ class brotli_block_compressor final : public block_compressor::impl {
|
||||
|
||||
class brotli_block_decompressor final : public block_decompressor::impl {
|
||||
public:
|
||||
brotli_block_decompressor(const uint8_t* data, size_t size,
|
||||
brotli_block_decompressor(uint8_t const* data, size_t size,
|
||||
std::vector<uint8_t>& target)
|
||||
: brotli_block_decompressor(folly::Range<uint8_t const*>(data, size),
|
||||
target) {}
|
||||
@ -166,7 +166,7 @@ class brotli_block_decompressor final : public block_decompressor::impl {
|
||||
}
|
||||
|
||||
std::vector<uint8_t>& decompressed_;
|
||||
const size_t uncompressed_size_;
|
||||
size_t const uncompressed_size_;
|
||||
uint8_t const* data_;
|
||||
size_t size_;
|
||||
std::unique_ptr<BrotliDecoderState, decltype(BrotliDecoderDestroyInstance)*>
|
||||
|
@ -66,7 +66,7 @@ class dwarfs_flac_stream_encoder final : public FLAC::Encoder::Stream {
|
||||
}
|
||||
|
||||
::FLAC__StreamEncoderWriteStatus
|
||||
write_callback(const FLAC__byte buffer[], size_t bytes, uint32_t,
|
||||
write_callback(FLAC__byte const buffer[], size_t bytes, uint32_t,
|
||||
uint32_t) override {
|
||||
size_t end = pos_ + bytes;
|
||||
if (data_.size() < end) {
|
||||
@ -136,8 +136,8 @@ class dwarfs_flac_stream_decoder final : public FLAC::Decoder::Stream {
|
||||
}
|
||||
|
||||
::FLAC__StreamDecoderWriteStatus
|
||||
write_callback(const ::FLAC__Frame* frame,
|
||||
const FLAC__int32* const buffer[]) override {
|
||||
write_callback(::FLAC__Frame const* frame,
|
||||
FLAC__int32 const* const buffer[]) override {
|
||||
auto samples = frame->header.blocksize;
|
||||
auto channels = frame->header.channels;
|
||||
tmp_.resize(channels * samples);
|
||||
@ -203,13 +203,13 @@ class flac_block_compressor final : public block_compressor::impl {
|
||||
: level_{level}
|
||||
, exhaustive_{exhaustive} {}
|
||||
|
||||
flac_block_compressor(const flac_block_compressor& rhs) = default;
|
||||
flac_block_compressor(flac_block_compressor const& rhs) = default;
|
||||
|
||||
std::unique_ptr<block_compressor::impl> clone() const override {
|
||||
return std::make_unique<flac_block_compressor>(*this);
|
||||
}
|
||||
|
||||
std::vector<uint8_t> compress(const std::vector<uint8_t>& data,
|
||||
std::vector<uint8_t> compress(std::vector<uint8_t> const& data,
|
||||
std::string const* metadata) const override {
|
||||
if (!metadata) {
|
||||
DWARFS_THROW(runtime_error,
|
||||
@ -309,7 +309,7 @@ class flac_block_compressor final : public block_compressor::impl {
|
||||
pcm_sample_transformer<FLAC__int32> xfm(pcm_end, pcm_sig, pcm_pad,
|
||||
bytes_per_sample, bits_per_sample);
|
||||
|
||||
const auto samples_per_call = kBlockSize / num_channels;
|
||||
auto const samples_per_call = kBlockSize / num_channels;
|
||||
std::vector<FLAC__int32> buffer;
|
||||
size_t input_pos = 0;
|
||||
|
||||
@ -392,7 +392,7 @@ class flac_block_compressor final : public block_compressor::impl {
|
||||
|
||||
class flac_block_decompressor final : public block_decompressor::impl {
|
||||
public:
|
||||
flac_block_decompressor(const uint8_t* data, size_t size,
|
||||
flac_block_decompressor(uint8_t const* data, size_t size,
|
||||
std::vector<uint8_t>& target)
|
||||
: flac_block_decompressor(folly::Range<uint8_t const*>(data, size),
|
||||
target) {}
|
||||
|
@ -35,9 +35,9 @@ namespace dwarfs {
|
||||
namespace {
|
||||
|
||||
struct lz4_compression_policy {
|
||||
static size_t compress(const void* src, void* dest, size_t size,
|
||||
static size_t compress(void const* src, void* dest, size_t size,
|
||||
size_t destsize, int /*level*/) {
|
||||
return to<size_t>(LZ4_compress_default(static_cast<const char*>(src),
|
||||
return to<size_t>(LZ4_compress_default(static_cast<char const*>(src),
|
||||
static_cast<char*>(dest),
|
||||
to<int>(size), to<int>(destsize)));
|
||||
}
|
||||
@ -46,9 +46,9 @@ struct lz4_compression_policy {
|
||||
};
|
||||
|
||||
struct lz4hc_compression_policy {
|
||||
static size_t compress(const void* src, void* dest, size_t size,
|
||||
static size_t compress(void const* src, void* dest, size_t size,
|
||||
size_t destsize, int level) {
|
||||
return to<size_t>(LZ4_compress_HC(static_cast<const char*>(src),
|
||||
return to<size_t>(LZ4_compress_HC(static_cast<char const*>(src),
|
||||
static_cast<char*>(dest), to<int>(size),
|
||||
to<int>(destsize), level));
|
||||
}
|
||||
@ -63,14 +63,14 @@ class lz4_block_compressor final : public block_compressor::impl {
|
||||
public:
|
||||
explicit lz4_block_compressor(int level = 0)
|
||||
: level_(level) {}
|
||||
lz4_block_compressor(const lz4_block_compressor& rhs) = default;
|
||||
lz4_block_compressor(lz4_block_compressor const& rhs) = default;
|
||||
|
||||
std::unique_ptr<block_compressor::impl> clone() const override {
|
||||
return std::make_unique<lz4_block_compressor>(*this);
|
||||
}
|
||||
|
||||
std::vector<uint8_t>
|
||||
compress(const std::vector<uint8_t>& data,
|
||||
compress(std::vector<uint8_t> const& data,
|
||||
std::string const* /*metadata*/) const override {
|
||||
std::vector<uint8_t> compressed(sizeof(uint32_t) +
|
||||
LZ4_compressBound(to<int>(data.size())));
|
||||
@ -109,12 +109,12 @@ class lz4_block_compressor final : public block_compressor::impl {
|
||||
}
|
||||
|
||||
private:
|
||||
const int level_;
|
||||
int const level_;
|
||||
};
|
||||
|
||||
class lz4_block_decompressor final : public block_decompressor::impl {
|
||||
public:
|
||||
lz4_block_decompressor(const uint8_t* data, size_t size,
|
||||
lz4_block_decompressor(uint8_t const* data, size_t size,
|
||||
std::vector<uint8_t>& target)
|
||||
: decompressed_(target)
|
||||
, data_(data + sizeof(uint32_t))
|
||||
@ -140,7 +140,7 @@ class lz4_block_decompressor final : public block_decompressor::impl {
|
||||
}
|
||||
|
||||
decompressed_.resize(uncompressed_size_);
|
||||
auto rv = LZ4_decompress_safe(reinterpret_cast<const char*>(data_),
|
||||
auto rv = LZ4_decompress_safe(reinterpret_cast<char const*>(data_),
|
||||
reinterpret_cast<char*>(&decompressed_[0]),
|
||||
static_cast<int>(input_size_),
|
||||
static_cast<int>(uncompressed_size_));
|
||||
@ -157,7 +157,7 @@ class lz4_block_decompressor final : public block_decompressor::impl {
|
||||
size_t uncompressed_size() const override { return uncompressed_size_; }
|
||||
|
||||
private:
|
||||
static size_t get_uncompressed_size(const uint8_t* data) {
|
||||
static size_t get_uncompressed_size(uint8_t const* data) {
|
||||
// TODO: enforce little-endian
|
||||
uint32_t size;
|
||||
::memcpy(&size, data, sizeof(size));
|
||||
@ -165,9 +165,9 @@ class lz4_block_decompressor final : public block_decompressor::impl {
|
||||
}
|
||||
|
||||
std::vector<uint8_t>& decompressed_;
|
||||
const uint8_t* const data_;
|
||||
const size_t input_size_;
|
||||
const size_t uncompressed_size_;
|
||||
uint8_t const* const data_;
|
||||
size_t const input_size_;
|
||||
size_t const uncompressed_size_;
|
||||
std::string error_;
|
||||
};
|
||||
|
||||
|
@ -93,7 +93,7 @@ std::string
|
||||
option_names(sorted_array_map<std::string_view, T, N> const& options) {
|
||||
// The string_view is needed because ranges::views::join() will include
|
||||
// the null terminator when using a string literal.
|
||||
static std::string_view constexpr kJoiner{", "};
|
||||
static constexpr std::string_view kJoiner{", "};
|
||||
return options | ranges::views::keys | ranges::views::join(kJoiner) |
|
||||
ranges::to<std::string>;
|
||||
}
|
||||
@ -108,13 +108,13 @@ std::string lzma_error_string(lzma_ret err) {
|
||||
class lzma_block_compressor final : public block_compressor::impl {
|
||||
public:
|
||||
explicit lzma_block_compressor(option_map& om);
|
||||
lzma_block_compressor(const lzma_block_compressor& rhs) = default;
|
||||
lzma_block_compressor(lzma_block_compressor const& rhs) = default;
|
||||
|
||||
std::unique_ptr<block_compressor::impl> clone() const override {
|
||||
return std::make_unique<lzma_block_compressor>(*this);
|
||||
}
|
||||
|
||||
std::vector<uint8_t> compress(const std::vector<uint8_t>& data,
|
||||
std::vector<uint8_t> compress(std::vector<uint8_t> const& data,
|
||||
std::string const* metadata) const override;
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved)
|
||||
@ -136,7 +136,7 @@ class lzma_block_compressor final : public block_compressor::impl {
|
||||
|
||||
private:
|
||||
std::vector<uint8_t>
|
||||
compress(const std::vector<uint8_t>& data, const lzma_filter* filters) const;
|
||||
compress(std::vector<uint8_t> const& data, lzma_filter const* filters) const;
|
||||
|
||||
static uint32_t get_preset(unsigned level, bool extreme) {
|
||||
uint32_t preset = level;
|
||||
@ -207,8 +207,8 @@ lzma_block_compressor::lzma_block_compressor(option_map& om) {
|
||||
}
|
||||
|
||||
std::vector<uint8_t>
|
||||
lzma_block_compressor::compress(const std::vector<uint8_t>& data,
|
||||
const lzma_filter* filters) const {
|
||||
lzma_block_compressor::compress(std::vector<uint8_t> const& data,
|
||||
lzma_filter const* filters) const {
|
||||
lzma_stream s = LZMA_STREAM_INIT;
|
||||
|
||||
if (auto ret = lzma_stream_encoder(&s, filters, LZMA_CHECK_CRC64);
|
||||
@ -247,7 +247,7 @@ lzma_block_compressor::compress(const std::vector<uint8_t>& data,
|
||||
}
|
||||
|
||||
std::vector<uint8_t>
|
||||
lzma_block_compressor::compress(const std::vector<uint8_t>& data,
|
||||
lzma_block_compressor::compress(std::vector<uint8_t> const& data,
|
||||
std::string const* /*metadata*/) const {
|
||||
auto lzma_opts = opt_lzma_;
|
||||
std::array<lzma_filter, 3> filters{{{binary_vli_, nullptr},
|
||||
@ -269,7 +269,7 @@ lzma_block_compressor::compress(const std::vector<uint8_t>& data,
|
||||
|
||||
class lzma_block_decompressor final : public block_decompressor::impl {
|
||||
public:
|
||||
lzma_block_decompressor(const uint8_t* data, size_t size,
|
||||
lzma_block_decompressor(uint8_t const* data, size_t size,
|
||||
std::vector<uint8_t>& target)
|
||||
: stream_(LZMA_STREAM_INIT)
|
||||
, decompressed_(target)
|
||||
@ -337,15 +337,15 @@ class lzma_block_decompressor final : public block_decompressor::impl {
|
||||
size_t uncompressed_size() const override { return uncompressed_size_; }
|
||||
|
||||
private:
|
||||
static size_t get_uncompressed_size(const uint8_t* data, size_t size);
|
||||
static size_t get_uncompressed_size(uint8_t const* data, size_t size);
|
||||
|
||||
lzma_stream stream_;
|
||||
std::vector<uint8_t>& decompressed_;
|
||||
const size_t uncompressed_size_;
|
||||
size_t const uncompressed_size_;
|
||||
std::string error_;
|
||||
};
|
||||
|
||||
size_t lzma_block_decompressor::get_uncompressed_size(const uint8_t* data,
|
||||
size_t lzma_block_decompressor::get_uncompressed_size(uint8_t const* data,
|
||||
size_t size) {
|
||||
if (size < 2 * LZMA_STREAM_HEADER_SIZE) {
|
||||
DWARFS_THROW(runtime_error, "lzma compressed block is too small");
|
||||
@ -353,7 +353,7 @@ size_t lzma_block_decompressor::get_uncompressed_size(const uint8_t* data,
|
||||
|
||||
lzma_stream s = LZMA_STREAM_INIT;
|
||||
file_off_t pos = size - LZMA_STREAM_HEADER_SIZE;
|
||||
const uint32_t* ptr = reinterpret_cast<const uint32_t*>(data + size) - 1;
|
||||
uint32_t const* ptr = reinterpret_cast<uint32_t const*>(data + size) - 1;
|
||||
|
||||
while (*ptr == 0) {
|
||||
pos -= 4;
|
||||
|
@ -35,14 +35,14 @@ namespace {
|
||||
class null_block_compressor final : public block_compressor::impl {
|
||||
public:
|
||||
null_block_compressor() = default;
|
||||
null_block_compressor(const null_block_compressor& rhs) = default;
|
||||
null_block_compressor(null_block_compressor const& rhs) = default;
|
||||
|
||||
std::unique_ptr<block_compressor::impl> clone() const override {
|
||||
return std::make_unique<null_block_compressor>(*this);
|
||||
}
|
||||
|
||||
std::vector<uint8_t>
|
||||
compress(const std::vector<uint8_t>& data,
|
||||
compress(std::vector<uint8_t> const& data,
|
||||
std::string const* /*metadata*/) const override {
|
||||
return data;
|
||||
}
|
||||
@ -67,7 +67,7 @@ class null_block_compressor final : public block_compressor::impl {
|
||||
|
||||
class null_block_decompressor final : public block_decompressor::impl {
|
||||
public:
|
||||
null_block_decompressor(const uint8_t* data, size_t size,
|
||||
null_block_decompressor(uint8_t const* data, size_t size,
|
||||
std::vector<uint8_t>& target)
|
||||
: decompressed_(target)
|
||||
, data_(data)
|
||||
@ -107,8 +107,8 @@ class null_block_decompressor final : public block_decompressor::impl {
|
||||
|
||||
private:
|
||||
std::vector<uint8_t>& decompressed_;
|
||||
const uint8_t* const data_;
|
||||
const size_t uncompressed_size_;
|
||||
uint8_t const* const data_;
|
||||
size_t const uncompressed_size_;
|
||||
};
|
||||
|
||||
class null_compression_factory : public compression_factory {
|
||||
|
@ -47,13 +47,13 @@ class ricepp_block_compressor final : public block_compressor::impl {
|
||||
ricepp_block_compressor(size_t block_size)
|
||||
: block_size_{block_size} {}
|
||||
|
||||
ricepp_block_compressor(const ricepp_block_compressor& rhs) = default;
|
||||
ricepp_block_compressor(ricepp_block_compressor const& rhs) = default;
|
||||
|
||||
std::unique_ptr<block_compressor::impl> clone() const override {
|
||||
return std::make_unique<ricepp_block_compressor>(*this);
|
||||
}
|
||||
|
||||
std::vector<uint8_t> compress(const std::vector<uint8_t>& data,
|
||||
std::vector<uint8_t> compress(std::vector<uint8_t> const& data,
|
||||
std::string const* metadata) const override {
|
||||
if (!metadata) {
|
||||
DWARFS_THROW(runtime_error,
|
||||
@ -174,7 +174,7 @@ class ricepp_block_compressor final : public block_compressor::impl {
|
||||
|
||||
class ricepp_block_decompressor final : public block_decompressor::impl {
|
||||
public:
|
||||
ricepp_block_decompressor(const uint8_t* data, size_t size,
|
||||
ricepp_block_decompressor(uint8_t const* data, size_t size,
|
||||
std::vector<uint8_t>& target)
|
||||
: ricepp_block_decompressor(folly::Range<uint8_t const*>(data, size),
|
||||
target) {}
|
||||
|
@ -48,13 +48,13 @@ class zstd_block_compressor final : public block_compressor::impl {
|
||||
: ctxmgr_{get_context_manager()}
|
||||
, level_{level} {}
|
||||
|
||||
zstd_block_compressor(const zstd_block_compressor& rhs) = default;
|
||||
zstd_block_compressor(zstd_block_compressor const& rhs) = default;
|
||||
|
||||
std::unique_ptr<block_compressor::impl> clone() const override {
|
||||
return std::make_unique<zstd_block_compressor>(*this);
|
||||
}
|
||||
|
||||
std::vector<uint8_t> compress(const std::vector<uint8_t>& data,
|
||||
std::vector<uint8_t> compress(std::vector<uint8_t> const& data,
|
||||
std::string const* metadata) const override;
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved)
|
||||
@ -90,11 +90,11 @@ class zstd_block_compressor final : public block_compressor::impl {
|
||||
static inline std::weak_ptr<zstd_context_manager> s_ctxmgr;
|
||||
|
||||
std::shared_ptr<zstd_context_manager> ctxmgr_;
|
||||
const int level_;
|
||||
int const level_;
|
||||
};
|
||||
|
||||
std::vector<uint8_t>
|
||||
zstd_block_compressor::compress(const std::vector<uint8_t>& data,
|
||||
zstd_block_compressor::compress(std::vector<uint8_t> const& data,
|
||||
std::string const* /*metadata*/) const {
|
||||
std::vector<uint8_t> compressed(ZSTD_compressBound(data.size()));
|
||||
auto ctx = ctxmgr_->make_context();
|
||||
@ -114,7 +114,7 @@ zstd_block_compressor::compress(const std::vector<uint8_t>& data,
|
||||
|
||||
class zstd_block_decompressor final : public block_decompressor::impl {
|
||||
public:
|
||||
zstd_block_decompressor(const uint8_t* data, size_t size,
|
||||
zstd_block_decompressor(uint8_t const* data, size_t size,
|
||||
std::vector<uint8_t>& target)
|
||||
: decompressed_(target)
|
||||
, data_(data)
|
||||
@ -169,9 +169,9 @@ class zstd_block_decompressor final : public block_decompressor::impl {
|
||||
|
||||
private:
|
||||
std::vector<uint8_t>& decompressed_;
|
||||
const uint8_t* const data_;
|
||||
const size_t size_;
|
||||
const unsigned long long uncompressed_size_;
|
||||
uint8_t const* const data_;
|
||||
size_t const size_;
|
||||
unsigned long long const uncompressed_size_;
|
||||
std::string error_;
|
||||
};
|
||||
|
||||
|
@ -47,7 +47,7 @@ void history::parse(std::span<uint8_t const> data) {
|
||||
}
|
||||
|
||||
void history::parse_append(std::span<uint8_t const> data) {
|
||||
folly::Range<const uint8_t*> range{data.data(), data.size()};
|
||||
folly::Range<uint8_t const*> range{data.data(), data.size()};
|
||||
thrift::history::history tmp;
|
||||
apache::thrift::CompactSerializer::deserialize(range, tmp);
|
||||
history_->entries()->insert(history_->entries()->end(),
|
||||
|
@ -182,7 +182,7 @@ class fs_section_v2 final : public fs_section::impl {
|
||||
return false;
|
||||
}
|
||||
|
||||
static auto constexpr kHdrCsLen =
|
||||
static constexpr auto kHdrCsLen =
|
||||
sizeof(section_header_v2) - offsetof(section_header_v2, number);
|
||||
|
||||
auto ok = checksum::verify(
|
||||
|
@ -31,7 +31,7 @@ namespace dwarfs::internal {
|
||||
|
||||
namespace {
|
||||
|
||||
std::string_view constexpr special_chars = R"(.^$|()[]{}+?*\)";
|
||||
constexpr std::string_view special_chars = R"(.^$|()[]{}+?*\)";
|
||||
|
||||
std::string escape_special(char c) {
|
||||
std::string esc;
|
||||
|
@ -55,7 +55,7 @@ template <typename LoggerPolicy, typename Policy>
|
||||
class basic_worker_group final : public worker_group::impl, private Policy {
|
||||
public:
|
||||
template <typename... Args>
|
||||
basic_worker_group(logger& lgr, os_access const& os, const char* group_name,
|
||||
basic_worker_group(logger& lgr, os_access const& os, char const* group_name,
|
||||
size_t num_workers, size_t max_queue_len,
|
||||
int niceness [[maybe_unused]], Args&&... args)
|
||||
: Policy(std::forward<Args>(args)...)
|
||||
@ -83,8 +83,8 @@ class basic_worker_group final : public worker_group::impl, private Policy {
|
||||
check_set_affinity_from_enviroment(group_name);
|
||||
}
|
||||
|
||||
basic_worker_group(const basic_worker_group&) = delete;
|
||||
basic_worker_group& operator=(const basic_worker_group&) = delete;
|
||||
basic_worker_group(basic_worker_group const&) = delete;
|
||||
basic_worker_group& operator=(basic_worker_group const&) = delete;
|
||||
|
||||
/**
|
||||
* Stop and destroy a worker group
|
||||
@ -233,7 +233,7 @@ class basic_worker_group final : public worker_group::impl, private Policy {
|
||||
return false;
|
||||
}
|
||||
|
||||
void check_set_affinity_from_enviroment(const char* group_name) {
|
||||
void check_set_affinity_from_enviroment(char const* group_name) {
|
||||
if (auto var = os_.getenv("DWARFS_WORKER_GROUP_AFFINITY")) {
|
||||
auto groups = split_to<std::vector<std::string_view>>(var.value(), ':');
|
||||
|
||||
@ -336,7 +336,7 @@ class basic_worker_group final : public worker_group::impl, private Policy {
|
||||
mutable std::mutex mx_;
|
||||
std::atomic<bool> running_;
|
||||
std::atomic<size_t> pending_;
|
||||
const size_t max_queue_len_;
|
||||
size_t const max_queue_len_;
|
||||
};
|
||||
|
||||
class no_policy {
|
||||
@ -353,7 +353,7 @@ using default_worker_group = basic_worker_group<LoggerPolicy, no_policy>;
|
||||
} // namespace
|
||||
|
||||
worker_group::worker_group(logger& lgr, os_access const& os,
|
||||
const char* group_name, size_t num_workers,
|
||||
char const* group_name, size_t num_workers,
|
||||
size_t max_queue_len, int niceness)
|
||||
: impl_{make_unique_logging_object<impl, default_worker_group,
|
||||
logger_policies>(
|
||||
|
@ -34,7 +34,7 @@
|
||||
|
||||
namespace dwarfs {
|
||||
|
||||
option_map::option_map(const std::string_view spec) {
|
||||
option_map::option_map(std::string_view const spec) {
|
||||
auto arg = split_to<std::vector<std::string_view>>(spec, ':');
|
||||
|
||||
choice_ = arg[0];
|
||||
@ -59,7 +59,7 @@ option_map::option_map(const std::string_view spec) {
|
||||
}
|
||||
}
|
||||
|
||||
size_t option_map::get_size(const std::string& key, size_t default_value) {
|
||||
size_t option_map::get_size(std::string const& key, size_t default_value) {
|
||||
auto i = opt_.find(key);
|
||||
|
||||
if (i != opt_.end()) {
|
||||
@ -75,7 +75,7 @@ void option_map::report() {
|
||||
if (!opt_.empty()) {
|
||||
std::vector<std::string> invalid;
|
||||
std::ranges::transform(opt_, std::back_inserter(invalid),
|
||||
[](const auto& p) { return p.first; });
|
||||
[](auto const& p) { return p.first; });
|
||||
std::ranges::sort(invalid);
|
||||
DWARFS_THROW(runtime_error,
|
||||
fmt::format("invalid option(s) for choice {}: {}", choice_,
|
||||
|
@ -151,7 +151,7 @@ metadata_v2
|
||||
make_metadata(logger& lgr, mmif& mm, section_map const& sections,
|
||||
std::vector<uint8_t>& schema_buffer,
|
||||
std::vector<uint8_t>& meta_buffer,
|
||||
const metadata_options& options, int inode_offset,
|
||||
metadata_options const& options, int inode_offset,
|
||||
bool force_buffers, mlock_mode lock_mode,
|
||||
bool force_consistency_check,
|
||||
std::shared_ptr<performance_monitor const> const& perfmon) {
|
||||
@ -213,7 +213,7 @@ template <typename LoggerPolicy>
|
||||
class filesystem_ final : public filesystem_v2::impl {
|
||||
public:
|
||||
filesystem_(logger& lgr, os_access const& os, std::shared_ptr<mmif> mm,
|
||||
const filesystem_options& options,
|
||||
filesystem_options const& options,
|
||||
std::shared_ptr<performance_monitor const> const& perfmon);
|
||||
|
||||
int check(filesystem_check_level level, size_t num_threads) const override;
|
||||
@ -654,7 +654,7 @@ void filesystem_<LoggerPolicy>::dump(std::ostream& os,
|
||||
}
|
||||
|
||||
meta_.dump(
|
||||
os, opts, get_info(opts), [&](const std::string& indent, uint32_t inode) {
|
||||
os, opts, get_info(opts), [&](std::string const& indent, uint32_t inode) {
|
||||
std::error_code ec;
|
||||
auto chunks = meta_.get_chunks(inode, ec);
|
||||
if (!ec) {
|
||||
@ -1116,7 +1116,7 @@ filesystem_v2::filesystem_v2(logger& lgr, os_access const& os,
|
||||
|
||||
filesystem_v2::filesystem_v2(
|
||||
logger& lgr, os_access const& os, std::shared_ptr<mmif> mm,
|
||||
const filesystem_options& options,
|
||||
filesystem_options const& options,
|
||||
std::shared_ptr<performance_monitor const> const& perfmon)
|
||||
: impl_(make_unique_logging_object<filesystem_v2::impl,
|
||||
internal::filesystem_, logger_policies>(
|
||||
|
@ -212,7 +212,7 @@ class block_request_set {
|
||||
std::vector<block_request> queue_;
|
||||
size_t range_end_{0};
|
||||
std::shared_ptr<cached_block> block_;
|
||||
const size_t block_no_;
|
||||
size_t const block_no_;
|
||||
};
|
||||
|
||||
// multi-threaded block cache
|
||||
@ -261,7 +261,7 @@ class block_cache_ final : public block_cache::impl {
|
||||
|
||||
LOG_DEBUG << "cached blocks:";
|
||||
|
||||
for (const auto& cb : cache_) {
|
||||
for (auto const& cb : cache_) {
|
||||
LOG_DEBUG << " block " << cb.first << ", decompression ratio = "
|
||||
<< double(cb.second->range_end()) /
|
||||
double(cb.second->uncompressed_size());
|
||||
@ -428,7 +428,7 @@ class block_cache_ final : public block_cache::impl {
|
||||
// That is a mighty long lock, let's see how it works...
|
||||
std::lock_guard lock(mx_);
|
||||
|
||||
const auto range_end = offset + size;
|
||||
auto const range_end = offset + size;
|
||||
|
||||
// See if the block is currently active (about-to-be decompressed)
|
||||
auto ia = active_.find(block_no);
|
||||
@ -444,7 +444,7 @@ class block_cache_ final : public block_cache::impl {
|
||||
auto end =
|
||||
std::remove_if(ia->second.begin(), ia->second.end(),
|
||||
[&brs, range_end, &add_to_set](
|
||||
const std::weak_ptr<block_request_set>& wp) {
|
||||
std::weak_ptr<block_request_set> const& wp) {
|
||||
if (auto rs = wp.lock()) {
|
||||
bool can_add_to_set = range_end <= rs->range_end();
|
||||
|
||||
@ -798,7 +798,7 @@ class block_cache_ final : public block_cache::impl {
|
||||
PERFMON_CLS_TIMER_DECL(decompress)
|
||||
std::unique_ptr<sequential_access_detector> seq_access_detector_;
|
||||
os_access const& os_;
|
||||
const block_cache_options options_;
|
||||
block_cache_options const options_;
|
||||
cache_tidy_config tidy_config_;
|
||||
};
|
||||
|
||||
@ -806,7 +806,7 @@ class block_cache_ final : public block_cache::impl {
|
||||
|
||||
block_cache::block_cache(
|
||||
logger& lgr, os_access const& os, std::shared_ptr<mmif> mm,
|
||||
const block_cache_options& options,
|
||||
block_cache_options const& options,
|
||||
std::shared_ptr<performance_monitor const> const& perfmon)
|
||||
: impl_(make_unique_logging_object<impl, block_cache_, logger_policies>(
|
||||
lgr, os, std::move(mm), options, perfmon)) {}
|
||||
|
@ -67,7 +67,7 @@ class cached_block_ final : public cached_block {
|
||||
// This can be called from any thread
|
||||
size_t range_end() const override { return range_end_.load(); }
|
||||
|
||||
const uint8_t* data() const override { return data_.data(); }
|
||||
uint8_t const* data() const override { return data_.data(); }
|
||||
|
||||
void decompress_until(size_t end) override {
|
||||
while (data_.size() < end) {
|
||||
|
@ -137,7 +137,7 @@ class inode_reader_ final : public inode_reader_v2::impl {
|
||||
std::vector<std::future<block_range>>
|
||||
readv(uint32_t inode, size_t size, file_off_t offset, size_t maxiov,
|
||||
chunk_range chunks, std::error_code& ec) const override;
|
||||
void dump(std::ostream& os, const std::string& indent,
|
||||
void dump(std::ostream& os, std::string const& indent,
|
||||
chunk_range chunks) const override;
|
||||
void set_num_workers(size_t num) override { cache_.set_num_workers(num); }
|
||||
void set_cache_tidy_config(cache_tidy_config const& cfg) override {
|
||||
@ -160,7 +160,7 @@ class inode_reader_ final : public inode_reader_v2::impl {
|
||||
template <typename StoreFunc>
|
||||
size_t read_internal(uint32_t inode, size_t size, file_off_t read_offset,
|
||||
size_t maxiov, chunk_range chunks, std::error_code& ec,
|
||||
const StoreFunc& store) const;
|
||||
StoreFunc const& store) const;
|
||||
|
||||
void do_readahead(uint32_t inode, chunk_range::iterator it,
|
||||
chunk_range::iterator const& end, file_off_t read_offset,
|
||||
@ -183,7 +183,7 @@ class inode_reader_ final : public inode_reader_v2::impl {
|
||||
|
||||
template <typename LoggerPolicy>
|
||||
void inode_reader_<LoggerPolicy>::dump(std::ostream& os,
|
||||
const std::string& indent,
|
||||
std::string const& indent,
|
||||
chunk_range chunks) const {
|
||||
for (auto const& [index, chunk] : ranges::views::enumerate(chunks)) {
|
||||
os << indent << " [" << index << "] -> (block=" << chunk.block()
|
||||
@ -346,7 +346,7 @@ template <typename LoggerPolicy>
|
||||
template <typename StoreFunc>
|
||||
size_t inode_reader_<LoggerPolicy>::read_internal(
|
||||
uint32_t inode, size_t size, file_off_t offset, size_t const maxiov,
|
||||
chunk_range chunks, std::error_code& ec, const StoreFunc& store) const {
|
||||
chunk_range chunks, std::error_code& ec, StoreFunc const& store) const {
|
||||
auto ranges = read_internal(inode, size, offset, maxiov, chunks, ec);
|
||||
|
||||
if (ec) {
|
||||
@ -413,7 +413,7 @@ size_t inode_reader_<LoggerPolicy>::read(char* buf, uint32_t inode, size_t size,
|
||||
PERFMON_SET_CONTEXT(static_cast<uint64_t>(offset), size);
|
||||
|
||||
return read_internal(inode, size, offset, kReadAllIOV, chunks, ec,
|
||||
[&](size_t num_read, const block_range& br) {
|
||||
[&](size_t num_read, block_range const& br) {
|
||||
::memcpy(buf + num_read, br.data(), br.size());
|
||||
});
|
||||
}
|
||||
@ -439,7 +439,7 @@ size_t inode_reader_<LoggerPolicy>::readv(iovec_read_buf& buf, uint32_t inode,
|
||||
PERFMON_SET_CONTEXT(static_cast<uint64_t>(offset), size);
|
||||
|
||||
auto rv = read_internal(inode, size, offset, maxiov, chunks, ec,
|
||||
[&](size_t, const block_range& br) {
|
||||
[&](size_t, block_range const& br) {
|
||||
auto& iov = buf.buf.emplace_back();
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
|
||||
iov.iov_base = const_cast<uint8_t*>(br.data());
|
||||
|
@ -386,7 +386,7 @@ get_category_info(MappedFrozen<thrift::metadata::metadata> const& meta,
|
||||
return catinfo;
|
||||
}
|
||||
|
||||
const uint16_t READ_ONLY_MASK = ~uint16_t(
|
||||
uint16_t const READ_ONLY_MASK = ~uint16_t(
|
||||
fs::perms::owner_write | fs::perms::group_write | fs::perms::others_write);
|
||||
|
||||
} // namespace
|
||||
@ -488,7 +488,7 @@ class metadata_ final : public metadata_v2::impl {
|
||||
|
||||
void dump(std::ostream& os, fsinfo_options const& opts,
|
||||
filesystem_info const* fsinfo,
|
||||
std::function<void(const std::string&, uint32_t)> const& icb)
|
||||
std::function<void(std::string const&, uint32_t)> const& icb)
|
||||
const override;
|
||||
|
||||
nlohmann::json info_as_json(fsinfo_options const& opts,
|
||||
@ -663,12 +663,12 @@ class metadata_ final : public metadata_v2::impl {
|
||||
|
||||
// TODO: see if we really need to pass the extra dir_entry_view in
|
||||
// addition to directory_view
|
||||
void dump(std::ostream& os, const std::string& indent,
|
||||
void dump(std::ostream& os, std::string const& indent,
|
||||
dir_entry_view const& entry, fsinfo_options const& opts,
|
||||
std::function<void(const std::string&, uint32_t)> const& icb) const;
|
||||
void dump(std::ostream& os, const std::string& indent, directory_view dir,
|
||||
std::function<void(std::string const&, uint32_t)> const& icb) const;
|
||||
void dump(std::ostream& os, std::string const& indent, directory_view dir,
|
||||
dir_entry_view const& entry, fsinfo_options const& opts,
|
||||
std::function<void(const std::string&, uint32_t)> const& icb) const;
|
||||
std::function<void(std::string const&, uint32_t)> const& icb) const;
|
||||
|
||||
nlohmann::json as_json(dir_entry_view const& entry) const;
|
||||
nlohmann::json as_json(directory_view dir, dir_entry_view const& entry) const;
|
||||
@ -1018,20 +1018,20 @@ class metadata_ final : public metadata_v2::impl {
|
||||
|
||||
std::span<uint8_t const> data_;
|
||||
MappedFrozen<thrift::metadata::metadata> meta_;
|
||||
const global_metadata global_;
|
||||
global_metadata const global_;
|
||||
dir_entry_view root_;
|
||||
LOG_PROXY_DECL(LoggerPolicy);
|
||||
const int inode_offset_;
|
||||
const int symlink_inode_offset_;
|
||||
const int file_inode_offset_;
|
||||
const int dev_inode_offset_;
|
||||
const int inode_count_;
|
||||
const packed_int_vector<uint32_t> nlinks_;
|
||||
const packed_int_vector<uint32_t> chunk_table_;
|
||||
const packed_int_vector<uint32_t> shared_files_;
|
||||
const int unique_files_;
|
||||
const metadata_options options_;
|
||||
const string_table symlinks_;
|
||||
int const inode_offset_;
|
||||
int const symlink_inode_offset_;
|
||||
int const file_inode_offset_;
|
||||
int const dev_inode_offset_;
|
||||
int const inode_count_;
|
||||
packed_int_vector<uint32_t> const nlinks_;
|
||||
packed_int_vector<uint32_t> const chunk_table_;
|
||||
packed_int_vector<uint32_t> const shared_files_;
|
||||
int const unique_files_;
|
||||
metadata_options const options_;
|
||||
string_table const symlinks_;
|
||||
std::vector<packed_int_vector<uint32_t>> const dir_icase_cache_;
|
||||
PERFMON_CLS_PROXY_DECL
|
||||
PERFMON_CLS_TIMER_DECL(find)
|
||||
@ -1181,9 +1181,9 @@ void metadata_<LoggerPolicy>::check_consistency() const {
|
||||
|
||||
template <typename LoggerPolicy>
|
||||
void metadata_<LoggerPolicy>::dump(
|
||||
std::ostream& os, const std::string& indent, dir_entry_view const& entry,
|
||||
std::ostream& os, std::string const& indent, dir_entry_view const& entry,
|
||||
fsinfo_options const& opts,
|
||||
std::function<void(const std::string&, uint32_t)> const& icb) const {
|
||||
std::function<void(std::string const&, uint32_t)> const& icb) const {
|
||||
auto iv = entry.inode();
|
||||
auto mode = iv.mode();
|
||||
auto inode = iv.inode_num();
|
||||
@ -1355,9 +1355,9 @@ metadata_<LoggerPolicy>::info_as_json(fsinfo_options const& opts,
|
||||
// TODO: can we move this to dir_entry_view?
|
||||
template <typename LoggerPolicy>
|
||||
void metadata_<LoggerPolicy>::dump(
|
||||
std::ostream& os, const std::string& indent, directory_view dir,
|
||||
std::ostream& os, std::string const& indent, directory_view dir,
|
||||
dir_entry_view const& entry, fsinfo_options const& opts,
|
||||
std::function<void(const std::string&, uint32_t)> const& icb) const {
|
||||
std::function<void(std::string const&, uint32_t)> const& icb) const {
|
||||
auto range = dir.entry_range();
|
||||
|
||||
os << " (" << range.size() << " entries, parent=" << dir.parent_entry()
|
||||
@ -1372,7 +1372,7 @@ void metadata_<LoggerPolicy>::dump(
|
||||
template <typename LoggerPolicy>
|
||||
void metadata_<LoggerPolicy>::dump(
|
||||
std::ostream& os, fsinfo_options const& opts, filesystem_info const* fsinfo,
|
||||
std::function<void(const std::string&, uint32_t)> const& icb) const {
|
||||
std::function<void(std::string const&, uint32_t)> const& icb) const {
|
||||
vfs_stat stbuf;
|
||||
statvfs(&stbuf);
|
||||
|
||||
|
@ -29,7 +29,7 @@ thread_pool::thread_pool() = default;
|
||||
thread_pool::~thread_pool() = default;
|
||||
|
||||
thread_pool::thread_pool(logger& lgr, os_access const& os,
|
||||
const char* group_name, size_t num_workers,
|
||||
char const* group_name, size_t num_workers,
|
||||
size_t max_queue_len, int niceness)
|
||||
: wg_{std::make_unique<internal::worker_group>(
|
||||
lgr, os, group_name, num_workers, max_queue_len, niceness)} {}
|
||||
|
@ -461,7 +461,7 @@ std::vector<HANDLE> suspend_other_threads() {
|
||||
return handles;
|
||||
}
|
||||
|
||||
void resume_suspended_threads(const std::vector<HANDLE>& handles) {
|
||||
void resume_suspended_threads(std::vector<HANDLE> const& handles) {
|
||||
for (auto th : handles) {
|
||||
::ResumeThread(th);
|
||||
::CloseHandle(th);
|
||||
|
@ -72,7 +72,7 @@ void rewrite_filesystem(logger& lgr, dwarfs::reader::filesystem_v2 const& fs,
|
||||
size_t block_no{0};
|
||||
|
||||
auto log_rewrite =
|
||||
[&](bool compressing, const auto& s,
|
||||
[&](bool compressing, auto const& s,
|
||||
std::optional<fragment_category::value_type> const& cat) {
|
||||
auto prefix = compressing ? "recompressing" : "copying";
|
||||
std::string catinfo;
|
||||
@ -91,12 +91,12 @@ void rewrite_filesystem(logger& lgr, dwarfs::reader::filesystem_v2 const& fs,
|
||||
};
|
||||
|
||||
auto log_recompress =
|
||||
[&](const auto& s,
|
||||
[&](auto const& s,
|
||||
std::optional<fragment_category::value_type> const& cat =
|
||||
std::nullopt) { log_rewrite(true, s, cat); };
|
||||
|
||||
auto copy_compressed =
|
||||
[&](const auto& s,
|
||||
[&](auto const& s,
|
||||
std::optional<fragment_category::value_type> const& cat =
|
||||
std::nullopt) {
|
||||
log_rewrite(false, s, cat);
|
||||
|
@ -196,7 +196,7 @@ class fsblock_merger_policy {
|
||||
|
||||
class raw_fsblock : public fsblock::impl {
|
||||
public:
|
||||
raw_fsblock(section_type type, const block_compressor& bc,
|
||||
raw_fsblock(section_type type, block_compressor const& bc,
|
||||
std::shared_ptr<block_data>&& data,
|
||||
std::shared_ptr<compression_progress> pctx,
|
||||
folly::Function<void(size_t)> set_block_cb)
|
||||
@ -286,9 +286,9 @@ class raw_fsblock : public fsblock::impl {
|
||||
}
|
||||
|
||||
private:
|
||||
const section_type type_;
|
||||
section_type const type_;
|
||||
block_compressor const& bc_;
|
||||
const size_t uncompressed_size_;
|
||||
size_t const uncompressed_size_;
|
||||
mutable std::recursive_mutex mx_;
|
||||
std::shared_ptr<block_data> data_;
|
||||
std::future<void> future_;
|
||||
@ -459,7 +459,7 @@ class rewritten_fsblock : public fsblock::impl {
|
||||
}
|
||||
|
||||
private:
|
||||
const section_type type_;
|
||||
section_type const type_;
|
||||
block_compressor const& bc_;
|
||||
mutable std::recursive_mutex mx_;
|
||||
std::span<uint8_t const> data_;
|
||||
@ -603,9 +603,9 @@ class filesystem_writer_ final : public filesystem_writer_detail {
|
||||
void
|
||||
write_section_impl(section_type type, std::shared_ptr<block_data>&& data);
|
||||
void write(fsblock const& fsb);
|
||||
void write(const char* data, size_t size);
|
||||
void write(char const* data, size_t size);
|
||||
template <typename T>
|
||||
void write(const T& obj);
|
||||
void write(T const& obj);
|
||||
void write(std::span<uint8_t const> range);
|
||||
void writer_thread();
|
||||
void push_section_index(section_type type);
|
||||
@ -627,7 +627,7 @@ class filesystem_writer_ final : public filesystem_writer_detail {
|
||||
std::shared_ptr<compression_progress> pctx_;
|
||||
mutable std::mutex mx_;
|
||||
std::condition_variable cond_;
|
||||
volatile bool flush_{true};
|
||||
bool volatile flush_{true};
|
||||
std::thread writer_thread_;
|
||||
uint32_t section_number_{0};
|
||||
std::vector<uint64_t> section_index_;
|
||||
@ -719,7 +719,7 @@ template <typename LoggerPolicy>
|
||||
size_t filesystem_writer_<LoggerPolicy>::mem_used() const {
|
||||
size_t s = 0;
|
||||
|
||||
for (const auto& holder : queue_) {
|
||||
for (auto const& holder : queue_) {
|
||||
s += holder.value()->size();
|
||||
}
|
||||
|
||||
@ -727,7 +727,7 @@ size_t filesystem_writer_<LoggerPolicy>::mem_used() const {
|
||||
}
|
||||
|
||||
template <typename LoggerPolicy>
|
||||
void filesystem_writer_<LoggerPolicy>::write(const char* data, size_t size) {
|
||||
void filesystem_writer_<LoggerPolicy>::write(char const* data, size_t size) {
|
||||
// TODO: error handling :-)
|
||||
os_.write(data, size);
|
||||
image_size_ += size;
|
||||
@ -736,13 +736,13 @@ void filesystem_writer_<LoggerPolicy>::write(const char* data, size_t size) {
|
||||
|
||||
template <typename LoggerPolicy>
|
||||
template <typename T>
|
||||
void filesystem_writer_<LoggerPolicy>::write(const T& obj) {
|
||||
write(reinterpret_cast<const char*>(&obj), sizeof(T));
|
||||
void filesystem_writer_<LoggerPolicy>::write(T const& obj) {
|
||||
write(reinterpret_cast<char const*>(&obj), sizeof(T));
|
||||
}
|
||||
|
||||
template <typename LoggerPolicy>
|
||||
void filesystem_writer_<LoggerPolicy>::write(std::span<uint8_t const> range) {
|
||||
write(reinterpret_cast<const char*>(range.data()), range.size());
|
||||
write(reinterpret_cast<char const*>(range.data()), range.size());
|
||||
}
|
||||
|
||||
template <typename LoggerPolicy>
|
||||
|
@ -37,21 +37,21 @@ namespace dwarfs::writer {
|
||||
|
||||
namespace {
|
||||
|
||||
std::array<std::pair<std::string_view, fragment_order_mode>,
|
||||
5> constexpr order_choices{{
|
||||
{"none", fragment_order_mode::NONE},
|
||||
{"path", fragment_order_mode::PATH},
|
||||
{"revpath", fragment_order_mode::REVPATH},
|
||||
{"similarity", fragment_order_mode::SIMILARITY},
|
||||
{"nilsimsa", fragment_order_mode::NILSIMSA},
|
||||
}};
|
||||
constexpr std::array<std::pair<std::string_view, fragment_order_mode>, 5>
|
||||
order_choices{{
|
||||
{"none", fragment_order_mode::NONE},
|
||||
{"path", fragment_order_mode::PATH},
|
||||
{"revpath", fragment_order_mode::REVPATH},
|
||||
{"similarity", fragment_order_mode::SIMILARITY},
|
||||
{"nilsimsa", fragment_order_mode::NILSIMSA},
|
||||
}};
|
||||
|
||||
} // namespace
|
||||
|
||||
std::string fragment_order_parser::choices() {
|
||||
// The string_view is needed because ranges::views::join() will include
|
||||
// the null terminator when using a string literal.
|
||||
static std::string_view constexpr kJoiner{", "};
|
||||
static constexpr std::string_view kJoiner{", "};
|
||||
return ranges::views::keys(order_choices) | ranges::views::join(kJoiner) |
|
||||
ranges::to<std::string>();
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ bool entry::has_parent() const {
|
||||
|
||||
std::shared_ptr<entry> entry::parent() const { return parent_.lock(); }
|
||||
|
||||
void entry::set_name(const std::string& name) { name_ = name; }
|
||||
void entry::set_name(std::string const& name) { name_ = name; }
|
||||
|
||||
std::u8string entry::u8name() const { return string_to_u8string(name_); }
|
||||
|
||||
@ -161,7 +161,7 @@ bool entry::is_directory() const { return stat_.is_directory(); }
|
||||
|
||||
void entry::walk(std::function<void(entry*)> const& f) { f(this); }
|
||||
|
||||
void entry::walk(std::function<void(const entry*)> const& f) const { f(this); }
|
||||
void entry::walk(std::function<void(entry const*)> const& f) const { f(this); }
|
||||
|
||||
void entry::update(global_entry_data& data) const {
|
||||
stat_.ensure_valid(file_stat::uid_valid | file_stat::gid_valid |
|
||||
@ -331,7 +331,7 @@ void dir::walk(std::function<void(entry*)> const& f) {
|
||||
}
|
||||
}
|
||||
|
||||
void dir::walk(std::function<void(const entry*)> const& f) const {
|
||||
void dir::walk(std::function<void(entry const*)> const& f) const {
|
||||
f(this);
|
||||
|
||||
for (entry_ptr const& e : entries_) {
|
||||
@ -452,7 +452,7 @@ void dir::populate_lookup_table() {
|
||||
|
||||
entry::type_t link::type() const { return E_LINK; }
|
||||
|
||||
const std::string& link::linkname() const { return link_; }
|
||||
std::string const& link::linkname() const { return link_; }
|
||||
|
||||
void link::accept(entry_visitor& v, bool) { v.visit(this); }
|
||||
|
||||
|
@ -35,7 +35,7 @@ namespace {
|
||||
|
||||
template <class T>
|
||||
std::pair<std::vector<uint8_t>, std::vector<uint8_t>>
|
||||
freeze_to_buffer(const T& x) {
|
||||
freeze_to_buffer(T const& x) {
|
||||
using namespace ::apache::thrift::frozen;
|
||||
|
||||
Layout<T> layout;
|
||||
@ -62,7 +62,7 @@ freeze_to_buffer(const T& x) {
|
||||
} // namespace
|
||||
|
||||
std::pair<std::vector<uint8_t>, std::vector<uint8_t>>
|
||||
metadata_freezer::freeze(const thrift::metadata::metadata& data) {
|
||||
metadata_freezer::freeze(thrift::metadata::metadata const& data) {
|
||||
return freeze_to_buffer(data);
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ auto progress::get_active_contexts() const
|
||||
contexts_.end());
|
||||
}
|
||||
|
||||
std::ranges::stable_sort(rv, [](const auto& a, const auto& b) {
|
||||
std::ranges::stable_sort(rv, [](auto const& a, auto const& b) {
|
||||
return a->get_priority() > b->get_priority();
|
||||
});
|
||||
|
||||
|
@ -69,7 +69,7 @@ class similarity::impl {
|
||||
|
||||
uint32_t finalize() {
|
||||
std::partial_sort(vec_.begin(), vec_.begin() + 4, vec_.end(),
|
||||
[](const auto& a, const auto& b) {
|
||||
[](auto const& a, auto const& b) {
|
||||
return a.first > b.first ||
|
||||
(a.first == b.first && a.second < b.second);
|
||||
});
|
||||
|
@ -260,7 +260,7 @@ filter_action rule_based_entry_filter_<LoggerPolicy>::filter(
|
||||
relpath.erase(0, root_path_.size());
|
||||
}
|
||||
|
||||
for (const auto& r : filter_) {
|
||||
for (auto const& r : filter_) {
|
||||
if (std::regex_match(r.floating ? path : relpath, r.re)) {
|
||||
LOG_TRACE << "[" << path << "] / [" << relpath << "] matched rule '"
|
||||
<< r.rule << "'";
|
||||
|
@ -298,7 +298,7 @@ class scanner_ final : public scanner::impl {
|
||||
public:
|
||||
scanner_(logger& lgr, worker_group& wg, segmenter_factory& sf,
|
||||
entry_factory& ef, os_access const& os,
|
||||
const scanner_options& options);
|
||||
scanner_options const& options);
|
||||
|
||||
void add_filter(std::unique_ptr<entry_filter>&& filter) override;
|
||||
|
||||
@ -354,7 +354,7 @@ template <typename LoggerPolicy>
|
||||
scanner_<LoggerPolicy>::scanner_(logger& lgr, worker_group& wg,
|
||||
segmenter_factory& sf, entry_factory& ef,
|
||||
os_access const& os,
|
||||
const scanner_options& options)
|
||||
scanner_options const& options)
|
||||
: LOG_PROXY_INIT(lgr)
|
||||
, wg_{wg}
|
||||
, options_{options}
|
||||
@ -483,7 +483,7 @@ scanner_<LoggerPolicy>::add_entry(std::filesystem::path const& name,
|
||||
}
|
||||
|
||||
return pe;
|
||||
} catch (const std::system_error& e) {
|
||||
} catch (std::system_error const& e) {
|
||||
LOG_ERROR << fmt::format("error reading entry (path={}): {}",
|
||||
path_to_utf8_string_sanitized(name),
|
||||
exception_str(e));
|
||||
@ -563,7 +563,7 @@ scanner_<LoggerPolicy>::scan_tree(std::filesystem::path const& path,
|
||||
queue.insert(queue.begin(), subdirs.begin(), subdirs.end());
|
||||
|
||||
prog.dirs_scanned++;
|
||||
} catch (const std::system_error& e) {
|
||||
} catch (std::system_error const& e) {
|
||||
LOG_ERROR << "cannot read directory `"
|
||||
<< path_to_utf8_string_sanitized(ppath)
|
||||
<< "`: " << exception_str(e);
|
||||
@ -657,7 +657,7 @@ scanner_<LoggerPolicy>::scan_list(std::filesystem::path const& path,
|
||||
|
||||
template <typename LoggerPolicy>
|
||||
void scanner_<LoggerPolicy>::scan(
|
||||
filesystem_writer& fs_writer, const std::filesystem::path& path,
|
||||
filesystem_writer& fs_writer, std::filesystem::path const& path,
|
||||
writer_progress& wprog,
|
||||
std::optional<std::span<std::filesystem::path const>> list,
|
||||
std::shared_ptr<file_access const> fa) {
|
||||
@ -1077,7 +1077,7 @@ void scanner_<LoggerPolicy>::scan(
|
||||
|
||||
scanner::scanner(logger& lgr, thread_pool& pool, segmenter_factory& sf,
|
||||
entry_factory& ef, os_access const& os,
|
||||
const scanner_options& options)
|
||||
scanner_options const& options)
|
||||
: impl_(
|
||||
make_unique_logging_object<impl, internal::scanner_, logger_policies>(
|
||||
lgr, pool.get_worker_group(), sf, ef, os, options)) {}
|
||||
|
@ -743,7 +743,7 @@ class segmenter_ final : public segmenter::impl, private SegmentingPolicy {
|
||||
segment_and_add_data(chunkable& chkable, size_t size_in_frames);
|
||||
|
||||
DWARFS_FORCE_INLINE size_t
|
||||
bloom_filter_size(const segmenter::config& cfg) const {
|
||||
bloom_filter_size(segmenter::config const& cfg) const {
|
||||
if constexpr (is_segmentation_enabled()) {
|
||||
auto hash_count =
|
||||
std::bit_ceil(std::max<size_t>(1, cfg.max_active_blocks) *
|
||||
@ -754,18 +754,18 @@ class segmenter_ final : public segmenter::impl, private SegmentingPolicy {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static DWARFS_FORCE_INLINE size_t window_size(const segmenter::config& cfg) {
|
||||
static DWARFS_FORCE_INLINE size_t window_size(segmenter::config const& cfg) {
|
||||
return cfg.blockhash_window_size > 0
|
||||
? static_cast<size_t>(1) << cfg.blockhash_window_size
|
||||
: 0;
|
||||
}
|
||||
|
||||
static DWARFS_FORCE_INLINE size_t window_step(const segmenter::config& cfg) {
|
||||
static DWARFS_FORCE_INLINE size_t window_step(segmenter::config const& cfg) {
|
||||
return std::max<size_t>(1, window_size(cfg) >> cfg.window_increment_shift);
|
||||
}
|
||||
|
||||
size_t DWARFS_FORCE_INLINE
|
||||
block_size_in_frames(const segmenter::config& cfg) const {
|
||||
block_size_in_frames(segmenter::config const& cfg) const {
|
||||
auto raw_size = static_cast<size_t>(1) << cfg.block_size_bits;
|
||||
return bytes_to_frames(constrained_block_size(raw_size));
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ namespace dwarfs {
|
||||
|
||||
namespace {
|
||||
|
||||
ssize_t portable_getxattr(const char* path, const char* name, void* value,
|
||||
ssize_t portable_getxattr(char const* path, char const* name, void* value,
|
||||
size_t size) {
|
||||
#ifdef __APPLE__
|
||||
return ::getxattr(path, name, value, size, 0, 0);
|
||||
@ -37,7 +37,7 @@ ssize_t portable_getxattr(const char* path, const char* name, void* value,
|
||||
#endif
|
||||
}
|
||||
|
||||
int portable_setxattr(const char* path, const char* name, const void* value,
|
||||
int portable_setxattr(char const* path, char const* name, void const* value,
|
||||
size_t size, int flags) {
|
||||
#ifdef __APPLE__
|
||||
return ::setxattr(path, name, value, size, 0, flags);
|
||||
@ -46,7 +46,7 @@ int portable_setxattr(const char* path, const char* name, const void* value,
|
||||
#endif
|
||||
}
|
||||
|
||||
int portable_removexattr(const char* path, const char* name) {
|
||||
int portable_removexattr(char const* path, char const* name) {
|
||||
#ifdef __APPLE__
|
||||
return ::removexattr(path, name, 0);
|
||||
#else
|
||||
@ -54,7 +54,7 @@ int portable_removexattr(const char* path, const char* name) {
|
||||
#endif
|
||||
}
|
||||
|
||||
ssize_t portable_listxattr(const char* path, char* list, size_t size) {
|
||||
ssize_t portable_listxattr(char const* path, char* list, size_t size) {
|
||||
#ifdef __APPLE__
|
||||
return ::listxattr(path, list, size, 0);
|
||||
#else
|
||||
|
@ -36,7 +36,7 @@ using namespace dwarfs;
|
||||
|
||||
namespace {
|
||||
|
||||
const auto testdata{std::filesystem::path{TEST_DATA_DIR} / "badfs"};
|
||||
auto const testdata{std::filesystem::path{TEST_DATA_DIR} / "badfs"};
|
||||
|
||||
std::vector<std::string> files;
|
||||
|
||||
|
@ -42,7 +42,7 @@ class mock_cached_block : public reader::internal::cached_block {
|
||||
: span_{span} {}
|
||||
|
||||
size_t range_end() const override { return span_ ? span_->size() : 0; }
|
||||
const uint8_t* data() const override {
|
||||
uint8_t const* data() const override {
|
||||
return span_ ? span_->data() : nullptr;
|
||||
}
|
||||
void decompress_until(size_t) override {}
|
||||
|
@ -869,9 +869,9 @@ void walk_tree(reader::filesystem_v2 const& fs, T& cb,
|
||||
|
||||
void check_compat(logger& lgr, reader::filesystem_v2 const& fs,
|
||||
std::string const& version, bool enable_nlink) {
|
||||
const bool has_devices = not(version == "0.2.0" or version == "0.2.3");
|
||||
const bool has_ac_time = version == "0.2.0" or version == "0.2.3";
|
||||
const bool nlink_affects_blocks =
|
||||
bool const has_devices = not(version == "0.2.0" or version == "0.2.3");
|
||||
bool const has_ac_time = version == "0.2.0" or version == "0.2.3";
|
||||
bool const nlink_affects_blocks =
|
||||
not(version.starts_with("0.2.") or version.starts_with("0.3.") or
|
||||
version.starts_with("0.4."));
|
||||
auto const expected_blocks =
|
||||
|
@ -35,15 +35,15 @@
|
||||
|
||||
namespace {
|
||||
|
||||
std::array<std::string_view, 5> constexpr integer_strings = {
|
||||
constexpr std::array<std::string_view, 5> integer_strings = {
|
||||
"0", "4711", "42", "1337", "1234567890",
|
||||
};
|
||||
|
||||
std::array<std::string_view, 5> constexpr integer_strings_invalid = {
|
||||
constexpr std::array<std::string_view, 5> integer_strings_invalid = {
|
||||
"a", "4711a", "42a", "1337a", "1234567890a",
|
||||
};
|
||||
|
||||
std::array<int, 5> constexpr integer_values = {0, 4711, 42, 1337, 1234567890};
|
||||
constexpr std::array<int, 5> integer_values = {0, 4711, 42, 1337, 1234567890};
|
||||
|
||||
void int_to_string_folly_to(::benchmark::State& state) {
|
||||
for (auto _ : state) {
|
||||
@ -96,7 +96,7 @@ void string_to_int_lexical_cast_invalid(::benchmark::State& state) {
|
||||
try {
|
||||
auto v = boost::lexical_cast<int>(s);
|
||||
benchmark::DoNotOptimize(v);
|
||||
} catch (const boost::bad_lexical_cast&) {
|
||||
} catch (boost::bad_lexical_cast const&) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ class filesystem : public ::benchmark::Fixture {
|
||||
fs.reset();
|
||||
}
|
||||
|
||||
void read_bench(::benchmark::State& state, const char* file) {
|
||||
void read_bench(::benchmark::State& state, char const* file) {
|
||||
auto dev = fs->find(file);
|
||||
auto iv = dev->inode();
|
||||
auto st = fs->getattr(iv);
|
||||
@ -250,7 +250,7 @@ class filesystem : public ::benchmark::Fixture {
|
||||
}
|
||||
}
|
||||
|
||||
void read_string_bench(::benchmark::State& state, const char* file) {
|
||||
void read_string_bench(::benchmark::State& state, char const* file) {
|
||||
auto dev = fs->find(file);
|
||||
auto i = fs->open(dev->inode());
|
||||
|
||||
@ -336,8 +336,8 @@ class filesystem_walk : public ::benchmark::Fixture {
|
||||
std::unique_ptr<reader::filesystem_v2> fs;
|
||||
|
||||
private:
|
||||
constexpr static int kDimension{32};
|
||||
constexpr static size_t kPatternLength{16};
|
||||
static constexpr int kDimension{32};
|
||||
static constexpr size_t kPatternLength{16};
|
||||
|
||||
static std::string make_data(std::mt19937_64& rng, size_t size) {
|
||||
std::string data;
|
||||
|
@ -2197,7 +2197,7 @@ TEST(filesystem, case_insensitive_lookup) {
|
||||
EXPECT_THAT(
|
||||
lgr.get_log(),
|
||||
testing::Contains(testing::ResultOf(
|
||||
[](const auto& entry) { return entry.output; },
|
||||
[](auto const& entry) { return entry.output; },
|
||||
testing::AllOf(testing::HasSubstr(u8string_to_string(
|
||||
u8"case-insensitive collision in directory "
|
||||
u8"\"lõREMÏpSüM\" (inode=")),
|
||||
|
@ -59,7 +59,7 @@ TEST(error_test, runtime_error) {
|
||||
try {
|
||||
test_throw_runtime_error(true);
|
||||
FAIL() << "expected runtime_error to be thrown";
|
||||
} catch (const runtime_error& e) {
|
||||
} catch (runtime_error const& e) {
|
||||
EXPECT_EQ("error_test.cpp",
|
||||
std::filesystem::path(e.file()).filename().string());
|
||||
EXPECT_EQ(fmt::format("my test error [error_test.cpp:{}]", e.line()),
|
||||
@ -77,7 +77,7 @@ TEST(error_test, system_error) {
|
||||
try {
|
||||
test_throw_system_error(true);
|
||||
FAIL() << "expected system_error to be thrown";
|
||||
} catch (const system_error& e) {
|
||||
} catch (system_error const& e) {
|
||||
EXPECT_THAT(std::string(e.what()),
|
||||
::testing::MatchesRegex("my test system error: .*"));
|
||||
EXPECT_EQ("error_test.cpp",
|
||||
|
@ -335,9 +335,9 @@ TEST(glob_matcher_test, python_case) {
|
||||
}
|
||||
|
||||
TEST(glob_matcher_test, python_char_set) {
|
||||
static std::string_view constexpr testcases =
|
||||
static constexpr std::string_view testcases =
|
||||
R"(abcdefghijklmnopqrstuvwxyz0123456789!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~)";
|
||||
static std::string_view constexpr uppercase = R"(ABCDEFGHIJKLMNOPQRSTUVWXYZ)";
|
||||
static constexpr std::string_view uppercase = R"(ABCDEFGHIJKLMNOPQRSTUVWXYZ)";
|
||||
using namespace std::literals;
|
||||
|
||||
for (char c : testcases) {
|
||||
@ -391,9 +391,9 @@ TEST(glob_matcher_test, python_char_set) {
|
||||
}
|
||||
|
||||
TEST(glob_matcher_test, python_range) {
|
||||
static std::string_view constexpr testcases =
|
||||
static constexpr std::string_view testcases =
|
||||
R"(abcdefghijklmnopqrstuvwxyz0123456789!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~)";
|
||||
static std::string_view constexpr uppercase = R"(ABCDEFGHIJKLMNOPQRSTUVWXYZ)";
|
||||
static constexpr std::string_view uppercase = R"(ABCDEFGHIJKLMNOPQRSTUVWXYZ)";
|
||||
using namespace std::literals;
|
||||
|
||||
for (char c : testcases) {
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
namespace {
|
||||
|
||||
const std::string s_loremipsum(
|
||||
std::string const s_loremipsum(
|
||||
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo "
|
||||
"igula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis "
|
||||
"is parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies "
|
||||
@ -412,7 +412,7 @@ const std::string s_loremipsum(
|
||||
namespace dwarfs {
|
||||
namespace test {
|
||||
|
||||
const std::string& loremipsum() { return s_loremipsum; }
|
||||
std::string const& loremipsum() { return s_loremipsum; }
|
||||
|
||||
std::string loremipsum(size_t size) {
|
||||
std::string str;
|
||||
|
@ -26,7 +26,7 @@
|
||||
namespace dwarfs {
|
||||
namespace test {
|
||||
|
||||
const std::string& loremipsum();
|
||||
std::string const& loremipsum();
|
||||
std::string loremipsum(size_t size);
|
||||
} // namespace test
|
||||
} // namespace dwarfs
|
||||
|
@ -26,17 +26,17 @@ namespace test {
|
||||
|
||||
class mmap_mock : public mmif {
|
||||
public:
|
||||
mmap_mock(const std::string& data)
|
||||
mmap_mock(std::string const& data)
|
||||
: mmap_mock{data, "<mock-file>"} {}
|
||||
|
||||
mmap_mock(const std::string& data, std::filesystem::path const& path)
|
||||
mmap_mock(std::string const& data, std::filesystem::path const& path)
|
||||
: data_{data}
|
||||
, path_{path} {}
|
||||
|
||||
mmap_mock(const std::string& data, size_t size)
|
||||
mmap_mock(std::string const& data, size_t size)
|
||||
: mmap_mock{data, size, "<mock-file>"} {}
|
||||
|
||||
mmap_mock(const std::string& data, size_t size,
|
||||
mmap_mock(std::string const& data, size_t size,
|
||||
std::filesystem::path const& path)
|
||||
: data_{data, 0, std::min(size, data.size())}
|
||||
, path_{path} {}
|
||||
|
@ -63,18 +63,18 @@ file_stat make_file_stat(simplestat const& ss) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
file_stat::uid_type constexpr kUid1{1000};
|
||||
file_stat::uid_type constexpr kUid2{1337};
|
||||
file_stat::uid_type constexpr kUid3{0};
|
||||
file_stat::gid_type constexpr kGid1{100};
|
||||
file_stat::gid_type constexpr kGid2{0};
|
||||
file_stat::dev_type constexpr kDev1{0};
|
||||
file_stat::dev_type constexpr kDev2{259};
|
||||
file_stat::dev_type constexpr kDev3{261};
|
||||
constexpr file_stat::uid_type kUid1{1000};
|
||||
constexpr file_stat::uid_type kUid2{1337};
|
||||
constexpr file_stat::uid_type kUid3{0};
|
||||
constexpr file_stat::gid_type kGid1{100};
|
||||
constexpr file_stat::gid_type kGid2{0};
|
||||
constexpr file_stat::dev_type kDev1{0};
|
||||
constexpr file_stat::dev_type kDev2{259};
|
||||
constexpr file_stat::dev_type kDev3{261};
|
||||
|
||||
std::array<std::pair<std::string_view, test::simplestat>,
|
||||
15> constexpr kTestEntries{{
|
||||
// clang-format off
|
||||
constexpr std::array<std::pair<std::string_view, test::simplestat>, 15>
|
||||
kTestEntries{{
|
||||
// clang-format off
|
||||
{"", { 1, posix_file_type::directory | 0777, 1, kUid1, kGid1, 0, kDev1, 1, 2, 3}},
|
||||
{"test.pl", { 3, posix_file_type::regular | 0644, 2, kUid1, kGid1, 0, kDev1, 1001, 1002, 1003}},
|
||||
{"somelink", { 4, posix_file_type::symlink | 0777, 1, kUid1, kGid1, 16, kDev1, 2001, 2002, 2003}},
|
||||
@ -90,8 +90,8 @@ std::array<std::pair<std::string_view, test::simplestat>,
|
||||
{"somedir/zero", { 14, posix_file_type::character | 0666, 1, kUid3, kGid2, 0, kDev3, 4000010001, 4000020002, 4000030003}},
|
||||
{"somedir/empty", {212, posix_file_type::regular | 0644, 1, kUid1, kGid1, 0, kDev1, 8101, 8102, 8103}},
|
||||
{"empty", {210, posix_file_type::regular | 0644, 3, kUid2, kGid2, 0, kDev1, 8201, 8202, 8203}},
|
||||
// clang-format on
|
||||
}};
|
||||
// clang-format on
|
||||
}};
|
||||
|
||||
std::unordered_map<std::string_view, std::string_view> const kTestLinks{
|
||||
{"somelink", "somedir/ipsum.py"},
|
||||
|
@ -75,7 +75,7 @@ namespace {
|
||||
|
||||
// TODO: this is a workaround for older Clang versions
|
||||
struct fs_path_hash {
|
||||
auto operator()(const std::filesystem::path& p) const noexcept {
|
||||
auto operator()(std::filesystem::path const& p) const noexcept {
|
||||
return std::filesystem::hash_value(p);
|
||||
}
|
||||
};
|
||||
@ -173,7 +173,7 @@ struct random_file_tree_options {
|
||||
bool with_invalid_utf8{false};
|
||||
};
|
||||
|
||||
auto constexpr default_fs_opts = reader::filesystem_options{
|
||||
constexpr auto default_fs_opts = reader::filesystem_options{
|
||||
.block_cache = {.max_bytes = 256 * 1024,
|
||||
.sequential_access_detector_threshold = 4},
|
||||
.metadata = {.check_consistency = true}};
|
||||
@ -1695,7 +1695,7 @@ constexpr std::array<std::string_view, 6> const debug_filter_mode_names = {
|
||||
"included", "excluded", "included-files", "excluded-files", "files", "all",
|
||||
};
|
||||
|
||||
const std::map<std::string_view, writer::debug_filter_mode> debug_filter_modes{
|
||||
std::map<std::string_view, writer::debug_filter_mode> const debug_filter_modes{
|
||||
{"included", writer::debug_filter_mode::INCLUDED},
|
||||
{"included-files", writer::debug_filter_mode::INCLUDED_FILES},
|
||||
{"excluded", writer::debug_filter_mode::EXCLUDED},
|
||||
|
File diff suppressed because one or more lines are too long
@ -159,7 +159,7 @@ void do_checksum(logger& lgr, reader::filesystem_v2& fs, iolayer const& iol,
|
||||
} // namespace
|
||||
|
||||
int dwarfsck_main(int argc, sys_char** argv, iolayer const& iol) {
|
||||
const size_t num_cpu = std::max(hardware_concurrency(), 1u);
|
||||
size_t const num_cpu = std::max(hardware_concurrency(), 1u);
|
||||
|
||||
auto algo_list = checksum::available_algorithms();
|
||||
auto checksum_desc = fmt::format("print checksums for all files ({})",
|
||||
|
@ -385,7 +385,7 @@ void validate(boost::any& v, std::vector<std::string> const& values,
|
||||
int mkdwarfs_main(int argc, sys_char** argv, iolayer const& iol) {
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
const size_t num_cpu = std::max(hardware_concurrency(), 1u);
|
||||
size_t const num_cpu = std::max(hardware_concurrency(), 1u);
|
||||
static constexpr size_t const kDefaultMaxActiveBlocks{1};
|
||||
static constexpr size_t const kDefaultBloomFilterSize{4};
|
||||
|
||||
@ -702,9 +702,9 @@ int mkdwarfs_main(int argc, sys_char** argv, iolayer const& iol) {
|
||||
auto constexpr usage = "Usage: mkdwarfs [OPTIONS...]\n";
|
||||
|
||||
if (vm.count("long-help")) {
|
||||
std::string_view constexpr block_data_hdr{"Block Data"};
|
||||
std::string_view constexpr schema_history_hdr{"Schema/History"};
|
||||
std::string_view constexpr metadata_hdr{"Metadata"};
|
||||
constexpr std::string_view block_data_hdr{"Block Data"};
|
||||
constexpr std::string_view schema_history_hdr{"Schema/History"};
|
||||
constexpr std::string_view metadata_hdr{"Metadata"};
|
||||
size_t l_dc{block_data_hdr.size()}, l_sc{schema_history_hdr.size()},
|
||||
l_mc{metadata_hdr.size()}, l_or{0};
|
||||
for (auto const& l : levels) {
|
||||
|
@ -62,7 +62,7 @@ int pxattr_main(int argc, sys_char** argv) {
|
||||
po::notify(vm);
|
||||
|
||||
if (vm.count("help")) {
|
||||
auto constexpr usage = "Usage: pxattr [OPTIONS...]\n";
|
||||
constexpr auto usage = "Usage: pxattr [OPTIONS...]\n";
|
||||
std::cout << tool::tool_header("pxattr") << usage << "\n" << desc << "\n";
|
||||
return 0;
|
||||
}
|
||||
@ -116,7 +116,7 @@ int pxattr_main(int argc, sys_char** argv) {
|
||||
std::cerr << "listxattr failed: " << ec.message() << "\n";
|
||||
return 1;
|
||||
}
|
||||
for (const auto& attr : attrs) {
|
||||
for (auto const& attr : attrs) {
|
||||
std::cout << attr << "\n";
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ namespace po = boost::program_options;
|
||||
|
||||
namespace boost {
|
||||
|
||||
void validate(boost::any& v, const std::vector<std::string>&,
|
||||
void validate(boost::any& v, std::vector<std::string> const&,
|
||||
std::optional<bool>*, int) {
|
||||
po::validators::check_first_occurrence(v);
|
||||
v = std::make_optional(true);
|
||||
|
@ -100,7 +100,7 @@ int SYS_MAIN(int argc, sys_char** argv) {
|
||||
|
||||
// The string_view is needed because ranges::views::join() will include
|
||||
// the null terminator when using a string literal.
|
||||
static std::string_view constexpr kJoiner{", "};
|
||||
static constexpr std::string_view kJoiner{", "};
|
||||
auto tools = ranges::views::keys(functions) | ranges::views::join(kJoiner) |
|
||||
ranges::to<std::string>;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user