Boost logo

Boost-Commit :

From: roland.schwarz_at_[hidden]
Date: 2007-11-04 12:17:01


Author: speedsnail
Date: 2007-11-04 12:17:01 EST (Sun, 04 Nov 2007)
New Revision: 40742
URL: http://svn.boost.org/trac/boost/changeset/40742

Log:
Get rid of "unsused variable" warnings by making use of BOOST_VERIFY.
This changeset is for pthread only.

Text files modified:
   trunk/boost/thread/pthread/condition_variable.hpp | 27 +++++++++------------------
   trunk/boost/thread/pthread/mutex.hpp | 30 ++++++++++--------------------
   trunk/boost/thread/pthread/once.hpp | 6 ++----
   trunk/boost/thread/pthread/pthread_mutex_scoped_lock.hpp | 6 ++----
   trunk/boost/thread/pthread/recursive_mutex.hpp | 39 +++++++++++++--------------------------
   trunk/libs/thread/src/pthread/thread.cpp | 30 +++++++++---------------------
   6 files changed, 45 insertions(+), 93 deletions(-)

Modified: trunk/boost/thread/pthread/condition_variable.hpp
==============================================================================
--- trunk/boost/thread/pthread/condition_variable.hpp (original)
+++ trunk/boost/thread/pthread/condition_variable.hpp 2007-11-04 12:17:01 EST (Sun, 04 Nov 2007)
@@ -28,15 +28,13 @@
     }
     inline condition_variable::~condition_variable()
     {
- int const res=pthread_cond_destroy(&cond);
- BOOST_ASSERT(!res);
+ BOOST_VERIFY(0==pthread_cond_destroy(&cond));
     }
 
     inline void condition_variable::wait(unique_lock<mutex>& m)
     {
         detail::interruption_checker check_for_interruption(&cond);
- int const cond_res=pthread_cond_wait(&cond,m.mutex()->native_handle());
- BOOST_ASSERT(!cond_res);
+ BOOST_VERIFY(0==pthread_cond_wait(&cond,m.mutex()->native_handle()));
     }
 
     inline bool condition_variable::timed_wait(unique_lock<mutex>& m,boost::system_time const& wait_until)
@@ -54,14 +52,12 @@
 
     inline void condition_variable::notify_one()
     {
- int const res=pthread_cond_signal(&cond);
- BOOST_ASSERT(!res);
+ BOOST_VERIFY(0==pthread_cond_signal(&cond));
     }
         
     inline void condition_variable::notify_all()
     {
- int const res=pthread_cond_broadcast(&cond);
- BOOST_ASSERT(!res);
+ BOOST_VERIFY(0==pthread_cond_broadcast(&cond));
     }
     
     class condition_variable_any
@@ -83,17 +79,14 @@
             int const res2=pthread_cond_init(&cond,NULL);
             if(res2)
             {
- int const destroy_res=pthread_mutex_destroy(&internal_mutex);
- BOOST_ASSERT(!destroy_res);
+ BOOST_VERIFY(0==pthread_mutex_destroy(&internal_mutex));
                 throw thread_resource_error();
             }
         }
         ~condition_variable_any()
         {
- int const res=pthread_mutex_destroy(&internal_mutex);
- BOOST_ASSERT(!res);
- int const res2=pthread_cond_destroy(&cond);
- BOOST_ASSERT(!res2);
+ BOOST_VERIFY(0==pthread_mutex_destroy(&internal_mutex));
+ BOOST_VERIFY(0==pthread_cond_destroy(&cond));
         }
         
         template<typename lock_type>
@@ -160,15 +153,13 @@
         void notify_one()
         {
             boost::pthread::pthread_mutex_scoped_lock internal_lock(&internal_mutex);
- int const res=pthread_cond_signal(&cond);
- BOOST_ASSERT(!res);
+ BOOST_VERIFY(0==pthread_cond_signal(&cond));
         }
         
         void notify_all()
         {
             boost::pthread::pthread_mutex_scoped_lock internal_lock(&internal_mutex);
- int const res=pthread_cond_broadcast(&cond);
- BOOST_ASSERT(!res);
+ BOOST_VERIFY(0==pthread_cond_broadcast(&cond));
         }
     };
 

