mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-03-07 19:47:50 +08:00
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.
This commit is contained in:
parent
9929975666
commit
5858cf8ab2
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user