[tcp6] use range-based for when iterating over lists (#7479)

This commit is contained in:
Abtin Keshavarzian
2022-03-14 12:19:04 -07:00
committed by GitHub
parent 15a9c4c0bd
commit 4dddcb673c
+5 -5
View File
@@ -645,21 +645,21 @@ bool Tcp::CanBind(const SockAddr &aSockName)
uint16_t port = HostSwap16(aSockName.mPort);
bool allowed = false;
for (Endpoint *endpoint = mEndpoints.GetHead(); endpoint != nullptr; endpoint = endpoint->GetNext())
for (Endpoint &endpoint : mEndpoints)
{
struct tcpcb *tp = &endpoint->GetTcb();
struct tcpcb *tp = &endpoint.GetTcb();
if (tp->lport == port)
{
VerifyOrExit(!aSockName.GetAddress().IsUnspecified());
VerifyOrExit(!reinterpret_cast<Address *>(&tp->laddr)->IsUnspecified());
VerifyOrExit(memcmp(&endpoint->GetTcb().laddr, &aSockName.mAddress, sizeof(tp->laddr)) != 0);
VerifyOrExit(memcmp(&endpoint.GetTcb().laddr, &aSockName.mAddress, sizeof(tp->laddr)) != 0);
}
}
for (Listener *listener = mListeners.GetHead(); listener != nullptr; listener = listener->GetNext())
for (Listener &listener : mListeners)
{
struct tcpcb_listen *tpl = &listener->GetTcbListen();
struct tcpcb_listen *tpl = &listener.GetTcbListen();
if (tpl->lport == port)
{