diff options
author | Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com> | 2020-06-01 17:20:32 +0300 |
---|---|---|
committer | Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com> | 2020-06-01 17:20:32 +0300 |
commit | 534ae977af3441daf399cf64e58ef323ceaa923d (patch) | |
tree | 140a96def457383bb109ea6efe64d1e77f4c79f5 /include/llfio | |
parent | 0aa8b60b7578762f6ec3126e11be0ec82003f0af (diff) |
Convert to latest Outcome v2.2 TRY operator.
Diffstat (limited to 'include/llfio')
37 files changed, 184 insertions, 184 deletions
diff --git a/include/llfio/v2.0/algorithm/handle_adapter/cached_parent.hpp b/include/llfio/v2.0/algorithm/handle_adapter/cached_parent.hpp index 6a3964e3..63d63c64 100644 --- a/include/llfio/v2.0/algorithm/handle_adapter/cached_parent.hpp +++ b/include/llfio/v2.0/algorithm/handle_adapter/cached_parent.hpp @@ -137,7 +137,7 @@ namespace algorithm LLFIO_HEADERS_ONLY_VIRTUAL_SPEC result<path_handle> parent_path_handle(deadline /* unused */ = std::chrono::seconds(30)) const noexcept override { LLFIO_LOG_FUNCTION_CALL(this); - OUTCOME_TRY(ret, _sph->h.clone_to_path_handle()); + OUTCOME_TRY(auto &&ret, _sph->h.clone_to_path_handle()); return {std::move(ret)}; } LLFIO_HEADERS_ONLY_VIRTUAL_SPEC @@ -177,7 +177,7 @@ namespace algorithm template <class T, class... Args> inline result<cached_parent_handle_adapter<T>> cache_parent(Args &&... args) noexcept { construct<T> constructor{std::forward<Args>(args)...}; - OUTCOME_TRY(h, constructor()); + OUTCOME_TRY(auto &&h, constructor()); try { return cached_parent_handle_adapter<T>(std::move(h), constructor.base, constructor._path); @@ -196,7 +196,7 @@ template <class T> struct construct<algorithm::cached_parent_handle_adapter<T>> construct<T> args; result<algorithm::cached_parent_handle_adapter<T>> operator()() const noexcept { - OUTCOME_TRY(h, args()); + OUTCOME_TRY(auto &&h, args()); try { return algorithm::cached_parent_handle_adapter<T>(std::move(h), args.base, args._path); diff --git a/include/llfio/v2.0/algorithm/handle_adapter/combining.hpp b/include/llfio/v2.0/algorithm/handle_adapter/combining.hpp index db0a6e4c..68d82270 100644 --- a/include/llfio/v2.0/algorithm/handle_adapter/combining.hpp +++ b/include/llfio/v2.0/algorithm/handle_adapter/combining.hpp @@ -184,7 +184,7 @@ namespace algorithm else { auto _bytes = (bytes + 63) & ~63; - OUTCOME_TRY(_, map_handle::map(_bytes * (1 + _have_source))); + OUTCOME_TRY(auto &&_, map_handle::map(_bytes * (1 + _have_source))); buffersh = std::move(_); buffers[0] = buffer_type{buffersh.address(), bytes}; if(_have_source) @@ -213,19 +213,19 @@ namespace algorithm // Handle any errors buffer_type filleds[2]; { - OUTCOME_TRY(_filled, std::move(*_filleds[0])); + OUTCOME_TRY(auto &&_filled, std::move(*_filleds[0])); filleds[0] = std::move(_filled[0]); } if(_have_source) { - OUTCOME_TRY(_filled, std::move(*_filleds[1])); + OUTCOME_TRY(auto &&_filled, std::move(*_filleds[1])); filleds[1] = std::move(_filled[0]); } // For each buffer in the request, perform Op, consuming temporary buffers as we go for(auto &b : reqs.buffers) { - OUTCOME_TRY(_b, Op<target_handle_type, source_handle_type>::do_read(b, filleds[0], filleds[1])); + OUTCOME_TRY(auto &&_b, Op<target_handle_type, source_handle_type>::do_read(b, filleds[0], filleds[1])); b = _b; filleds[0] = buffer_type{filleds[0].data() + b.size(), filleds[0].size() - b.size()}; if(_have_source) @@ -261,7 +261,7 @@ namespace algorithm else { auto _bytes = (bytes + 63) & ~63; - OUTCOME_TRY(_, map_handle::map(_bytes * (1 + _have_source))); + OUTCOME_TRY(auto &&_, map_handle::map(_bytes * (1 + _have_source))); buffersh = std::move(_); buffers[0] = buffer_type{buffers[0].data(), bytes}; if(_have_source) @@ -275,7 +275,7 @@ namespace algorithm if(_have_source) { io_request<buffers_type> req({&buffers[1], 1}, reqs.offset); - OUTCOME_TRY(_, _source->read(req, d)); + OUTCOME_TRY(auto &&_, _source->read(req, d)); tempbuffers[1] = buffer_type{_[0].data(), _[0].size()}; } @@ -283,7 +283,7 @@ namespace algorithm for(auto &b : reqs.buffers) { // Returns buffers to be written into target - OUTCOME_TRY(_b, Op<target_handle_type, source_handle_type>::do_write(tempbuffers[0], tempbuffers[1], b)); + OUTCOME_TRY(auto &&_b, Op<target_handle_type, source_handle_type>::do_write(tempbuffers[0], tempbuffers[1], b)); // Adjust inputs to match tempbuffers[0] = buffer_type{tempbuffers[0].data() + _b.size(), tempbuffers[0].size() - _b.size()}; if(_have_source) @@ -299,7 +299,7 @@ namespace algorithm { const_buffer_type b(buffers[0]); io_request<const_buffers_type> req({&b, 1}, reqs.offset); - OUTCOME_TRY(_, _target->write(req, d)); + OUTCOME_TRY(auto &&_, _target->write(req, d)); OUTCOME_TRY((Op<target_handle_type, source_handle_type>::adjust_written_buffers(reqs.buffers, _[0], buffers[0]))); } return std::move(reqs.buffers); @@ -366,12 +366,12 @@ namespace algorithm } // Handle any errors { - OUTCOME_TRY(_, std::move(*_locks[0])); + OUTCOME_TRY(auto &&_, std::move(*_locks[0])); _.release(); } if(_have_source) { - OUTCOME_TRY(_, std::move(*_locks[1])); + OUTCOME_TRY(auto &&_, std::move(*_locks[1])); _.release(); } return _extent_guard(this, offset, bytes, kind); @@ -390,12 +390,12 @@ namespace algorithm LLFIO_HEADERS_ONLY_VIRTUAL_SPEC result<extent_type> maximum_extent() const noexcept override { extent_type r = (extent_type) -1; - OUTCOME_TRY(x, this->_target->maximum_extent()); + OUTCOME_TRY(auto &&x, this->_target->maximum_extent()); if(x < r) r = x; if(_have_source) { - OUTCOME_TRY(y, this->_source->maximum_extent()); + OUTCOME_TRY(auto &&y, this->_source->maximum_extent()); if(y < r) r = y; } @@ -422,13 +422,13 @@ namespace algorithm extent_type ret = (extent_type) -1; // Handle any errors { - OUTCOME_TRY(_, std::move(*r[0])); + OUTCOME_TRY(auto &&_, std::move(*r[0])); if(_ < ret) ret = _; } if(_have_source) { - OUTCOME_TRY(_, std::move(*r[1])); + OUTCOME_TRY(auto &&_, std::move(*r[1])); if(_ < ret) ret = _; } @@ -457,13 +457,13 @@ namespace algorithm extent_type ret = (extent_type) -1; // Handle any errors { - OUTCOME_TRY(_, std::move(*r[0])); + OUTCOME_TRY(auto &&_, std::move(*r[0])); if(_ < ret) ret = _; } if(_have_source) { - OUTCOME_TRY(_, std::move(*r[1])); + OUTCOME_TRY(auto &&_, std::move(*r[1])); if(_ < ret) ret = _; } diff --git a/include/llfio/v2.0/algorithm/shared_fs_mutex/atomic_append.hpp b/include/llfio/v2.0/algorithm/shared_fs_mutex/atomic_append.hpp index fbe76010..c95acb2f 100644 --- a/include/llfio/v2.0/algorithm/shared_fs_mutex/atomic_append.hpp +++ b/include/llfio/v2.0/algorithm/shared_fs_mutex/atomic_append.hpp @@ -146,7 +146,7 @@ namespace algorithm do { file_handle::buffer_type req{reinterpret_cast<byte *>(&_header), 48}; - OUTCOME_TRY(_, _h.read({{&req, 1}, 0})); + OUTCOME_TRY(auto &&_, _h.read({{&req, 1}, 0})); if(_[0].data() != reinterpret_cast<byte *>(&_header)) { memcpy(&_header, _[0].data(), _[0].size()); @@ -203,7 +203,7 @@ namespace algorithm static result<atomic_append> fs_mutex_append(const path_handle &base, path_view lockfile, bool nfs_compatibility = false, bool skip_hashing = false) noexcept { LLFIO_LOG_FUNCTION_CALL(0); - OUTCOME_TRY(ret, file_handle::file(base, lockfile, file_handle::mode::write, file_handle::creation::if_needed, file_handle::caching::temporary)); + OUTCOME_TRY(auto &&ret, file_handle::file(base, lockfile, file_handle::mode::write, file_handle::creation::if_needed, file_handle::caching::temporary)); atomic_append_detail::header header; // Lock the entire header for exclusive access auto lockresult = ret.lock_file_range(0, sizeof(header), lock_kind::exclusive, std::chrono::seconds(0)); @@ -231,7 +231,7 @@ namespace algorithm OUTCOME_TRYV(ret.write(0, {{reinterpret_cast<byte *>(&header), sizeof(header)}})); } // Open a shared lock on last byte in header to prevent other users zomping the file - OUTCOME_TRY(guard, ret.lock_file_range(sizeof(header) - 1, 1, lock_kind::shared)); + OUTCOME_TRY(auto &&guard, ret.lock_file_range(sizeof(header) - 1, 1, lock_kind::shared)); // Unlock any exclusive lock I gained earlier now if(lockresult) { @@ -282,7 +282,7 @@ namespace algorithm lock_request.hash = QUICKCPPLIB_NAMESPACE::algorithm::hash::fast_hash::hash((reinterpret_cast<char *>(&lock_request)) + 16, sizeof(lock_request) - 16); } // My lock request will be the file's current length or higher - OUTCOME_TRY(my_lock_request_offset, _h.maximum_extent()); + OUTCOME_TRY(auto &&my_lock_request_offset, _h.maximum_extent()); { OUTCOME_TRYV(_h.set_append_only(true)); auto undo = make_scope_exit([this]() noexcept { (void) _h.set_append_only(false); }); @@ -292,7 +292,7 @@ namespace algorithm auto lastbyte = static_cast<file_handle::extent_type>(-1); // Lock up to the beginning of the shadow lock space lastbyte &= ~(1ULL << 63U); - OUTCOME_TRY(append_guard_, _h.lock_file_range(my_lock_request_offset, lastbyte, lock_kind::exclusive)); + OUTCOME_TRY(auto &&append_guard_, _h.lock_file_range(my_lock_request_offset, lastbyte, lock_kind::exclusive)); append_guard = std::move(append_guard_); } OUTCOME_TRYV(_h.write(0, {{reinterpret_cast<byte *>(&lock_request), sizeof(lock_request)}})); @@ -338,7 +338,7 @@ namespace algorithm auto lock_offset = my_lock_request_offset; // Set the top bit to use the shadow lock space on Windows lock_offset |= (1ULL << 63U); - OUTCOME_TRY(my_request_guard_, _h.lock_file_range(lock_offset, sizeof(lock_request), lock_kind::exclusive)); + OUTCOME_TRY(auto &&my_request_guard_, _h.lock_file_range(lock_offset, sizeof(lock_request), lock_kind::exclusive)); my_request_guard = std::move(my_request_guard_); } @@ -371,7 +371,7 @@ namespace algorithm assert(record_offset >= start_offset); assert(record_offset - start_offset <= sizeof(_buffer)); file_handle::buffer_type req{_buffer, (size_t)(record_offset - start_offset) + sizeof(atomic_append_detail::lock_request)}; - OUTCOME_TRY(batchread, _h.read({{&req, 1}, start_offset})); + OUTCOME_TRY(auto &&batchread, _h.read({{&req, 1}, start_offset})); assert(batchread[0].size() == record_offset - start_offset + sizeof(atomic_append_detail::lock_request)); const atomic_append_detail::lock_request *record = reinterpret_cast<atomic_append_detail::lock_request *>(batchread[0].data() + batchread[0].size() - sizeof(atomic_append_detail::lock_request)); const atomic_append_detail::lock_request *firstrecord = reinterpret_cast<atomic_append_detail::lock_request *>(batchread[0].data()); diff --git a/include/llfio/v2.0/algorithm/shared_fs_mutex/byte_ranges.hpp b/include/llfio/v2.0/algorithm/shared_fs_mutex/byte_ranges.hpp index 2ce3d5e9..dc63d81c 100644 --- a/include/llfio/v2.0/algorithm/shared_fs_mutex/byte_ranges.hpp +++ b/include/llfio/v2.0/algorithm/shared_fs_mutex/byte_ranges.hpp @@ -104,7 +104,7 @@ namespace algorithm static result<byte_ranges> fs_mutex_byte_ranges(const path_handle &base, path_view lockfile) noexcept { LLFIO_LOG_FUNCTION_CALL(0); - OUTCOME_TRY(ret, file_handle::file(base, lockfile, file_handle::mode::write, file_handle::creation::if_needed, file_handle::caching::temporary)); + OUTCOME_TRY(auto &&ret, file_handle::file(base, lockfile, file_handle::mode::write, file_handle::creation::if_needed, file_handle::caching::temporary)); return byte_ranges(std::move(ret)); } diff --git a/include/llfio/v2.0/algorithm/shared_fs_mutex/memory_map.hpp b/include/llfio/v2.0/algorithm/shared_fs_mutex/memory_map.hpp index a63c61de..517e1e92 100644 --- a/include/llfio/v2.0/algorithm/shared_fs_mutex/memory_map.hpp +++ b/include/llfio/v2.0/algorithm/shared_fs_mutex/memory_map.hpp @@ -197,7 +197,7 @@ namespace algorithm LLFIO_LOG_FUNCTION_CALL(0); try { - OUTCOME_TRY(ret, file_handle::file(base, lockfile, file_handle::mode::write, file_handle::creation::if_needed, file_handle::caching::reads)); + OUTCOME_TRY(auto &&ret, file_handle::file(base, lockfile, file_handle::mode::write, file_handle::creation::if_needed, file_handle::caching::reads)); file_handle temph; // Am I the first person to this file? Lock everything exclusively auto lockinuse = ret.lock_file_range(_initialisingoffset, 2, lock_kind::exclusive, std::chrono::seconds(0)); @@ -227,25 +227,25 @@ namespace algorithm } temph = std::move(_temph.value()); // Map the hash index file into memory for read/write access - OUTCOME_TRY(temphsection, section_handle::section(temph, HashIndexSize)); - OUTCOME_TRY(temphmap, map_handle::map(temphsection, HashIndexSize)); + OUTCOME_TRY(auto &&temphsection, section_handle::section(temph, HashIndexSize)); + OUTCOME_TRY(auto &&temphmap, map_handle::map(temphsection, HashIndexSize)); // Map the path file into memory with its maximum possible size, read only - OUTCOME_TRY(hsection, section_handle::section(ret, 65536, section_handle::flag::read)); - OUTCOME_TRY(hmap, map_handle::map(hsection, 0, 0, section_handle::flag::read)); + OUTCOME_TRY(auto &&hsection, section_handle::section(ret, 65536, section_handle::flag::read)); + OUTCOME_TRY(auto &&hmap, map_handle::map(hsection, 0, 0, section_handle::flag::read)); return memory_map(std::move(ret), std::move(temph), std::move(lockinuse.value()), std::move(hmap), std::move(temphmap)); } // I am the first person to be using this (stale?) file, so create a new hash index file in /tmp auto &tempdirh = path_discovery::memory_backed_temporary_files_directory().is_valid() ? path_discovery::memory_backed_temporary_files_directory() : path_discovery::storage_backed_temporary_files_directory(); - OUTCOME_TRY(_temph, file_handle::uniquely_named_file(tempdirh)); + OUTCOME_TRY(auto &&_temph, file_handle::uniquely_named_file(tempdirh)); temph = std::move(_temph); // Truncate it out to the hash index size, and map it into memory for read/write access OUTCOME_TRYV(temph.truncate(HashIndexSize)); - OUTCOME_TRY(temphsection, section_handle::section(temph, HashIndexSize)); - OUTCOME_TRY(temphmap, map_handle::map(temphsection, HashIndexSize)); + OUTCOME_TRY(auto &&temphsection, section_handle::section(temph, HashIndexSize)); + OUTCOME_TRY(auto &&temphmap, map_handle::map(temphsection, HashIndexSize)); // Write the path of my new hash index file, padding zeros to the nearest page size // multiple to work around a race condition in the Linux kernel - OUTCOME_TRY(temppath, temph.current_path()); + OUTCOME_TRY(auto &&temppath, temph.current_path()); char buffer[4096]; memset(buffer, 0, sizeof(buffer)); size_t bytes = temppath.native().size() * sizeof(*temppath.c_str()); @@ -253,13 +253,13 @@ namespace algorithm OUTCOME_TRYV(ret.truncate(65536)); OUTCOME_TRYV(ret.write({buffers, 0})); // Map for read the maximum possible path file size, again to avoid race problems - OUTCOME_TRY(hsection, section_handle::section(ret, 65536, section_handle::flag::read)); - OUTCOME_TRY(hmap, map_handle::map(hsection, 0, 0, section_handle::flag::read)); + OUTCOME_TRY(auto &&hsection, section_handle::section(ret, 65536, section_handle::flag::read)); + OUTCOME_TRY(auto &&hmap, map_handle::map(hsection, 0, 0, section_handle::flag::read)); /* Take shared locks on inuse. Even if this implementation doesn't implement atomic downgrade of exclusive range to shared range, we're fully prepared for other users now. The _initialisingoffset remains exclusive to prevent double entry into this init routine. */ - OUTCOME_TRY(lockinuse2, ret.lock_file_range(_lockinuseoffset, 1, lock_kind::shared)); + OUTCOME_TRY(auto &&lockinuse2, ret.lock_file_range(_lockinuseoffset, 1, lock_kind::shared)); lockinuse = std::move(lockinuse2); // releases exclusive lock on all three offsets return memory_map(std::move(ret), std::move(temph), std::move(lockinuse.value()), std::move(hmap), std::move(temphmap)); } diff --git a/include/llfio/v2.0/algorithm/shared_fs_mutex/safe_byte_ranges.hpp b/include/llfio/v2.0/algorithm/shared_fs_mutex/safe_byte_ranges.hpp index 313607dd..1e094008 100644 --- a/include/llfio/v2.0/algorithm/shared_fs_mutex/safe_byte_ranges.hpp +++ b/include/llfio/v2.0/algorithm/shared_fs_mutex/safe_byte_ranges.hpp @@ -45,7 +45,7 @@ namespace algorithm LLFIO_MAKE_FREE_FUNCTION static result<safe_byte_ranges> fs_mutex_safe_byte_ranges(const path_handle &base, path_view lockfile) noexcept { - OUTCOME_TRY(v, byte_ranges::fs_mutex_byte_ranges(base, lockfile)); + OUTCOME_TRY(auto &&v, byte_ranges::fs_mutex_byte_ranges(base, lockfile)); return safe_byte_ranges(std::move(v)); } }; @@ -152,7 +152,7 @@ namespace algorithm LLFIO_MAKE_FREE_FUNCTION static result<safe_byte_ranges> fs_mutex_safe_byte_ranges(const path_handle &base, path_view lockfile) noexcept { - OUTCOME_TRY(ret, detail::inode_to_fs_mutex(base, lockfile)); + OUTCOME_TRY(auto &&ret, detail::inode_to_fs_mutex(base, lockfile)); return safe_byte_ranges(std::move(ret)); } diff --git a/include/llfio/v2.0/algorithm/summarize.hpp b/include/llfio/v2.0/algorithm/summarize.hpp index 358ed903..8bdbe29d 100644 --- a/include/llfio/v2.0/algorithm/summarize.hpp +++ b/include/llfio/v2.0/algorithm/summarize.hpp @@ -100,12 +100,12 @@ namespace algorithm // Fetch any missing metadata if(entry.stat.st_type == filesystem::file_type::directory) { - OUTCOME_TRY(fh, directory_handle::directory(*dirh, entry.leafname, file_handle::mode::attr_read)); + OUTCOME_TRY(auto &&fh, directory_handle::directory(*dirh, entry.leafname, file_handle::mode::attr_read)); OUTCOME_TRY(entry.stat.fill(fh, state->want & ~already_have_metadata)); } else { - OUTCOME_TRY(fh, file_handle::file(*dirh, entry.leafname, file_handle::mode::attr_read)); + OUTCOME_TRY(auto &&fh, file_handle::file(*dirh, entry.leafname, file_handle::mode::attr_read)); OUTCOME_TRY(entry.stat.fill(fh, state->want & ~already_have_metadata)); } } diff --git a/include/llfio/v2.0/detail/impl/clone.ipp b/include/llfio/v2.0/detail/impl/clone.ipp index 7cc11e4e..9ce59999 100644 --- a/include/llfio/v2.0/detail/impl/clone.ipp +++ b/include/llfio/v2.0/detail/impl/clone.ipp @@ -36,7 +36,7 @@ namespace algorithm filesystem::path destleaf_; if(destleaf.empty()) { - OUTCOME_TRY(_, src.current_path()); + OUTCOME_TRY(auto &&_, src.current_path()); if(_.empty()) { // Source has been deleted, so can't infer leafname @@ -47,7 +47,7 @@ namespace algorithm } stat_t stat(nullptr); OUTCOME_TRY(stat.fill(src)); - OUTCOME_TRY(dest, file_handle::file(destdir, destleaf, file_handle::mode::write, creation, src.kernel_caching())); + OUTCOME_TRY(auto &&dest, file_handle::file(destdir, destleaf, file_handle::mode::write, creation, src.kernel_caching())); bool failed = true; auto undest = make_scope_exit([&]() noexcept { if(failed) @@ -73,7 +73,7 @@ namespace algorithm { return errc::no_space_on_device; } - OUTCOME_TRY(copied, dest.clone_extents_to(dest, d, force_copy_now, true)); + OUTCOME_TRY(auto &&copied, dest.clone_extents_to(dest, d, force_copy_now, true)); failed = false; return copied.length; } diff --git a/include/llfio/v2.0/detail/impl/posix/directory_handle.ipp b/include/llfio/v2.0/detail/impl/posix/directory_handle.ipp index e30e2c35..e597ba60 100644 --- a/include/llfio/v2.0/detail/impl/posix/directory_handle.ipp +++ b/include/llfio/v2.0/detail/impl/posix/directory_handle.ipp @@ -63,7 +63,7 @@ result<directory_handle> directory_handle::directory(const path_handle &base, pa { return errc::is_a_directory; } - OUTCOME_TRY(attribs, attribs_from_handle_mode_caching_and_flags(nativeh, _mode, _creation, _caching, flags)); + OUTCOME_TRY(auto &&attribs, attribs_from_handle_mode_caching_and_flags(nativeh, _mode, _creation, _caching, flags)); attribs &= ~O_NONBLOCK; nativeh.behaviour &= ~native_handle_type::disposition::nonblocking; nativeh.behaviour &= ~native_handle_type::disposition::seekable; // not seekable @@ -86,16 +86,16 @@ result<directory_handle> directory_handle::directory(const path_handle &base, pa path_handle dirh; if(base.is_valid() && path_parent.empty()) { - OUTCOME_TRY(dh, base.clone()); + OUTCOME_TRY(auto &&dh, base.clone()); dirh = path_handle(std::move(dh)); } else if(!path_parent.empty()) { - OUTCOME_TRY(dh, path_handle::path(base, path_parent)); + OUTCOME_TRY(auto &&dh, path_handle::path(base, path_parent)); dirh = std::move(dh); } // Create a randomly named directory, and rename it over - OUTCOME_TRY(rfh, uniquely_named_directory(dirh, _mode, _caching, flags)); + OUTCOME_TRY(auto &&rfh, uniquely_named_directory(dirh, _mode, _caching, flags)); auto r = rfh.relink(dirh, path.filename()); if(r) { @@ -207,7 +207,7 @@ result<directory_handle> directory_handle::reopen(mode mode_, caching caching_, for(;;) { // Get the current path of myself - OUTCOME_TRY(currentpath, current_path()); + OUTCOME_TRY(auto &¤tpath, current_path()); // Open myself auto fh = directory({}, currentpath, mode_, creation::open_existing, caching_, _flags); if(fh) diff --git a/include/llfio/v2.0/detail/impl/posix/file_handle.ipp b/include/llfio/v2.0/detail/impl/posix/file_handle.ipp index 9a90bbb8..06b94904 100644 --- a/include/llfio/v2.0/detail/impl/posix/file_handle.ipp +++ b/include/llfio/v2.0/detail/impl/posix/file_handle.ipp @@ -34,7 +34,7 @@ result<file_handle> file_handle::file(const path_handle &base, file_handle::path native_handle_type &nativeh = ret.value()._v; LLFIO_LOG_FUNCTION_CALL(&ret); nativeh.behaviour |= native_handle_type::disposition::file; - OUTCOME_TRY(attribs, attribs_from_handle_mode_caching_and_flags(nativeh, _mode, _creation, _caching, flags)); + OUTCOME_TRY(auto &&attribs, attribs_from_handle_mode_caching_and_flags(nativeh, _mode, _creation, _caching, flags)); attribs &= ~O_NONBLOCK; nativeh.behaviour &= ~native_handle_type::disposition::nonblocking; path_view::c_str<> zpath(path); @@ -55,16 +55,16 @@ result<file_handle> file_handle::file(const path_handle &base, file_handle::path path_handle dirh; if(base.is_valid() && path_parent.empty()) { - OUTCOME_TRY(dh, base.clone()); + OUTCOME_TRY(auto &&dh, base.clone()); dirh = path_handle(std::move(dh)); } else if(!path_parent.empty()) { - OUTCOME_TRY(dh, path_handle::path(base, path_parent)); + OUTCOME_TRY(auto &&dh, path_handle::path(base, path_parent)); dirh = std::move(dh); } // Create a randomly named file, and rename it over - OUTCOME_TRY(rfh, uniquely_named_file(dirh, _mode, _caching, flags)); + OUTCOME_TRY(auto &&rfh, uniquely_named_file(dirh, _mode, _caching, flags)); auto r = rfh.relink(dirh, path.filename()); if(r) { @@ -109,7 +109,7 @@ result<file_handle> file_handle::temp_inode(const path_handle &dirh, mode _mode, LLFIO_LOG_FUNCTION_CALL(&ret); nativeh.behaviour |= native_handle_type::disposition::file; // Open file exclusively to prevent collision - OUTCOME_TRY(attribs, attribs_from_handle_mode_caching_and_flags(nativeh, _mode, creation::only_if_not_exist, _caching, flags)); + OUTCOME_TRY(auto &&attribs, attribs_from_handle_mode_caching_and_flags(nativeh, _mode, creation::only_if_not_exist, _caching, flags)); attribs &= ~O_NONBLOCK; nativeh.behaviour &= ~native_handle_type::disposition::nonblocking; #ifdef O_TMPFILE @@ -263,7 +263,7 @@ result<file_handle> file_handle::reopen(mode mode_, caching caching_, deadline d for(;;) { // Get the current path of myself - OUTCOME_TRY(currentpath, current_path()); + OUTCOME_TRY(auto &¤tpath, current_path()); if(currentpath.empty()) { // Cannot reopen a file which has been unlinked @@ -387,7 +387,7 @@ result<std::vector<file_handle::extent_pair>> file_handle::extents() const noexc // If it failed with no output, probably this filing system doesn't support extents if(out.empty()) { - OUTCOME_TRY(size, file_handle::maximum_extent()); + OUTCOME_TRY(auto &&size, file_handle::maximum_extent()); out.emplace_back(0, size); return out; } @@ -459,7 +459,7 @@ result<file_handle::extent_type> file_handle::zero(file_handle::extent_pair exte { auto *buffer = static_cast<byte *>(alloca((size_type) extent.length)); memset(buffer, 0, (size_type) extent.length); - OUTCOME_TRY(written, write(extent.offset, {{buffer, (size_type) extent.length}}, d)); + OUTCOME_TRY(auto &&written, write(extent.offset, {{buffer, (size_type) extent.length}}, d)); return written; } try @@ -472,7 +472,7 @@ result<file_handle::extent_type> file_handle::zero(file_handle::extent_pair exte while(extent.length > 0) { auto towrite = (extent.length < blocksize) ? (size_t) extent.length : blocksize; - OUTCOME_TRY(written, write(extent.offset, {{buffer, towrite}}, d)); + OUTCOME_TRY(auto &&written, write(extent.offset, {{buffer, towrite}}, d)); extent.offset += written; extent.length -= written; ret += written; diff --git a/include/llfio/v2.0/detail/impl/posix/fs_handle.ipp b/include/llfio/v2.0/detail/impl/posix/fs_handle.ipp index 776244fc..c7f167e7 100644 --- a/include/llfio/v2.0/detail/impl/posix/fs_handle.ipp +++ b/include/llfio/v2.0/detail/impl/posix/fs_handle.ipp @@ -62,7 +62,7 @@ namespace detail for(;;) { // Get current path for handle and open its containing dir - OUTCOME_TRY(_currentpath, h.current_path()); + OUTCOME_TRY(auto &&_currentpath, h.current_path()); // If current path is empty, it's been deleted if(_currentpath.empty()) { @@ -174,7 +174,7 @@ result<void> fs_handle::relink(const path_handle &base, path_view_type path, boo { OUTCOME_TRY(_fetch_inode()); } - OUTCOME_TRY(dirh, detail::containing_directory(std::ref(filename), h, *this, d)); + OUTCOME_TRY(auto &&dirh, detail::containing_directory(std::ref(filename), h, *this, d)); if(!atomic_replace) { // Some systems provide an extension for atomic non-replacing renames @@ -207,7 +207,7 @@ result<void> fs_handle::unlink(deadline d) noexcept { OUTCOME_TRY(_fetch_inode()); } - OUTCOME_TRY(dirh, detail::containing_directory(std::ref(filename), h, *this, d)); + OUTCOME_TRY(auto &&dirh, detail::containing_directory(std::ref(filename), h, *this, d)); if(-1 == ::unlinkat(dirh.native_handle().fd, filename.c_str(), h.is_directory() ? AT_REMOVEDIR : 0)) { return posix_error(); diff --git a/include/llfio/v2.0/detail/impl/posix/map_handle.ipp b/include/llfio/v2.0/detail/impl/posix/map_handle.ipp index 7e16c7ed..7c9e54a5 100644 --- a/include/llfio/v2.0/detail/impl/posix/map_handle.ipp +++ b/include/llfio/v2.0/detail/impl/posix/map_handle.ipp @@ -98,7 +98,7 @@ result<section_handle> section_handle::section(file_handle &backing, extent_type result<section_handle> section_handle::section(extent_type bytes, const path_handle &dirh, flag _flag) noexcept { - OUTCOME_TRY(_anonh, file_handle::temp_inode(dirh)); + OUTCOME_TRY(auto &&_anonh, file_handle::temp_inode(dirh)); OUTCOME_TRYV(_anonh.truncate(bytes)); result<section_handle> ret(section_handle(native_handle_type(), nullptr, std::move(_anonh), _flag)); native_handle_type &nativeh = ret.value()._v; @@ -397,8 +397,8 @@ result<map_handle> map_handle::map(size_type bytes, bool /*unused*/, section_han bytes = utils::round_up_to_page_size(bytes, /*FIXME*/ utils::page_size()); result<map_handle> ret(map_handle(nullptr, _flag)); native_handle_type &nativeh = ret.value()._v; - OUTCOME_TRY(pagesize, detail::pagesize_from_flags(ret.value()._flag)); - OUTCOME_TRY(addr, do_mmap(nativeh, nullptr, 0, nullptr, pagesize, bytes, 0, ret.value()._flag)); + OUTCOME_TRY(auto &&pagesize, detail::pagesize_from_flags(ret.value()._flag)); + OUTCOME_TRY(auto &&addr, do_mmap(nativeh, nullptr, 0, nullptr, pagesize, bytes, 0, ret.value()._flag)); ret.value()._addr = static_cast<byte *>(addr); ret.value()._reservation = bytes; ret.value()._length = bytes; @@ -411,15 +411,15 @@ result<map_handle> map_handle::map(size_type bytes, bool /*unused*/, section_han result<map_handle> map_handle::map(section_handle §ion, size_type bytes, extent_type offset, section_handle::flag _flag) noexcept { - OUTCOME_TRY(length, section.length()); // length of the backing file + OUTCOME_TRY(auto &&length, section.length()); // length of the backing file if(bytes == 0u) { bytes = length - offset; } result<map_handle> ret{map_handle(§ion, _flag)}; native_handle_type &nativeh = ret.value()._v; - OUTCOME_TRY(pagesize, detail::pagesize_from_flags(ret.value()._flag)); - OUTCOME_TRY(addr, do_mmap(nativeh, nullptr, 0, §ion, pagesize, bytes, offset, ret.value()._flag)); + OUTCOME_TRY(auto &&pagesize, detail::pagesize_from_flags(ret.value()._flag)); + OUTCOME_TRY(auto &&addr, do_mmap(nativeh, nullptr, 0, §ion, pagesize, bytes, offset, ret.value()._flag)); ret.value()._addr = static_cast<byte *>(addr); ret.value()._offset = offset; ret.value()._reservation = utils::round_up_to_page_size(bytes, pagesize); @@ -439,7 +439,7 @@ result<map_handle::size_type> map_handle::truncate(size_type newsize, bool permi extent_type length = _length; if(_section != nullptr) { - OUTCOME_TRY(length_, _section->length()); // length of the backing file + OUTCOME_TRY(auto &&length_, _section->length()); // length of the backing file length = length_; } auto _newsize = utils::round_up_to_page_size(newsize, _pagesize); @@ -462,7 +462,7 @@ result<map_handle::size_type> map_handle::truncate(size_type newsize, bool permi // If not mapped yet ... if(_addr == nullptr) { - OUTCOME_TRY(addr, do_mmap(_v, nullptr, 0, _section, _pagesize, newsize, _offset, _flag)); + OUTCOME_TRY(auto &&addr, do_mmap(_v, nullptr, 0, _section, _pagesize, newsize, _offset, _flag)); _addr = static_cast<byte *>(addr); _reservation = _newsize; _length = (length - _offset < newsize) ? (length - _offset) : newsize; // length of backing, not reservation @@ -488,7 +488,7 @@ result<map_handle::size_type> map_handle::truncate(size_type newsize, bool permi byte *addrafter = _addr + _reservation; size_type bytes = newsize - _reservation; extent_type offset = _offset + _reservation; - OUTCOME_TRY(addr, do_mmap(_v, addrafter, MAP_FIXED | MAP_EXCL, _section, _pagesize, bytes, offset, _flag)); + OUTCOME_TRY(auto &&addr, do_mmap(_v, addrafter, MAP_FIXED | MAP_EXCL, _section, _pagesize, bytes, offset, _flag)); _reservation = _newsize; _length = (length - _offset < newsize) ? (length - _offset) : newsize; // length of backing, not reservation return newsize; @@ -496,7 +496,7 @@ result<map_handle::size_type> map_handle::truncate(size_type newsize, bool permi byte *addrafter = _addr + _reservation; size_type bytes = newsize - _reservation; extent_type offset = _offset + _reservation; - OUTCOME_TRY(addr, do_mmap(_v, addrafter, 0, _section, _pagesize, bytes, offset, _flag)); + OUTCOME_TRY(auto &&addr, do_mmap(_v, addrafter, 0, _section, _pagesize, bytes, offset, _flag)); if(addr != addrafter) { ::munmap(addr, bytes); diff --git a/include/llfio/v2.0/detail/impl/posix/mapped_file_handle.ipp b/include/llfio/v2.0/detail/impl/posix/mapped_file_handle.ipp index e7aef53b..94e9bf9d 100644 --- a/include/llfio/v2.0/detail/impl/posix/mapped_file_handle.ipp +++ b/include/llfio/v2.0/detail/impl/posix/mapped_file_handle.ipp @@ -30,7 +30,7 @@ LLFIO_V2_NAMESPACE_BEGIN result<mapped_file_handle::size_type> mapped_file_handle::reserve(size_type reservation) noexcept { LLFIO_LOG_FUNCTION_CALL(this); - OUTCOME_TRY(length, underlying_file_maximum_extent()); + OUTCOME_TRY(auto &&length, underlying_file_maximum_extent()); if(length == 0) { // Not portable to map an empty file, so do nothing @@ -44,7 +44,7 @@ result<mapped_file_handle::size_type> mapped_file_handle::reserve(size_type rese if(!_sh.is_valid()) { section_handle::flag sectionflags = _sh.section_flags() | section_handle::flag::readwrite; - OUTCOME_TRY(sh, section_handle::section(*this, length, sectionflags)); + OUTCOME_TRY(auto &&sh, section_handle::section(*this, length, sectionflags)); _sh = std::move(sh); } if(_mh.is_valid() && reservation == _mh.length()) @@ -59,7 +59,7 @@ result<mapped_file_handle::size_type> mapped_file_handle::reserve(size_type rese mapflags |= section_handle::flag::write; } OUTCOME_TRYV(_mh.close()); - OUTCOME_TRY(mh, map_handle::map(_sh, reservation, 0, mapflags)); + OUTCOME_TRY(auto &&mh, map_handle::map(_sh, reservation, 0, mapflags)); _mh = std::move(mh); _reservation = reservation; return _reservation; @@ -104,7 +104,7 @@ result<mapped_file_handle::extent_type> mapped_file_handle::truncate(extent_type } if(!_sh.is_valid()) { - OUTCOME_TRY(ret, file_handle::truncate(newsize)); + OUTCOME_TRY(auto &&ret, file_handle::truncate(newsize)); if(newsize > _reservation) { _reservation = newsize; @@ -114,7 +114,7 @@ result<mapped_file_handle::extent_type> mapped_file_handle::truncate(extent_type return ret; } // On POSIX the section's size is the file's size - OUTCOME_TRY(size, _sh.length()); + OUTCOME_TRY(auto &&size, _sh.length()); if(size != newsize) { // If we are making this smaller, we must discard the pages about to get truncated @@ -130,7 +130,7 @@ result<mapped_file_handle::extent_type> mapped_file_handle::truncate(extent_type // Have we exceeded the reservation? If so, reserve a new reservation which will recreate the map. if(newsize > _reservation) { - OUTCOME_TRY(ret, reserve(newsize)); + OUTCOME_TRY(auto &&ret, reserve(newsize)); return ret; } size = newsize; @@ -142,7 +142,7 @@ result<mapped_file_handle::extent_type> mapped_file_handle::truncate(extent_type result<mapped_file_handle::extent_type> mapped_file_handle::update_map() noexcept { - OUTCOME_TRY(length, underlying_file_maximum_extent()); + OUTCOME_TRY(auto &&length, underlying_file_maximum_extent()); if(length > _reservation) { // This API never exceeds the reservation diff --git a/include/llfio/v2.0/detail/impl/posix/pipe_handle.ipp b/include/llfio/v2.0/detail/impl/posix/pipe_handle.ipp index e288cfbc..110971d6 100644 --- a/include/llfio/v2.0/detail/impl/posix/pipe_handle.ipp +++ b/include/llfio/v2.0/detail/impl/posix/pipe_handle.ipp @@ -33,7 +33,7 @@ result<pipe_handle> pipe_handle::pipe(pipe_handle::path_view_type path, pipe_han native_handle_type &nativeh = ret.value()._v; LLFIO_LOG_FUNCTION_CALL(&ret); nativeh.behaviour |= native_handle_type::disposition::pipe; - OUTCOME_TRY(attribs, attribs_from_handle_mode_caching_and_flags(nativeh, _mode, _creation, _caching, flags)); + OUTCOME_TRY(auto &&attribs, attribs_from_handle_mode_caching_and_flags(nativeh, _mode, _creation, _caching, flags)); attribs &= ~(O_CREAT | O_EXCL); // needs to be emulated for fifos nativeh.behaviour &= ~native_handle_type::disposition::seekable; // not seekable if(creation::truncate_existing == _creation) @@ -54,7 +54,7 @@ result<pipe_handle> pipe_handle::pipe(pipe_handle::path_view_type path, pipe_han } else if(!path_parent.empty()) { - OUTCOME_TRY(dh, path_handle::path(base, path_parent.empty() ? "." : path_parent)); + OUTCOME_TRY(auto &&dh, path_handle::path(base, path_parent.empty() ? "." : path_parent)); dirh = std::move(dh); dirhfd = dirh.native_handle().fd; } @@ -132,7 +132,7 @@ result<std::pair<pipe_handle, pipe_handle>> pipe_handle::anonymous_pipe(caching result<std::pair<pipe_handle, pipe_handle>> ret(pipe_handle(native_handle_type(), 0, 0, _caching, flags, nullptr), pipe_handle(native_handle_type(), 0, 0, _caching, flags, nullptr)); native_handle_type &readnativeh = ret.value().first._v, &writenativeh = ret.value().second._v; LLFIO_LOG_FUNCTION_CALL(&ret); - OUTCOME_TRY(readattribs, attribs_from_handle_mode_caching_and_flags(readnativeh, mode::read, creation::open_existing, _caching, flags)); + OUTCOME_TRY(auto &&readattribs, attribs_from_handle_mode_caching_and_flags(readnativeh, mode::read, creation::open_existing, _caching, flags)); OUTCOME_TRY(attribs_from_handle_mode_caching_and_flags(writenativeh, mode::append, creation::open_existing, _caching, flags)); #ifdef O_DIRECT readattribs &= O_DIRECT | O_NONBLOCK; diff --git a/include/llfio/v2.0/detail/impl/posix/process_handle.ipp b/include/llfio/v2.0/detail/impl/posix/process_handle.ipp index 9e492f4a..0f6498c4 100644 --- a/include/llfio/v2.0/detail/impl/posix/process_handle.ipp +++ b/include/llfio/v2.0/detail/impl/posix/process_handle.ipp @@ -174,7 +174,7 @@ LLFIO_HEADERS_ONLY_MEMFUNC_SPEC result<intptr_t> process_handle::wait(deadline d // We currently spin poll non-infinite non-zero waits :( for(;;) { - OUTCOME_TRY(running, check_child()); + OUTCOME_TRY(auto &&running, check_child()); if(!running) return ret; LLFIO_POSIX_DEADLINE_TO_TIMEOUT_LOOP(d); @@ -207,20 +207,20 @@ LLFIO_HEADERS_ONLY_MEMFUNC_SPEC result<process_handle> process_handle::launch_pr if(!(flags & flag::no_redirect_in_pipe)) { - OUTCOME_TRY(handles, pipe_handle::anonymous_pipe(pipe_handle::caching::all, pipeflags)); + OUTCOME_TRY(auto &&handles, pipe_handle::anonymous_pipe(pipe_handle::caching::all, pipeflags)); ret.value()._in_pipe = std::move(handles.first); childoutpipe = std::move(handles.second); } if(!(flags & flag::no_redirect_out_pipe)) { - OUTCOME_TRY(handles, pipe_handle::anonymous_pipe(pipe_handle::caching::all, pipeflags)); + OUTCOME_TRY(auto &&handles, pipe_handle::anonymous_pipe(pipe_handle::caching::all, pipeflags)); ret.value()._out_pipe = std::move(handles.second); childinpipe = std::move(handles.first); } if(!(flags & flag::no_redirect_error_pipe)) { // stderr must not buffer writes - OUTCOME_TRY(handles, pipe_handle::anonymous_pipe(pipe_handle::caching::reads, pipeflags)); + OUTCOME_TRY(auto &&handles, pipe_handle::anonymous_pipe(pipe_handle::caching::reads, pipeflags)); ret.value()._error_pipe = std::move(handles.first); childerrorpipe = std::move(handles.second); } diff --git a/include/llfio/v2.0/detail/impl/posix/storage_profile.ipp b/include/llfio/v2.0/detail/impl/posix/storage_profile.ipp index f4ea2123..c46d9161 100644 --- a/include/llfio/v2.0/detail/impl/posix/storage_profile.ipp +++ b/include/llfio/v2.0/detail/impl/posix/storage_profile.ipp @@ -291,7 +291,7 @@ namespace storage_profile #endif return errc::function_not_supported; } - OUTCOME_TRY(deviceh, file_handle::file({}, mntfromname, handle::mode::none, handle::creation::open_existing, handle::caching::only_metadata)); + OUTCOME_TRY(auto &&deviceh, file_handle::file({}, mntfromname, handle::mode::none, handle::creation::open_existing, handle::caching::only_metadata)); // TODO(ned): See https://github.com/baruch/diskscan/blob/master/arch/arch-linux.c // sp.controller_type.value = "SCSI"; diff --git a/include/llfio/v2.0/detail/impl/posix/symlink_handle.ipp b/include/llfio/v2.0/detail/impl/posix/symlink_handle.ipp index aeb6aeb2..b13c5909 100644 --- a/include/llfio/v2.0/detail/impl/posix/symlink_handle.ipp +++ b/include/llfio/v2.0/detail/impl/posix/symlink_handle.ipp @@ -130,7 +130,7 @@ result<symlink_handle> symlink_handle::reopen(mode mode_, deadline d) const noex #if LLFIO_SYMLINK_HANDLE_IS_FAKED result<symlink_handle> ret(symlink_handle(native_handle_type(), _devid, _inode, _flags)); ret.value()._v.behaviour = _v.behaviour; - OUTCOME_TRY(dirh, _dirh.clone()); + OUTCOME_TRY(auto &&dirh, _dirh.clone()); ret.value()._dirh = path_handle(std::move(dirh)); try { @@ -171,7 +171,7 @@ result<symlink_handle> symlink_handle::reopen(mode mode_, deadline d) const noex for(;;) { // Get the current path of myself - OUTCOME_TRY(currentpath, current_path()); + OUTCOME_TRY(auto &¤tpath, current_path()); // Open myself auto fh = symlink({}, currentpath, mode_, creation::open_existing, _flags); if(fh) @@ -228,7 +228,7 @@ result<symlink_handle::path_type> symlink_handle::current_path() const noexcept { return posix_error(); } - OUTCOME_TRY(dirpath, _dirh.current_path()); + OUTCOME_TRY(auto &&dirpath, _dirh.current_path()); dirpath /= _leafname; if(-1 == ::lstat(dirpath.c_str(), &s2) || s1.st_dev != s2.st_dev || s1.st_ino != s2.st_ino) { @@ -254,12 +254,12 @@ result<void> symlink_handle::relink(const path_handle &base, path_view_type path _leafname = path.filename().path(); if(base.is_valid() && path_parent.empty()) { - OUTCOME_TRY(dh, base.clone()); + OUTCOME_TRY(auto &&dh, base.clone()); _dirh = path_handle(std::move(dh)); } else if(!path_parent.empty()) { - OUTCOME_TRY(dh, path_handle::path(base, path_parent)); + OUTCOME_TRY(auto &&dh, path_handle::path(base, path_parent)); _dirh = std::move(dh); } } @@ -290,7 +290,7 @@ LLFIO_HEADERS_ONLY_MEMFUNC_SPEC result<symlink_handle> symlink_handle::symlink(c { return errc::function_not_supported; } - OUTCOME_TRY(attribs, attribs_from_handle_mode_caching_and_flags(nativeh, _mode, _creation, caching::all, flags)); + OUTCOME_TRY(auto &&attribs, attribs_from_handle_mode_caching_and_flags(nativeh, _mode, _creation, caching::all, flags)); attribs &= ~O_NONBLOCK; nativeh.behaviour &= ~native_handle_type::disposition::nonblocking; nativeh.behaviour &= ~native_handle_type::disposition::seekable; // not seekable @@ -313,7 +313,7 @@ LLFIO_HEADERS_ONLY_MEMFUNC_SPEC result<symlink_handle> symlink_handle::symlink(c #if !LLFIO_SYMLINK_HANDLE_IS_FAKED dirhfd = base.native_handle().fd; #else - OUTCOME_TRY(dh, base.clone()); + OUTCOME_TRY(auto &&dh, base.clone()); dirh = path_handle(std::move(dh)); dirhfd = dirh.native_handle().fd; #endif @@ -323,7 +323,7 @@ LLFIO_HEADERS_ONLY_MEMFUNC_SPEC result<symlink_handle> symlink_handle::symlink(c if(!path_parent.empty()) #endif { - OUTCOME_TRY(dh, path_handle::path(base, path_parent.empty() ? "." : path_parent)); + OUTCOME_TRY(auto &&dh, path_handle::path(base, path_parent.empty() ? "." : path_parent)); dirh = std::move(dh); dirhfd = dirh.native_handle().fd; } @@ -443,7 +443,7 @@ result<symlink_handle::const_buffers_type> symlink_handle::write(symlink_handle: OUTCOME_TRY(_fetch_inode()); } path_type filename; - OUTCOME_TRY(dirh, detail::containing_directory(std::ref(filename), *this, *this, d)); + OUTCOME_TRY(auto &&dirh, detail::containing_directory(std::ref(filename), *this, *this, d)); #else const path_handle &dirh = _dirh; const path_type &filename = _leafname; diff --git a/include/llfio/v2.0/detail/impl/posix/test/io_uring_multiplexer.ipp b/include/llfio/v2.0/detail/impl/posix/test/io_uring_multiplexer.ipp index fe34cb5d..0988410a 100644 --- a/include/llfio/v2.0/detail/impl/posix/test/io_uring_multiplexer.ipp +++ b/include/llfio/v2.0/detail/impl/posix/test/io_uring_multiplexer.ipp @@ -941,7 +941,7 @@ namespace test } } // The default implementation uses mmap, so this is done for us - OUTCOME_TRY(ret, _base::do_io_handle_allocate_registered_buffer(h, bytes)); + OUTCOME_TRY(auto &&ret, _base::do_io_handle_allocate_registered_buffer(h, bytes)); // Register this buffer with io_uring struct iovec upd; upd.iov_base = ret->data(); diff --git a/include/llfio/v2.0/detail/impl/posix/utils.ipp b/include/llfio/v2.0/detail/impl/posix/utils.ipp index 8be629e0..e3b47484 100644 --- a/include/llfio/v2.0/detail/impl/posix/utils.ipp +++ b/include/llfio/v2.0/detail/impl/posix/utils.ipp @@ -362,10 +362,10 @@ namespace utils //std::cerr << "Anon entries:"; for(auto &i : anon_entries) { - OUTCOME_TRY(size, parse(i, "\nSize:")); - OUTCOME_TRY(rss, parse(i, "\nRss:")); - OUTCOME_TRY(anonymous, parse(i, "\nAnonymous:")); - OUTCOME_TRY(lazyfree, parse(i, "\nLazyFree:")); + OUTCOME_TRY(auto &&size, parse(i, "\nSize:")); + OUTCOME_TRY(auto &&rss, parse(i, "\nRss:")); + OUTCOME_TRY(auto &&anonymous, parse(i, "\nAnonymous:")); + OUTCOME_TRY(auto &&lazyfree, parse(i, "\nLazyFree:")); if(size != (uint64_t) -1 && rss != (uint64_t) -1 && anonymous != (uint64_t) -1) { ret.total_address_space_in_use += size; @@ -383,9 +383,9 @@ namespace utils //std::cerr << "\n\nNon-anon entries:"; for(auto &i : non_anon_entries) { - OUTCOME_TRY(size, parse(i, "\nSize:")); - OUTCOME_TRY(rss, parse(i, "\nRss:")); - OUTCOME_TRY(lazyfree, parse(i, "\nLazyFree:")); + OUTCOME_TRY(auto &&size, parse(i, "\nSize:")); + OUTCOME_TRY(auto &&rss, parse(i, "\nRss:")); + OUTCOME_TRY(auto &&lazyfree, parse(i, "\nLazyFree:")); if(size != (uint64_t) -1 && rss != (uint64_t) -1) { ret.total_address_space_in_use += size; diff --git a/include/llfio/v2.0/detail/impl/reduce.ipp b/include/llfio/v2.0/detail/impl/reduce.ipp index 49a270d8..222fd82b 100644 --- a/include/llfio/v2.0/detail/impl/reduce.ipp +++ b/include/llfio/v2.0/detail/impl/reduce.ipp @@ -303,7 +303,7 @@ namespace algorithm auto r = detail::remove(dirh, entry.leafname, false); if(!r) { - OUTCOME_TRY(success, state->visitor->unlink_failed(data, std::move(r).error(), dirh, entry, depth)); + OUTCOME_TRY(auto &&success, state->visitor->unlink_failed(data, std::move(r).error(), dirh, entry, depth)); if(success) { state->items_removed.fetch_add(1, std::memory_order_relaxed); @@ -339,7 +339,7 @@ namespace algorithm auto r = detail::rename(dirh, entry.leafname, false, state->topdirh); if(!r) { - OUTCOME_TRY(success, state->visitor->rename_failed(data, std::move(r).error(), dirh, entry, depth)); + OUTCOME_TRY(auto &&success, state->visitor->rename_failed(data, std::move(r).error(), dirh, entry, depth)); if(!success) { state->failed_to_rename.fetch_add(1, std::memory_order_relaxed); @@ -357,7 +357,7 @@ namespace algorithm visitor = &default_visitor; } { - OUTCOME_TRY(dirhparent, topdirh.parent_path_handle()); + OUTCOME_TRY(auto &&dirhparent, topdirh.parent_path_handle()); for(;;) { auto randomname = utils::random_string(32); diff --git a/include/llfio/v2.0/detail/impl/storage_profile.ipp b/include/llfio/v2.0/detail/impl/storage_profile.ipp index efc384c7..61ab55d8 100644 --- a/include/llfio/v2.0/detail/impl/storage_profile.ipp +++ b/include/llfio/v2.0/detail/impl/storage_profile.ipp @@ -1057,7 +1057,7 @@ namespace storage_profile { return success(); } - OUTCOME_TRY(s, _latency_test(srch, 1, 0, false)); + OUTCOME_TRY(auto &&s, _latency_test(srch, 1, 0, false)); sp.read_qd1_min.value = s.min; sp.read_qd1_mean.value = s.mean; sp.read_qd1_max.value = s.max; @@ -1073,7 +1073,7 @@ namespace storage_profile { return success(); } - OUTCOME_TRY(s, _latency_test(srch, 0, 1, false)); + OUTCOME_TRY(auto &&s, _latency_test(srch, 0, 1, false)); sp.write_qd1_min.value = s.min; sp.write_qd1_mean.value = s.mean; sp.write_qd1_max.value = s.max; @@ -1089,7 +1089,7 @@ namespace storage_profile { return success(); } - OUTCOME_TRY(s, _latency_test(srch, 16, 0, true)); + OUTCOME_TRY(auto &&s, _latency_test(srch, 16, 0, true)); sp.read_qd16_min.value = s.min; sp.read_qd16_mean.value = s.mean; sp.read_qd16_max.value = s.max; @@ -1105,7 +1105,7 @@ namespace storage_profile { return success(); } - OUTCOME_TRY(s, _latency_test(srch, 0, 16, true)); + OUTCOME_TRY(auto &&s, _latency_test(srch, 0, 16, true)); sp.write_qd16_min.value = s.min; sp.write_qd16_mean.value = s.mean; sp.write_qd16_max.value = s.max; @@ -1121,7 +1121,7 @@ namespace storage_profile { return success(); } - OUTCOME_TRY(s, _latency_test(srch, 3, 1, true)); + OUTCOME_TRY(auto &&s, _latency_test(srch, 3, 1, true)); sp.readwrite_qd4_min.value = s.min; sp.readwrite_qd4_mean.value = s.mean; sp.readwrite_qd4_max.value = s.max; @@ -1307,7 +1307,7 @@ namespace storage_profile return success(); } size_t items = srch.are_writes_durable() ? 256 : 16384; - OUTCOME_TRY(s, _traversal_N(srch, items, 0, false, true, false)); + OUTCOME_TRY(auto &&s, _traversal_N(srch, items, 0, false, true, false)); sp.create_file_warm_racefree_0b.value = s.create; sp.enumerate_file_warm_racefree_0b.value = s.enumerate; sp.open_file_read_warm_racefree_0b.value = s.open_read; @@ -1322,7 +1322,7 @@ namespace storage_profile return success(); } size_t items = srch.are_writes_durable() ? 256 : 16384; - OUTCOME_TRY(s, _traversal_N(srch, items, 0, false, false, false)); + OUTCOME_TRY(auto &&s, _traversal_N(srch, items, 0, false, false, false)); sp.create_file_warm_nonracefree_0b.value = s.create; sp.enumerate_file_warm_nonracefree_0b.value = s.enumerate; sp.open_file_read_warm_nonracefree_0b.value = s.open_read; @@ -1337,7 +1337,7 @@ namespace storage_profile return success(); } size_t items = srch.are_writes_durable() ? 256 : 16384; - OUTCOME_TRY(s, _traversal_N(srch, items, 0, true, true, false)); + OUTCOME_TRY(auto &&s, _traversal_N(srch, items, 0, true, true, false)); sp.create_file_cold_racefree_0b.value = s.create; sp.enumerate_file_cold_racefree_0b.value = s.enumerate; sp.open_file_read_cold_racefree_0b.value = s.open_read; @@ -1354,7 +1354,7 @@ namespace storage_profile { return errc::invalid_argument; } - OUTCOME_TRY(s, _traversal_N(srch, 1000000, 0, false, false, true)); + OUTCOME_TRY(auto &&s, _traversal_N(srch, 1000000, 0, false, false, true)); sp.create_1M_files.value = s.create; sp.enumerate_1M_files.value = s.enumerate; sp.delete_1M_files.value = s.destroy; diff --git a/include/llfio/v2.0/detail/impl/traverse.ipp b/include/llfio/v2.0/detail/impl/traverse.ipp index 7d44e9ef..7b8c069b 100644 --- a/include/llfio/v2.0/detail/impl/traverse.ipp +++ b/include/llfio/v2.0/detail/impl/traverse.ipp @@ -48,7 +48,7 @@ namespace algorithm LLFIO_LOG_FUNCTION_CALL(&_topdirh); std::shared_ptr<directory_handle> topdirh; { - OUTCOME_TRY(dirh, directory_handle::directory(_topdirh, {})); + OUTCOME_TRY(auto &&dirh, directory_handle::directory(_topdirh, {})); topdirh = std::make_shared<directory_handle>(std::move(dirh)); } bool use_slow_path = force_slow_path; @@ -222,7 +222,7 @@ namespace algorithm auto r = directory_handle::directory(*mywork.dirh, mywork.leaf()); if(!r) { - OUTCOME_TRY(replacementh, state->visitor->directory_open_failed(data, std::move(r).error(), *mywork.dirh, mywork.leaf(), mylevel)); + OUTCOME_TRY(auto &&replacementh, state->visitor->directory_open_failed(data, std::move(r).error(), *mywork.dirh, mywork.leaf(), mylevel)); mydirh = std::make_shared<directory_handle>(std::move(replacementh)); } else @@ -232,13 +232,13 @@ namespace algorithm } if(mydirh->is_valid()) { - OUTCOME_TRY(do_enumerate, state->visitor->pre_enumeration(data, *mydirh, mylevel)); + OUTCOME_TRY(auto &&do_enumerate, state->visitor->pre_enumeration(data, *mydirh, mylevel)); if(do_enumerate) { for(;;) { buffers = {entries, std::move(buffers)}; - OUTCOME_TRY(filled, mydirh->read({std::move(buffers), {}, directory_handle::filter::none})); + OUTCOME_TRY(auto &&filled, mydirh->read({std::move(buffers), {}, directory_handle::filter::none})); buffers = std::move(filled); if(buffers.done()) { diff --git a/include/llfio/v2.0/detail/impl/windows/directory_handle.ipp b/include/llfio/v2.0/detail/impl/windows/directory_handle.ipp index d0723d26..9bd50277 100644 --- a/include/llfio/v2.0/detail/impl/windows/directory_handle.ipp +++ b/include/llfio/v2.0/detail/impl/windows/directory_handle.ipp @@ -45,8 +45,8 @@ result<directory_handle> directory_handle::directory(const path_handle &base, pa { return errc::is_a_directory; } - OUTCOME_TRY(access, access_mask_from_handle_mode(nativeh, _mode, flags)); - OUTCOME_TRY(attribs, attributes_from_handle_caching_and_flags(nativeh, _caching, flags)); + OUTCOME_TRY(auto &&access, access_mask_from_handle_mode(nativeh, _mode, flags)); + OUTCOME_TRY(auto &&attribs, attributes_from_handle_caching_and_flags(nativeh, _caching, flags)); nativeh.behaviour &= ~native_handle_type::disposition::seekable; // not seekable /* It is super important that we remove the DELETE permission for directories as otherwise relative renames will always fail due to an unfortunate design choice by Microsoft. This breaks renaming by open handle, @@ -80,7 +80,7 @@ result<directory_handle> directory_handle::directory(const path_handle &base, pa } attribs &= 0x00ffffff; // the real attributes only, not the win32 flags - OUTCOME_TRY(ntflags, ntflags_from_handle_caching_and_flags(nativeh, _caching, flags)); + OUTCOME_TRY(auto &&ntflags, ntflags_from_handle_caching_and_flags(nativeh, _caching, flags)); ntflags |= 0x01 /*FILE_DIRECTORY_FILE*/; // required to open a directory IO_STATUS_BLOCK isb = make_iostatus(); @@ -261,7 +261,7 @@ result<void> directory_handle::relink(const path_handle &base, directory_handle: race free renames into that directory will fail, so we are forced to duplicate the handle with DELETE privs temporarily in order to issue the rename */ - OUTCOME_TRY(h, detail::duplicate_handle_with_delete_privs(this)); + OUTCOME_TRY(auto &&h, detail::duplicate_handle_with_delete_privs(this)); return h.relink(base, newpath, atomic_replace, d); } @@ -272,7 +272,7 @@ result<void> directory_handle::unlink(deadline d) noexcept race free renames into that directory will fail, so we are forced to duplicate the handle with DELETE privs temporarily in order to issue the unlink */ - OUTCOME_TRY(h, detail::duplicate_handle_with_delete_privs(this)); + OUTCOME_TRY(auto &&h, detail::duplicate_handle_with_delete_privs(this)); return h.unlink(d); } diff --git a/include/llfio/v2.0/detail/impl/windows/file_handle.ipp b/include/llfio/v2.0/detail/impl/windows/file_handle.ipp index 6f7b2e59..d7e7fb94 100644 --- a/include/llfio/v2.0/detail/impl/windows/file_handle.ipp +++ b/include/llfio/v2.0/detail/impl/windows/file_handle.ipp @@ -36,8 +36,8 @@ result<file_handle> file_handle::file(const path_handle &base, file_handle::path LLFIO_LOG_FUNCTION_CALL(&ret); nativeh.behaviour |= native_handle_type::disposition::file; DWORD fileshare = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; - OUTCOME_TRY(access, access_mask_from_handle_mode(nativeh, _mode, flags)); - OUTCOME_TRY(attribs, attributes_from_handle_caching_and_flags(nativeh, _caching, flags)); + OUTCOME_TRY(auto &&access, access_mask_from_handle_mode(nativeh, _mode, flags)); + OUTCOME_TRY(auto &&attribs, attributes_from_handle_caching_and_flags(nativeh, _caching, flags)); bool need_to_set_sparse = false; if(base.is_valid() || path.is_ntpath()) { @@ -61,7 +61,7 @@ result<file_handle> file_handle::file(const path_handle &base, file_handle::path } attribs &= 0x00ffffff; // the real attributes only, not the win32 flags - OUTCOME_TRY(ntflags, ntflags_from_handle_caching_and_flags(nativeh, _caching, flags)); + OUTCOME_TRY(auto &&ntflags, ntflags_from_handle_caching_and_flags(nativeh, _caching, flags)); ntflags |= 0x040 /*FILE_NON_DIRECTORY_FILE*/; // do not open a directory IO_STATUS_BLOCK isb = make_iostatus(); @@ -192,12 +192,12 @@ result<file_handle> file_handle::temp_inode(const path_handle &dirh, mode _mode, LLFIO_LOG_FUNCTION_CALL(&ret); nativeh.behaviour |= native_handle_type::disposition::file; DWORD fileshare = /* no read nor write access for others */ FILE_SHARE_DELETE; - OUTCOME_TRY(access, access_mask_from_handle_mode(nativeh, _mode, flags)); - OUTCOME_TRY(attribs, attributes_from_handle_caching_and_flags(nativeh, _caching, flags)); + OUTCOME_TRY(auto &&access, access_mask_from_handle_mode(nativeh, _mode, flags)); + OUTCOME_TRY(auto &&attribs, attributes_from_handle_caching_and_flags(nativeh, _caching, flags)); DWORD creatdisp = 0x00000002 /*FILE_CREATE*/; attribs &= 0x00ffffff; // the real attributes only, not the win32 flags - OUTCOME_TRY(ntflags, ntflags_from_handle_caching_and_flags(nativeh, _caching, flags)); + OUTCOME_TRY(auto &&ntflags, ntflags_from_handle_caching_and_flags(nativeh, _caching, flags)); ntflags |= 0x040 /*FILE_NON_DIRECTORY_FILE*/; // do not open a directory UNICODE_STRING _path{}; _path.MaximumLength = (_path.Length = static_cast<USHORT>(68 * sizeof(wchar_t))) + sizeof(wchar_t); @@ -391,7 +391,7 @@ result<file_handle::extent_pair> file_handle::clone_extents_to(file_handle::exte if(extent.offset == (extent_type) -1 && extent.length == (extent_type)-1) { extent.offset = 0; - OUTCOME_TRY(_, maximum_extent()); + OUTCOME_TRY(auto &&_, maximum_extent()); extent.length = _; } if(extent.offset + extent.length < extent.offset) @@ -421,14 +421,14 @@ result<file_handle::extent_pair> file_handle::clone_extents_to(file_handle::exte auto towrite = (extent.length < blocksize) ? (size_t) extent.length : blocksize; buffer_type b(buffer, towrite); LLFIO_DEADLINE_TO_PARTIAL_DEADLINE(nd, d); - OUTCOME_TRY(readed, read({{&b, 1}, extent.offset}, nd)); + OUTCOME_TRY(auto &&readed, read({{&b, 1}, extent.offset}, nd)); const_buffer_type cb(readed.front()); if(cb.size() == 0) { return ret; } LLFIO_DEADLINE_TO_PARTIAL_DEADLINE(nd, d); - OUTCOME_TRY(written_, dest_.write({{&cb, 1}, destoffset}, nd)); + OUTCOME_TRY(auto &&written_, dest_.write({{&cb, 1}, destoffset}, nd)); const auto written = written_.front().size(); extent.offset += written; destoffset += written; @@ -508,7 +508,7 @@ result<file_handle::extent_pair> file_handle::clone_extents_to(file_handle::exte } // Ensure the destination file is big enough auto &dest = static_cast<file_handle &>(dest_); - OUTCOME_TRY(dest_length, dest.maximum_extent()); + OUTCOME_TRY(auto &&dest_length, dest.maximum_extent()); if(destoffset + extent.length < dest_length) { OUTCOME_TRY(dest.truncate(destoffset + extent.length)); @@ -569,7 +569,7 @@ result<file_handle::extent_pair> file_handle::clone_extents_to(file_handle::exte deadline nd; buffer_type b(buffer, thisblock); LLFIO_DEADLINE_TO_PARTIAL_DEADLINE(nd, d); - OUTCOME_TRY(readed, read({{&b, 1}, item.src.offset + thisoffset}, nd)); + OUTCOME_TRY(auto &&readed, read({{&b, 1}, item.src.offset + thisoffset}, nd)); buffer_dirty = true; const_buffer_type cb(readed.front()); if(cb.size() != thisblock) @@ -577,7 +577,7 @@ result<file_handle::extent_pair> file_handle::clone_extents_to(file_handle::exte return errc::resource_unavailable_try_again; // something is wrong } LLFIO_DEADLINE_TO_PARTIAL_DEADLINE(nd, d); - OUTCOME_TRY(written, dest.write({{&cb, 1}, destoffset}, nd)); + OUTCOME_TRY(auto &&written, dest.write({{&cb, 1}, destoffset}, nd)); if(written.front().size()!=thisblock) { return errc::resource_unavailable_try_again; // something is wrong @@ -628,7 +628,7 @@ result<file_handle::extent_pair> file_handle::clone_extents_to(file_handle::exte buffer_dirty = false; } LLFIO_DEADLINE_TO_PARTIAL_DEADLINE(nd, d); - OUTCOME_TRY(written, dest.write({{&cb, 1}, destoffset}, nd)); + OUTCOME_TRY(auto &&written, dest.write({{&cb, 1}, destoffset}, nd)); if(written.front().size() != thisblock) { return errc::resource_unavailable_try_again; // something is wrong diff --git a/include/llfio/v2.0/detail/impl/windows/fs_handle.ipp b/include/llfio/v2.0/detail/impl/windows/fs_handle.ipp index 4c3ce1a5..6705aa7b 100644 --- a/include/llfio/v2.0/detail/impl/windows/fs_handle.ipp +++ b/include/llfio/v2.0/detail/impl/windows/fs_handle.ipp @@ -54,7 +54,7 @@ result<path_handle> fs_handle::parent_path_handle(deadline d) const noexcept for(;;) { // Get current path for handle and open its containing dir - OUTCOME_TRY(currentpath, h.current_path()); + OUTCOME_TRY(auto &¤tpath, h.current_path()); // If current path is empty, it's been deleted if(currentpath.empty()) { @@ -282,7 +282,7 @@ result<void> fs_handle::unlink(deadline d) noexcept { return error_from_exception(); } - OUTCOME_TRY(dirh, parent_path_handle(d)); + OUTCOME_TRY(auto &&dirh, parent_path_handle(d)); result<void> out = relink(dirh, randomname); if(!out) { diff --git a/include/llfio/v2.0/detail/impl/windows/import.hpp b/include/llfio/v2.0/detail/impl/windows/import.hpp index 11835b09..a36721ae 100644 --- a/include/llfio/v2.0/detail/impl/windows/import.hpp +++ b/include/llfio/v2.0/detail/impl/windows/import.hpp @@ -1618,7 +1618,7 @@ inline result<void> do_clone_handle(native_handle_type &dest, const native_handl using namespace windows_nt_kernel; dest.behaviour |= src.behaviour & ~127U; // propagate type of handle only DWORD fileshare = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; - OUTCOME_TRY(access, access_mask_from_handle_mode(dest, mode_, _flags)); + OUTCOME_TRY(auto &&access, access_mask_from_handle_mode(dest, mode_, _flags)); OUTCOME_TRYV(attributes_from_handle_caching_and_flags(dest, caching_, _flags)); if(isdir) { @@ -1627,7 +1627,7 @@ inline result<void> do_clone_handle(native_handle_type &dest, const native_handl */ access &= ~DELETE; } - OUTCOME_TRY(ntflags, ntflags_from_handle_caching_and_flags(dest, caching_, _flags)); + OUTCOME_TRY(auto &&ntflags, ntflags_from_handle_caching_and_flags(dest, caching_, _flags)); ntflags |= 0x040 /*FILE_NON_DIRECTORY_FILE*/; // do not open a directory OBJECT_ATTRIBUTES oa{}; memset(&oa, 0, sizeof(oa)); diff --git a/include/llfio/v2.0/detail/impl/windows/map_handle.ipp b/include/llfio/v2.0/detail/impl/windows/map_handle.ipp index d16fffde..d05d2b2e 100644 --- a/include/llfio/v2.0/detail/impl/windows/map_handle.ipp +++ b/include/llfio/v2.0/detail/impl/windows/map_handle.ipp @@ -181,7 +181,7 @@ result<section_handle> section_handle::section(extent_type bytes, const path_han { windows_nt_kernel::init(); using namespace windows_nt_kernel; - OUTCOME_TRY(_anonh, file_handle::temp_inode(dirh)); + OUTCOME_TRY(auto &&_anonh, file_handle::temp_inode(dirh)); OUTCOME_TRYV(_anonh.truncate(bytes)); result<section_handle> ret(section_handle(native_handle_type(), nullptr, std::move(_anonh), _flag)); native_handle_type &nativeh = ret.value()._v; @@ -288,7 +288,7 @@ result<section_handle::extent_type> section_handle::truncate(extent_type newsize { if(_backing != nullptr) { - OUTCOME_TRY(length, _backing->maximum_extent()); + OUTCOME_TRY(auto &&length, _backing->maximum_extent()); newsize = length; } else @@ -556,7 +556,7 @@ result<map_handle> map_handle::map(size_type bytes, bool /*unused*/, section_han native_handle_type &nativeh = ret.value()._v; DWORD allocation = MEM_RESERVE | MEM_COMMIT, prot; PVOID addr = nullptr; - OUTCOME_TRY(pagesize, detail::pagesize_from_flags(ret.value()._flag)); + OUTCOME_TRY(auto &&pagesize, detail::pagesize_from_flags(ret.value()._flag)); bytes = utils::round_up_to_page_size(bytes, pagesize); { size_t commitsize; @@ -602,7 +602,7 @@ result<map_handle> map_handle::map(section_handle §ion, size_type bytes, ext size_t commitsize = bytes; LARGE_INTEGER _offset{}; _offset.QuadPart = offset; - OUTCOME_TRY(pagesize, detail::pagesize_from_flags(ret.value()._flag)); + OUTCOME_TRY(auto &&pagesize, detail::pagesize_from_flags(ret.value()._flag)); SIZE_T _bytes = bytes; OUTCOME_TRY(win32_map_flags(nativeh, allocation, prot, commitsize, section.backing() != nullptr, ret.value()._flag)); LLFIO_LOG_FUNCTION_CALL(&ret); @@ -678,7 +678,7 @@ result<map_handle::size_type> map_handle::truncate(size_type newsize, bool /* un } // So this must be file backed memory. Totally different APIs for that :) - OUTCOME_TRY(length, _section->length()); // length of the backing file + OUTCOME_TRY(auto &&length, _section->length()); // length of the backing file if(newsize < _reservation) { // If newsize isn't exactly a previous extension, this will fail, same as for the VirtualAlloc case diff --git a/include/llfio/v2.0/detail/impl/windows/mapped_file_handle.ipp b/include/llfio/v2.0/detail/impl/windows/mapped_file_handle.ipp index 44f0b441..2409fd49 100644 --- a/include/llfio/v2.0/detail/impl/windows/mapped_file_handle.ipp +++ b/include/llfio/v2.0/detail/impl/windows/mapped_file_handle.ipp @@ -30,7 +30,7 @@ LLFIO_V2_NAMESPACE_BEGIN result<mapped_file_handle::size_type> mapped_file_handle::reserve(size_type reservation) noexcept { LLFIO_LOG_FUNCTION_CALL(this); - OUTCOME_TRY(length, underlying_file_maximum_extent()); + OUTCOME_TRY(auto &&length, underlying_file_maximum_extent()); if(length == 0) { // Cannot create a section nor a map for a zero lengthed file @@ -49,7 +49,7 @@ result<mapped_file_handle::size_type> mapped_file_handle::reserve(size_type rese sectionflags |= section_handle::flag::read; if(this->is_writable()) sectionflags |= section_handle::flag::write; - OUTCOME_TRY(sh, section_handle::section(*this, 0, sectionflags)); + OUTCOME_TRY(auto &&sh, section_handle::section(*this, 0, sectionflags)); _sh = std::move(sh); } if(_mh.is_valid() && reservation == _mh.length()) @@ -69,7 +69,7 @@ result<mapped_file_handle::size_type> mapped_file_handle::reserve(size_type rese map_size = length; } OUTCOME_TRYV(_mh.close()); - OUTCOME_TRY(mh, map_handle::map(_sh, map_size, 0, mapflags)); + OUTCOME_TRY(auto &&mh, map_handle::map(_sh, map_size, 0, mapflags)); _mh = std::move(mh); _reservation = reservation; return _reservation; @@ -114,7 +114,7 @@ result<mapped_file_handle::extent_type> mapped_file_handle::truncate(extent_type } if(!_sh.is_valid()) { - OUTCOME_TRY(ret, file_handle::truncate(newsize)); + OUTCOME_TRY(auto &&ret, file_handle::truncate(newsize)); if(newsize > _reservation) { _reservation = newsize; @@ -127,7 +127,7 @@ result<mapped_file_handle::extent_type> mapped_file_handle::truncate(extent_type // because the section is a singleton based on the canonical path of the file, another // LLFIO in another process may have already resized the section for us in which case // we can skip doing work now. - OUTCOME_TRY(size, _sh.length()); + OUTCOME_TRY(auto &&size, _sh.length()); if(size != newsize) { // If we are making this smaller, we must destroy the map and section first @@ -136,7 +136,7 @@ result<mapped_file_handle::extent_type> mapped_file_handle::truncate(extent_type OUTCOME_TRYV(_mh.close()); OUTCOME_TRYV(_sh.close()); // This will fail on Windows if any other processes are holding a section on this file - OUTCOME_TRY(ret, file_handle::truncate(newsize)); + OUTCOME_TRY(auto &&ret, file_handle::truncate(newsize)); // Put the reservation and map back OUTCOME_TRYV(reserve(_reservation)); return ret; @@ -149,7 +149,7 @@ result<mapped_file_handle::extent_type> mapped_file_handle::truncate(extent_type // Have we exceeded the reservation? If so, reserve a new reservation which will recreate the map. if(newsize > _reservation) { - OUTCOME_TRY(ret, reserve(newsize)); + OUTCOME_TRY(auto &&ret, reserve(newsize)); return ret; } size = newsize; @@ -161,7 +161,7 @@ result<mapped_file_handle::extent_type> mapped_file_handle::truncate(extent_type result<mapped_file_handle::extent_type> mapped_file_handle::update_map() noexcept { - OUTCOME_TRY(length, underlying_file_maximum_extent()); + OUTCOME_TRY(auto &&length, underlying_file_maximum_extent()); if(length > _reservation) { // This API never exceeds the reservation @@ -178,7 +178,7 @@ result<mapped_file_handle::extent_type> mapped_file_handle::update_map() noexcep OUTCOME_TRYV(reserve(_reservation)); return length; } - OUTCOME_TRY(size, _sh.length()); + OUTCOME_TRY(auto &&size, _sh.length()); // Section may have become bigger than our reservation ... if(size >= length) { diff --git a/include/llfio/v2.0/detail/impl/windows/path_handle.ipp b/include/llfio/v2.0/detail/impl/windows/path_handle.ipp index ee752eb0..07cec50d 100644 --- a/include/llfio/v2.0/detail/impl/windows/path_handle.ipp +++ b/include/llfio/v2.0/detail/impl/windows/path_handle.ipp @@ -37,8 +37,8 @@ result<path_handle> path_handle::path(const path_handle &base, path_handle::path nativeh.behaviour |= native_handle_type::disposition::directory; DWORD fileshare = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; // Open directory with no access requested, this is much faster than asking for access - OUTCOME_TRY(access, access_mask_from_handle_mode(nativeh, mode::none, flag::none)); - OUTCOME_TRY(attribs, attributes_from_handle_caching_and_flags(nativeh, caching::all, flag::none)); + OUTCOME_TRY(auto &&access, access_mask_from_handle_mode(nativeh, mode::none, flag::none)); + OUTCOME_TRY(auto &&attribs, attributes_from_handle_caching_and_flags(nativeh, caching::all, flag::none)); nativeh.behaviour &= ~native_handle_type::disposition::seekable; // not seekable /* It is super important that we remove the DELETE permission for directories as otherwise relative renames will always fail due to an unfortunate design choice by Microsoft. @@ -48,7 +48,7 @@ result<path_handle> path_handle::path(const path_handle &base, path_handle::path { DWORD creatdisp = 0x00000001 /*FILE_OPEN*/; attribs &= 0x00ffffff; // the real attributes only, not the win32 flags - OUTCOME_TRY(ntflags, ntflags_from_handle_caching_and_flags(nativeh, caching::all, flag::none)); + OUTCOME_TRY(auto &&ntflags, ntflags_from_handle_caching_and_flags(nativeh, caching::all, flag::none)); ntflags |= 0x01 /*FILE_DIRECTORY_FILE*/; // required to open a directory IO_STATUS_BLOCK isb = make_iostatus(); diff --git a/include/llfio/v2.0/detail/impl/windows/pipe_handle.ipp b/include/llfio/v2.0/detail/impl/windows/pipe_handle.ipp index b99d72da..502b2a66 100644 --- a/include/llfio/v2.0/detail/impl/windows/pipe_handle.ipp +++ b/include/llfio/v2.0/detail/impl/windows/pipe_handle.ipp @@ -37,8 +37,8 @@ result<pipe_handle> pipe_handle::pipe(pipe_handle::path_view_type path, pipe_han LLFIO_LOG_FUNCTION_CALL(&ret); nativeh.behaviour |= native_handle_type::disposition::pipe; DWORD fileshare = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; - OUTCOME_TRY(access, access_mask_from_handle_mode(nativeh, _mode, flags)); - OUTCOME_TRY(attribs, attributes_from_handle_caching_and_flags(nativeh, _caching, flags)); + OUTCOME_TRY(auto &&access, access_mask_from_handle_mode(nativeh, _mode, flags)); + OUTCOME_TRY(auto &&attribs, attributes_from_handle_caching_and_flags(nativeh, _caching, flags)); nativeh.behaviour &= ~native_handle_type::disposition::seekable; // not seekable if(creation::truncate_existing == _creation || creation::always_new == _creation || !base.is_valid()) { @@ -68,7 +68,7 @@ result<pipe_handle> pipe_handle::pipe(pipe_handle::path_view_type path, pipe_han } attribs &= 0x00ffffff; // the real attributes only, not the win32 flags - OUTCOME_TRY(ntflags, ntflags_from_handle_caching_and_flags(nativeh, _caching, flags)); + OUTCOME_TRY(auto &&ntflags, ntflags_from_handle_caching_and_flags(nativeh, _caching, flags)); ntflags &= ~0x00000008 /*FILE_NO_INTERMEDIATE_BUFFERING*/; // pipes always buffer IO_STATUS_BLOCK isb = make_iostatus(); @@ -169,20 +169,20 @@ result<std::pair<pipe_handle, pipe_handle>> pipe_handle::anonymous_pipe(caching using namespace windows_nt_kernel; // Create an unnamed new pipe flags &= ~flag::unlink_on_first_close; - OUTCOME_TRY(anonpipe, pipe({}, mode::read, creation::only_if_not_exist, _caching, flags)); + OUTCOME_TRY(auto &&anonpipe, pipe({}, mode::read, creation::only_if_not_exist, _caching, flags)); std::pair<pipe_handle, pipe_handle> ret(std::move(anonpipe), pipe_handle(native_handle_type(), 0, 0, _caching, flags, nullptr)); native_handle_type &readnativeh = ret.first._v, &writenativeh = ret.second._v; DWORD fileshare = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; - OUTCOME_TRY(access, access_mask_from_handle_mode(writenativeh, mode::append, flags)); + OUTCOME_TRY(auto &&access, access_mask_from_handle_mode(writenativeh, mode::append, flags)); access = SYNCHRONIZE | DELETE | GENERIC_WRITE; // correct for pipes - OUTCOME_TRY(attribs, attributes_from_handle_caching_and_flags(writenativeh, _caching, flags)); + OUTCOME_TRY(auto &&attribs, attributes_from_handle_caching_and_flags(writenativeh, _caching, flags)); writenativeh.behaviour |= native_handle_type::disposition::pipe; writenativeh.behaviour &= ~native_handle_type::disposition::seekable; // not seekable LLFIO_LOG_FUNCTION_CALL(&ret.first); // Now clone the handle, but as a write privileged handle attribs &= 0x00ffffff; // the real attributes only, not the win32 flags - OUTCOME_TRY(ntflags, ntflags_from_handle_caching_and_flags(writenativeh, _caching, flags)); + OUTCOME_TRY(auto &&ntflags, ntflags_from_handle_caching_and_flags(writenativeh, _caching, flags)); ntflags &= ~0x00000008 /*FILE_NO_INTERMEDIATE_BUFFERING*/; // pipes always buffer IO_STATUS_BLOCK isb = make_iostatus(); diff --git a/include/llfio/v2.0/detail/impl/windows/process_handle.ipp b/include/llfio/v2.0/detail/impl/windows/process_handle.ipp index f1222dec..875faa7c 100644 --- a/include/llfio/v2.0/detail/impl/windows/process_handle.ipp +++ b/include/llfio/v2.0/detail/impl/windows/process_handle.ipp @@ -75,7 +75,7 @@ LLFIO_HEADERS_ONLY_MEMFUNC_SPEC result<void> process_handle::close() noexcept LLFIO_HEADERS_ONLY_MEMFUNC_SPEC result<process_handle> process_handle::clone() const noexcept { - OUTCOME_TRY(duph, handle::clone()); + OUTCOME_TRY(auto &&duph, handle::clone()); return process_handle(std::move(duph)); } @@ -172,20 +172,20 @@ LLFIO_HEADERS_ONLY_MEMFUNC_SPEC result<process_handle> process_handle::launch_pr if(!(flags & flag::no_redirect_in_pipe)) { - OUTCOME_TRY(handles, pipe_handle::anonymous_pipe(pipe_handle::caching::all, pipeflags)); + OUTCOME_TRY(auto &&handles, pipe_handle::anonymous_pipe(pipe_handle::caching::all, pipeflags)); ret.value()._in_pipe = std::move(handles.first); childoutpipe = std::move(handles.second); } if(!(flags & flag::no_redirect_out_pipe)) { - OUTCOME_TRY(handles, pipe_handle::anonymous_pipe(pipe_handle::caching::all, pipeflags)); + OUTCOME_TRY(auto &&handles, pipe_handle::anonymous_pipe(pipe_handle::caching::all, pipeflags)); ret.value()._out_pipe = std::move(handles.second); childinpipe = std::move(handles.first); } if(!(flags & flag::no_redirect_error_pipe)) { // stderr must not buffer writes - OUTCOME_TRY(handles, pipe_handle::anonymous_pipe(pipe_handle::caching::reads, pipeflags)); + OUTCOME_TRY(auto &&handles, pipe_handle::anonymous_pipe(pipe_handle::caching::reads, pipeflags)); ret.value()._error_pipe = std::move(handles.first); childerrorpipe = std::move(handles.second); } diff --git a/include/llfio/v2.0/detail/impl/windows/storage_profile.ipp b/include/llfio/v2.0/detail/impl/windows/storage_profile.ipp index b15effbc..044b7d18 100644 --- a/include/llfio/v2.0/detail/impl/windows/storage_profile.ipp +++ b/include/llfio/v2.0/detail/impl/windows/storage_profile.ipp @@ -230,7 +230,7 @@ namespace storage_profile } alignas(8) wchar_t buffer[32769]; // Firstly open a handle to the volume - OUTCOME_TRY(volumeh, file_handle::file({}, _mntfromname, handle::mode::none, handle::creation::open_existing, handle::caching::only_metadata)); + OUTCOME_TRY(auto &&volumeh, file_handle::file({}, _mntfromname, handle::mode::none, handle::creation::open_existing, handle::caching::only_metadata)); STORAGE_PROPERTY_QUERY spq{}; memset(&spq, 0, sizeof(spq)); spq.PropertyId = StorageAdapterProperty; @@ -355,7 +355,7 @@ namespace storage_profile } *e++ = '0' + (vde->Extents[0].DiskNumber % 10); *e = 0; - OUTCOME_TRY(diskh, file_handle::file({}, path_view(physicaldrivename, e - physicaldrivename, true), handle::mode::none, handle::creation::open_existing, handle::caching::only_metadata)); + OUTCOME_TRY(auto &&diskh, file_handle::file({}, path_view(physicaldrivename, e - physicaldrivename, true), handle::mode::none, handle::creation::open_existing, handle::caching::only_metadata)); memset(&spq, 0, sizeof(spq)); spq.PropertyId = StorageDeviceProperty; spq.QueryType = PropertyStandardQuery; diff --git a/include/llfio/v2.0/detail/impl/windows/symlink_handle.ipp b/include/llfio/v2.0/detail/impl/windows/symlink_handle.ipp index dd926449..d36eda1b 100644 --- a/include/llfio/v2.0/detail/impl/windows/symlink_handle.ipp +++ b/include/llfio/v2.0/detail/impl/windows/symlink_handle.ipp @@ -77,8 +77,8 @@ LLFIO_HEADERS_ONLY_MEMFUNC_SPEC result<symlink_handle> symlink_handle::symlink(c return errc::function_not_supported; } } - OUTCOME_TRY(access, access_mask_from_handle_mode(nativeh, _mode, flags)); - OUTCOME_TRY(attribs, attributes_from_handle_caching_and_flags(nativeh, caching::all, flags)); + OUTCOME_TRY(auto &&access, access_mask_from_handle_mode(nativeh, _mode, flags)); + OUTCOME_TRY(auto &&attribs, attributes_from_handle_caching_and_flags(nativeh, caching::all, flags)); nativeh.behaviour &= ~native_handle_type::disposition::seekable; // not seekable if(base.is_valid() || path.is_ntpath()) { @@ -102,7 +102,7 @@ LLFIO_HEADERS_ONLY_MEMFUNC_SPEC result<symlink_handle> symlink_handle::symlink(c } attribs &= 0x00ffffff; // the real attributes only, not the win32 flags - OUTCOME_TRY(ntflags, ntflags_from_handle_caching_and_flags(nativeh, caching::all, flags)); + OUTCOME_TRY(auto &&ntflags, ntflags_from_handle_caching_and_flags(nativeh, caching::all, flags)); ntflags |= 0x4000 /*FILE_OPEN_FOR_BACKUP_INTENT*/ | 0x00200000 /*FILE_OPEN_REPARSE_POINT*/; ntflags |= 0x040 /*FILE_NON_DIRECTORY_FILE*/; // do not open a directory IO_STATUS_BLOCK isb = make_iostatus(); diff --git a/include/llfio/v2.0/io_handle.hpp b/include/llfio/v2.0/io_handle.hpp index 9af56de6..edddd2f8 100644 --- a/include/llfio/v2.0/io_handle.hpp +++ b/include/llfio/v2.0/io_handle.hpp @@ -488,7 +488,7 @@ inline result<void> io_handle::set_multiplexer(io_multiplexer *c) noexcept } if(c != nullptr) { - OUTCOME_TRY(state, c->do_io_handle_register(this)); + OUTCOME_TRY(auto &&state, c->do_io_handle_register(this)); _v.behaviour = (_v.behaviour & ~(native_handle_type::disposition::_multiplexer_state_bit0 | native_handle_type::disposition::_multiplexer_state_bit1)); if((state & 1) != 0) { diff --git a/include/llfio/v2.0/map_handle.hpp b/include/llfio/v2.0/map_handle.hpp index e7df07f4..b6836a36 100644 --- a/include/llfio/v2.0/map_handle.hpp +++ b/include/llfio/v2.0/map_handle.hpp @@ -615,7 +615,7 @@ public: { return _reservation; } - OUTCOME_TRY(length, _section->length()); // length of the backing file + OUTCOME_TRY(auto &&length, _section->length()); // length of the backing file length -= _offset; if(length > _reservation) { @@ -715,7 +715,7 @@ public: //! \overload static result<buffer_type> prefetch(buffer_type region) noexcept { - OUTCOME_TRY(ret, prefetch(span<buffer_type>(®ion, 1))); + OUTCOME_TRY(auto &&ret, prefetch(span<buffer_type>(®ion, 1))); return *ret.data(); } diff --git a/include/llfio/v2.0/mapped_file_handle.hpp b/include/llfio/v2.0/mapped_file_handle.hpp index ece9cd3b..363940d9 100644 --- a/include/llfio/v2.0/mapped_file_handle.hpp +++ b/include/llfio/v2.0/mapped_file_handle.hpp @@ -170,7 +170,7 @@ protected: deadline nd; LLFIO_DEADLINE_TO_PARTIAL_DEADLINE(nd, d); thisreq.buffers = reqs.buffers.subspan(n, std::min(batch, reqs.buffers.size() - n)); - OUTCOME_TRY(written, file_handle::_do_write(thisreq, nd)); + OUTCOME_TRY(auto &&written, file_handle::_do_write(thisreq, nd)); if(written.empty()) { reqs.buffers = reqs.buffers.subspan(0, n); @@ -265,7 +265,7 @@ public: { return errc::invalid_argument; } - OUTCOME_TRY(fh, file_handle::file(base, _path, _mode, _creation, _caching, flags)); + OUTCOME_TRY(auto &&fh, file_handle::file(base, _path, _mode, _creation, _caching, flags)); switch(_creation) { default: @@ -356,7 +356,7 @@ public: LLFIO_MAKE_FREE_FUNCTION static LLFIO_HEADERS_ONLY_MEMFUNC_SPEC result<mapped_file_handle> mapped_temp_inode(size_type reservation = 0, const path_handle &dir = path_discovery::storage_backed_temporary_files_directory(), mode _mode = mode::write, flag flags = flag::none, section_handle::flag sflags = section_handle::flag::none) noexcept { - OUTCOME_TRY(v, file_handle::temp_inode(dir, _mode, flags)); + OUTCOME_TRY(auto &&v, file_handle::temp_inode(dir, _mode, flags)); mapped_file_handle ret(std::move(v), sflags); ret._reservation = reservation; return {std::move(ret)}; @@ -407,7 +407,7 @@ public: LLFIO_HEADERS_ONLY_VIRTUAL_SPEC native_handle_type release() noexcept override; result<mapped_file_handle> reopen(size_type reservation, mode mode_ = mode::unchanged, caching caching_ = caching::unchanged, deadline d = std::chrono::seconds(30)) const noexcept { - OUTCOME_TRY(fh, file_handle::reopen(mode_, caching_, d)); + OUTCOME_TRY(auto &&fh, file_handle::reopen(mode_, caching_, d)); return mapped_file_handle(std::move(fh), reservation, _sh.section_flags()); } LLFIO_DEADLINE_TRY_FOR_UNTIL(reopen) diff --git a/include/llfio/v2.0/path_handle.hpp b/include/llfio/v2.0/path_handle.hpp index 8e2ee7e2..816caec3 100644 --- a/include/llfio/v2.0/path_handle.hpp +++ b/include/llfio/v2.0/path_handle.hpp @@ -99,7 +99,7 @@ public: //! A `path_handle` returning edition of `handle::clone()` result<path_handle> clone_to_path_handle() const noexcept { - OUTCOME_TRY(newh, handle::clone()); + OUTCOME_TRY(auto &&newh, handle::clone()); return path_handle(std::move(newh)); } |