From 71463bfee433fcc783613bf641d1ff7f3a306f2a Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Thu, 2 Jan 2025 12:07:01 -0600 Subject: [PATCH] refactor --- .../src/drives/fuse/fuse_base.cpp | 40 +++++++++---------- .../drives/remote/remote_open_file_table.cpp | 28 ++++++------- .../src/platform/unix_platform.cpp | 20 +++++----- .../src/providers/sia/sia_provider.cpp | 2 +- repertory/librepertory/src/utils/polling.cpp | 2 +- 5 files changed, 46 insertions(+), 46 deletions(-) diff --git a/repertory/librepertory/src/drives/fuse/fuse_base.cpp b/repertory/librepertory/src/drives/fuse/fuse_base.cpp index d9634f36..547dcf20 100644 --- a/repertory/librepertory/src/drives/fuse/fuse_base.cpp +++ b/repertory/librepertory/src/drives/fuse/fuse_base.cpp @@ -118,8 +118,8 @@ auto fuse_base::chflags_(const char *path, uint32_t flags) -> int { #endif // __APPLE__ #if FUSE_USE_VERSION >= 30 -auto fuse_base::chmod_(const char *path, mode_t mode, - struct fuse_file_info *fi) -> int { +auto fuse_base::chmod_(const char *path, mode_t mode, struct fuse_file_info *fi) + -> int { REPERTORY_USES_FUNCTION_NAME(); return instance().execute_callback( @@ -186,7 +186,7 @@ void fuse_base::display_options( #if FUSE_USE_VERSION >= 30 fuse_cmdline_help(); #else - struct fuse_operations fuse_ops {}; + struct fuse_operations fuse_ops{}; fuse_main(args.size(), reinterpret_cast(const_cast(args.data())), &fuse_ops, nullptr); @@ -196,7 +196,7 @@ void fuse_base::display_options( } void fuse_base::display_version_information(std::vector args) { - struct fuse_operations fuse_ops {}; + struct fuse_operations fuse_ops{}; fuse_main(static_cast(args.size()), reinterpret_cast(const_cast(args.data())), &fuse_ops, nullptr); @@ -334,8 +334,8 @@ auto fuse_base::getxtimes_(const char *path, struct timespec *bkuptime, #endif // __APPLE__ #if FUSE_USE_VERSION >= 30 -auto fuse_base::init_(struct fuse_conn_info *conn, - struct fuse_config *cfg) -> void * { +auto fuse_base::init_(struct fuse_conn_info *conn, struct fuse_config *cfg) + -> void * { REPERTORY_USES_FUNCTION_NAME(); return execute_void_pointer_callback(function_name, [&]() -> void * { @@ -408,7 +408,7 @@ auto fuse_base::mount(std::vector args) -> int { char *mount_location{nullptr}; #if FUSE_USE_VERSION >= 30 - struct fuse_cmdline_opts opts {}; + struct fuse_cmdline_opts opts{}; fuse_parse_cmdline(&fa, &opts); mount_location = opts.mountpoint; #else @@ -477,8 +477,8 @@ auto fuse_base::read_(const char *path, char *buffer, size_t read_size, #if FUSE_USE_VERSION >= 30 auto fuse_base::readdir_(const char *path, void *buf, fuse_fill_dir_t fuse_fill_dir, off_t offset, - struct fuse_file_info *fi, - fuse_readdir_flags flags) -> int { + struct fuse_file_info *fi, fuse_readdir_flags flags) + -> int { REPERTORY_USES_FUNCTION_NAME(); return instance().execute_callback( @@ -510,8 +510,8 @@ auto fuse_base::release_(const char *path, struct fuse_file_info *fi) -> int { }); } -auto fuse_base::releasedir_(const char *path, - struct fuse_file_info *fi) -> int { +auto fuse_base::releasedir_(const char *path, struct fuse_file_info *fi) + -> int { REPERTORY_USES_FUNCTION_NAME(); return instance().execute_callback( @@ -521,8 +521,8 @@ auto fuse_base::releasedir_(const char *path, } #if FUSE_USE_VERSION >= 30 -auto fuse_base::rename_(const char *from, const char *to, - unsigned int flags) -> int { +auto fuse_base::rename_(const char *from, const char *to, unsigned int flags) + -> int { REPERTORY_USES_FUNCTION_NAME(); return instance().execute_callback( @@ -603,7 +603,7 @@ auto fuse_base::listxattr_(const char *path, char *buffer, size_t size) -> int { void fuse_base::notify_fuse_args_parsed(const std::vector &args) { event_system::instance().raise(std::accumulate( args.begin(), args.end(), std::string(), - [](std::string command_line, const auto &arg) { + [](auto &&command_line, auto &&arg) -> auto { command_line += (command_line.empty() ? arg : (" " + std::string(arg))); return command_line; })); @@ -765,8 +765,8 @@ auto fuse_base::setattr_x_(const char *path, struct setattr_x *attr) -> int { }); } -auto fuse_base::setbkuptime_(const char *path, - const struct timespec *bkuptime) -> int { +auto fuse_base::setbkuptime_(const char *path, const struct timespec *bkuptime) + -> int { REPERTORY_USES_FUNCTION_NAME(); return instance().execute_callback( @@ -775,8 +775,8 @@ auto fuse_base::setbkuptime_(const char *path, }); } -auto fuse_base::setchgtime_(const char *path, - const struct timespec *chgtime) -> int { +auto fuse_base::setchgtime_(const char *path, const struct timespec *chgtime) + -> int { REPERTORY_USES_FUNCTION_NAME(); return instance().execute_callback( @@ -785,8 +785,8 @@ auto fuse_base::setchgtime_(const char *path, }); } -auto fuse_base::setcrtime_(const char *path, - const struct timespec *crtime) -> int { +auto fuse_base::setcrtime_(const char *path, const struct timespec *crtime) + -> int { REPERTORY_USES_FUNCTION_NAME(); return instance().execute_callback( diff --git a/repertory/librepertory/src/drives/remote/remote_open_file_table.cpp b/repertory/librepertory/src/drives/remote/remote_open_file_table.cpp index ec83b276..bb92cb72 100644 --- a/repertory/librepertory/src/drives/remote/remote_open_file_table.cpp +++ b/repertory/librepertory/src/drives/remote/remote_open_file_table.cpp @@ -42,7 +42,7 @@ void remote_open_file_table::close_all(const std::string &client_id) { auto compat_handles = std::accumulate(compat_file_lookup_.begin(), compat_file_lookup_.end(), std::vector(), - [&client_id](auto &&list, auto &&value) { + [&client_id](auto &&list, auto &&value) -> auto { auto &&op_info = value.second; if (op_info->client_id == client_id) { list.insert(list.end(), op_info->handles.begin(), @@ -54,7 +54,7 @@ void remote_open_file_table::close_all(const std::string &client_id) { auto handles = std::accumulate( file_lookup_.begin(), file_lookup_.end(), std::vector(), - [&client_id](auto &&list, auto &&value) { + [&client_id](auto &&list, auto &&value) -> auto { auto &&op_info = value.second; if (op_info->client_id == client_id) { list.insert(list.end(), op_info->handles.begin(), @@ -161,21 +161,21 @@ auto remote_open_file_table::has_compat_open_info( void remote_open_file_table::remove_all(const std::string &file_path) { unique_recur_mutex_lock lock(file_mutex_); - auto compat_open_list = std::accumulate( - compat_file_lookup_.begin(), compat_file_lookup_.end(), - std::vector(), - [&file_path](auto &&list, auto &&kv) -> std::vector { - if (kv.first == file_path) { - auto *op_info = kv.second.get(); - list.insert(list.end(), op_info->handles.begin(), - op_info->handles.end()); - } - return list; - }); + auto compat_open_list = + std::accumulate(compat_file_lookup_.begin(), compat_file_lookup_.end(), + std::vector(), + [&file_path](auto &&list, auto &&kv) -> auto { + if (kv.first == file_path) { + auto *op_info = kv.second.get(); + list.insert(list.end(), op_info->handles.begin(), + op_info->handles.end()); + } + return list; + }); auto open_list = std::accumulate( file_lookup_.begin(), file_lookup_.end(), std::vector(), - [&file_path](auto &&list, auto &&kv) -> std::vector { + [&file_path](auto &&list, auto &&kv) -> auto { if (kv.first == file_path) { auto *op_info = kv.second.get(); list.insert(list.end(), op_info->handles.begin(), diff --git a/repertory/librepertory/src/platform/unix_platform.cpp b/repertory/librepertory/src/platform/unix_platform.cpp index 6dd74088..15485caa 100644 --- a/repertory/librepertory/src/platform/unix_platform.cpp +++ b/repertory/librepertory/src/platform/unix_platform.cpp @@ -150,16 +150,16 @@ auto lock_data::set_mount_state(bool active, const std::string &mount_location, (mount_state[mount_id]["Location"].get() != mount_location)))) { const auto lines = utils::file::read_file_lines(get_lock_data_file()); - const auto txt = - std::accumulate(lines.begin(), lines.end(), std::string(), - [](std::string s, const std::string &s2) { - return std::move(s) + s2; - }); - auto json = json::parse(txt.empty() ? "{}" : txt); - json[mount_id] = {{"Active", active}, - {"Location", active ? mount_location : ""}, - {"PID", active ? pid : -1}}; - ret = utils::file::write_json_file(get_lock_data_file(), json); + const auto txt = std::accumulate( + lines.begin(), lines.end(), std::string(), + [](auto &&lines, auto &&line) -> auto { return lines + line; }); + auto json_data = json::parse(txt.empty() ? "{}" : txt); + json_data[mount_id] = { + {"Active", active}, + {"Location", active ? mount_location : ""}, + {"PID", active ? pid : -1}, + }; + ret = utils::file::write_json_file(get_lock_data_file(), json_data); } else { ret = true; } diff --git a/repertory/librepertory/src/providers/sia/sia_provider.cpp b/repertory/librepertory/src/providers/sia/sia_provider.cpp index ef99cceb..28568753 100644 --- a/repertory/librepertory/src/providers/sia/sia_provider.cpp +++ b/repertory/librepertory/src/providers/sia/sia_provider.cpp @@ -210,7 +210,7 @@ auto sia_provider::get_file(const std::string &api_path, api_file &file) const auto size{ std::accumulate( slabs.begin(), slabs.end(), std::uint64_t(0U), - [](std::uint64_t total_size, const json &slab) -> std::uint64_t { + [](auto &&total_size, const json &slab) -> std::uint64_t { return total_size + slab["Length"].get(); }), }; diff --git a/repertory/librepertory/src/utils/polling.cpp b/repertory/librepertory/src/utils/polling.cpp index d960fde2..21e6b290 100644 --- a/repertory/librepertory/src/utils/polling.cpp +++ b/repertory/librepertory/src/utils/polling.cpp @@ -35,7 +35,7 @@ void polling::frequency_thread( unique_mutex_lock lock(mutex_); auto futures = std::accumulate( items_.begin(), items_.end(), std::deque{}, - [this, &freq](auto &&list, auto &&item) { + [this, &freq](auto &&list, auto &&item) -> auto { if (item.second.freq != freq) { return list; }