-- more assert fixes for thrift concurrency

Reviewed By: mcslee


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665074 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/concurrency/Monitor.cpp b/lib/cpp/src/concurrency/Monitor.cpp
index 955fe9a..2443a6e 100644
--- a/lib/cpp/src/concurrency/Monitor.cpp
+++ b/lib/cpp/src/concurrency/Monitor.cpp
@@ -33,10 +33,10 @@
     
     try {
       int ret = pthread_mutex_init(&pthread_mutex_, NULL);
-      assert(ret);
+      assert(ret == 0);
       mutexInitialized_ = true;
       ret = pthread_cond_init(&pthread_cond_, NULL);
-      assert(ret);
+      assert(ret == 0);
       condInitialized_ = true;
     } catch(...) {
       cleanup();
@@ -52,11 +52,10 @@
   void wait(long long timeout) const {
 
     // XXX Need to assert that caller owns mutex
-    bool bret = (timeout >= 0LL);
-    assert(bret);
+    assert(timeout >= 0LL);
     if (timeout == 0LL) {
       int iret = pthread_cond_wait(&pthread_cond_, &pthread_mutex_);
-      assert(iret);
+      assert(iret == 0);
     } else {
       struct timespec abstime;
       long long now = Util::currentTime();
@@ -65,8 +64,7 @@
                                           &pthread_mutex_,
                                           &abstime);
       if (result == ETIMEDOUT) {
-        bret = (Util::currentTime() >= (now + timeout));
-	assert(bret);
+	assert(Util::currentTime() >= (now + timeout));
       }
     }
   }
@@ -74,13 +72,13 @@
   void notify() {
     // XXX Need to assert that caller owns mutex
     int iret = pthread_cond_signal(&pthread_cond_);
-    assert(iret);
+    assert(iret == 0);
   }
 
   void notifyAll() {
     // XXX Need to assert that caller owns mutex
     int iret = pthread_cond_broadcast(&pthread_cond_);
-    assert(iret);
+    assert(iret == 0);
   }
 
  private:
@@ -89,13 +87,13 @@
     if (mutexInitialized_) {
       mutexInitialized_ = false;
       int iret = pthread_mutex_destroy(&pthread_mutex_);
-      assert(iret);
+      assert(iret == 0);
     }
 
     if (condInitialized_) {
       condInitialized_ = false;
       int iret = pthread_cond_destroy(&pthread_cond_);
-      assert(iret);
+      assert(iret == 0);
     }
   }
 
diff --git a/lib/cpp/src/concurrency/Mutex.cpp b/lib/cpp/src/concurrency/Mutex.cpp
index 0f650a1..5993ea1 100644
--- a/lib/cpp/src/concurrency/Mutex.cpp
+++ b/lib/cpp/src/concurrency/Mutex.cpp
@@ -21,7 +21,7 @@
  public:
   impl() : initialized_(false) {
     int ret = pthread_mutex_init(&pthread_mutex_, NULL);
-    assert(ret);
+    assert(ret == 0);
     initialized_ = true;
   }
 
@@ -29,7 +29,7 @@
     if (initialized_) {
       initialized_ = false;
       int ret = pthread_mutex_destroy(&pthread_mutex_);
-      assert(ret);
+      assert(ret == 0);
     }
   }
 
diff --git a/lib/cpp/src/concurrency/PosixThreadFactory.cpp b/lib/cpp/src/concurrency/PosixThreadFactory.cpp
index a043418..972c1c1 100644
--- a/lib/cpp/src/concurrency/PosixThreadFactory.cpp
+++ b/lib/cpp/src/concurrency/PosixThreadFactory.cpp
@@ -69,31 +69,31 @@
 
     pthread_attr_t thread_attr;
     int ret = pthread_attr_init(&thread_attr);
-    assert(ret);
+    assert(ret == 0);
 
     ret = pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_JOINABLE);
-    assert(ret);
+    assert(ret == 0);
 
     // Set thread stack size
     ret = pthread_attr_setstacksize(&thread_attr, MB * stackSize_);
-    assert(ret);
+    assert(ret == 0);
 
     // Set thread policy
     ret = pthread_attr_setschedpolicy(&thread_attr, policy_);
-    assert(ret);
+    assert(ret == 0);
 
     struct sched_param sched_param;
     sched_param.sched_priority = priority_;
 
     // Set thread priority
     ret = pthread_attr_setschedparam(&thread_attr, &sched_param);
-    assert(ret);
+    assert(ret == 0);
 
     // Create reference
     shared_ptr<PthreadThread>* selfRef = new shared_ptr<PthreadThread>();
     *selfRef = self_.lock();
     ret = pthread_create(&pthread_, &thread_attr, threadMain, (void*)selfRef);
-    assert(ret);
+    assert(ret == 0);
   }
 
   void join() {
@@ -108,8 +108,7 @@
   void runnable(shared_ptr<Runnable> value) { Thread::runnable(value); }
 
   void weakRef(shared_ptr<PthreadThread> self) {
-    bool ret = (self.get() == this);
-    assert(ret);
+    assert(self.get() == this);
     self_ = weak_ptr<PthreadThread>(self);
   }
 };
diff --git a/lib/cpp/src/concurrency/TimerManager.cpp b/lib/cpp/src/concurrency/TimerManager.cpp
index 6ab0e76..050885d 100644
--- a/lib/cpp/src/concurrency/TimerManager.cpp
+++ b/lib/cpp/src/concurrency/TimerManager.cpp
@@ -96,8 +96,7 @@
 	  if (!manager_->taskMap_.empty()) {
             timeout = manager_->taskMap_.begin()->first - now;
 	  }
-          bool ret = (timeout != 0 && manager_->taskCount_ > 0) || (timeout == 0 && manager_->taskCount_ == 0);
-          assert(ret);
+          assert((timeout != 0 && manager_->taskCount_ > 0) || (timeout == 0 && manager_->taskCount_ == 0));
           manager_->monitor_.wait(timeout);
 	  now = Util::currentTime();
 	}
@@ -183,8 +182,7 @@
     while (state_ == TimerManager::STARTING) {
       monitor_.wait();
     }
-    bool ret = (state_ != TimerManager::STARTING);
-    assert(ret);
+    assert(state_ != TimerManager::STARTING);
   }
 }
 
diff --git a/lib/cpp/src/concurrency/Util.h b/lib/cpp/src/concurrency/Util.h
index de4d578..fe12b49 100644
--- a/lib/cpp/src/concurrency/Util.h
+++ b/lib/cpp/src/concurrency/Util.h
@@ -68,7 +68,7 @@
 #if defined(HAVE_CLOCK_GETTIME)
     struct timespec now;
     int ret = clock_gettime(CLOCK_REALTIME, &now);
-    assert(ret);
+    assert(ret == 0);
     return
       (now.tv_sec * MS_PER_S) +
       (now.tv_nsec / NS_PER_MS) +
@@ -76,7 +76,7 @@
 #elif defined(HAVE_GETTIMEOFDAY)
     struct timeval now;
     int ret = gettimeofday(&now, NULL);
-    assert(ret);
+    assert(ret == 0);
     return
       (((long long)now.tv_sec) * MS_PER_S) +
       (now.tv_usec / MS_PER_S) +