Commit 3c6f1f78 authored by Rosen Penev's avatar Rosen Penev Committed by Facebook Github Bot

Simplify boolean expressions (#1301)

Summary:
Found with readability-simplify-boolean-expr
Signed-off-by: default avatarRosen Penev <rosenp@gmail.com>
Pull Request resolved: https://github.com/facebook/folly/pull/1301

Reviewed By: yfeldblum

Differential Revision: D19302630

Pulled By: Orvid

fbshipit-source-id: 9833e4ab3fe93592fa8f868f6ed2d56a263949fe
parent 26dd59cd
......@@ -282,10 +282,7 @@ bool IPAddressV6::isIPv4Mapped() const {
}
}
// check if bytes 11 and 12 are 255
if (by[10] == 0xff && by[11] == 0xff) {
return true;
}
return false;
return by[10] == 0xff && by[11] == 0xff;
}
// public
......
......@@ -312,10 +312,7 @@ bool StreamCodec::uncompressStream(
MutableByteRange& output,
StreamCodec::FlushOp flushOp) {
if (state_ == State::RESET && input.empty()) {
if (uncompressedLength().value_or(0) == 0) {
return true;
}
return false;
return uncompressedLength().value_or(0) == 0;
}
// Handle input state transitions
if (state_ == State::RESET) {
......
......@@ -1020,14 +1020,16 @@ bool AsyncSSLSocket::willBlock(
// Register for read event if not already.
updateEventRegistration(EventHandler::READ, EventHandler::WRITE);
return true;
} else if (error == SSL_ERROR_WANT_WRITE) {
}
if (error == SSL_ERROR_WANT_WRITE) {
VLOG(3) << "AsyncSSLSocket(fd=" << fd_ << ", state=" << int(state_)
<< ", sslState=" << sslState_ << ", events=" << eventFlags_ << "): "
<< "SSL_ERROR_WANT_WRITE";
// Register for write event if not already.
updateEventRegistration(EventHandler::WRITE, EventHandler::READ);
return true;
} else if ((false
}
if ((false
#ifdef SSL_ERROR_WANT_ASYNC // OpenSSL 1.1.0 Async API
|| error == SSL_ERROR_WANT_ASYNC
#endif
......@@ -1964,7 +1966,7 @@ void AsyncSSLSocket::getSSLClientCiphers(
bool convertToString) const {
std::string ciphers;
if (parseClientHello_ == false ||
if (!parseClientHello_ ||
clientHelloInfo_->clientHelloCipherSuites_.empty()) {
clientCiphers = "";
return;
......
......@@ -733,7 +733,7 @@ NetworkSocket AsyncServerSocket::createSocket(int family) {
* TOS derived from the client's connect request
*/
void AsyncServerSocket::setTosReflect(bool enable) {
if (!kIsLinux || enable == false) {
if (!kIsLinux || !enable) {
tosReflect_ = false;
return;
}
......
......@@ -895,7 +895,7 @@ bool AsyncSocket::setZeroCopy(bool enable) {
ret = netops::getsockopt(fd_, SOL_SOCKET, SO_ZEROCOPY, &val, &optlen);
if (!ret) {
enable = val ? true : false;
enable = val != 0;
}
}
......
......@@ -517,13 +517,10 @@ bool SSLContext::setRandomizedAdvertisedNextProtocols(
// Client cannot really use randomized alpn
// Note that this function reverses the typical return value convention
// of openssl and returns 0 on success.
if (SSL_CTX_set_alpn_protos(
return SSL_CTX_set_alpn_protos(
ctx_,
advertisedNextProtocols_[0].protocols,
advertisedNextProtocols_[0].length) != 0) {
return false;
}
return true;
advertisedNextProtocols_[0].length) == 0;
}
void SSLContext::deleteNextProtocolsStrings() {
......
......@@ -288,11 +288,7 @@ bool checkTimeout(
// On x86 Linux, sleep calls generally have precision only to the nearest
// millisecond. The tolerance parameter lets users allow a few ms of slop.
auto overrun = effectiveElapsedTime - expected;
if (overrun > tolerance) {
return false;
}
return true;
return overrun <= tolerance;
}
} // namespace folly
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment