From a3406d98f4eb6dc2757f54681db4e02fe773decf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Mon, 30 May 2022 11:13:25 +0200 Subject: [PATCH] lib/utils nit: deduplicate one line --- lib/utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/utils.c b/lib/utils.c index 5d89e28c3..b54b019d3 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -596,6 +596,7 @@ int kr_straddr_subnet(void *dst, const char *addr) int family = kr_straddr_family(addr); if (family != AF_INET && family != AF_INET6) return kr_error(EINVAL); + const int max_len = (family == AF_INET6) ? 128 : 32; auto_free char *addr_str = strdup(addr); char *subnet = strchr(addr_str, '/'); if (subnet) { @@ -603,13 +604,12 @@ int kr_straddr_subnet(void *dst, const char *addr) subnet += 1; bit_len = strtol(subnet, NULL, 10); /* Check client subnet length */ - const int max_len = (family == AF_INET6) ? 128 : 32; if (bit_len < 0 || bit_len > max_len) { return kr_error(ERANGE); } } else { /* No subnet, use maximal subnet length. */ - bit_len = (family == AF_INET6) ? 128 : 32; + bit_len = max_len; } /* Parse address */ int ret = inet_pton(family, addr_str, dst); -- 2.47.2