From b137b57dbcc56a114fe7870e7410578802078761 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Mon, 30 Oct 2023 10:36:31 -0500 Subject: [PATCH] \#10 Address compiler warnings --- CHANGELOG.md | 2 ++ include/events/event_system.hpp | 6 ++-- .../file_manager_ring_buffer_open_file.cpp | 6 ++-- src/providers/base_provider.cpp | 5 ++-- src/providers/encrypt/encrypt_provider.cpp | 30 ++++++++++--------- src/providers/sia/sia_provider.cpp | 7 ++--- 6 files changed, 29 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 583024e2..72d17d60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ ### Issues +* \#10 Address compiler warnings + ### Changes from v2.0.0-rc * Removed MSVC compilation support (MinGW-64 should be used) diff --git a/include/events/event_system.hpp b/include/events/event_system.hpp index ac4759fc..b49dfa9a 100644 --- a/include/events/event_system.hpp +++ b/include/events/event_system.hpp @@ -68,9 +68,9 @@ using event_consumer = event_system::event_consumer; #define E_PROP(type, name, short_name, ts) \ private: \ - void init_##short_name(const type &val) { \ - ss_ << "|" << #short_name << "|" << ts(val); \ - j_[#name] = ts(val); \ + void init_##short_name(const type &val_##name) { \ + ss_ << "|" << #short_name << "|" << ts(val_##name); \ + j_[#name] = ts(val_##name); \ } \ \ public: \ diff --git a/src/file_manager/file_manager_ring_buffer_open_file.cpp b/src/file_manager/file_manager_ring_buffer_open_file.cpp index 8ba6c7d8..27da956f 100644 --- a/src/file_manager/file_manager_ring_buffer_open_file.cpp +++ b/src/file_manager/file_manager_ring_buffer_open_file.cpp @@ -264,18 +264,18 @@ auto file_manager::ring_buffer_open_file::read(std::size_t read_size, res = do_io([this, &buffer, &chunk, &data, read_offset, &to_read]() -> api_error { std::size_t bytes_read{}; - auto res = nf_->read_bytes(buffer.data(), buffer.size(), + auto ret = nf_->read_bytes(buffer.data(), buffer.size(), ((chunk % ring_state_.size()) * chunk_size_), bytes_read) ? api_error::success : api_error::os_error; - if (res == api_error::success) { + if (ret == api_error::success) { data.insert(data.end(), buffer.begin() + read_offset, buffer.begin() + read_offset + to_read); reset_timeout(); } - return res; + return ret; }); read_offset = 0u; read_size -= to_read; diff --git a/src/providers/base_provider.cpp b/src/providers/base_provider.cpp index 673460c4..5555a8c9 100644 --- a/src/providers/base_provider.cpp +++ b/src/providers/base_provider.cpp @@ -407,8 +407,7 @@ void base_provider::remove_deleted_files() { removed_files.pop_back(); bool exists{}; - auto res = is_directory(api_path, exists); - if (res != api_error::success) { + if (is_directory(api_path, exists) != api_error::success) { continue; } @@ -421,7 +420,7 @@ void base_provider::remove_deleted_files() { fm_->perform_locked_operation( [this, &api_path, &source_path](i_provider &) -> bool { if (fm_->has_no_open_file_handles()) { - const auto res = meta_db_->remove_item_meta(api_path); + auto res = meta_db_->remove_item_meta(api_path); if (res == api_error::success) { event_system::instance().raise( api_path, source_path); diff --git a/src/providers/encrypt/encrypt_provider.cpp b/src/providers/encrypt/encrypt_provider.cpp index 15d3d09d..3fc08c37 100644 --- a/src/providers/encrypt/encrypt_provider.cpp +++ b/src/providers/encrypt/encrypt_provider.cpp @@ -222,21 +222,23 @@ auto encrypt_provider::get_directory_items(const std::string &api_path, for (const auto &dir_entry : std::filesystem::directory_iterator(source_path)) { try { - std::string api_path{}; + std::string entry_api_path{}; if (dir_entry.is_directory()) { db_->Get(rocksdb::ReadOptions(), dir_family_, - dir_entry.path().string(), &api_path); - if (api_path.empty()) { + dir_entry.path().string(), &entry_api_path); + if (entry_api_path.empty()) { const auto cfg = config_.get_encrypt_config(); for (const auto &child_dir_entry : std::filesystem::directory_iterator(dir_entry.path())) { - if (process_directory_entry(child_dir_entry, cfg, api_path)) { - api_path = utils::path::get_parent_api_path(api_path); + if (process_directory_entry(child_dir_entry, cfg, + entry_api_path)) { + entry_api_path = + utils::path::get_parent_api_path(entry_api_path); break; } } - if (api_path.empty()) { + if (entry_api_path.empty()) { continue; } } @@ -246,16 +248,16 @@ auto encrypt_provider::get_directory_items(const std::string &api_path, dir_entry.path().string(), &api_path_data); if (api_path_data.empty()) { const auto cfg = config_.get_encrypt_config(); - if (not process_directory_entry(dir_entry, cfg, api_path)) { + if (not process_directory_entry(dir_entry, cfg, entry_api_path)) { continue; } } else { - api_path = + entry_api_path = json::parse(api_path_data).at("api_path").get(); } } - auto file = create_api_file(api_path, dir_entry.is_directory(), + auto file = create_api_file(entry_api_path, dir_entry.is_directory(), dir_entry.path().string()); directory_item di{}; @@ -464,13 +466,13 @@ auto encrypt_provider::get_filesystem_item(const std::string &api_path, } if (directory) { - std::string api_path{}; - db_->Get(rocksdb::ReadOptions(), dir_family_, source_path, &api_path); - if (api_path.empty()) { + std::string db_api_path{}; + db_->Get(rocksdb::ReadOptions(), dir_family_, source_path, &db_api_path); + if (db_api_path.empty()) { return api_error::item_not_found; } - fsi.api_parent = utils::path::get_parent_api_path(api_path); - fsi.api_path = api_path; + fsi.api_parent = utils::path::get_parent_api_path(db_api_path); + fsi.api_path = db_api_path; fsi.directory = true; fsi.size = 0U; fsi.source_path = source_path; diff --git a/src/providers/sia/sia_provider.cpp b/src/providers/sia/sia_provider.cpp index 7920dd49..e491894e 100644 --- a/src/providers/sia/sia_provider.cpp +++ b/src/providers/sia/sia_provider.cpp @@ -961,8 +961,8 @@ void sia_provider::remove_deleted_files() { if (get_item_meta(iterator->key().ToString(), meta) == api_error::success) { if (utils::string::to_bool(meta[META_DIRECTORY])) { bool exists{}; - auto res = is_directory(iterator->key().ToString(), exists); - if (res != api_error::success) { + if (is_directory(iterator->key().ToString(), exists) != + api_error::success) { continue; } if (not exists) { @@ -973,8 +973,7 @@ void sia_provider::remove_deleted_files() { } bool exists{}; - auto res = is_file(iterator->key().ToString(), exists); - if (res != api_error::success) { + if (is_file(iterator->key().ToString(), exists) != api_error::success) { continue; } if (not exists) {