From 3b91b5b8d6c0712e0fd54b10e18e935850b95f0c Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Thu, 24 Jul 2025 13:20:51 -0500 Subject: [PATCH] cleanup --- .../include/drives/fuse/fuse_drive_base.hpp | 9 +++------ .../include/file_manager/open_file_base.hpp | 4 ++-- .../librepertory/include/types/repertory.hpp | 3 +-- .../librepertory/include/utils/error_utils.hpp | 8 ++++---- .../include/utils/unix/unix_utils.hpp | 2 +- .../include/utils/windows/windows_utils.hpp | 18 +++++++++--------- .../src/drives/fuse/fuse_drive_base.cpp | 7 +++---- .../src/file_manager/open_file_base.cpp | 4 ++-- repertory/librepertory/src/types/repertory.cpp | 2 +- .../librepertory/src/utils/error_utils.cpp | 8 ++++---- .../librepertory/src/utils/unix/unix_utils.cpp | 2 +- .../src/utils/windows/windows_utils.cpp | 2 +- .../repertory_test/src/open_file_test.cpp | 2 +- 13 files changed, 33 insertions(+), 38 deletions(-) diff --git a/repertory/librepertory/include/drives/fuse/fuse_drive_base.hpp b/repertory/librepertory/include/drives/fuse/fuse_drive_base.hpp index 98d9bf1b..2cc51149 100644 --- a/repertory/librepertory/include/drives/fuse/fuse_drive_base.hpp +++ b/repertory/librepertory/include/drives/fuse/fuse_drive_base.hpp @@ -64,17 +64,14 @@ protected: [[nodiscard]] auto get_effective_uid() const -> uid_t; [[nodiscard]] static auto check_open_flags(int flags, int mask, - const api_error &fail_error) - -> api_error; + api_error fail_error) -> api_error; [[nodiscard]] auto check_owner(const api_meta_map &meta) const -> api_error; - [[nodiscard]] static auto check_readable(int flags, - const api_error &fail_error) + [[nodiscard]] static auto check_readable(int flags, api_error fail_error) -> api_error; - [[nodiscard]] static auto check_writeable(int flags, - const api_error &fail_error) + [[nodiscard]] static auto check_writeable(int flags, api_error fail_error) -> api_error; #if defined(__APPLE__) diff --git a/repertory/librepertory/include/file_manager/open_file_base.hpp b/repertory/librepertory/include/file_manager/open_file_base.hpp index df5d15be..ab527159 100644 --- a/repertory/librepertory/include/file_manager/open_file_base.hpp +++ b/repertory/librepertory/include/file_manager/open_file_base.hpp @@ -66,7 +66,7 @@ public: std::condition_variable notify_; public: - void notify(const api_error &err); + void notify(api_error err); auto wait() -> api_error; }; @@ -149,7 +149,7 @@ protected: void reset_timeout(); - auto set_api_error(const api_error &err) -> api_error; + auto set_api_error(api_error err) -> api_error; void set_file_size(std::uint64_t size); diff --git a/repertory/librepertory/include/types/repertory.hpp b/repertory/librepertory/include/types/repertory.hpp index 0021f1c4..9e59cad3 100644 --- a/repertory/librepertory/include/types/repertory.hpp +++ b/repertory/librepertory/include/types/repertory.hpp @@ -221,8 +221,7 @@ enum class api_error { [[nodiscard]] auto api_error_from_string(std::string_view str) -> api_error; -[[nodiscard]] auto api_error_to_string(const api_error &error) - -> const std::string &; +[[nodiscard]] auto api_error_to_string(api_error error) -> const std::string &; enum class database_type { rocksdb, diff --git a/repertory/librepertory/include/utils/error_utils.hpp b/repertory/librepertory/include/utils/error_utils.hpp index 5d3f76de..4c030e17 100644 --- a/repertory/librepertory/include/utils/error_utils.hpp +++ b/repertory/librepertory/include/utils/error_utils.hpp @@ -27,7 +27,7 @@ namespace repertory::utils::error { void raise_error(std::string_view function, std::string_view msg); -void raise_error(std::string_view function, const api_error &err, +void raise_error(std::string_view function, api_error err, std::string_view msg); void raise_error(std::string_view function, const std::exception &exception); @@ -41,7 +41,7 @@ void raise_error(std::string_view function, std::int64_t err, void raise_error(std::string_view function, const json &err, std::string_view msg); -void raise_error(std::string_view function, const api_error &err, +void raise_error(std::string_view function, api_error err, std::string_view file_path, std::string_view msg); void raise_error(std::string_view function, std::int64_t err, @@ -51,7 +51,7 @@ void raise_error(std::string_view function, const std::exception &exception, std::string_view file_path, std::string_view msg); void raise_api_path_error(std::string_view function, std::string_view api_path, - const api_error &err, std::string_view msg); + api_error err, std::string_view msg); void raise_api_path_error(std::string_view function, std::string_view api_path, const std::exception &exception); @@ -67,7 +67,7 @@ void raise_api_path_error(std::string_view function, std::string_view api_path, const json &err, std::string_view msg); void raise_api_path_error(std::string_view function, std::string_view api_path, - std::string_view source_path, const api_error &err, + std::string_view source_path, api_error err, std::string_view msg); void raise_api_path_error(std::string_view function, std::string_view api_path, diff --git a/repertory/librepertory/include/utils/unix/unix_utils.hpp b/repertory/librepertory/include/utils/unix/unix_utils.hpp index d7849865..045f7326 100644 --- a/repertory/librepertory/include/utils/unix/unix_utils.hpp +++ b/repertory/librepertory/include/utils/unix/unix_utils.hpp @@ -37,7 +37,7 @@ inline const std::array attribute_namespaces = { }; #endif -[[nodiscard]] auto from_api_error(const api_error &err) -> int; +[[nodiscard]] auto from_api_error(api_error err) -> int; [[nodiscard]] auto to_api_error(int err) -> api_error; diff --git a/repertory/librepertory/include/utils/windows/windows_utils.hpp b/repertory/librepertory/include/utils/windows/windows_utils.hpp index 013a260f..4d4f9769 100644 --- a/repertory/librepertory/include/utils/windows/windows_utils.hpp +++ b/repertory/librepertory/include/utils/windows/windows_utils.hpp @@ -28,19 +28,19 @@ #include "utils/windows.hpp" namespace repertory::utils { -[[nodiscard]] auto -get_accessed_time_from_meta(const api_meta_map &meta) -> std::uint64_t; +[[nodiscard]] auto get_accessed_time_from_meta(const api_meta_map &meta) + -> std::uint64_t; -[[nodiscard]] auto -get_changed_time_from_meta(const api_meta_map &meta) -> std::uint64_t; +[[nodiscard]] auto get_changed_time_from_meta(const api_meta_map &meta) + -> std::uint64_t; -[[nodiscard]] auto -get_creation_time_from_meta(const api_meta_map &meta) -> std::uint64_t; +[[nodiscard]] auto get_creation_time_from_meta(const api_meta_map &meta) + -> std::uint64_t; -[[nodiscard]] auto -get_written_time_from_meta(const api_meta_map &meta) -> std::uint64_t; +[[nodiscard]] auto get_written_time_from_meta(const api_meta_map &meta) + -> std::uint64_t; -[[nodiscard]] auto from_api_error(const api_error &e) -> NTSTATUS; +[[nodiscard]] auto from_api_error(api_error e) -> NTSTATUS; [[nodiscard]] auto unix_access_mask_to_windows(std::int32_t mask) -> int; diff --git a/repertory/librepertory/src/drives/fuse/fuse_drive_base.cpp b/repertory/librepertory/src/drives/fuse/fuse_drive_base.cpp index 276af68b..8a0911c1 100644 --- a/repertory/librepertory/src/drives/fuse/fuse_drive_base.cpp +++ b/repertory/librepertory/src/drives/fuse/fuse_drive_base.cpp @@ -138,8 +138,7 @@ auto fuse_drive_base::check_and_perform( } auto fuse_drive_base::check_open_flags(int flags, int mask, - const api_error &fail_error) - -> api_error { + api_error fail_error) -> api_error { return (((flags & mask) == 0) ? api_error::success : fail_error); } @@ -196,13 +195,13 @@ auto fuse_drive_base::check_parent_access(const std::string &api_path, return ret; } -auto fuse_drive_base::check_readable(int flags, const api_error &fail_error) +auto fuse_drive_base::check_readable(int flags, api_error fail_error) -> api_error { auto mode = (flags & O_ACCMODE); return ((mode == O_WRONLY) ? fail_error : api_error::success); } -auto fuse_drive_base::check_writeable(int flags, const api_error &fail_error) +auto fuse_drive_base::check_writeable(int flags, api_error fail_error) -> api_error { return (((flags & O_ACCMODE) == 0) ? fail_error : api_error::success); } diff --git a/repertory/librepertory/src/file_manager/open_file_base.cpp b/repertory/librepertory/src/file_manager/open_file_base.cpp index 48935496..babfe479 100644 --- a/repertory/librepertory/src/file_manager/open_file_base.cpp +++ b/repertory/librepertory/src/file_manager/open_file_base.cpp @@ -30,7 +30,7 @@ #include "utils/path.hpp" namespace repertory { -void open_file_base::download::notify(const api_error &err) { +void open_file_base::download::notify(api_error err) { complete_ = true; error_ = err; unique_mutex_lock lock(mtx_); @@ -360,7 +360,7 @@ void open_file_base::reset_timeout() { last_access_ = std::chrono::system_clock::now(); } -auto open_file_base::set_api_error(const api_error &err) -> api_error { +auto open_file_base::set_api_error(api_error err) -> api_error { mutex_lock error_lock(error_mtx_); if (error_ == err) { return error_; diff --git a/repertory/librepertory/src/types/repertory.cpp b/repertory/librepertory/src/types/repertory.cpp index 3186e2a5..676cc803 100644 --- a/repertory/librepertory/src/types/repertory.cpp +++ b/repertory/librepertory/src/types/repertory.cpp @@ -230,7 +230,7 @@ auto api_error_from_string(std::string_view str) -> api_error { return iter == LOOKUP.end() ? api_error::error : iter->first; } -auto api_error_to_string(const api_error &error) -> const std::string & { +auto api_error_to_string(api_error error) -> const std::string & { if (LOOKUP.size() != static_cast(api_error::ERROR_COUNT)) { throw startup_exception("undefined api_error strings"); } diff --git a/repertory/librepertory/src/utils/error_utils.cpp b/repertory/librepertory/src/utils/error_utils.cpp index a047b4b7..4a5e9ff2 100644 --- a/repertory/librepertory/src/utils/error_utils.cpp +++ b/repertory/librepertory/src/utils/error_utils.cpp @@ -87,7 +87,7 @@ void raise_error(std::string_view function, std::string_view msg) { function, static_cast(msg)); } -void raise_error(std::string_view function, const api_error &err, +void raise_error(std::string_view function, api_error err, std::string_view msg) { event_system::instance().raise( function, @@ -121,7 +121,7 @@ void raise_error(std::string_view function, std::int64_t err, function, static_cast(msg) + "|err|" + std::to_string(err)); } -void raise_error(std::string_view function, const api_error &err, +void raise_error(std::string_view function, api_error err, std::string_view file_path, std::string_view msg) { event_system::instance().raise( function, static_cast(msg) + "|sp|" + @@ -147,7 +147,7 @@ void raise_error(std::string_view function, const std::exception &exception, } void raise_api_path_error(std::string_view function, std::string_view api_path, - const api_error &err, std::string_view msg) { + api_error err, std::string_view msg) { event_system::instance().raise( function, static_cast(msg) + "|ap|" + static_cast(api_path) + "|err|" + @@ -181,7 +181,7 @@ void raise_api_path_error(std::string_view function, std::string_view api_path, } void raise_api_path_error(std::string_view function, std::string_view api_path, - std::string_view source_path, const api_error &err, + std::string_view source_path, api_error err, std::string_view msg) { event_system::instance().raise( function, static_cast(msg) + "|ap|" + diff --git a/repertory/librepertory/src/utils/unix/unix_utils.cpp b/repertory/librepertory/src/utils/unix/unix_utils.cpp index 4e204fc9..f04bc7e9 100644 --- a/repertory/librepertory/src/utils/unix/unix_utils.cpp +++ b/repertory/librepertory/src/utils/unix/unix_utils.cpp @@ -26,7 +26,7 @@ #include "utils/error_utils.hpp" namespace repertory::utils { -auto from_api_error(const api_error &err) -> int { +auto from_api_error(api_error err) -> int { switch (err) { case api_error::access_denied: return -EACCES; diff --git a/repertory/librepertory/src/utils/windows/windows_utils.cpp b/repertory/librepertory/src/utils/windows/windows_utils.cpp index cccde872..673ee58d 100644 --- a/repertory/librepertory/src/utils/windows/windows_utils.cpp +++ b/repertory/librepertory/src/utils/windows/windows_utils.cpp @@ -31,7 +31,7 @@ #endif namespace repertory::utils { -auto from_api_error(const api_error &e) -> NTSTATUS { +auto from_api_error(api_error e) -> NTSTATUS { switch (e) { case api_error::access_denied: return STATUS_ACCESS_DENIED; diff --git a/repertory/repertory_test/src/open_file_test.cpp b/repertory/repertory_test/src/open_file_test.cpp index 1eb5be9a..49ec415c 100644 --- a/repertory/repertory_test/src/open_file_test.cpp +++ b/repertory/repertory_test/src/open_file_test.cpp @@ -66,7 +66,7 @@ protected: std::atomic open_file_test::inst{0U}; static void test_closeable_open_file(const open_file &file, bool directory, - const api_error &err, std::uint64_t size, + api_error err, std::uint64_t size, const std::string &source_path) { EXPECT_EQ(directory, file.is_directory()); EXPECT_EQ(err, file.get_api_error());