From 5858cf8ab2c7a186fab050725992d6ef640e38a5 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 4 Jan 2014 14:01:51 -0500 Subject: [PATCH] Fix header comment for bitncmp(). The result is an int less than, equal to, or greater than zero, in the style of memcmp (and, in fact, exactly the output of memcmp in some cases). This comment previously said -1, 1, or 0, which was an overspecification, as noted by Emre Hasegeli. All of the existing callers appear to be fine with the actual behavior, so just fix the comment. In passing, improve infelicitous formatting of some call sites. --- src/backend/utils/adt/network.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/backend/utils/adt/network.c b/src/backend/utils/adt/network.c index f2c337cb8d..5e837fab2d 100644 --- a/src/backend/utils/adt/network.c +++ b/src/backend/utils/adt/network.c @@ -544,8 +544,8 @@ network_sub(PG_FUNCTION_ARGS) if (ip_family(a1) == ip_family(a2)) { - PG_RETURN_BOOL(ip_bits(a1) > ip_bits(a2) - && bitncmp(ip_addr(a1), ip_addr(a2), ip_bits(a2)) == 0); + PG_RETURN_BOOL(ip_bits(a1) > ip_bits(a2) && + bitncmp(ip_addr(a1), ip_addr(a2), ip_bits(a2)) == 0); } PG_RETURN_BOOL(false); @@ -559,8 +559,8 @@ network_subeq(PG_FUNCTION_ARGS) if (ip_family(a1) == ip_family(a2)) { - PG_RETURN_BOOL(ip_bits(a1) >= ip_bits(a2) - && bitncmp(ip_addr(a1), ip_addr(a2), ip_bits(a2)) == 0); + PG_RETURN_BOOL(ip_bits(a1) >= ip_bits(a2) && + bitncmp(ip_addr(a1), ip_addr(a2), ip_bits(a2)) == 0); } PG_RETURN_BOOL(false); @@ -574,8 +574,8 @@ network_sup(PG_FUNCTION_ARGS) if (ip_family(a1) == ip_family(a2)) { - PG_RETURN_BOOL(ip_bits(a1) < ip_bits(a2) - && bitncmp(ip_addr(a1), ip_addr(a2), ip_bits(a1)) == 0); + PG_RETURN_BOOL(ip_bits(a1) < ip_bits(a2) && + bitncmp(ip_addr(a1), ip_addr(a2), ip_bits(a1)) == 0); } PG_RETURN_BOOL(false); @@ -589,8 +589,8 @@ network_supeq(PG_FUNCTION_ARGS) if (ip_family(a1) == ip_family(a2)) { - PG_RETURN_BOOL(ip_bits(a1) <= ip_bits(a2) - && bitncmp(ip_addr(a1), ip_addr(a2), ip_bits(a1)) == 0); + PG_RETURN_BOOL(ip_bits(a1) <= ip_bits(a2) && + bitncmp(ip_addr(a1), ip_addr(a2), ip_bits(a1)) == 0); } PG_RETURN_BOOL(false); @@ -955,7 +955,7 @@ convert_network_to_scalar(Datum value, Oid typid) * bitncmp(l, r, n) * compare bit masks l and r, for n bits. * return: - * -1, 1, or 0 in the libc tradition. + * <0, >0, or 0 in the libc tradition. * note: * network byte order assumed. this means 192.5.5.240/28 has * 0x11110000 in its fourth octet. -- 2.40.0