Modified: trunk/boost/thread/pthread/mutex.hpp
==============================================================================
--- trunk/boost/thread/pthread/mutex.hpp (original)
+++ trunk/boost/thread/pthread/mutex.hpp 2007-11-04 12:17:01 EST (Sun, 04 Nov 2007)
@@ -42,20 +42,17 @@
         }
         ~mutex()
         {
- int const res=pthread_mutex_destroy(&m);
- BOOST_ASSERT(!res);
+ BOOST_VERIFY(0==pthread_mutex_destroy(&m));
         }
         
         void lock()
         {
- int const res=pthread_mutex_lock(&m);
- BOOST_ASSERT(!res);
+ BOOST_VERIFY(0==pthread_mutex_lock(&m));
         }
 
         void unlock()
         {
- int const res=pthread_mutex_unlock(&m);
- BOOST_ASSERT(!res);
+ BOOST_VERIFY(0==pthread_mutex_unlock(&m));
         }
         
         bool try_lock()
@@ -98,8 +95,7 @@
             int const res2=pthread_cond_init(&cond,NULL);
             if(res2)
             {
- int const destroy_res=pthread_mutex_destroy(&m);
- BOOST_ASSERT(!destroy_res);
+ BOOST_VERIFY(0==pthread_mutex_destroy(&m));
                 throw thread_resource_error();
             }
             is_locked=false;
@@ -107,11 +103,9 @@
         }
         ~timed_mutex()
         {
- int const res=pthread_mutex_destroy(&m);
- BOOST_ASSERT(!res);
+ BOOST_VERIFY(0==pthread_mutex_destroy(&m));
 #ifndef BOOST_PTHREAD_HAS_TIMEDLOCK
- int const res2=pthread_cond_destroy(&cond);
- BOOST_ASSERT(!res2);
+ BOOST_VERIFY(0==pthread_cond_destroy(&cond));
 #endif
         }
 
@@ -124,14 +118,12 @@
 #ifdef BOOST_PTHREAD_HAS_TIMEDLOCK
         void lock()
         {
- int const res=pthread_mutex_lock(&m);
- BOOST_ASSERT(!res);
+ BOOST_VERIFY(0==pthread_mutex_lock(&m));
         }
 
         void unlock()
         {
- int const res=pthread_mutex_unlock(&m);
- BOOST_ASSERT(!res);
+ BOOST_VERIFY(0==pthread_mutex_unlock(&m));
         }
         
         bool try_lock()
@@ -153,8 +145,7 @@
             boost::pthread::pthread_mutex_scoped_lock const local_lock(&m);
             while(is_locked)
             {
- int const cond_res=pthread_cond_wait(&cond,&m);
- BOOST_ASSERT(!cond_res);
+ BOOST_VERIFY(0==pthread_cond_wait(&cond,&m));
             }
             is_locked=true;
         }
@@ -163,8 +154,7 @@
         {
             boost::pthread::pthread_mutex_scoped_lock const local_lock(&m);
             is_locked=false;
- int const res=pthread_cond_signal(&cond);
- BOOST_ASSERT(!res);
+ BOOST_VERIFY(0==pthread_cond_signal(&cond));
         }
         
         bool try_lock()

Modified: trunk/boost/thread/pthread/once.hpp
==============================================================================
--- trunk/boost/thread/pthread/once.hpp (original)
+++ trunk/boost/thread/pthread/once.hpp 2007-11-04 12:17:01 EST (Sun, 04 Nov 2007)
@@ -33,13 +33,11 @@
             explicit pthread_mutex_scoped_lock(pthread_mutex_t* mutex_):
                 mutex(mutex_)
             {
- int const res=pthread_mutex_lock(mutex);
- BOOST_ASSERT(!res);
+ BOOST_VERIFY(0==pthread_mutex_lock(mutex));
             }
             ~pthread_mutex_scoped_lock()
             {
- int const res=pthread_mutex_unlock(mutex);
- BOOST_ASSERT(!res);
+ BOOST_VERIFY(0==pthread_mutex_unlock(mutex));
             }
         };
     }

