From efc75031f568a16e8520019deeb71e272818c467 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Wed, 20 Oct 2021 00:18:59 +0200 Subject: [PATCH] Support Clang's -Wconversion -Wfloat-conversion -Wsign-conversion with -Werror --- include/boost/interprocess/detail/atomic.hpp | 2 +- .../detail/managed_memory_impl.hpp | 4 +- .../detail/managed_open_or_create_impl.hpp | 2 +- .../detail/os_thread_functions.hpp | 2 +- .../interprocess/detail/robust_emulation.hpp | 12 +-- include/boost/interprocess/mapped_region.hpp | 8 +- include/boost/interprocess/permissions.hpp | 2 +- .../interprocess/shared_memory_object.hpp | 2 +- .../sync/posix/pthread_helpers.hpp | 2 +- .../sync/posix/timepoint_to_timespec.hpp | 16 ++-- .../boost/interprocess/sync/windows/mutex.hpp | 14 ++-- .../interprocess/sync/windows/semaphore.hpp | 16 ++-- .../interprocess/sync/windows/sync_utils.hpp | 84 +++++++++++-------- .../boost/interprocess/xsi_shared_memory.hpp | 2 +- test/condition_test_template.hpp | 6 +- test/expand_bwd_test_template.hpp | 4 +- test/managed_mapped_file_test.cpp | 2 +- test/managed_shared_memory_test.cpp | 2 +- test/managed_windows_shared_memory_test.cpp | 2 +- test/managed_xsi_shared_memory_test.cpp | 8 +- test/map_test.hpp | 8 +- test/memory_algorithm_test_template.hpp | 2 +- test/named_allocation_test_template.hpp | 12 +-- test/util.hpp | 2 +- 24 files changed, 114 insertions(+), 102 deletions(-) diff --git a/include/boost/interprocess/detail/atomic.hpp b/include/boost/interprocess/detail/atomic.hpp index 80a037b..c4612d5 100644 --- a/include/boost/interprocess/detail/atomic.hpp +++ b/include/boost/interprocess/detail/atomic.hpp @@ -158,7 +158,7 @@ inline boost::uint32_t atomic_add32 // int r = *pw; // *mem += val; // return r; - int r; + boost::uint32_t r; asm volatile ( diff --git a/include/boost/interprocess/detail/managed_memory_impl.hpp b/include/boost/interprocess/detail/managed_memory_impl.hpp index 6cfbc85..72e242d 100644 --- a/include/boost/interprocess/detail/managed_memory_impl.hpp +++ b/include/boost/interprocess/detail/managed_memory_impl.hpp @@ -121,7 +121,7 @@ class basic_managed_memory_impl device_type f(open_or_create, filename, read_write); if(!f.get_size(old_size)) return false; - f.truncate(old_size + extra_bytes); + f.truncate(old_size + static_cast(extra_bytes)); } ManagedMemory managed_memory(open_only, filename); //Grow always works @@ -151,7 +151,7 @@ class basic_managed_memory_impl //Decrease file size { device_type f(open_or_create, filename, read_write); - f.truncate(new_size); + f.truncate(static_cast(new_size)); } return true; } diff --git a/include/boost/interprocess/detail/managed_open_or_create_impl.hpp b/include/boost/interprocess/detail/managed_open_or_create_impl.hpp index 2e6d99d..84a89ad 100644 --- a/include/boost/interprocess/detail/managed_open_or_create_impl.hpp +++ b/include/boost/interprocess/detail/managed_open_or_create_impl.hpp @@ -344,7 +344,7 @@ class managed_open_or_create_impl { BOOST_TRY{ //If this throws, we are lost - truncate_device(dev, size, file_like_t()); + truncate_device(dev, static_cast(size), file_like_t()); //If the following throws, we will truncate the file to 1 mapped_region region(dev, read_write, 0, 0, addr); diff --git a/include/boost/interprocess/detail/os_thread_functions.hpp b/include/boost/interprocess/detail/os_thread_functions.hpp index 7b26059..81ec62c 100644 --- a/include/boost/interprocess/detail/os_thread_functions.hpp +++ b/include/boost/interprocess/detail/os_thread_functions.hpp @@ -421,7 +421,7 @@ inline void thread_sleep_tick() struct timespec rqt; //Sleep for the half of the tick time rqt.tv_sec = 0; - rqt.tv_nsec = get_system_tick_ns()/2; + rqt.tv_nsec = (long)get_system_tick_ns()/2; ::nanosleep(&rqt, 0); } diff --git a/include/boost/interprocess/detail/robust_emulation.hpp b/include/boost/interprocess/detail/robust_emulation.hpp index cba090f..707782d 100644 --- a/include/boost/interprocess/detail/robust_emulation.hpp +++ b/include/boost/interprocess/detail/robust_emulation.hpp @@ -217,7 +217,7 @@ class robust_spin_mutex template inline robust_spin_mutex::robust_spin_mutex() - : mtx(), owner(get_invalid_process_id()), state(correct_state) + : mtx(), owner((boost::uint32_t)get_invalid_process_id()), state(correct_state) {} template @@ -237,7 +237,7 @@ inline bool robust_spin_mutex::try_lock() } if (mtx.try_lock()){ - atomic_write32(&this->owner, get_current_process_id()); + atomic_write32(&this->owner, static_cast(get_current_process_id())); return true; } else{ @@ -259,7 +259,7 @@ inline bool robust_spin_mutex::timed_lock template inline void robust_spin_mutex::owner_to_filename(boost::uint32_t own, std::string &s) { - robust_emulation_helpers::create_and_get_robust_lock_file_path(s, own); + robust_emulation_helpers::create_and_get_robust_lock_file_path(s, (OS_process_id_t)own); } template @@ -278,7 +278,7 @@ inline bool robust_spin_mutex::robust_check() template inline bool robust_spin_mutex::check_if_owner_dead_and_take_ownership_atomically() { - boost::uint32_t cur_owner = get_current_process_id(); + boost::uint32_t cur_owner = static_cast(get_current_process_id()); boost::uint32_t old_owner = atomic_read32(&this->owner), old_owner2; //The cas loop guarantees that only one thread from this or another process //will succeed taking ownership @@ -300,7 +300,7 @@ template inline bool robust_spin_mutex::is_owner_dead(boost::uint32_t own) { //If owner is an invalid id, then it's clear it's dead - if(own == (boost::uint32_t)get_invalid_process_id()){ + if(own == static_cast(get_invalid_process_id())){ return true; } @@ -364,7 +364,7 @@ inline void robust_spin_mutex::unlock() atomic_write32(&this->state, broken_state); } //Write an invalid owner to minimize pid reuse possibility - atomic_write32(&this->owner, get_invalid_process_id()); + atomic_write32(&this->owner, static_cast(get_invalid_process_id())); mtx.unlock(); } diff --git a/include/boost/interprocess/mapped_region.hpp b/include/boost/interprocess/mapped_region.hpp index 671b665..1ef2845 100644 --- a/include/boost/interprocess/mapped_region.hpp +++ b/include/boost/interprocess/mapped_region.hpp @@ -364,12 +364,12 @@ inline offset_t mapped_region::priv_page_offset_addr_fixup(offset_t offset, cons //We calculate the difference between demanded and valid offset //(always less than a page in std::size_t, thus, representable by std::size_t) const std::size_t page_offset = - static_cast(offset - (offset / page_size) * page_size); + static_cast(offset - (offset / offset_t(page_size)) * offset_t(page_size)); //Update the mapping address if(address){ address = static_cast(address) - page_offset; } - return page_offset; + return offset_t(page_offset); } #if defined (BOOST_INTERPROCESS_WINDOWS) @@ -695,7 +695,7 @@ inline mapped_region::mapped_region //Map it to the address space void* base = mmap ( const_cast(address) - , static_cast(page_offset + size) + , static_cast(page_offset) + size , prot , flags , mapping.get_mapping_handle().handle @@ -709,7 +709,7 @@ inline mapped_region::mapped_region //Calculate new base for the user m_base = static_cast(base) + page_offset; - m_page_offset = page_offset; + m_page_offset = static_cast(page_offset); m_size = size; //Check for fixed mapping error diff --git a/include/boost/interprocess/permissions.hpp b/include/boost/interprocess/permissions.hpp index ce4255c..ab55411 100644 --- a/include/boost/interprocess/permissions.hpp +++ b/include/boost/interprocess/permissions.hpp @@ -70,7 +70,7 @@ class permissions #if defined(BOOST_INTERPROCESS_WINDOWS) typedef void* os_permissions_type; #else - typedef int os_permissions_type; + typedef ::mode_t os_permissions_type; #endif os_permissions_type m_perm; diff --git a/include/boost/interprocess/shared_memory_object.hpp b/include/boost/interprocess/shared_memory_object.hpp index b32a0dc..dedede1 100644 --- a/include/boost/interprocess/shared_memory_object.hpp +++ b/include/boost/interprocess/shared_memory_object.hpp @@ -368,7 +368,7 @@ inline bool shared_memory_object::priv_open_or_create error_info err(mode_error); throw interprocess_exception(err); } - int unix_perm = perm.get_permissions(); + ::mode_t unix_perm = perm.get_permissions(); switch(type){ case ipcdetail::DoOpen: diff --git a/include/boost/interprocess/sync/posix/pthread_helpers.hpp b/include/boost/interprocess/sync/posix/pthread_helpers.hpp index cdf89a5..f247d5e 100644 --- a/include/boost/interprocess/sync/posix/pthread_helpers.hpp +++ b/include/boost/interprocess/sync/posix/pthread_helpers.hpp @@ -148,7 +148,7 @@ namespace ipcdetail{ //!Constructor. Takes barrier attributes to initialize the barrier barrier_initializer(pthread_barrier_t &mut, pthread_barrierattr_t &mut_attr, - int count) + unsigned int count) : mp_barrier(&mut) { if(pthread_barrier_init(mp_barrier, &mut_attr, count) != 0) diff --git a/include/boost/interprocess/sync/posix/timepoint_to_timespec.hpp b/include/boost/interprocess/sync/posix/timepoint_to_timespec.hpp index 04918d8..297fe8a 100644 --- a/include/boost/interprocess/sync/posix/timepoint_to_timespec.hpp +++ b/include/boost/interprocess/sync/posix/timepoint_to_timespec.hpp @@ -42,16 +42,16 @@ inline timespec timepoint_to_timespec ( const TimePoint &tm time_duration_type duration = (tm <= epoch) ? time_duration_type(epoch - epoch) : time_duration_type(tm - epoch); timespec ts; - ts.tv_sec = duration.total_seconds(); - ts.tv_nsec = duration.total_nanoseconds() % 1000000000; + ts.tv_sec = static_cast(duration.total_seconds()); + ts.tv_nsec = static_cast(duration.total_nanoseconds() % 1000000000); return ts; } inline timespec timepoint_to_timespec (const ustime &tm) { timespec ts; - ts.tv_sec = tm.get_microsecs()/1000000u; - ts.tv_nsec = (tm.get_microsecs()%1000000u)*1000u; + ts.tv_sec = static_cast(tm.get_microsecs()/1000000u); + ts.tv_nsec = static_cast((tm.get_microsecs()%1000000u)*1000u); return ts; } @@ -65,15 +65,15 @@ inline timespec timepoint_to_timespec ( const TimePoint &tm timespec ts; BOOST_IF_CONSTEXPR(duration_t::period::num == 1 && duration_t::period::den == 1000000000) { - ts.tv_sec = d.count()/duration_t::period::den; - ts.tv_nsec = d.count()%duration_t::period::den; + ts.tv_sec = static_cast(d.count()/duration_t::period::den); + ts.tv_nsec = static_cast(d.count()%duration_t::period::den); } else { const double factor = double(duration_t::period::num)/double(duration_t::period::den); const double res = d.count()*factor; - ts.tv_sec = static_cast(res); - ts.tv_nsec = static_cast(res - double(ts.tv_sec)); + ts.tv_sec = static_cast(res); + ts.tv_nsec = static_cast(res - double(ts.tv_sec)); } return ts; } diff --git a/include/boost/interprocess/sync/windows/mutex.hpp b/include/boost/interprocess/sync/windows/mutex.hpp index 55c2472..e1bd190 100644 --- a/include/boost/interprocess/sync/windows/mutex.hpp +++ b/include/boost/interprocess/sync/windows/mutex.hpp @@ -59,13 +59,13 @@ class winapi_mutex }; inline winapi_mutex::winapi_mutex() - : id_(this) + : id_() { sync_handles &handles = windows_intermodule_singleton::get(); //Create mutex with the initial count bool open_or_created; - (void)handles.obtain_mutex(this->id_, &open_or_created); + (void)handles.obtain_mutex(this->id_, this, &open_or_created); //The mutex must be created, never opened BOOST_ASSERT(open_or_created); BOOST_ASSERT(open_or_created && winapi::get_last_error() != winapi::error_already_exists); @@ -76,7 +76,7 @@ inline winapi_mutex::~winapi_mutex() { sync_handles &handles = windows_intermodule_singleton::get(); - handles.destroy_handle(this->id_); + handles.destroy_handle(this->id_, this); } inline void winapi_mutex::lock(void) @@ -84,7 +84,7 @@ inline void winapi_mutex::lock(void) sync_handles &handles = windows_intermodule_singleton::get(); //This can throw - winapi_mutex_functions mut(handles.obtain_mutex(this->id_)); + winapi_mutex_functions mut(handles.obtain_mutex(this->id_, this)); mut.lock(); } @@ -93,7 +93,7 @@ inline bool winapi_mutex::try_lock(void) sync_handles &handles = windows_intermodule_singleton::get(); //This can throw - winapi_mutex_functions mut(handles.obtain_mutex(this->id_)); + winapi_mutex_functions mut(handles.obtain_mutex(this->id_, this)); return mut.try_lock(); } @@ -103,7 +103,7 @@ inline bool winapi_mutex::timed_lock(const TimePoint &abs_time) sync_handles &handles = windows_intermodule_singleton::get(); //This can throw - winapi_mutex_functions mut(handles.obtain_mutex(this->id_)); + winapi_mutex_functions mut(handles.obtain_mutex(this->id_, this)); return mut.timed_lock(abs_time); } @@ -112,7 +112,7 @@ inline void winapi_mutex::unlock(void) sync_handles &handles = windows_intermodule_singleton::get(); //This can throw - winapi_mutex_functions mut(handles.obtain_mutex(this->id_)); + winapi_mutex_functions mut(handles.obtain_mutex(this->id_, this)); return mut.unlock(); } diff --git a/include/boost/interprocess/sync/windows/semaphore.hpp b/include/boost/interprocess/sync/windows/semaphore.hpp index 2a47a12..888ab71 100644 --- a/include/boost/interprocess/sync/windows/semaphore.hpp +++ b/include/boost/interprocess/sync/windows/semaphore.hpp @@ -53,13 +53,13 @@ class winapi_semaphore }; inline winapi_semaphore::winapi_semaphore(unsigned int initialCount) - : id_(this), initial_count_(initialCount) + : id_(), initial_count_(initialCount) { sync_handles &handles = windows_intermodule_singleton::get(); //Force smeaphore creation with the initial count bool open_or_created; - handles.obtain_semaphore(this->id_, initialCount, &open_or_created); + handles.obtain_semaphore(this->id_, this, initialCount, &open_or_created); //The semaphore must be created, never opened BOOST_ASSERT(open_or_created); BOOST_ASSERT(open_or_created && winapi::get_last_error() != winapi::error_already_exists); @@ -70,7 +70,7 @@ inline winapi_semaphore::~winapi_semaphore() { sync_handles &handles = windows_intermodule_singleton::get(); - handles.destroy_handle(this->id_); + handles.destroy_handle(this->id_, this); } inline void winapi_semaphore::wait() @@ -78,7 +78,7 @@ inline void winapi_semaphore::wait() sync_handles &handles = windows_intermodule_singleton::get(); //This can throw - winapi_semaphore_functions sem(handles.obtain_semaphore(this->id_, initial_count_)); + winapi_semaphore_functions sem(handles.obtain_semaphore(this->id_, this, initial_count_)); sem.wait(); } @@ -87,7 +87,7 @@ inline bool winapi_semaphore::try_wait() sync_handles &handles = windows_intermodule_singleton::get(); //This can throw - winapi_semaphore_functions sem(handles.obtain_semaphore(this->id_, initial_count_)); + winapi_semaphore_functions sem(handles.obtain_semaphore(this->id_, this, initial_count_)); return sem.try_wait(); } @@ -97,7 +97,7 @@ inline bool winapi_semaphore::timed_wait(const TimePoint &abs_time) sync_handles &handles = windows_intermodule_singleton::get(); //This can throw - winapi_semaphore_functions sem(handles.obtain_semaphore(this->id_, initial_count_)); + winapi_semaphore_functions sem(handles.obtain_semaphore(this->id_, this, initial_count_)); return sem.timed_wait(abs_time); } @@ -105,8 +105,8 @@ inline void winapi_semaphore::post(unsigned release_count) { sync_handles &handles = windows_intermodule_singleton::get(); - winapi_semaphore_functions sem(handles.obtain_semaphore(this->id_, initial_count_)); - sem.post(release_count); + winapi_semaphore_functions sem(handles.obtain_semaphore(this->id_, this, initial_count_)); + sem.post(static_cast(release_count)); } diff --git a/include/boost/interprocess/sync/windows/sync_utils.hpp b/include/boost/interprocess/sync/windows/sync_utils.hpp index f249cbc..15b2b8c 100644 --- a/include/boost/interprocess/sync/windows/sync_utils.hpp +++ b/include/boost/interprocess/sync/windows/sync_utils.hpp @@ -30,11 +30,10 @@ //Shield against external warnings #include - #include +#include #include +#include - -#include #include namespace boost { @@ -89,12 +88,10 @@ class sync_id { public: typedef __int64 internal_type; - sync_id(const void *map_addr) - : map_addr_(map_addr) + sync_id() { winapi::query_performance_counter(&rand_); } - explicit sync_id(internal_type val, const void *map_addr) - : map_addr_(map_addr) + explicit sync_id(internal_type val) { rand_ = val; } const internal_type &internal_pod() const @@ -103,18 +100,14 @@ class sync_id internal_type &internal_pod() { return rand_; } - const void *map_address() const - { return map_addr_; } - friend std::size_t hash_value(const sync_id &m) { return boost::hash_value(m.rand_); } friend bool operator==(const sync_id &l, const sync_id &r) - { return l.rand_ == r.rand_ && l.map_addr_ == r.map_addr_; } + { return l.rand_ == r.rand_; } private: internal_type rand_; - const void * const map_addr_; }; class sync_handles @@ -123,19 +116,15 @@ class sync_handles enum type { MUTEX, SEMAPHORE }; private: - struct address_less - { - bool operator()(sync_id const * const l, sync_id const * const r) const - { return l->map_address() < r->map_address(); } - }; + //key: id -> mapped: HANDLE. Hash map to allow efficient sync operations typedef boost::unordered_map umap_type; - typedef boost::container::map map_type; + //key: ordered address of the sync type -> iterator from umap_type. Ordered map to allow closing handles when unmapping + typedef boost::container::flat_map map_type; static const std::size_t LengthOfGlobal = sizeof("Global\\boost.ipc")-1; static const std::size_t StrSize = LengthOfGlobal + (sizeof(sync_id)*2+1); typedef char NameBuf[StrSize]; - void fill_name(NameBuf &name, const sync_id &id) { const char *n = "Global\\boost.ipc"; @@ -151,7 +140,7 @@ class sync_handles void throw_if_error(void *hnd_val) { if(!hnd_val){ - error_info err(winapi::get_last_error()); + error_info err(static_cast(winapi::get_last_error())); throw interprocess_exception(err); } } @@ -183,41 +172,57 @@ class sync_handles } public: - void *obtain_mutex(const sync_id &id, bool *popen_created = 0) + sync_handles() + : num_handles_() + {} + + ~sync_handles() + { + BOOST_ASSERT(num_handles_ == 0); //Sanity check that handle we don't leak handles + } + + void *obtain_mutex(const sync_id &id, const void *mapping_address, bool *popen_created = 0) { umap_type::value_type v(id, (void*)0); scoped_lock lock(mtx_); umap_type::iterator it = umap_.insert(v).first; void *&hnd_val = it->second; if(!hnd_val){ - map_[&it->first] = it; + BOOST_ASSERT(map_.find(mapping_address) == map_.end()); + map_[mapping_address] = it; hnd_val = open_or_create_mutex(id); if(popen_created) *popen_created = true; + ++num_handles_; } else if(popen_created){ + BOOST_ASSERT(map_.find(mapping_address) != map_.end()); *popen_created = false; } + return hnd_val; } - void *obtain_semaphore(const sync_id &id, unsigned int initial_count, bool *popen_created = 0) + void *obtain_semaphore(const sync_id &id, const void *mapping_address, unsigned int initial_count, bool *popen_created = 0) { umap_type::value_type v(id, (void*)0); scoped_lock lock(mtx_); umap_type::iterator it = umap_.insert(v).first; void *&hnd_val = it->second; if(!hnd_val){ - map_[&it->first] = it; + BOOST_ASSERT(map_.find(mapping_address) == map_.end()); + map_[mapping_address] = it; hnd_val = open_or_create_semaphore(id, initial_count); if(popen_created) *popen_created = true; + ++num_handles_; } else if(popen_created){ + BOOST_ASSERT(map_.find(mapping_address) != map_.end()); *popen_created = false; } return hnd_val; } - void destroy_handle(const sync_id &id) + void destroy_handle(const sync_id &id, const void *mapping_address) { scoped_lock lock(mtx_); umap_type::iterator it = umap_.find(id); @@ -225,31 +230,38 @@ class sync_handles if(it != itend){ winapi::close_handle(it->second); - const map_type::key_type &k = &it->first; - map_.erase(k); + --num_handles_; + std::size_t i = map_.erase(mapping_address); + BOOST_ASSERT(i == 1); //The entry should be there umap_.erase(it); } } void destroy_syncs_in_range(const void *addr, std::size_t size) { - const sync_id low_id(addr); - const sync_id hig_id(static_cast(addr)+size); + const void *low_id(addr); + const void *hig_id(static_cast(addr)+size); scoped_lock lock(mtx_); - map_type::iterator itlow(map_.lower_bound(&low_id)), - ithig(map_.lower_bound(&hig_id)); - while(itlow != ithig){ - void * const hnd = umap_[*itlow->first]; - winapi::close_handle(hnd); - umap_.erase(*itlow->first); - itlow = map_.erase(itlow); + map_type::iterator itlow(map_.lower_bound(low_id)), + ithig(map_.lower_bound(hig_id)), + it(itlow); + for (; it != ithig; ++it){ + umap_type::iterator uit = it->second; + void * const hnd = uit->second; + umap_.erase(uit); + int ret = winapi::close_handle(hnd); + --num_handles_; + BOOST_ASSERT(ret != 0); (void)ret; //Sanity check that handle was ok } + + map_.erase(itlow, ithig); } private: spin_mutex mtx_; umap_type umap_; map_type map_; + std::size_t num_handles_; }; diff --git a/include/boost/interprocess/xsi_shared_memory.hpp b/include/boost/interprocess/xsi_shared_memory.hpp index a35a7c7..9479f0d 100644 --- a/include/boost/interprocess/xsi_shared_memory.hpp +++ b/include/boost/interprocess/xsi_shared_memory.hpp @@ -164,7 +164,7 @@ inline mapping_handle_t xsi_shared_memory::get_mapping_handle() const BOOST_NOEX inline bool xsi_shared_memory::priv_open_or_create (ipcdetail::create_enum_t type, const xsi_key &key, const permissions& permissions, std::size_t size) { - int perm = permissions.get_permissions(); + int perm = (int)permissions.get_permissions(); perm &= 0x01FF; int shmflg = perm; diff --git a/test/condition_test_template.hpp b/test/condition_test_template.hpp index de3929f..659a974 100644 --- a/test/condition_test_template.hpp +++ b/test/condition_test_template.hpp @@ -115,7 +115,7 @@ void do_test_condition_notify_all() { const int NUMTHREADS = 3; - boost::interprocess::ipcdetail::OS_thread_t thgroup[NUMTHREADS]; + boost::interprocess::ipcdetail::OS_thread_t thgroup[std::size_t(NUMTHREADS)]; condition_test_data data; for(int i = 0; i< NUMTHREADS; ++i){ @@ -365,7 +365,7 @@ void do_test_condition_queue_notify_one(void) waiting_readers = 0; waiting_writer = 0; - boost::interprocess::ipcdetail::OS_thread_t thgroup[NumThreads]; + boost::interprocess::ipcdetail::OS_thread_t thgroup[std::size_t(NumThreads)]; for(int i = 0; i< NumThreads; ++i){ condition_func func(cond_full, cond_empty, mutex); boost::interprocess::ipcdetail::thread_launch(thgroup[i], func); @@ -410,7 +410,7 @@ void do_test_condition_queue_notify_all(void) waiting_readers = 0; waiting_writer = 0; - boost::interprocess::ipcdetail::OS_thread_t thgroup[NumThreads]; + boost::interprocess::ipcdetail::OS_thread_t thgroup[std::size_t(NumThreads)]; for(int i = 0; i< NumThreads; ++i){ condition_func func(cond_full, cond_empty, mutex); boost::interprocess::ipcdetail::thread_launch(thgroup[i], func); diff --git a/test/expand_bwd_test_template.hpp b/test/expand_bwd_test_template.hpp index 6253122..c2bc42b 100644 --- a/test/expand_bwd_test_template.hpp +++ b/test/expand_bwd_test_template.hpp @@ -130,7 +130,7 @@ bool test_insert_with_expand_bwd() { 100, 100, 100, 200, 300, 25, 100, 200 }; //Number of tests - const std::size_t Iterations = sizeof(InsertSize)/sizeof(int); + const std::size_t Iterations = sizeof(InsertSize)/sizeof(std::size_t); for(std::size_t iteration = 0; iteration < Iterations; ++iteration) { @@ -187,7 +187,7 @@ bool test_assign_with_expand_bwd() const std::size_t Offset[] = { 50, 50, 50}; const std::size_t InitialSize[] = { 25, 25, 25}; const std::size_t InsertSize[] = { 15, 35, 55}; - const std::size_t Iterations = sizeof(InsertSize)/sizeof(int); + const std::size_t Iterations = sizeof(InsertSize)/sizeof(std::size_t); for(std::size_t iteration = 0; iteration buffers; - const int BufferLen = 100; + const std::size_t BufferLen = 100; char_type name[BufferLen]; typedef std::basic_string string_type; std::set names; @@ -177,7 +177,7 @@ bool test_shrink_to_fit(ManagedMemory &m) { typedef typename ManagedMemory::char_type char_type; std::vector buffers; - const int BufferLen = 100; + const std::size_t BufferLen = 100; char_type name[BufferLen]; basic_bufferstream formatter(name, BufferLen); @@ -218,7 +218,7 @@ bool test_direct_named_allocation_destruction(ManagedMemory &m) { typedef typename ManagedMemory::char_type char_type; std::vector buffers; - const int BufferLen = 100; + const std::size_t BufferLen = 100; char_type name[BufferLen]; basic_bufferstream formatter(name, BufferLen); @@ -259,7 +259,7 @@ bool test_named_allocation_inverse_destruction(ManagedMemory &m) typedef typename ManagedMemory::char_type char_type; std::vector buffers; - const int BufferLen = 100; + const std::size_t BufferLen = 100; char_type name[BufferLen]; basic_bufferstream formatter(name, BufferLen); @@ -298,7 +298,7 @@ bool test_named_allocation_mixed_destruction(ManagedMemory &m) typedef typename ManagedMemory::char_type char_type; std::vector buffers; - const int BufferLen = 100; + const std::size_t BufferLen = 100; char_type name[BufferLen]; basic_bufferstream formatter(name, BufferLen); @@ -339,7 +339,7 @@ bool test_inverse_named_allocation_destruction(ManagedMemory &m) typedef typename ManagedMemory::char_type char_type; std::vector buffers; - const int BufferLen = 100; + const std::size_t BufferLen = 100; char_type name[BufferLen]; basic_bufferstream formatter(name, BufferLen); diff --git a/test/util.hpp b/test/util.hpp index 3a14db6..b6dfcda 100644 --- a/test/util.hpp +++ b/test/util.hpp @@ -25,7 +25,7 @@ #include #include -#if defined(BOOST_GCC) && (BOOST_GCC >= 40600) +#if defined(BOOST_CLANG) || (defined(BOOST_GCC) && (BOOST_GCC >= 40600)) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wsign-conversion" #pragma GCC diagnostic ignored "-Wconversion"