]> granicus.if.org Git - postgresql/commitdiff
Fix header comment for bitncmp().
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 4 Jan 2014 19:01:51 +0000 (14:01 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 4 Jan 2014 19:01:51 +0000 (14:01 -0500)
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

index f2c337cb8d13e6c489833699dc3d2f916d1bda2d..5e837fab2def2ca4272d04f32a805c782fc76635 100644 (file)
@@ -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.