From: Michael Tremer Date: Wed, 31 May 2017 22:10:34 +0000 (+0100) Subject: inetcalc: Use memcmp to determine which IP address is higher X-Git-Tag: 009~243 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5439682dc8c341dd92e7c31897c065036d9bd32d;p=network.git inetcalc: Use memcmp to determine which IP address is higher Signed-off-by: Michael Tremer --- diff --git a/src/inetcalc.c b/src/inetcalc.c index cdb4a0f6..d08f0f3a 100644 --- a/src/inetcalc.c +++ b/src/inetcalc.c @@ -206,10 +206,8 @@ static int ip_address_gt(const ip_address_t* a1, const ip_address_t* a2) { if (a1->family != a2->family || a1->prefix != a2->prefix) return -1; - for (unsigned int i = 0; i < 16; i++) { - if (a1->addr.s6_addr[i] > a2->addr.s6_addr[i]) - return 0; - } + if (memcmp(&a1->addr.s6_addr, &a2->addr.s6_addr, sizeof(a1->addr.s6_addr)) > 0) + return 0; return 1; }