]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: slightly shorten nexthop_compare_func()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 29 Sep 2020 12:53:05 +0000 (21:53 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 6 Oct 2020 17:39:51 +0000 (02:39 +0900)
src/network/networkd-nexthop.c

index 4f40883e54343108ba94d012df6273f03b34ffc2..03e4bd152a38359f5f4ca8bb13f1233b455a6dc9 100644 (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(