diff --git a/include/boost/interprocess/detail/os_file_functions.hpp b/include/boost/interprocess/detail/os_file_functions.hpp index 95e5d9c..692eb07 100644 --- a/include/boost/interprocess/detail/os_file_functions.hpp +++ b/include/boost/interprocess/detail/os_file_functions.hpp @@ -126,11 +126,11 @@ inline bool get_temporary_path(char *buffer, std::size_t buf_len, std::size_t &r required_len = 0; //std::size_t is always bigger or equal than unsigned long in Windows systems //In case std::size_t is bigger than unsigned long - unsigned long buf = buf_len; - if(buf_len != buf){ //maybe overflowed + unsigned long ulbuflen = static_cast(buf_len); //Potentially losing convertion in 64 bits + if(buf_len != ulbuflen){ //maybe overflowed return false; } - required_len = winapi::get_temp_path(buf_len, buffer); + required_len = winapi::get_temp_path(ulbuflen, buffer); const bool ret = required_len && (buf_len > required_len); if(ret && buffer[required_len-1] == '\\'){ buffer[required_len-1] = '\0'; @@ -143,11 +143,11 @@ inline bool get_temporary_path(wchar_t *buffer, std::size_t buf_len, std::size_t required_len = 0; //std::size_t is always bigger or equal than unsigned long in Windows systems //In case std::size_t is bigger than unsigned long - unsigned long buf = buf_len; - if(buf_len != buf){ //maybe overflowed + unsigned long ulbuflen = static_cast(buf_len); //Potentially losing convertion in 64 bits + if(buf_len != ulbuflen){ //maybe overflowed return false; } - required_len = winapi::get_temp_path(buf_len, buffer); + required_len = winapi::get_temp_path(ulbuflen, buffer); const bool ret = !(buf_len < required_len); if(ret && buffer[required_len-1] == L'\\'){ buffer[required_len-1] = L'\0'; @@ -225,7 +225,7 @@ inline bool truncate_file (file_handle_t hnd, std::size_t size) } } else{ - if(!winapi::set_file_pointer(hnd, size, 0, winapi::file_begin)){ + if(!winapi::set_file_pointer(hnd, static_cast(size), 0, winapi::file_begin)){ return false; } if(!winapi::set_end_of_file(hnd)){ diff --git a/include/boost/interprocess/detail/win32_api.hpp b/include/boost/interprocess/detail/win32_api.hpp index 2c8bb7b..44b770d 100644 --- a/include/boost/interprocess/detail/win32_api.hpp +++ b/include/boost/interprocess/detail/win32_api.hpp @@ -1243,8 +1243,8 @@ class nt_query_mem_deleter (SystemTimeOfDayInfoLength + sizeof(unsigned long) + sizeof(boost::winapi::DWORD_))*2; public: - explicit nt_query_mem_deleter(std::size_t object_name_info_size) - : m_size(object_name_info_size + rename_offset + rename_suffix) + explicit nt_query_mem_deleter(unsigned long object_name_info_size) + : m_size(static_cast(object_name_info_size + rename_offset + rename_suffix)) , m_buf(new char [m_size]) {} @@ -1270,7 +1270,7 @@ class nt_query_mem_deleter return static_cast(m_size - rename_offset - SystemTimeOfDayInfoLength*2); } - std::size_t file_rename_information_size() const + unsigned long file_rename_information_size() const { return static_cast(m_size); } private: @@ -1444,7 +1444,7 @@ inline bool get_registry_value_buffer(hkey key_type, const CharT *subkey_name, c reg_closer key_closer(key); //Obtain the value - unsigned long size = buflen; + unsigned long size = static_cast(buflen); unsigned long type; buflen = 0; bret = 0 == reg_query_value_ex( key, value_name, 0, &type, (unsigned char*)buf, &size); diff --git a/include/boost/interprocess/mapped_region.hpp b/include/boost/interprocess/mapped_region.hpp index 1ef2845..0871a72 100644 --- a/include/boost/interprocess/mapped_region.hpp +++ b/include/boost/interprocess/mapped_region.hpp @@ -477,7 +477,7 @@ inline mapped_region::mapped_region (native_mapping_handle, map_access, ::boost::ulong_long_type(offset - page_offset), - static_cast(page_offset + size), + static_cast(page_offset) + size, const_cast(address)); //Check error if(!base){ diff --git a/include/boost/interprocess/sync/windows/named_sync.hpp b/include/boost/interprocess/sync/windows/named_sync.hpp index eed1229..1e960fd 100644 --- a/include/boost/interprocess/sync/windows/named_sync.hpp +++ b/include/boost/interprocess/sync/windows/named_sync.hpp @@ -81,7 +81,7 @@ inline windows_named_sync::windows_named_sync() inline void windows_named_sync::close(windows_named_sync_interface &sync_interface) { - const std::size_t buflen = sync_interface.get_data_size(); + const unsigned long buflen = static_cast(sync_interface.get_data_size()); winapi::interprocess_overlapped overlapped; if(winapi::lock_file_ex (m_file_hnd, winapi::lockfile_exclusive_lock, 0, 1, 0, &overlapped)){ @@ -129,7 +129,7 @@ inline void windows_named_sync::open_or_create bool success = false; if(m_file_hnd != winapi::invalid_handle_value){ //Now lock the file - const std::size_t buflen = sync_interface.get_data_size(); + const unsigned long buflen = static_cast(sync_interface.get_data_size()); typedef __int64 unique_id_type; const std::size_t sizeof_file_info = sizeof(unique_id_type) + buflen; winapi::interprocess_overlapped overlapped;