diff --git a/src/core/net/ip6_routes.cpp b/src/core/net/ip6_routes.cpp index 8919d6546..df54f1f0b 100644 --- a/src/core/net/ip6_routes.cpp +++ b/src/core/net/ip6_routes.cpp @@ -82,7 +82,7 @@ ThreadError Routes::Remove(Route &aRoute) int8_t Routes::Lookup(const Address &aSource, const Address &aDestination) { - uint8_t maxPrefixMatch = 0; + int8_t maxPrefixMatch = -1; uint8_t prefixMatch; int8_t rval = -1; @@ -100,21 +100,21 @@ int8_t Routes::Lookup(const Address &aSource, const Address &aDestination) prefixMatch = cur->mPrefixLength; } - if (maxPrefixMatch > prefixMatch) + if (maxPrefixMatch > static_cast(prefixMatch)) { continue; } - maxPrefixMatch = prefixMatch; + maxPrefixMatch = static_cast(prefixMatch); rval = cur->mInterfaceId; } for (Netif *netif = Netif::GetNetifList(); netif; netif = netif->GetNext()) { if (netif->RouteLookup(aSource, aDestination, &prefixMatch) == kThreadError_None && - prefixMatch > maxPrefixMatch) + static_cast(prefixMatch) > maxPrefixMatch) { - maxPrefixMatch = prefixMatch; + maxPrefixMatch = static_cast(prefixMatch); rval = netif->GetInterfaceId(); } }