From 7fa954bddeae1fbc47aade91b402520fe356cb6d Mon Sep 17 00:00:00 2001 From: Oliver Schonrock Date: Fri, 13 Dec 2024 20:23:38 +0000 Subject: [PATCH] silencing -Wconversion and -Wsign-conversion warnings --- include/mio/detail/mmap.ipp | 16 +++++++++------- include/mio/page.hpp | 5 +++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/include/mio/detail/mmap.ipp b/include/mio/detail/mmap.ipp index 1fec025..d2a6126 100644 --- a/include/mio/detail/mmap.ipp +++ b/include/mio/detail/mmap.ipp @@ -26,6 +26,8 @@ #include "mio/detail/string_util.hpp" #include +#include +#include #ifndef _WIN32 # include @@ -155,7 +157,7 @@ inline size_t query_file_size(file_handle_type handle, std::error_code& error) error = detail::last_error(); return 0; } - return sbuf.st_size; + return static_cast(sbuf.st_size); #endif } @@ -172,7 +174,7 @@ struct mmap_context inline mmap_context memory_map(const file_handle_type file_handle, const int64_t offset, const int64_t length, const access_mode mode, std::error_code& error) { - const int64_t aligned_offset = make_offset_page_aligned(offset); + const int64_t aligned_offset = static_cast(make_offset_page_aligned(static_cast(offset))); const int64_t length_to_map = offset - aligned_offset + length; #ifdef _WIN32 const int64_t max_file_size = offset + length; @@ -204,7 +206,7 @@ inline mmap_context memory_map(const file_handle_type file_handle, const int64_t #else // POSIX char* mapping_start = static_cast(::mmap( 0, // Don't give hint as to where to map. - length_to_map, + static_cast(length_to_map), mode == access_mode::read ? PROT_READ : PROT_READ | PROT_WRITE, MAP_SHARED, file_handle, @@ -345,8 +347,8 @@ void basic_mmap::map(const handle_type handle, return; } - const auto ctx = detail::memory_map(handle, offset, - length == map_entire_file ? (file_size - offset) : length, + const auto ctx = detail::memory_map(handle, static_cast(offset), + static_cast(length == map_entire_file ? (file_size - offset) : length), AccessMode, error); if(!error) { @@ -359,8 +361,8 @@ void basic_mmap::map(const handle_type handle, file_handle_ = handle; is_handle_internal_ = false; data_ = reinterpret_cast(ctx.data); - length_ = ctx.length; - mapped_length_ = ctx.mapped_length; + length_ = static_cast(ctx.length); + mapped_length_ = static_cast(ctx.mapped_length); #ifdef _WIN32 file_mapping_handle_ = ctx.file_mapping_handle; #endif diff --git a/include/mio/page.hpp b/include/mio/page.hpp index cae7377..4868128 100644 --- a/include/mio/page.hpp +++ b/include/mio/page.hpp @@ -21,6 +21,7 @@ #ifndef MIO_PAGE_HEADER #define MIO_PAGE_HEADER +#include #ifdef _WIN32 # include #else @@ -48,7 +49,7 @@ enum class access_mode */ inline size_t page_size() { - static const size_t page_size = [] + static const size_t page_size = static_cast([] { #ifdef _WIN32 SYSTEM_INFO SystemInfo; @@ -57,7 +58,7 @@ inline size_t page_size() #else return sysconf(_SC_PAGE_SIZE); #endif - }(); + }()); return page_size; }