From cf5a228f7b17d73f1f49e07882ed87a1f7362c99 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 29 Sep 2020 21:53:05 +0900 Subject: [PATCH] network: slightly shorten nexthop_compare_func() --- src/network/networkd-nexthop.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/network/networkd-nexthop.c b/src/network/networkd-nexthop.c index 4f40883e54..03e4bd152a 100644 --- a/src/network/networkd-nexthop.c +++ b/src/network/networkd-nexthop.c @@ -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(