network: slightly shorten nexthop_compare_func()

This commit is contained in:
Yu Watanabe 2020-09-29 21:53:05 +09:00
parent 75156ccbdc
commit cf5a228f7b
1 changed files with 3 additions and 12 deletions

View File

@ -125,19 +125,10 @@ static int nexthop_compare_func(const NextHop *a, const NextHop *b) {
if (r != 0)
return r;
switch (a->family) {
case AF_INET:
case AF_INET6:
if (IN_SET(a->family, AF_INET, AF_INET6))
return memcmp(&a->gw, &b->gw, FAMILY_ADDRESS_SIZE(a->family));
r = memcmp(&a->gw, &b->gw, FAMILY_ADDRESS_SIZE(a->family));
if (r != 0)
return r;
return 0;
default:
/* treat any other address family as AF_UNSPEC */
return 0;
}
return 0;
}
DEFINE_HASH_OPS_WITH_KEY_DESTRUCTOR(