Modified: trunk/boost/thread/pthread/pthread_mutex_scoped_lock.hpp
==============================================================================
--- trunk/boost/thread/pthread/pthread_mutex_scoped_lock.hpp (original)
+++ trunk/boost/thread/pthread/pthread_mutex_scoped_lock.hpp 2007-11-04 12:17:01 EST (Sun, 04 Nov 2007)
@@ -14,13 +14,11 @@
             explicit pthread_mutex_scoped_lock(pthread_mutex_t* m_):
                 m(m_)
             {
- int const res=pthread_mutex_lock(m);
- BOOST_ASSERT(!res);
+ BOOST_VERIFY(0==pthread_mutex_lock(m));
             }
             ~pthread_mutex_scoped_lock()
             {
- int const res=pthread_mutex_unlock(m);
- BOOST_ASSERT(!res);
+ BOOST_VERIFY(0==pthread_mutex_unlock(m));
             }
             
         };

Modified: trunk/boost/thread/pthread/recursive_mutex.hpp
==============================================================================
--- trunk/boost/thread/pthread/recursive_mutex.hpp (original)
+++ trunk/boost/thread/pthread/recursive_mutex.hpp 2007-11-04 12:17:01 EST (Sun, 04 Nov 2007)
@@ -53,25 +53,21 @@
             {
                 throw thread_resource_error();
             }
- int const destroy_attr_res=pthread_mutexattr_destroy(&attr);
- BOOST_ASSERT(!destroy_attr_res);
+ BOOST_VERIFY(0==pthread_mutexattr_destroy(&attr));
         }
         ~recursive_mutex()
         {
- int const res=pthread_mutex_destroy(&m);
- BOOST_ASSERT(!res);
+ BOOST_VERIFY(0==pthread_mutex_destroy(&m));
         }
         
         void lock()
         {
- int const res=pthread_mutex_lock(&m);
- BOOST_ASSERT(!res);
+ BOOST_VERIFY(0==pthread_mutex_lock(&m));
         }
 
         void unlock()
         {
- int const res=pthread_mutex_unlock(&m);
- BOOST_ASSERT(!res);
+ BOOST_VERIFY(0==pthread_mutex_unlock(&m));
         }
         
         bool try_lock()
@@ -117,12 +113,10 @@
             int const res=pthread_mutex_init(&m,&attr);
             if(res)
             {
- int const destroy_attr_res=pthread_mutexattr_destroy(&attr);
- BOOST_ASSERT(!destroy_attr_res);
+ BOOST_VERIFY(0==pthread_mutexattr_destroy(&attr));
                 throw thread_resource_error();
             }
- int const destroy_attr_res=pthread_mutexattr_destroy(&attr);
- BOOST_ASSERT(!destroy_attr_res);
+ BOOST_VERIFY(0==pthread_mutexattr_destroy(&attr));
 #else
             int const res=pthread_mutex_init(&m,NULL);
             if(res)
@@ -132,8 +126,7 @@
             int const res2=pthread_cond_init(&cond,NULL);
             if(res2)
             {
- int const destroy_res=pthread_mutex_destroy(&m);
- BOOST_ASSERT(!destroy_res);
+ BOOST_VERIFY(0==pthread_mutex_destroy(&m));
                 throw thread_resource_error();
             }
             is_locked=false;
@@ -142,11 +135,9 @@
         }
         ~recursive_timed_mutex()
         {
- int const res=pthread_mutex_destroy(&m);
- BOOST_ASSERT(!res);
+ BOOST_VERIFY(0==pthread_mutex_destroy(&m));
 #ifndef BOOST_PTHREAD_HAS_TIMEDLOCK
- int const res2=pthread_cond_destroy(&cond);
- BOOST_ASSERT(!res2);
+ BOOST_VERIFY(0==pthread_cond_destroy(&cond));
 #endif
         }
 
@@ -159,14 +150,12 @@
 #ifdef BOOST_PTHREAD_HAS_TIMEDLOCK
         void lock()
         {
- int const res=pthread_mutex_lock(&m);
- BOOST_ASSERT(!res);
+ BOOST_VERIFY(0==pthread_mutex_lock(&m));
         }
 
         void unlock()
         {
- int const res=pthread_mutex_unlock(&m);
- BOOST_ASSERT(!res);
+ BOOST_VERIFY(0==pthread_mutex_unlock(&m));
         }
         
         bool try_lock()
@@ -194,8 +183,7 @@
             
             while(is_locked)
             {
- int const cond_res=pthread_cond_wait(&cond,&m);
- BOOST_ASSERT(!cond_res);
+ BOOST_VERIFY(0==pthread_cond_wait(&cond,&m));
             }
             is_locked=true;
             ++count;
