From b0b6a792e3f764921bd43fb43737ea7eca257e68 Mon Sep 17 00:00:00 2001 From: Christopher Dykes Date: Mon, 23 Oct 2017 19:26:29 -0700 Subject: [PATCH] Prefer bool literals rather than integers in boolean contexts Summary: Via clang-tidy's modernize-use-bool-literals Reviewed By: yfeldblum Differential Revision: D6130384 fbshipit-source-id: 359d5195897f04612c9b9042cf69383050a2ec7a --- folly/executors/CPUThreadPoolExecutor.cpp | 2 +- folly/executors/ThreadPoolExecutor.cpp | 2 +- folly/io/async/AsyncSSLSocket.cpp | 8 ++++---- folly/test/ConcurrentSkipListBenchmark.cpp | 4 ++-- folly/test/FBStringTest.cpp | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/folly/executors/CPUThreadPoolExecutor.cpp b/folly/executors/CPUThreadPoolExecutor.cpp index 3c50a299..a7c8520b 100644 --- a/folly/executors/CPUThreadPoolExecutor.cpp +++ b/folly/executors/CPUThreadPoolExecutor.cpp @@ -113,7 +113,7 @@ void CPUThreadPoolExecutor::threadRun(std::shared_ptr thread) { this->threadPoolHook_.registerThread(); thread->startupBaton.post(); - while (1) { + while (true) { auto task = taskQueue_->take(); if (UNLIKELY(task.poison)) { CHECK(threadsToStop_-- > 0); diff --git a/folly/executors/ThreadPoolExecutor.cpp b/folly/executors/ThreadPoolExecutor.cpp index 84394db0..bacf3c28 100644 --- a/folly/executors/ThreadPoolExecutor.cpp +++ b/folly/executors/ThreadPoolExecutor.cpp @@ -214,7 +214,7 @@ void ThreadPoolExecutor::StoppedThreadQueue::add( } ThreadPoolExecutor::ThreadPtr ThreadPoolExecutor::StoppedThreadQueue::take() { - while (1) { + while (true) { { std::lock_guard guard(mutex_); if (queue_.size() > 0) { diff --git a/folly/io/async/AsyncSSLSocket.cpp b/folly/io/async/AsyncSSLSocket.cpp index 2001f306..0cb7c73a 100644 --- a/folly/io/async/AsyncSSLSocket.cpp +++ b/folly/io/async/AsyncSSLSocket.cpp @@ -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. diff --git a/folly/test/ConcurrentSkipListBenchmark.cpp b/folly/test/ConcurrentSkipListBenchmark.cpp index 762c6f5c..51f9a9f7 100644 --- a/folly/test/ConcurrentSkipListBenchmark.cpp +++ b/folly/test/ConcurrentSkipListBenchmark.cpp @@ -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]); } diff --git a/folly/test/FBStringTest.cpp b/folly/test/FBStringTest.cpp index 08e22608..9f51947a 100644 --- a/folly/test/FBStringTest.cpp +++ b/folly/test/FBStringTest.cpp @@ -1018,7 +1018,7 @@ TEST(FBString, testAllClauses) { void(*f_fbstring)(folly::fbstring&), void(*f_wfbstring)(folly::basic_fbstring&)) { do { - if (1) { + if (true) { } else { EXPECT_TRUE(1) << "Testing clause " << clause; } -- 2.34.1