Skip to content

Commit

Permalink
Fix clang warnings -Wunreachable-code (#17865)
Browse files Browse the repository at this point in the history
../../third_party/connectedhomeip/src/transport/raw/TCP.cpp:236:63: error: code will never be executed [-Werror,-Wunreachable-code]
    endPoint->mAppState            = reinterpret_cast<void *>(this);
                                                              ^~~~
1 error generated.
  • Loading branch information
mspang authored and pull[bot] committed Oct 2, 2023
1 parent 0bf19aa commit 2063465
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/transport/raw/TCP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,11 @@ CHIP_ERROR TCPBase::SendAfterConnect(const PeerAddress & addr, System::PacketBuf
// Ensures sufficient active connections size exist
VerifyOrReturnError(mUsedEndPointCount < mActiveConnectionsSize, CHIP_ERROR_NO_MEMORY);

Inet::TCPEndPoint * endPoint = nullptr;
#if INET_CONFIG_ENABLE_TCP_ENDPOINT
Inet::TCPEndPoint * endPoint = nullptr;
ReturnErrorOnFailure(mListenSocket->GetEndPointManager().NewEndPoint(&endPoint));
auto EndPointDeletor = [](Inet::TCPEndPoint * e) { e->Free(); };
std::unique_ptr<Inet::TCPEndPoint, decltype(EndPointDeletor)> endPointHolder(endPoint, EndPointDeletor);
#else
return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
#endif

endPoint->mAppState = reinterpret_cast<void *>(this);
endPoint->OnDataReceived = OnTcpReceive;
Expand All @@ -247,11 +244,12 @@ CHIP_ERROR TCPBase::SendAfterConnect(const PeerAddress & addr, System::PacketBuf
VerifyOrReturnError(mPendingPackets.CreateObject(addr, std::move(msg)) != nullptr, CHIP_ERROR_NO_MEMORY);
mUsedEndPointCount++;

#if INET_CONFIG_ENABLE_TCP_ENDPOINT
endPointHolder.release();
#endif

return CHIP_NO_ERROR;
#else
return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
#endif
}

CHIP_ERROR TCPBase::ProcessReceivedBuffer(Inet::TCPEndPoint * endPoint, const PeerAddress & peerAddress,
Expand Down

0 comments on commit 2063465

Please sign in to comment.