@@ -209,8 +197,7 @@
             {
                 is_locked=false;
             }
- int const res=pthread_cond_signal(&cond);
- BOOST_ASSERT(!res);
+ BOOST_VERIFY(0==pthread_cond_signal(&cond));
         }
         
         bool try_lock()

Modified: trunk/libs/thread/src/pthread/thread.cpp
==============================================================================
--- trunk/libs/thread/src/pthread/thread.cpp (original)
+++ trunk/libs/thread/src/pthread/thread.cpp 2007-11-04 12:17:01 EST (Sun, 04 Nov 2007)
@@ -55,8 +55,7 @@
 
             void create_current_thread_tls_key()
             {
- int const res=pthread_key_create(&current_thread_tls_key,NULL);
- BOOST_ASSERT(!res);
+ BOOST_VERIFY(0==pthread_key_create(&current_thread_tls_key,NULL));
             }
         }
         
@@ -69,8 +68,7 @@
         void set_current_thread_data(detail::thread_data_base* new_data)
         {
             boost::call_once(current_thread_tls_init_flag,create_current_thread_tls_key);
- int const res=pthread_setspecific(current_thread_tls_key,new_data);
- BOOST_ASSERT(!res);
+ BOOST_VERIFY(0==pthread_setspecific(current_thread_tls_key,new_data));
         }
     }
     
@@ -172,8 +170,7 @@
             if(do_join)
             {
                 void* result=0;
- int const res=pthread_join(local_thread_info->thread_handle,&result);
- BOOST_ASSERT(!res);
+ BOOST_VERIFY(0==pthread_join(local_thread_info->thread_handle,&result));
                 lock_guard<mutex> lock(local_thread_info->data_mutex);
                 local_thread_info->joined=true;
                 local_thread_info->done_condition.notify_all();
@@ -220,8 +217,7 @@
             if(do_join)
             {
                 void* result=0;
- int const res=pthread_join(local_thread_info->thread_handle,&result);
- BOOST_ASSERT(!res);
+ BOOST_VERIFY(0==pthread_join(local_thread_info->thread_handle,&result));
                 lock_guard<mutex> lock(local_thread_info->data_mutex);
                 local_thread_info->joined=true;
                 local_thread_info->done_condition.notify_all();
@@ -255,8 +251,7 @@
             lock_guard<mutex> lock(local_thread_info->data_mutex);
             if(!local_thread_info->join_started)
             {
- int const res=pthread_detach(local_thread_info->thread_handle);
- BOOST_ASSERT(!res);
+ BOOST_VERIFY(0==pthread_detach(local_thread_info->thread_handle));
                 local_thread_info->join_started=true;
                 local_thread_info->joined=true;
             }
@@ -281,9 +276,7 @@
 # if defined(BOOST_HAS_PTHREAD_DELAY_NP)
                 timespec ts;
                 to_timespec_duration(xt, ts);
- int res = 0;
- res = pthread_delay_np(&ts);
- BOOST_ASSERT(res == 0);
+ BOOST_VERIFY(0==pthread_delay_np(&ts));
 # elif defined(BOOST_HAS_NANOSLEEP)
                 timespec ts;
                 to_timespec_duration(xt, ts);
@@ -308,13 +301,9 @@
     void thread::yield()
     {
 # if defined(BOOST_HAS_SCHED_YIELD)
- int res = 0;
- res = sched_yield();
- BOOST_ASSERT(res == 0);
+ BOOST_VERIFY(0==sched_yield());
 # elif defined(BOOST_HAS_PTHREAD_YIELD)
- int res = 0;
- res = pthread_yield();
- BOOST_ASSERT(res == 0);
+ BOOST_VERIFY(0==pthread_yield());
 # else
         xtime xt;
         xtime_get(&xt, TIME_UTC);
@@ -349,8 +338,7 @@
             local_thread_info->interrupt_requested=true;
             if(local_thread_info->current_cond)
             {
- int const res=pthread_cond_broadcast(local_thread_info->current_cond);
- BOOST_ASSERT(!res);
+ BOOST_VERIFY(0==pthread_cond_broadcast(local_thread_info->current_cond));
             }
         }
     }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk