From 285020360a4142fb982ad94bb21a0e87275cfed7 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Wed, 13 Sep 2017 16:18:29 +1000 Subject: [PATCH] ctdb-protocol: Factor out static function ctdb_sock_addr_cmp_family() Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- ctdb/protocol/protocol_util.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/ctdb/protocol/protocol_util.c b/ctdb/protocol/protocol_util.c index 3c8c21a472a..b42cf47fbc3 100644 --- a/ctdb/protocol/protocol_util.c +++ b/ctdb/protocol/protocol_util.c @@ -328,11 +328,9 @@ void ctdb_sock_addr_set_port(ctdb_sock_addr *addr, unsigned int port) } } -int ctdb_sock_addr_cmp_ip(const ctdb_sock_addr *addr1, - const ctdb_sock_addr *addr2) +static int ctdb_sock_addr_cmp_family(const ctdb_sock_addr *addr1, + const ctdb_sock_addr *addr2) { - int ret = 0; - /* This is somewhat arbitrary. However, when used for sorting * it just needs to be consistent. */ @@ -343,6 +341,19 @@ int ctdb_sock_addr_cmp_ip(const ctdb_sock_addr *addr1, return 1; } + return 0; +} + +int ctdb_sock_addr_cmp_ip(const ctdb_sock_addr *addr1, + const ctdb_sock_addr *addr2) +{ + int ret; + + ret = ctdb_sock_addr_cmp_family(addr1, addr2); + if (ret != 0) { + return ret; + } + switch (addr1->sa.sa_family) { case AF_INET: ret = memcmp(&addr1->ip.sin_addr.s_addr, -- 2.11.4.GIT