mirror of
https://github.com/espressif/openthread.git
synced 2026-07-30 23:57:47 +00:00
[ip6] reduce scope of local vars in SelectSourceAddress() (#4377)
This commit is contained in:
+9
-10
@@ -1298,20 +1298,16 @@ exit:
|
||||
|
||||
const NetifUnicastAddress *Ip6::SelectSourceAddress(MessageInfo &aMessageInfo)
|
||||
{
|
||||
Address * destination = &aMessageInfo.GetPeerAddr();
|
||||
const NetifUnicastAddress *rvalAddr = NULL;
|
||||
const Address * candidateAddr;
|
||||
uint8_t rvalPrefixMatched = 0;
|
||||
Address * destination = &aMessageInfo.GetPeerAddr();
|
||||
uint8_t destinationScope = destination->GetScope();
|
||||
const NetifUnicastAddress *rvalAddr = NULL;
|
||||
uint8_t rvalPrefixMatched = 0;
|
||||
|
||||
for (const NetifUnicastAddress *addr = Get<ThreadNetif>().GetUnicastAddresses(); addr; addr = addr->GetNext())
|
||||
{
|
||||
uint8_t overrideScope;
|
||||
uint8_t candidatePrefixMatched;
|
||||
|
||||
candidateAddr = &addr->GetAddress();
|
||||
candidatePrefixMatched = destination->PrefixMatch(*candidateAddr);
|
||||
overrideScope = (candidatePrefixMatched >= addr->mPrefixLength) ? addr->GetScope() : destinationScope;
|
||||
const Address *candidateAddr = &addr->GetAddress();
|
||||
uint8_t candidatePrefixMatched;
|
||||
uint8_t overrideScope;
|
||||
|
||||
if (candidateAddr->IsAnycastRoutingLocator())
|
||||
{
|
||||
@@ -1319,6 +1315,9 @@ const NetifUnicastAddress *Ip6::SelectSourceAddress(MessageInfo &aMessageInfo)
|
||||
continue;
|
||||
}
|
||||
|
||||
candidatePrefixMatched = destination->PrefixMatch(*candidateAddr);
|
||||
overrideScope = (candidatePrefixMatched >= addr->mPrefixLength) ? addr->GetScope() : destinationScope;
|
||||
|
||||
if (rvalAddr == NULL)
|
||||
{
|
||||
// Rule 0: Prefer any address
|
||||
|
||||
Reference in New Issue
Block a user