diff options
-rw-r--r-- | .clang-tidy | 2 | ||||
-rw-r--r-- | include/afio/revision.hpp | 6 | ||||
-rw-r--r-- | include/afio/v2.0/algorithm/mapped_view.hpp | 2 | ||||
-rw-r--r-- | include/afio/v2.0/algorithm/shared_fs_mutex/atomic_append.hpp | 24 | ||||
-rw-r--r-- | include/afio/v2.0/algorithm/shared_fs_mutex/base.hpp | 6 | ||||
-rw-r--r-- | include/afio/v2.0/algorithm/shared_fs_mutex/byte_ranges.hpp | 7 | ||||
-rw-r--r-- | include/afio/v2.0/algorithm/shared_fs_mutex/lock_files.hpp | 7 | ||||
-rw-r--r-- | include/afio/v2.0/algorithm/shared_fs_mutex/memory_map.hpp | 6 | ||||
-rw-r--r-- | include/afio/v2.0/algorithm/shared_fs_mutex/safe_byte_ranges.hpp | 7 | ||||
-rw-r--r-- | include/afio/v2.0/config.hpp | 16 | ||||
-rw-r--r-- | include/afio/v2.0/detail/impl/safe_byte_ranges.ipp | 4 | ||||
-rw-r--r-- | include/afio/v2.0/file_handle.hpp | 8 | ||||
-rw-r--r-- | include/afio/v2.0/handle.hpp | 36 | ||||
-rw-r--r-- | include/afio/v2.0/native_handle_type.hpp | 32 |
14 files changed, 94 insertions, 69 deletions
diff --git a/.clang-tidy b/.clang-tidy index d406e68d..2d91ae67 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' +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' WarningsAsErrors: '' HeaderFilterRegex: '.*' AnalyzeTemporaryDtors: true diff --git a/include/afio/revision.hpp b/include/afio/revision.hpp index bbee8307..f0a52b2c 100644 --- a/include/afio/revision.hpp +++ b/include/afio/revision.hpp @@ -1,4 +1,4 @@ // Note the second line of this file must ALWAYS be the git SHA, third line ALWAYS the git SHA update time -#define AFIO_PREVIOUS_COMMIT_REF e30bd053dffc1a43a834300c2a441baedf34da1c -#define AFIO_PREVIOUS_COMMIT_DATE "2018-01-15 20:57:57 +00:00" -#define AFIO_PREVIOUS_COMMIT_UNIQUE e30bd053 +#define AFIO_PREVIOUS_COMMIT_REF 30709f68192c73276b5fc1cc4650fb7d51c15c9e +#define AFIO_PREVIOUS_COMMIT_DATE "2018-01-18 22:00:05 +00:00" +#define AFIO_PREVIOUS_COMMIT_UNIQUE 30709f68 diff --git a/include/afio/v2.0/algorithm/mapped_view.hpp b/include/afio/v2.0/algorithm/mapped_view.hpp index 9eb9c8cd..a417fe3e 100644 --- a/include/afio/v2.0/algorithm/mapped_view.hpp +++ b/include/afio/v2.0/algorithm/mapped_view.hpp @@ -76,7 +76,7 @@ namespace algorithm : _mapping(map_handle::map(length * sizeof(T), _flag).value()) { char *addr = _mapping.address(); - static_cast<span<T> &>(*this) = span<T>(reinterpret_cast<T *>(addr), length); + static_cast<span<T> &>(*this) = span<T>(reinterpret_cast<T *>(addr), length); // NOLINT } /*! Construct a mapped view of the given section handle. diff --git a/include/afio/v2.0/algorithm/shared_fs_mutex/atomic_append.hpp b/include/afio/v2.0/algorithm/shared_fs_mutex/atomic_append.hpp index 23e75a25..2e48080a 100644 --- a/include/afio/v2.0/algorithm/shared_fs_mutex/atomic_append.hpp +++ b/include/afio/v2.0/algorithm/shared_fs_mutex/atomic_append.hpp @@ -67,6 +67,11 @@ namespace algorithm uint64 us_count : 56; // Microseconds since the lock file created uint64 items : 8; // The number of entities below which are valid shared_fs_mutex::entity_type entities[12]; // Entities to exclusive or share lock + constexpr lock_request() + : us_count{} + , items{} + { + } }; static_assert(sizeof(lock_request) == 128, "lock_request structure is not 128 bytes long!"); #pragma pack(pop) @@ -123,12 +128,10 @@ namespace algorithm { // guard now points at a non-existing handle _guard.set_handle(&_h); - utils::random_fill(reinterpret_cast<char *>(&_unique_id), sizeof(_unique_id)); // crypto strong random + utils::random_fill(reinterpret_cast<char *>(&_unique_id), sizeof(_unique_id)); // NOLINT crypto strong random memset(&_header, 0, sizeof(_header)); (void) _read_header(); } - atomic_append(const atomic_append &) = delete; - atomic_append &operator=(const atomic_append &) = delete; result<void> _read_header() { @@ -163,6 +166,11 @@ namespace algorithm //! The type of a sequence of entities using entities_type = shared_fs_mutex::entities_type; + //! No copy construction + atomic_append(const atomic_append &) = delete; + //! No copy assignment + atomic_append &operator=(const atomic_append &) = delete; + ~atomic_append() = default; //! Move constructor atomic_append(atomic_append &&o) noexcept : _h(std::move(o._h)), _guard(std::move(o._guard)), _nfs_compatibility(o._nfs_compatibility), _skip_hashing(o._skip_hashing), _unique_id(o._unique_id), _header(o._header) { _guard.set_handle(&_h); } //! Move assign @@ -275,7 +283,7 @@ namespace algorithm { auto lastbyte = static_cast<file_handle::extent_type>(-1); // Lock up to the beginning of the shadow lock space - lastbyte &= ~(1ULL << 63); + lastbyte &= ~(1ULL << 63U); OUTCOME_TRY(append_guard_, _h.lock(my_lock_request_offset, lastbyte, true)); append_guard = std::move(append_guard_); } @@ -426,7 +434,7 @@ namespace algorithm } auto lock_offset = record_offset; // Set the top bit to use the shadow lock space on Windows - lock_offset |= (1ULL << 63); + lock_offset |= (1ULL << 63U); OUTCOME_TRYV(_h.lock(lock_offset, sizeof(record), false, nd)); } // Make sure we haven't timed out during this wait @@ -483,7 +491,7 @@ namespace algorithm } // Every 32 records or so, bump _header.first_known_good - if((my_lock_request_offset & 4095) == 0u) + if((my_lock_request_offset & 4095U) == 0U) { //_read_header(); @@ -521,9 +529,9 @@ namespace algorithm } } // Hole punch if >= 1Mb of zeros exists - if(_header.first_known_good - _header.first_after_hole_punch >= 1024 * 1024) + if(_header.first_known_good - _header.first_after_hole_punch >= 1024U * 1024U) { - handle::extent_type holepunchend = _header.first_known_good & ~(1024 * 1024 - 1); + handle::extent_type holepunchend = _header.first_known_good & ~(1024U * 1024U - 1); #ifdef _DEBUG fprintf(stderr, "hole_punch(%llx, %llx)\n", _header.first_after_hole_punch, holepunchend - _header.first_after_hole_punch); #endif diff --git a/include/afio/v2.0/algorithm/shared_fs_mutex/base.hpp b/include/afio/v2.0/algorithm/shared_fs_mutex/base.hpp index cd7c6ef9..640f9243 100644 --- a/include/afio/v2.0/algorithm/shared_fs_mutex/base.hpp +++ b/include/afio/v2.0/algorithm/shared_fs_mutex/base.hpp @@ -78,7 +78,7 @@ namespace algorithm #pragma warning(pop) #endif //! Default constructor - constexpr entity_type() noexcept : _init(0) {} + constexpr entity_type() noexcept : _init(0) {} // NOLINT //! Constructor #if !defined(__GNUC__) || defined(__clang__) || __GNUC__ >= 7 constexpr @@ -96,6 +96,10 @@ namespace algorithm protected: shared_fs_mutex() = default; + shared_fs_mutex(const shared_fs_mutex &) = default; + shared_fs_mutex(shared_fs_mutex &&) = default; + shared_fs_mutex &operator=(const shared_fs_mutex &) = default; + shared_fs_mutex &operator=(shared_fs_mutex &&) = default; public: AFIO_HEADERS_ONLY_VIRTUAL_SPEC ~shared_fs_mutex() = default; diff --git a/include/afio/v2.0/algorithm/shared_fs_mutex/byte_ranges.hpp b/include/afio/v2.0/algorithm/shared_fs_mutex/byte_ranges.hpp index 05065b3c..36c99935 100644 --- a/include/afio/v2.0/algorithm/shared_fs_mutex/byte_ranges.hpp +++ b/include/afio/v2.0/algorithm/shared_fs_mutex/byte_ranges.hpp @@ -78,8 +78,6 @@ namespace algorithm : _h(std::move(h)) { } - byte_ranges(const byte_ranges &) = delete; - byte_ranges &operator=(const byte_ranges &) = delete; public: //! The type of an entity id @@ -87,6 +85,11 @@ namespace algorithm //! The type of a sequence of entities using entities_type = shared_fs_mutex::entities_type; + //! No copy construction + byte_ranges(const byte_ranges &) = delete; + //! No copy assignment + byte_ranges &operator=(const byte_ranges &) = delete; + ~byte_ranges() = default; //! Move constructor byte_ranges(byte_ranges &&o) noexcept : _h(std::move(o._h)) {} //! Move assign diff --git a/include/afio/v2.0/algorithm/shared_fs_mutex/lock_files.hpp b/include/afio/v2.0/algorithm/shared_fs_mutex/lock_files.hpp index 9fd42cd8..f0698e55 100644 --- a/include/afio/v2.0/algorithm/shared_fs_mutex/lock_files.hpp +++ b/include/afio/v2.0/algorithm/shared_fs_mutex/lock_files.hpp @@ -79,8 +79,6 @@ namespace algorithm : _path(o) { } - lock_files(const lock_files &) = delete; - lock_files &operator=(const lock_files &) = delete; public: //! The type of an entity id @@ -88,6 +86,11 @@ namespace algorithm //! The type of a sequence of entities using entities_type = shared_fs_mutex::entities_type; + //! No copy construction + lock_files(const lock_files &) = delete; + //! No copy assignment + lock_files &operator=(const lock_files &) = delete; + ~lock_files() = default; //! Move constructor lock_files(lock_files &&o) noexcept : _path(o._path), _hs(std::move(o._hs)) {} //! Move assign 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 8c100fff..143d1e23 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 @@ -123,10 +123,12 @@ namespace algorithm { _hlockinuse.set_handle(&_h); } - memory_map(const memory_map &) = delete; - memory_map &operator=(const memory_map &) = delete; public: + //! No copy construction + memory_map(const memory_map &) = delete; + //! No copy assignment + memory_map &operator=(const memory_map &) = delete; //! Move constructor memory_map(memory_map &&o) noexcept : _h(std::move(o._h)), _temph(std::move(o._temph)), _hlockinuse(std::move(o._hlockinuse)), _hmap(std::move(o._hmap)), _temphmap(std::move(o._temphmap)) { _hlockinuse.set_handle(&_h); } //! Move assign diff --git a/include/afio/v2.0/algorithm/shared_fs_mutex/safe_byte_ranges.hpp b/include/afio/v2.0/algorithm/shared_fs_mutex/safe_byte_ranges.hpp index 7c679c3b..96fd3a4d 100644 --- a/include/afio/v2.0/algorithm/shared_fs_mutex/safe_byte_ranges.hpp +++ b/include/afio/v2.0/algorithm/shared_fs_mutex/safe_byte_ranges.hpp @@ -127,8 +127,6 @@ namespace algorithm : _p(std::move(p)) { } - safe_byte_ranges(const safe_byte_ranges &) = delete; - safe_byte_ranges &operator=(const safe_byte_ranges &) = delete; public: //! The type of an entity id @@ -136,6 +134,11 @@ namespace algorithm //! The type of a sequence of entities using entities_type = shared_fs_mutex::entities_type; + //! No copy construction + safe_byte_ranges(const safe_byte_ranges &) = delete; + //! No copy assignment + safe_byte_ranges &operator=(const safe_byte_ranges &) = delete; + ~safe_byte_ranges() = default; //! Move constructor safe_byte_ranges(safe_byte_ranges &&o) noexcept : _p(std::move(o._p)) {} //! Move assign diff --git a/include/afio/v2.0/config.hpp b/include/afio/v2.0/config.hpp index 9347fa67..1aaf1513 100644 --- a/include/afio/v2.0/config.hpp +++ b/include/afio/v2.0/config.hpp @@ -63,9 +63,9 @@ Distributed under the Boost Software License, Version 1.0. #if !defined(AFIO_LOG_BACKTRACE_LEVELS) //! \brief Bit mask of which log levels should be stack backtraced -//! which will slow those logs thirty fold or so. Defaults to (1<<1)|(1<<2)|(1<<3) i.e. stack backtrace +//! which will slow those logs thirty fold or so. Defaults to (1U<<1U)|(1U<<2U)|(1U<<3U) i.e. stack backtrace //! on fatal, error and warn logs. \ingroup config -#define AFIO_LOG_BACKTRACE_LEVELS ((1 << 1) | (1 << 2) | (1 << 3)) +#define AFIO_LOG_BACKTRACE_LEVELS ((1U << 1U) | (1U << 2U) | (1U << 3U)) #endif #if !defined(AFIO_LOGGING_MEMORY) @@ -615,24 +615,24 @@ AFIO_V2_NAMESPACE_END #if AFIO_LOGGING_LEVEL >= 1 #define AFIO_LOG_FATAL(inst, message) \ { \ - AFIO_V2_NAMESPACE::log().emplace_back(QUICKCPPLIB_NAMESPACE::ringbuffer_log::level::fatal, (message), (unsigned) (uintptr_t)(inst), QUICKCPPLIB_NAMESPACE::utils::thread::this_thread_id(), (AFIO_LOG_BACKTRACE_LEVELS & (1 << 1)) ? nullptr : __func__, __LINE__); \ + AFIO_V2_NAMESPACE::log().emplace_back(QUICKCPPLIB_NAMESPACE::ringbuffer_log::level::fatal, (message), (unsigned) (uintptr_t)(inst), QUICKCPPLIB_NAMESPACE::utils::thread::this_thread_id(), (AFIO_LOG_BACKTRACE_LEVELS & (1U << 1U)) ? nullptr : __func__, __LINE__); \ AFIO_LOG_FATAL_TO_CERR(message); \ } #else #define AFIO_LOG_FATAL(inst, message) AFIO_LOG_FATAL_TO_CERR(message) #endif #if AFIO_LOGGING_LEVEL >= 2 -#define AFIO_LOG_ERROR(inst, message) AFIO_V2_NAMESPACE::log().emplace_back(QUICKCPPLIB_NAMESPACE::ringbuffer_log::level::error, (message), (unsigned) (uintptr_t)(inst), QUICKCPPLIB_NAMESPACE::utils::thread::this_thread_id(), (AFIO_LOG_BACKTRACE_LEVELS & (1 << 2)) ? nullptr : __func__, __LINE__) +#define AFIO_LOG_ERROR(inst, message) AFIO_V2_NAMESPACE::log().emplace_back(QUICKCPPLIB_NAMESPACE::ringbuffer_log::level::error, (message), (unsigned) (uintptr_t)(inst), QUICKCPPLIB_NAMESPACE::utils::thread::this_thread_id(), (AFIO_LOG_BACKTRACE_LEVELS & (1U << 2U)) ? nullptr : __func__, __LINE__) #else #define AFIO_LOG_ERROR(inst, message) #endif #if AFIO_LOGGING_LEVEL >= 3 -#define AFIO_LOG_WARN(inst, message) AFIO_V2_NAMESPACE::log().emplace_back(QUICKCPPLIB_NAMESPACE::ringbuffer_log::level::warn, (message), (unsigned) (uintptr_t)(inst), QUICKCPPLIB_NAMESPACE::utils::thread::this_thread_id(), (AFIO_LOG_BACKTRACE_LEVELS & (1 << 3)) ? nullptr : __func__, __LINE__) +#define AFIO_LOG_WARN(inst, message) AFIO_V2_NAMESPACE::log().emplace_back(QUICKCPPLIB_NAMESPACE::ringbuffer_log::level::warn, (message), (unsigned) (uintptr_t)(inst), QUICKCPPLIB_NAMESPACE::utils::thread::this_thread_id(), (AFIO_LOG_BACKTRACE_LEVELS & (1U << 3U)) ? nullptr : __func__, __LINE__) #else #define AFIO_LOG_WARN(inst, message) #endif #if AFIO_LOGGING_LEVEL >= 4 -#define AFIO_LOG_INFO(inst, message) AFIO_V2_NAMESPACE::log().emplace_back(QUICKCPPLIB_NAMESPACE::ringbuffer_log::level::info, (message), (unsigned) (uintptr_t)(inst), QUICKCPPLIB_NAMESPACE::utils::thread::this_thread_id(), (AFIO_LOG_BACKTRACE_LEVELS & (1 << 4)) ? nullptr : __func__, __LINE__) +#define AFIO_LOG_INFO(inst, message) AFIO_V2_NAMESPACE::log().emplace_back(QUICKCPPLIB_NAMESPACE::ringbuffer_log::level::info, (message), (unsigned) (uintptr_t)(inst), QUICKCPPLIB_NAMESPACE::utils::thread::this_thread_id(), (AFIO_LOG_BACKTRACE_LEVELS & (1U << 4U)) ? nullptr : __func__, __LINE__) // Need to expand out our namespace into a string #define AFIO_LOG_STRINGIFY9(s) #s "::" @@ -725,12 +725,12 @@ AFIO_V2_NAMESPACE_END #define AFIO_LOG_FUNCTION_CALL(inst) AFIO_LOG_INST_TO_TLS(inst) #endif #if AFIO_LOGGING_LEVEL >= 5 -#define AFIO_LOG_DEBUG(inst, message) AFIO_V2_NAMESPACE::log().emplace_back(QUICKCPPLIB_NAMESPACE::ringbuffer_log::level::debug, (message), (unsigned) (uintptr_t)(inst), QUICKCPPLIB_NAMESPACE::utils::thread::this_thread_id(), (AFIO_LOG_BACKTRACE_LEVELS & (1 << 5)) ? nullptr : __func__, __LINE__) +#define AFIO_LOG_DEBUG(inst, message) AFIO_V2_NAMESPACE::log().emplace_back(QUICKCPPLIB_NAMESPACE::ringbuffer_log::level::debug, (message), (unsigned) (uintptr_t)(inst), QUICKCPPLIB_NAMESPACE::utils::thread::this_thread_id(), (AFIO_LOG_BACKTRACE_LEVELS & (1U << 5U)) ? nullptr : __func__, __LINE__) #else #define AFIO_LOG_DEBUG(inst, message) #endif #if AFIO_LOGGING_LEVEL >= 6 -#define AFIO_LOG_ALL(inst, message) AFIO_V2_NAMESPACE::log().emplace_back(QUICKCPPLIB_NAMESPACE::ringbuffer_log::level::all, (message), (unsigned) (uintptr_t)(inst), QUICKCPPLIB_NAMESPACE::utils::thread::this_thread_id(), (AFIO_LOG_BACKTRACE_LEVELS & (1 << 6)) ? nullptr : __func__, __LINE__) +#define AFIO_LOG_ALL(inst, message) AFIO_V2_NAMESPACE::log().emplace_back(QUICKCPPLIB_NAMESPACE::ringbuffer_log::level::all, (message), (unsigned) (uintptr_t)(inst), QUICKCPPLIB_NAMESPACE::utils::thread::this_thread_id(), (AFIO_LOG_BACKTRACE_LEVELS & (1U << 6U)) ? nullptr : __func__, __LINE__) #else #define AFIO_LOG_ALL(inst, message) #endif 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 eea77fca..f839ce75 100644 --- a/include/afio/v2.0/detail/impl/safe_byte_ranges.ipp +++ b/include/afio/v2.0/detail/impl/safe_byte_ranges.ipp @@ -87,7 +87,7 @@ namespace algorithm // _m mutex must be held on entry! void _unlock(unsigned mythreadid, entity_type entity) { - auto it = _thread_locks.find(entity.value); + auto it = _thread_locks.find(entity.value); // NOLINT assert(it != _thread_locks.end()); assert(it->second.writer_tid == mythreadid || it->second.writer_tid == 0); if(it->second.writer_tid == mythreadid) @@ -385,7 +385,7 @@ namespace algorithm }; if(-1 == ::fstatat(base.is_valid() ? base.native_handle().fd : AT_FDCWD, zpath.buffer, &s, AT_SYMLINK_NOFOLLOW)) { - return { errno, std::system_category() }; + return {errno, std::system_category()}; } threaded_byte_ranges_list::key_type key; key.as_longlongs[0] = s.st_ino; diff --git a/include/afio/v2.0/file_handle.hpp b/include/afio/v2.0/file_handle.hpp index 2fc13132..271fd33b 100644 --- a/include/afio/v2.0/file_handle.hpp +++ b/include/afio/v2.0/file_handle.hpp @@ -79,9 +79,7 @@ protected: public: //! Default constructor - constexpr file_handle() - { - } + file_handle() = default; //! Construct a handle from a supplied native handle constexpr file_handle(native_handle_type h, dev_t devid, ino_t inode, caching caching = caching::none, flag flags = flag::none) : io_handle(std::move(h), caching, flags) @@ -89,6 +87,10 @@ public: , _service(nullptr) { } + //! No copy construction (use clone()) + file_handle(const file_handle &) = delete; + //! No copy assignment + file_handle &operator=(const file_handle &) = delete; //! Implicit move construction of file_handle permitted constexpr file_handle(file_handle &&o) noexcept : io_handle(std::move(o)), fs_handle(std::move(o)), _service(o._service) { o._service = nullptr; } //! Explicit conversion from handle and io_handle permitted diff --git a/include/afio/v2.0/handle.hpp b/include/afio/v2.0/handle.hpp index e6d2e4ae..fb0d8868 100644 --- a/include/afio/v2.0/handle.hpp +++ b/include/afio/v2.0/handle.hpp @@ -105,7 +105,7 @@ public: somewhat emulated by AFIO on Windows by renaming the file to a random name on `close()` causing it to appear to have been unlinked immediately. */ - unlink_on_close = 1 << 0, + unlink_on_close = 1U << 0U, /*! Some kernel caching modes have unhelpfully inconsistent behaviours in getting your data onto storage, so by default unless this flag is @@ -124,7 +124,7 @@ public: * caching::reads_and_metadata * caching::safety_fsyncs */ - disable_safety_fsyncs = 1 << 2, + disable_safety_fsyncs = 1U << 2U, /*! `file_handle::unlink()` could accidentally delete the wrong file if someone has renamed the open file handle since the time it was opened. To prevent this occuring, where the OS doesn't provide race free unlink-by-open-handle we compare the inode of @@ -133,17 +133,17 @@ public: and executing the unlink a third party changes the item about to be unlinked. Only operating systems with a true race-free unlink syscall are race free. */ - disable_safety_unlinks = 1 << 3, + disable_safety_unlinks = 1U << 3U, /*! Ask the OS to disable prefetching of data. This can improve random i/o performance. */ - disable_prefetching = 1 << 4, + disable_prefetching = 1U << 4U, /*! Ask the OS to maximise prefetching of data, possibly prefetching the entire file into kernel cache. This can improve sequential i/o performance. */ - maximum_prefetching = 1 << 5, + maximum_prefetching = 1U << 5U, - win_disable_unlink_emulation = 1 << 24, //!< See the documentation for `unlink_on_close` + win_disable_unlink_emulation = 1U << 24U, //!< See the documentation for `unlink_on_close` /*! Microsoft Windows NTFS, having been created in the late 1980s, did not originally implement extents-based storage and thus could only represent sparse files via efficient compression of intermediate zeros. With NTFS v3.0 (Microsoft Windows 2000), @@ -159,13 +159,13 @@ public: extents-based storage for any empty file it creates. If you don't want this, you can specify this flag to prevent that happening. */ - win_disable_sparse_file_creation = 1 << 25, + win_disable_sparse_file_creation = 1U << 25U, // NOTE: IF UPDATING THIS UPDATE THE std::ostream PRINTER BELOW!!! - overlapped = 1 << 28, //!< On Windows, create any new handles with OVERLAPPED semantics - byte_lock_insanity = 1 << 29, //!< Using insane POSIX byte range locks - anonymous_inode = 1 << 30 //!< This is an inode created with no representation on the filing system + overlapped = 1U << 28U, //!< On Windows, create any new handles with OVERLAPPED semantics + byte_lock_insanity = 1U << 29U, //!< Using insane POSIX byte range locks + anonymous_inode = 1U << 30U //!< This is an inode created with no representation on the filing system } QUICKCPPLIB_BITFIELD_END(flag); @@ -176,7 +176,7 @@ protected: public: //! Default constructor - constexpr handle() {} + handle() = default; //! Construct a handle from a supplied native handle explicit constexpr handle(native_handle_type h, caching caching = caching::none, flag flags = flag::none) noexcept : _caching(caching), _flags(flags), _v(std::move(h)) {} AFIO_HEADERS_ONLY_VIRTUAL_SPEC ~handle(); @@ -308,7 +308,7 @@ public: //! True if writes are safely on storage on completion bool are_writes_durable() const noexcept { return _caching == caching::none || _caching == caching::reads || _caching == caching::reads_and_metadata; } //! True if issuing safety fsyncs is on - bool are_safety_fsyncs_issued() const noexcept { return !(_flags & flag::disable_safety_fsyncs) && !((static_cast<int>(_caching) & 1) == 0); } + bool are_safety_fsyncs_issued() const noexcept { return !(_flags & flag::disable_safety_fsyncs) && !((static_cast<unsigned>(_caching) & 1U) == 0U); } //! The flags this handle was opened with flag flags() const noexcept { return _flags; } @@ -328,29 +328,29 @@ inline std::ostream &operator<<(std::ostream &s, const handle &v) inline std::ostream &operator<<(std::ostream &s, const handle::mode &v) { static constexpr const char *values[] = {"unchanged", nullptr, "none", nullptr, "attr_read", "attr_write", "read", "write", nullptr, "append"}; - if(static_cast<size_t>(v) >= sizeof(values) / sizeof(values[0]) || (values[static_cast<size_t>(v)] == nullptr)) + if(static_cast<size_t>(v) >= sizeof(values) / sizeof(values[0]) || (values[static_cast<size_t>(v)] == nullptr)) // NOLINT { return s << "afio::handle::mode::<unknown>"; } - return s << "afio::handle::mode::" << values[static_cast<size_t>(v)]; + return s << "afio::handle::mode::" << values[static_cast<size_t>(v)]; // NOLINT } inline std::ostream &operator<<(std::ostream &s, const handle::creation &v) { static constexpr const char *values[] = {"open_existing", "only_if_not_exist", "if_needed", "truncate"}; - if(static_cast<size_t>(v) >= sizeof(values) / sizeof(values[0]) || (values[static_cast<size_t>(v)] == nullptr)) + if(static_cast<size_t>(v) >= sizeof(values) / sizeof(values[0]) || (values[static_cast<size_t>(v)] == nullptr)) // NOLINT { return s << "afio::handle::creation::<unknown>"; } - return s << "afio::handle::creation::" << values[static_cast<size_t>(v)]; + return s << "afio::handle::creation::" << values[static_cast<size_t>(v)]; // NOLINT } inline std::ostream &operator<<(std::ostream &s, const handle::caching &v) { static constexpr const char *values[] = {"unchanged", "none", "only_metadata", "reads", "all", "reads_and_metadata", "temporary", "safety_fsyncs"}; - if(static_cast<size_t>(v) >= sizeof(values) / sizeof(values[0]) || (values[static_cast<size_t>(v)] == nullptr)) + if(static_cast<size_t>(v) >= sizeof(values) / sizeof(values[0]) || (values[static_cast<size_t>(v)] == nullptr)) // NOLINT { return s << "afio::handle::caching::<unknown>"; } - return s << "afio::handle::caching::" << values[static_cast<size_t>(v)]; + return s << "afio::handle::caching::" << values[static_cast<size_t>(v)]; // NOLINT } inline std::ostream &operator<<(std::ostream &s, const handle::flag &v) { diff --git a/include/afio/v2.0/native_handle_type.hpp b/include/afio/v2.0/native_handle_type.hpp index bddd8cf7..b2e4fcac 100644 --- a/include/afio/v2.0/native_handle_type.hpp +++ b/include/afio/v2.0/native_handle_type.hpp @@ -43,22 +43,22 @@ struct native_handle_type //! The type of handle. QUICKCPPLIB_BITFIELD_BEGIN(disposition) { - invalid = 0, //!< Invalid handle - - readable = 1 << 0, //!< Is readable - writable = 1 << 1, //!< Is writable - append_only = 1 << 2, //!< Is append only - - overlapped = 1 << 4, //!< Requires additional synchronisation - seekable = 1 << 5, //!< Is seekable - aligned_io = 1 << 6, //!< Requires sector aligned i/o (typically 512 or 4096) - - file = 1 << 8, //!< Is a regular file - directory = 1 << 9, //!< Is a directory - symlink = 1 << 10, //!< Is a symlink - multiplexer = 1 << 11, //!< Is a kqueue/epoll/iocp - process = 1 << 12, //!< Is a child process - section = 1 << 13 //!< Is a memory section + invalid = 0U, //!< Invalid handle + + readable = 1U << 0U, //!< Is readable + writable = 1U << 1U, //!< Is writable + append_only = 1U << 2U, //!< Is append only + + overlapped = 1U << 4U, //!< Requires additional synchronisation + seekable = 1U << 5U, //!< Is seekable + aligned_io = 1U << 6U, //!< Requires sector aligned i/o (typically 512 or 4096) + + file = 1U << 8U, //!< Is a regular file + directory = 1U << 9U, //!< Is a directory + symlink = 1U << 10U, //!< Is a symlink + multiplexer = 1U << 11U, //!< Is a kqueue/epoll/iocp + process = 1U << 12U, //!< Is a child process + section = 1U << 13U //!< Is a memory section } QUICKCPPLIB_BITFIELD_END(disposition) disposition behaviour; //! The behaviour of the handle |