From 827999354ff3d2a2ce52be135c5b784817ac342e Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Thu, 24 Mar 2022 16:53:00 -0400 Subject: [PATCH] Apply most of readability-simplify-boolean-expr from clang-tidy (#16635) --- .../chip-tool/commands/common/CHIPCommand.cpp | 2 +- examples/chip-tool/commands/common/Commands.cpp | 10 +++++----- .../commands/discovery/DiscoveryCommands.cpp | 2 +- src/lib/asn1/ASN1Reader.cpp | 2 +- src/lib/dnssd/Resolver.h | 17 ++++------------- src/platform/Linux/ConnectivityUtils.cpp | 2 +- 6 files changed, 13 insertions(+), 22 deletions(-) diff --git a/examples/chip-tool/commands/common/CHIPCommand.cpp b/examples/chip-tool/commands/common/CHIPCommand.cpp index b09b4d993fefc3..6edcda0252ac6e 100644 --- a/examples/chip-tool/commands/common/CHIPCommand.cpp +++ b/examples/chip-tool/commands/common/CHIPCommand.cpp @@ -133,7 +133,7 @@ void CHIPCommand::StartTracing() { chip::trace::SetTraceStream(new chip::trace::TraceStreamFile(mTraceFile.Value())); } - else if (mTraceLog.HasValue() && mTraceLog.Value() == true) + else if (mTraceLog.HasValue() && mTraceLog.Value()) { chip::trace::SetTraceStream(new chip::trace::TraceStreamLog()); } diff --git a/examples/chip-tool/commands/common/Commands.cpp b/examples/chip-tool/commands/common/Commands.cpp index e6b98bc0662b40..0e444768ac5739 100644 --- a/examples/chip-tool/commands/common/Commands.cpp +++ b/examples/chip-tool/commands/common/Commands.cpp @@ -227,23 +227,23 @@ void Commands::ShowCluster(std::string executable, std::string clusterName, Comm if (IsGlobalCommand(command->GetName())) { - if (strcmp(command->GetName(), "read") == 0 && readCommand == false) + if (strcmp(command->GetName(), "read") == 0 && !readCommand) { readCommand = true; } - else if (strcmp(command->GetName(), "write") == 0 && writeCommand == false) + else if (strcmp(command->GetName(), "write") == 0 && !writeCommand) { writeCommand = true; } - else if (strcmp(command->GetName(), "subscribe") == 0 && subscribeCommand == false) + else if (strcmp(command->GetName(), "subscribe") == 0 && !subscribeCommand) { subscribeCommand = true; } - else if (strcmp(command->GetName(), "read-event") == 0 && readEventCommand == false) + else if (strcmp(command->GetName(), "read-event") == 0 && !readEventCommand) { readEventCommand = true; } - else if (strcmp(command->GetName(), "subscribe-event") == 0 && subscribeEventCommand == false) + else if (strcmp(command->GetName(), "subscribe-event") == 0 && !subscribeEventCommand) { subscribeEventCommand = true; } diff --git a/src/app/tests/suites/commands/discovery/DiscoveryCommands.cpp b/src/app/tests/suites/commands/discovery/DiscoveryCommands.cpp index 1af491838f20e0..71be49564599f8 100644 --- a/src/app/tests/suites/commands/discovery/DiscoveryCommands.cpp +++ b/src/app/tests/suites/commands/discovery/DiscoveryCommands.cpp @@ -98,7 +98,7 @@ CHIP_ERROR DiscoveryCommands::SetupDiscoveryCommands() { ReturnErrorOnFailure(TearDownDiscoveryCommands()); - if (mReady == false) + if (!mReady) { ReturnErrorOnFailure(mDNSResolver.Init(chip::DeviceLayer::UDPEndPointManager())); mReady = true; diff --git a/src/lib/asn1/ASN1Reader.cpp b/src/lib/asn1/ASN1Reader.cpp index a6aaec2548b3a8..b45f32daeb2244 100644 --- a/src/lib/asn1/ASN1Reader.cpp +++ b/src/lib/asn1/ASN1Reader.cpp @@ -297,7 +297,7 @@ CHIP_ERROR ASN1Reader::DecodeHead() mHeadLen = static_cast(p - mElemStart); - EndOfContents = (Class == kASN1TagClass_Universal && Tag == 0 && Constructed == false && ValueLen == 0); + EndOfContents = (Class == kASN1TagClass_Universal && Tag == 0 && !Constructed && ValueLen == 0); Value = p; diff --git a/src/lib/dnssd/Resolver.h b/src/lib/dnssd/Resolver.h index 8984790d9f9326..f8298e41809b05 100644 --- a/src/lib/dnssd/Resolver.h +++ b/src/lib/dnssd/Resolver.h @@ -71,12 +71,8 @@ struct ResolvedNodeData // If either retry interval (Idle - CRI, Active - CRA) has a value and that value is greater // than the value passed to this function, then the peer device will be treated as if it is // a Sleepy End Device (SED) - if ((mMrpRetryIntervalIdle.HasValue() && (mMrpRetryIntervalIdle.Value() > defaultMRPConfig->mIdleRetransTimeout)) || - (mMrpRetryIntervalActive.HasValue() && (mMrpRetryIntervalActive.Value() > defaultMRPConfig->mActiveRetransTimeout))) - { - return true; - } - return false; + return (mMrpRetryIntervalIdle.HasValue() && (mMrpRetryIntervalIdle.Value() > defaultMRPConfig->mIdleRetransTimeout)) || + (mMrpRetryIntervalActive.HasValue() && (mMrpRetryIntervalActive.Value() > defaultMRPConfig->mActiveRetransTimeout)); } PeerId mPeerId; @@ -156,13 +152,8 @@ struct DiscoveredNodeData // If either retry interval (Idle - CRI, Active - CRA) has a value and that value is greater // than the value passed to this function, then the peer device will be treated as if it is // a Sleepy End Device (SED) - if ((mrpRetryIntervalIdle.HasValue() && (mrpRetryIntervalIdle.Value() > defaultMRPConfig->mIdleRetransTimeout)) || - (mrpRetryIntervalActive.HasValue() && (mrpRetryIntervalActive.Value() > defaultMRPConfig->mActiveRetransTimeout))) - - { - return true; - } - return false; + return (mrpRetryIntervalIdle.HasValue() && (mrpRetryIntervalIdle.Value() > defaultMRPConfig->mIdleRetransTimeout)) || + (mrpRetryIntervalActive.HasValue() && (mrpRetryIntervalActive.Value() > defaultMRPConfig->mActiveRetransTimeout)); } void LogDetail() const diff --git a/src/platform/Linux/ConnectivityUtils.cpp b/src/platform/Linux/ConnectivityUtils.cpp index ac8206cb9f2440..8f9b43613fe24d 100644 --- a/src/platform/Linux/ConnectivityUtils.cpp +++ b/src/platform/Linux/ConnectivityUtils.cpp @@ -632,7 +632,7 @@ CHIP_ERROR ConnectivityUtils::GetEthFullDuplex(const char * ifname, bool & fullD } else { - fullDuplex = (ecmd.duplex == DUPLEX_FULL) ? true : false; + fullDuplex = ecmd.duplex == DUPLEX_FULL; err = CHIP_NO_ERROR; }