Prefer bool literals rather than integers in boolean contexts
authorChristopher Dykes <cdykes@fb.com>
Tue, 24 Oct 2017 02:26:29 +0000 (19:26 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 24 Oct 2017 02:35:08 +0000 (19:35 -0700)
Summary: Via clang-tidy's modernize-use-bool-literals

Reviewed By: yfeldblum

Differential Revision: D6130384

fbshipit-source-id: 359d5195897f04612c9b9042cf69383050a2ec7a

folly/executors/CPUThreadPoolExecutor.cpp
folly/executors/ThreadPoolExecutor.cpp
folly/io/async/AsyncSSLSocket.cpp
folly/test/ConcurrentSkipListBenchmark.cpp
folly/test/FBStringTest.cpp

index 3c50a29985bd41aa219229dc0d1854af731e07b8..a7c8520bfe93c605ace4445d0cb7ffb8590b2dcb 100644 (file)
@@ -113,7 +113,7 @@ void CPUThreadPoolExecutor::threadRun(std::shared_ptr<Thread> thread) {
   this->threadPoolHook_.registerThread();
 
   thread->startupBaton.post();
-  while (1) {
+  while (true) {
     auto task = taskQueue_->take();
     if (UNLIKELY(task.poison)) {
       CHECK(threadsToStop_-- > 0);
index 84394db0059bd396cb2f68387a5a929c2d2685b9..bacf3c28f4842b3fc92402dd0757949d733083c2 100644 (file)
@@ -214,7 +214,7 @@ void ThreadPoolExecutor::StoppedThreadQueue::add(
 }
 
 ThreadPoolExecutor::ThreadPtr ThreadPoolExecutor::StoppedThreadQueue::take() {
-  while (1) {
+  while (true) {
     {
       std::lock_guard<std::mutex> guard(mutex_);
       if (queue_.size() > 0) {
index 2001f30684ab86580cbf209a709db100e614d846..0cb7c73ac649b898c2967e808fa51283f5161f33 100644 (file)
@@ -965,14 +965,14 @@ bool AsyncSSLSocket::willBlock(int ret,
     // The timeout (if set) keeps running here
     return true;
 #endif
-  } else if ((0
+  } else if ((false
 #ifdef SSL_ERROR_WANT_RSA_ASYNC_PENDING
-      || error == SSL_ERROR_WANT_RSA_ASYNC_PENDING
+              || error == SSL_ERROR_WANT_RSA_ASYNC_PENDING
 #endif
 #ifdef SSL_ERROR_WANT_ECDSA_ASYNC_PENDING
-      || error == SSL_ERROR_WANT_ECDSA_ASYNC_PENDING
+              || error == SSL_ERROR_WANT_ECDSA_ASYNC_PENDING
 #endif
-      )) {
+              )) {
     // Our custom openssl function has kicked off an async request to do
     // rsa/ecdsa private key operation.  When that call returns, a callback will
     // be invoked that will re-call handleAccept.
index 762c6f5cf569376a96ad04041c06821f6e54cb2e..51f9a9f7b47df75ed50cd0d4fb0f8b40d39e9898 100644 (file)
@@ -446,7 +446,7 @@ class ConcurrentAccessData {
         } else {
           skipListInsert(0, writeValues_[t]);
         }
-        return 0;
+        return false;
       default:
         return skipListFind(0, readValues_[t]);
     }
@@ -465,7 +465,7 @@ class ConcurrentAccessData {
         } else {
           setInsert(idx, writeValues_[t]);
         }
-        return 0;
+        return false;
       default:
         return setFind(idx, readValues_[t]);
     }
index 08e22608078df07217b1bb0da89120ffe40e2da7..9f51947af6c855bc88f92f749818712523b18cbf 100644 (file)
@@ -1018,7 +1018,7 @@ TEST(FBString, testAllClauses) {
                void(*f_fbstring)(folly::fbstring&),
                void(*f_wfbstring)(folly::basic_fbstring<wchar_t>&)) {
     do {
-      if (1) {
+      if (true) {
       } else {
         EXPECT_TRUE(1) << "Testing clause " << clause;
       }