diff options
author | Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com> | 2018-01-24 12:59:55 +0300 |
---|---|---|
committer | Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com> | 2018-01-24 12:59:55 +0300 |
commit | 1f39a831d72e81973d89edf4dde58852f5e7f341 (patch) | |
tree | 620b5e81371c1d7ef913e7b2f10656e24945c9b8 | |
parent | 17a4e933c56d044e12e7851f79e7fb99b1a9adec (diff) |
Ever more delint
-rw-r--r-- | .clang-tidy | 2 | ||||
-rw-r--r-- | include/afio/v2.0/algorithm/cached_parent_handle_adapter.hpp | 6 | ||||
-rw-r--r-- | include/afio/v2.0/algorithm/shared_fs_mutex/memory_map.hpp | 8 | ||||
-rw-r--r-- | include/afio/v2.0/algorithm/trivial_vector.hpp | 6 | ||||
-rw-r--r-- | include/afio/v2.0/async_file_handle.hpp | 28 | ||||
-rw-r--r-- | include/afio/v2.0/config.hpp | 1 | ||||
-rw-r--r-- | include/afio/v2.0/deadline.h | 8 | ||||
-rw-r--r-- | include/afio/v2.0/detail/impl/safe_byte_ranges.ipp | 8 | ||||
-rw-r--r-- | include/afio/v2.0/directory_handle.hpp | 12 | ||||
-rw-r--r-- | include/afio/v2.0/fs_handle.hpp | 10 | ||||
-rw-r--r-- | include/afio/v2.0/io_handle.hpp | 8 | ||||
-rw-r--r-- | include/afio/v2.0/map_handle.hpp | 28 | ||||
-rw-r--r-- | include/afio/v2.0/mapped_file_handle.hpp | 4 | ||||
-rw-r--r-- | include/afio/v2.0/path_discovery.hpp | 3 | ||||
-rw-r--r-- | include/afio/v2.0/path_handle.hpp | 4 | ||||
-rw-r--r-- | include/afio/v2.0/utils.hpp | 8 |
16 files changed, 98 insertions, 46 deletions
diff --git a/.clang-tidy b/.clang-tidy index 2d91ae67..d0d5c40f 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,5 +1,5 @@ --- -Checks: '*,-llvm-header-guard,-google-build-using-namespace,-google-runtime-int,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-modernize-unary-static-assert,-fuchsia-*,-llvm-namespace-comment,-hicpp-no-array-decay,-cppcoreguidelines-pro-type-union-access,-hicpp-use-override,-modernize-use-override,-google-default-arguments,-google-runtime-references,-cppcoreguidelines-pro-type-reinterpret-cast,-hicpp-vararg,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-pro-bounds-constant-array-index' +Checks: '*,-llvm-header-guard,-google-build-using-namespace,-google-runtime-int,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-modernize-unary-static-assert,-fuchsia-*,-llvm-namespace-comment,-hicpp-no-array-decay,-cppcoreguidelines-pro-type-union-access,-hicpp-use-override,-modernize-use-override,-google-default-arguments,-google-runtime-references,-cppcoreguidelines-pro-type-reinterpret-cast,-hicpp-vararg,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-pro-type-const-cast' WarningsAsErrors: '' HeaderFilterRegex: '.*' AnalyzeTemporaryDtors: true diff --git a/include/afio/v2.0/algorithm/cached_parent_handle_adapter.hpp b/include/afio/v2.0/algorithm/cached_parent_handle_adapter.hpp index 9293615e..652cbe8f 100644 --- a/include/afio/v2.0/algorithm/cached_parent_handle_adapter.hpp +++ b/include/afio/v2.0/algorithm/cached_parent_handle_adapter.hpp @@ -74,7 +74,7 @@ namespace algorithm */ template <class T> AFIO_REQUIRES(sizeof(construct<T>) > 0) class AFIO_DECL cached_parent_handle_adapter : public T { - static_assert(sizeof(construct<T>) > 0, "Type T must be registered with the construct<T> framework so cached_parent_handle_adapter<T> knows how to construct it"); + static_assert(sizeof(construct<T>) > 0, "Type T must be registered with the construct<T> framework so cached_parent_handle_adapter<T> knows how to construct it"); // NOLINT public: //! The handle type being adapted @@ -89,9 +89,9 @@ namespace algorithm public: cached_parent_handle_adapter() = default; cached_parent_handle_adapter(const cached_parent_handle_adapter &) = default; - cached_parent_handle_adapter(cached_parent_handle_adapter &&) = default; + cached_parent_handle_adapter(cached_parent_handle_adapter &&) = default; // NOLINT cached_parent_handle_adapter &operator=(const cached_parent_handle_adapter &) = default; - cached_parent_handle_adapter &operator=(cached_parent_handle_adapter &&) = default; + cached_parent_handle_adapter &operator=(cached_parent_handle_adapter &&) = default; // NOLINT cached_parent_handle_adapter(adapted_handle_type &&o, const path_handle &base, path_view path) : adapted_handle_type(std::move(o)) { diff --git a/include/afio/v2.0/algorithm/shared_fs_mutex/memory_map.hpp b/include/afio/v2.0/algorithm/shared_fs_mutex/memory_map.hpp index 143d1e23..48c3b1c6 100644 --- a/include/afio/v2.0/algorithm/shared_fs_mutex/memory_map.hpp +++ b/include/afio/v2.0/algorithm/shared_fs_mutex/memory_map.hpp @@ -110,7 +110,7 @@ namespace algorithm _hash_index_type &_index() const { - auto *ret = (_hash_index_type *) _temphmap.address(); + auto *ret = reinterpret_cast<_hash_index_type *>(_temphmap.address()); return *ret; } @@ -211,7 +211,7 @@ namespace algorithm char buffer[65536]; memset(buffer, 0, sizeof(buffer)); OUTCOME_TRYV(ret.read(0, buffer, 65535)); - path_view temphpath((filesystem::path::value_type *) buffer); + path_view temphpath(reinterpret_cast<filesystem::path::value_type *>(buffer)); result<file_handle> _temph(in_place_type<file_handle>); _temph = file_handle::file({}, temphpath, file_handle::mode::write, file_handle::creation::open_existing, file_handle::caching::temporary); // If temp file doesn't exist, I am on a different machine @@ -317,7 +317,7 @@ namespace algorithm } } // alloca() always returns 16 byte aligned addresses - span<_entity_idx> entity_to_idx(_hash_entities((_entity_idx *) alloca(sizeof(_entity_idx) * out.entities.size()), out.entities)); + span<_entity_idx> entity_to_idx(_hash_entities(reinterpret_cast<_entity_idx *>(alloca(sizeof(_entity_idx) * out.entities.size())), out.entities)); _hash_index_type &index = _index(); // Fire this if an error occurs auto disableunlock = undoer([&] { out.release(); }); @@ -387,7 +387,7 @@ namespace algorithm AFIO_HEADERS_ONLY_VIRTUAL_SPEC void unlock(entities_type entities, unsigned long long /*unused*/) noexcept final { AFIO_LOG_FUNCTION_CALL(this); - span<_entity_idx> entity_to_idx(_hash_entities((_entity_idx *) alloca(sizeof(_entity_idx) * entities.size()), entities)); + span<_entity_idx> entity_to_idx(_hash_entities(reinterpret_cast<_entity_idx *>(alloca(sizeof(_entity_idx) * entities.size())), entities)); _hash_index_type &index = _index(); for(const auto &i : entity_to_idx) { diff --git a/include/afio/v2.0/algorithm/trivial_vector.hpp b/include/afio/v2.0/algorithm/trivial_vector.hpp index 334781c2..253921d3 100644 --- a/include/afio/v2.0/algorithm/trivial_vector.hpp +++ b/include/afio/v2.0/algorithm/trivial_vector.hpp @@ -244,7 +244,7 @@ namespace algorithm { if(i >= size()) { - throw std::out_of_range("bounds exceeded"); + throw std::out_of_range("bounds exceeded"); // NOLINT } return _begin[i]; } @@ -253,7 +253,7 @@ namespace algorithm { if(i >= size()) { - throw std::out_of_range("bounds exceeded"); + throw std::out_of_range("bounds exceeded"); // NOLINT } return _begin[i]; } @@ -310,7 +310,7 @@ namespace algorithm { if(n > max_size()) { - throw std::length_error("Max size exceeded"); + throw std::length_error("Max size exceeded"); // NOLINT } size_type current_size = size(); size_type bytes = n * sizeof(value_type); diff --git a/include/afio/v2.0/async_file_handle.hpp b/include/afio/v2.0/async_file_handle.hpp index 97070d65..11639606 100644 --- a/include/afio/v2.0/async_file_handle.hpp +++ b/include/afio/v2.0/async_file_handle.hpp @@ -88,6 +88,7 @@ protected: public: //! Default constructor async_file_handle() = default; + ~async_file_handle() = default; //! Construct a handle from a supplied native handle constexpr async_file_handle(io_service *service, native_handle_type h, dev_t devid, ino_t inode, caching caching = caching::none, flag flags = flag::none) @@ -97,6 +98,8 @@ public: } //! Implicit move construction of async_file_handle permitted async_file_handle(async_file_handle &&o) noexcept = default; + //! No copy construction (use `clone()`) + async_file_handle(const async_file_handle &) = delete; //! Explicit conversion from file_handle permitted explicit constexpr async_file_handle(file_handle &&o) noexcept : file_handle(std::move(o)) {} //! Explicit conversion from handle and io_handle permitted @@ -108,6 +111,8 @@ public: new(this) async_file_handle(std::move(o)); return *this; } + //! No copy assignment + async_file_handle &operator=(const async_file_handle &) = delete; //! Swap with another instance AFIO_MAKE_FREE_FUNCTION void swap(async_file_handle &o) noexcept @@ -295,6 +300,12 @@ protected: - internal_state: address of pointer to struct aiocb in io_service's _aiocbsv */ virtual void _system_io_completion(long errcode, long bytes_transferred, void *internal_state) noexcept = 0; + + protected: + _erased_io_state_type(_erased_io_state_type &&) = default; + _erased_io_state_type(const _erased_io_state_type &) = default; + _erased_io_state_type &operator=(_erased_io_state_type &&) = default; + _erased_io_state_type &operator=(const _erased_io_state_type &) = default; }; struct _io_state_deleter { @@ -304,8 +315,8 @@ protected: _ptr->~U(); if(must_deallocate_self) { - auto *ptr = (char *) _ptr; - ::free(ptr); + auto *ptr = reinterpret_cast<char *>(_ptr); + ::free(ptr); // NOLINT } } }; @@ -333,6 +344,13 @@ protected: virtual void operator()(_erased_io_state_type *state) = 0; // Returns a pointer to the completion handler virtual void *address() noexcept = 0; + + protected: + _erased_completion_handler() = default; + _erased_completion_handler(_erased_completion_handler &&) = default; + _erased_completion_handler(const _erased_completion_handler &) = default; + _erased_completion_handler &operator=(_erased_completion_handler &&) = default; + _erased_completion_handler &operator=(const _erased_completion_handler &) = default; }; template <class BuffersType, class IORoutine> result<io_state_ptr> AFIO_HEADERS_ONLY_MEMFUNC_SPEC _begin_io(span<char> mem, operation_t operation, io_request<BuffersType> reqs, _erased_completion_handler &&completion, IORoutine &&ioroutine) noexcept; AFIO_HEADERS_ONLY_MEMFUNC_SPEC result<io_state_ptr> _begin_io(span<char> mem, operation_t operation, io_request<const_buffers_type> reqs, _erased_completion_handler &&completion) noexcept; @@ -373,7 +391,7 @@ public: size_t bytes() const noexcept final { return sizeof(*this); } void move(_erased_completion_handler *_dest) final { - auto *dest = (void *) _dest; + auto *dest = reinterpret_cast<void *>(_dest); new(dest) completion_handler(std::move(*this)); } void operator()(_erased_io_state_type *state) final { completion(state->parent, state->result.write); } @@ -422,7 +440,7 @@ public: size_t bytes() const noexcept final { return sizeof(*this); } void move(_erased_completion_handler *_dest) final { - auto *dest = (void *) _dest; + auto *dest = reinterpret_cast<void *>(_dest); new(dest) completion_handler(std::move(*this)); } void operator()(_erased_io_state_type *state) final { completion(state->parent, state->result.read); } @@ -458,7 +476,7 @@ public: size_t bytes() const noexcept final { return sizeof(*this); } void move(_erased_completion_handler *_dest) final { - auto *dest = (void *) _dest; + auto *dest = reinterpret_cast<void *>(_dest); new(dest) completion_handler(std::move(*this)); } void operator()(_erased_io_state_type *state) final { completion(state->parent, state->result.write); } diff --git a/include/afio/v2.0/config.hpp b/include/afio/v2.0/config.hpp index 15adbe91..eef1c944 100644 --- a/include/afio/v2.0/config.hpp +++ b/include/afio/v2.0/config.hpp @@ -567,6 +567,7 @@ namespace detail tls_current_handle_holder(tls_current_handle_holder &&) = delete; tls_current_handle_holder &operator=(const tls_current_handle_holder &) = delete; tls_current_handle_holder &operator=(tls_current_handle_holder &&) = delete; + ~tls_current_handle_holder() = default; template <class T> explicit tls_current_handle_holder(T && /*unused*/) {} }; #define AFIO_LOG_INST_TO_TLS(inst) AFIO_V2_NAMESPACE::detail::tls_current_handle_holder<std::is_base_of<AFIO_V2_NAMESPACE::handle, std::decay_t<std::remove_pointer_t<decltype(inst)>>>::value> AFIO_UNIQUE_NAME(inst) diff --git a/include/afio/v2.0/deadline.h b/include/afio/v2.0/deadline.h index fb621a24..e4629843 100644 --- a/include/afio/v2.0/deadline.h +++ b/include/afio/v2.0/deadline.h @@ -56,9 +56,9 @@ struct AFIO_DEADLINE_NAME unsigned long long nsecs; // NOLINT }; #ifdef __cplusplus - constexpr deadline() - : steady(false) - , utc{0, 0} + constexpr deadline() // NOLINT + : steady(false), + utc{0, 0} { } //! True if deadline is valid @@ -95,7 +95,7 @@ struct AFIO_DEADLINE_NAME { if(steady) { - throw std::invalid_argument("Not a UTC deadline!"); + throw std::invalid_argument("Not a UTC deadline!"); // NOLINT } std::chrono::system_clock::time_point tp(std::chrono::system_clock::from_time_t(utc.tv_sec)); tp += std::chrono::duration_cast<std::chrono::system_clock::duration>(std::chrono::nanoseconds(utc.tv_nsec)); diff --git a/include/afio/v2.0/detail/impl/safe_byte_ranges.ipp b/include/afio/v2.0/detail/impl/safe_byte_ranges.ipp index f839ce75..592ba1c3 100644 --- a/include/afio/v2.0/detail/impl/safe_byte_ranges.ipp +++ b/include/afio/v2.0/detail/impl/safe_byte_ranges.ipp @@ -69,9 +69,9 @@ namespace algorithm std::condition_variable _changed; struct _entity_info { - std::vector<unsigned> reader_tids; // thread ids of all shared lock holders - unsigned writer_tid; // thread id of exclusive lock holder - io_handle::extent_guard filelock; // exclusive if writer_tid, else shared + std::vector<unsigned> reader_tids{}; // thread ids of all shared lock holders + unsigned writer_tid; // thread id of exclusive lock holder + io_handle::extent_guard filelock; // exclusive if writer_tid, else shared _entity_info(bool exclusive, unsigned tid, io_handle::extent_guard _filelock) : writer_tid(exclusive ? tid : 0) , filelock(std::move(_filelock)) @@ -83,7 +83,7 @@ namespace algorithm } } }; - std::unordered_map<entity_type::value_type, _entity_info> _thread_locks; // entity to thread lock + std::unordered_map<entity_type::value_type, _entity_info> _thread_locks{}; // entity to thread lock // _m mutex must be held on entry! void _unlock(unsigned mythreadid, entity_type entity) { diff --git a/include/afio/v2.0/directory_handle.hpp b/include/afio/v2.0/directory_handle.hpp index 74aebd8f..9558d962 100644 --- a/include/afio/v2.0/directory_handle.hpp +++ b/include/afio/v2.0/directory_handle.hpp @@ -88,21 +88,29 @@ public: struct buffers_type : public span<buffer_type> { using span<buffer_type>::span; + //! Implicit construction from a span buffers_type(span<buffer_type> v) // NOLINT : span<buffer_type>(v) { } + ~buffers_type() = default; + //! Move constructor buffers_type(buffers_type &&o) noexcept : span<buffer_type>(std::move(o)), _kernel_buffer(std::move(o._kernel_buffer)), _kernel_buffer_size(o._kernel_buffer_size) { static_cast<span<buffer_type> &>(o) = {}; o._kernel_buffer_size = 0; } + //! No copy construction + buffers_type(const buffers_type &) = delete; + //! Move assignment buffers_type &operator=(buffers_type &&o) noexcept { this->~buffers_type(); new(this) buffers_type(std::move(o)); return *this; } + //! No copy assignment + buffers_type &operator=(const buffers_type &) = delete; private: friend class directory_handle; @@ -129,6 +137,8 @@ public: } //! Implicit move construction of directory_handle permitted constexpr directory_handle(directory_handle &&o) noexcept : path_handle(std::move(o)), fs_handle(std::move(o)) {} + //! No copy construction (use `clone()`) + directory_handle(const directory_handle &) = delete; //! Explicit conversion from handle permitted explicit constexpr directory_handle(handle &&o, dev_t devid, ino_t inode) noexcept : path_handle(std::move(o)), fs_handle(devid, inode) {} //! Move assignment of directory_handle permitted @@ -138,6 +148,8 @@ public: new(this) directory_handle(std::move(o)); return *this; } + //! No copy assignment + directory_handle &operator=(const directory_handle &) = delete; //! Swap with another instance AFIO_MAKE_FREE_FUNCTION void swap(directory_handle &o) noexcept diff --git a/include/afio/v2.0/fs_handle.hpp b/include/afio/v2.0/fs_handle.hpp index 55a44db1..ec75b549 100644 --- a/include/afio/v2.0/fs_handle.hpp +++ b/include/afio/v2.0/fs_handle.hpp @@ -66,16 +66,13 @@ protected: protected: //! Default constructor fs_handle() = default; + ~fs_handle() = default; //! Construct a handle constexpr fs_handle(dev_t devid, ino_t inode) : _devid(devid) , _inode(inode) { } - //! No copy construction (use clone()) - fs_handle(const fs_handle &) = delete; - //! No copy assignment - fs_handle &operator=(const fs_handle &o) = delete; //! Implicit move construction of fs_handle permitted constexpr fs_handle(fs_handle &&o) noexcept : _devid(o._devid), _inode(o._inode) { @@ -93,6 +90,11 @@ protected: } public: + //! No copy construction (use `clone()`) + fs_handle(const fs_handle &) = delete; + //! No copy assignment + fs_handle &operator=(const fs_handle &o) = delete; + //! Unless `flag::disable_safety_unlinks` is set, the device id of the file when opened dev_t st_dev() const noexcept { return _devid; } //! Unless `flag::disable_safety_unlinks` is set, the inode of the file when opened. When combined with st_dev(), forms a unique identifer on this system diff --git a/include/afio/v2.0/io_handle.hpp b/include/afio/v2.0/io_handle.hpp index 63559669..40effad7 100644 --- a/include/afio/v2.0/io_handle.hpp +++ b/include/afio/v2.0/io_handle.hpp @@ -130,10 +130,11 @@ public: using Base::Base; io_result() = default; #endif + ~io_result() = default; io_result(const io_result &) = default; - io_result(io_result &&) = default; + io_result(io_result &&) = default; // NOLINT io_result &operator=(const io_result &) = default; - io_result &operator=(io_result &&) = default; + io_result &operator=(io_result &&) = default; // NOLINT //! Returns bytes transferred size_type bytes_transferred() noexcept { @@ -304,10 +305,11 @@ public: , _exclusive(exclusive) { } + + public: extent_guard(const extent_guard &) = delete; extent_guard &operator=(const extent_guard &) = delete; - public: //! Default constructor extent_guard() = default; //! Move constructor diff --git a/include/afio/v2.0/map_handle.hpp b/include/afio/v2.0/map_handle.hpp index 5946d383..26880f1f 100644 --- a/include/afio/v2.0/map_handle.hpp +++ b/include/afio/v2.0/map_handle.hpp @@ -55,18 +55,18 @@ public: using size_type = handle::size_type; //! The behaviour of the memory section - QUICKCPPLIB_BITFIELD_BEGIN(flag){none = 0, //!< No flags - read = 1 << 0, //!< Memory views can be read - write = 1 << 1, //!< Memory views can be written - cow = 1 << 2, //!< Memory views can be copy on written - execute = 1 << 3, //!< Memory views can execute code + QUICKCPPLIB_BITFIELD_BEGIN(flag){none = 0U, //!< No flags + read = 1U << 0U, //!< Memory views can be read + write = 1U << 1U, //!< Memory views can be written + cow = 1U << 2U, //!< Memory views can be copy on written + execute = 1U << 3U, //!< Memory views can execute code - nocommit = 1 << 8, //!< Don't allocate space for this memory in the system immediately - prefault = 1 << 9, //!< Prefault, as if by reading every page, any views of memory upon creation. - executable = 1 << 10, //!< The backing storage is in fact an executable program binary. - singleton = 1 << 11, //!< A single instance of this section is to be shared by all processes using the same backing file. + nocommit = 1U << 8U, //!< Don't allocate space for this memory in the system immediately + prefault = 1U << 9U, //!< Prefault, as if by reading every page, any views of memory upon creation. + executable = 1U << 10U, //!< The backing storage is in fact an executable program binary. + singleton = 1U << 11U, //!< A single instance of this section is to be shared by all processes using the same backing file. - barrier_on_close = 1 << 16, //!< Maps of this section, if writable, issue a `barrier()` when destructed blocking until data (not metadata) reaches physical storage. + barrier_on_close = 1U << 16U, //!< Maps of this section, if writable, issue a `barrier()` when destructed blocking until data (not metadata) reaches physical storage. // NOTE: IF UPDATING THIS UPDATE THE std::ostream PRINTER BELOW!!! @@ -97,6 +97,8 @@ public: o._backing = nullptr; o._flag = flag::none; } + //! No copy construction (use `clone()`) + section_handle(const section_handle &) = delete; //! Move assignment of section_handle permitted section_handle &operator=(section_handle &&o) noexcept { @@ -104,6 +106,8 @@ public: new(this) section_handle(std::move(o)); return *this; } + //! No copy assignment + section_handle &operator=(const section_handle &) = delete; //! Swap with another instance AFIO_MAKE_FREE_FUNCTION void swap(section_handle &o) noexcept @@ -281,6 +285,8 @@ public: o._length = 0; o._flag = section_handle::flag::none; } + //! No copy construction (use `clone()`) + map_handle(const map_handle &) = delete; //! Move assignment of map_handle permitted map_handle &operator=(map_handle &&o) noexcept { @@ -288,6 +294,8 @@ public: new(this) map_handle(std::move(o)); return *this; } + //! No copy assignment + map_handle &operator=(const map_handle &) = delete; //! Swap with another instance AFIO_MAKE_FREE_FUNCTION void swap(map_handle &o) noexcept diff --git a/include/afio/v2.0/mapped_file_handle.hpp b/include/afio/v2.0/mapped_file_handle.hpp index 37fb0839..af3c658e 100644 --- a/include/afio/v2.0/mapped_file_handle.hpp +++ b/include/afio/v2.0/mapped_file_handle.hpp @@ -139,6 +139,8 @@ public: _sh.set_backing(this); _mh.set_section(&_sh); } + //! No copy construction (use `clone()`) + mapped_file_handle(const mapped_file_handle &) = delete; //! Explicit conversion from file_handle permitted explicit constexpr mapped_file_handle(file_handle &&o) noexcept : file_handle(std::move(o)) {} //! Explicit conversion from file_handle permitted, this overload also attempts to map the file @@ -158,6 +160,8 @@ public: new(this) mapped_file_handle(std::move(o)); return *this; } + //! No copy assignment + mapped_file_handle &operator=(const mapped_file_handle &) = delete; //! Swap with another instance AFIO_MAKE_FREE_FUNCTION void swap(mapped_file_handle &o) noexcept diff --git a/include/afio/v2.0/path_discovery.hpp b/include/afio/v2.0/path_discovery.hpp index af3a4e97..ad6ee9fb 100644 --- a/include/afio/v2.0/path_discovery.hpp +++ b/include/afio/v2.0/path_discovery.hpp @@ -42,11 +42,12 @@ namespace path_discovery //! Source of the discovered path. enum class source_type { + unknown, //!< This path comes from an unknown source. local, //!< This path was added locally. environment, //!< This path came from an environment variable (an override?). system, //!< This path came from querying the system. hardcoded //!< This path came from an internal hardcoded list of paths likely for this system. - } source; + } source{source_type::unknown}; /*! If this path was successfully probed for criteria verification, this was its stat after any symlink derefencing at that time. Secure applications ought to verify that any handles opened to the path have diff --git a/include/afio/v2.0/path_handle.hpp b/include/afio/v2.0/path_handle.hpp index c1b85e33..3a680949 100644 --- a/include/afio/v2.0/path_handle.hpp +++ b/include/afio/v2.0/path_handle.hpp @@ -69,8 +69,12 @@ public: explicit constexpr path_handle(handle &&o) noexcept : handle(std::move(o)) {} //! Move construction permitted path_handle(path_handle &&) = default; + //! No copy construction (use `clone()`) + path_handle(const path_handle &) = delete; //! Move assignment permitted path_handle &operator=(path_handle &&) = default; + //! No copy assignment + path_handle &operator=(const path_handle &) = delete; /*! Create a path handle opening access to some location on the filing system. Some operating systems provide a particularly lightweight method of doing this diff --git a/include/afio/v2.0/utils.hpp b/include/afio/v2.0/utils.hpp index 3d273f38..0bae626e 100644 --- a/include/afio/v2.0/utils.hpp +++ b/include/afio/v2.0/utils.hpp @@ -51,7 +51,7 @@ namespace utils template <class T> inline T round_down_to_page_size(T i) noexcept { const size_t pagesize = page_size(); - i = (T)((uintptr_t) i & ~(pagesize - 1)); + i = (T)(AFIO_V2_NAMESPACE::detail::unsigned_integer_cast<uintptr_t>(i) & ~(pagesize - 1)); // NOLINT return i; } /*! \brief Round a value to its next highest page size multiple @@ -59,7 +59,7 @@ namespace utils template <class T> inline T round_up_to_page_size(T i) noexcept { const size_t pagesize = page_size(); - i = (T)(((uintptr_t) i + pagesize - 1) & ~(pagesize - 1)); + i = (T)((AFIO_V2_NAMESPACE::detail::unsigned_integer_cast<uintptr_t>(i) + pagesize - 1) & ~(pagesize - 1)); // NOLINT return i; } /*! \brief Round a pair of a pointer and a size_t to their nearest page size multiples. The pointer will be rounded @@ -68,7 +68,7 @@ namespace utils template <class T> inline T round_to_page_size(T i) noexcept { const size_t pagesize = page_size(); - i.data = (char *) (((uintptr_t) i.data) & ~(pagesize - 1)); + i.data = reinterpret_cast<char *>((AFIO_V2_NAMESPACE::detail::unsigned_integer_cast<uintptr_t>(i.data)) & ~(pagesize - 1)); i.len = (i.len + pagesize - 1) & ~(pagesize - 1); return i; } @@ -228,7 +228,7 @@ namespace utils template <class U> explicit page_allocator(const page_allocator<U> & /*unused*/) noexcept {} - size_type max_size() const noexcept { return size_type(~0) / sizeof(T); } + size_type max_size() const noexcept { return size_type(~0U) / sizeof(T); } pointer address(reference x) const noexcept { return std::addressof(x); } |