Fix GCC Wconversion errors when compiling in 64 bit mode.

This commit is contained in:
Ion Gaztañaga
2024-08-22 00:07:58 +02:00
parent 9e2968be1a
commit 1ab1b42ce6
4 changed files with 14 additions and 14 deletions

View File

@@ -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<unsigned long>(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<unsigned long>(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<unsigned long>(size), 0, winapi::file_begin)){
return false;
}
if(!winapi::set_end_of_file(hnd)){

View File

@@ -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<unsigned long>(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<unsigned long>(m_size - rename_offset - SystemTimeOfDayInfoLength*2);
}
std::size_t file_rename_information_size() const
unsigned long file_rename_information_size() const
{ return static_cast<unsigned long>(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<unsigned long>(buflen);
unsigned long type;
buflen = 0;
bret = 0 == reg_query_value_ex( key, value_name, 0, &type, (unsigned char*)buf, &size);

View File

@@ -477,7 +477,7 @@ inline mapped_region::mapped_region
(native_mapping_handle,
map_access,
::boost::ulong_long_type(offset - page_offset),
static_cast<std::size_t>(page_offset + size),
static_cast<std::size_t>(page_offset) + size,
const_cast<void*>(address));
//Check error
if(!base){

View File

@@ -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<unsigned long>(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<unsigned long>(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;