diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2019-08-18 19:27:23 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2019-08-18 19:27:23 -0400 |
commit | 927f34ce8a215c8b254136f710cca9ca4da1352c (patch) | |
tree | 08193b74ccd8c5afa2d9f37f0d99c1fbb5ad0f00 /src/backend/utils/adt | |
parent | 232720be9b6412ec2b6bee405299bcbbbe700f0b (diff) | |
download | postgresql-927f34ce8a215c8b254136f710cca9ca4da1352c.tar.gz postgresql-927f34ce8a215c8b254136f710cca9ca4da1352c.zip |
Avoid conflicts with library versions of inet_net_ntop() and friends.
Prefix inet_net_ntop and sibling routines with "pg_" to ensure that
they aren't mistaken for C-library functions. This fixes warnings
from cpluspluscheck on some platforms, and should help reduce reader
confusion everywhere, since our functions aren't exactly interchangeable
with the library versions (they may have different ideas about address
family codes).
This shouldn't be fixing any actual bugs, unless somebody's linker
is misbehaving, so no need to back-patch.
Discussion: https://postgr.es/m/20518.1559494394@sss.pgh.pa.us
Diffstat (limited to 'src/backend/utils/adt')
-rw-r--r-- | src/backend/utils/adt/inet_cidr_ntop.c | 4 | ||||
-rw-r--r-- | src/backend/utils/adt/inet_net_pton.c | 6 | ||||
-rw-r--r-- | src/backend/utils/adt/network.c | 24 |
3 files changed, 17 insertions, 17 deletions
diff --git a/src/backend/utils/adt/inet_cidr_ntop.c b/src/backend/utils/adt/inet_cidr_ntop.c index 3000b1735d0..5f74c05a65d 100644 --- a/src/backend/utils/adt/inet_cidr_ntop.c +++ b/src/backend/utils/adt/inet_cidr_ntop.c @@ -44,7 +44,7 @@ static char *inet_cidr_ntop_ipv6(const u_char *src, int bits, /* * char * - * inet_cidr_ntop(af, src, bits, dst, size) + * pg_inet_cidr_ntop(af, src, bits, dst, size) * convert network number from network to presentation format. * generates CIDR style result always. * return: @@ -53,7 +53,7 @@ static char *inet_cidr_ntop_ipv6(const u_char *src, int bits, * Paul Vixie (ISC), July 1996 */ char * -inet_cidr_ntop(int af, const void *src, int bits, char *dst, size_t size) +pg_inet_cidr_ntop(int af, const void *src, int bits, char *dst, size_t size) { switch (af) { diff --git a/src/backend/utils/adt/inet_net_pton.c b/src/backend/utils/adt/inet_net_pton.c index c28809fad68..d3221a13139 100644 --- a/src/backend/utils/adt/inet_net_pton.c +++ b/src/backend/utils/adt/inet_net_pton.c @@ -42,7 +42,7 @@ static int inet_cidr_pton_ipv6(const char *src, u_char *dst, size_t size); /* * int - * inet_net_pton(af, src, dst, size) + * pg_inet_net_pton(af, src, dst, size) * convert network number from presentation to network format. * accepts hex octets, hex strings, decimal octets, and /CIDR. * "size" is in bytes and describes "dst". @@ -59,7 +59,7 @@ static int inet_cidr_pton_ipv6(const char *src, u_char *dst, size_t size); * */ int -inet_net_pton(int af, const char *src, void *dst, size_t size) +pg_inet_net_pton(int af, const char *src, void *dst, size_t size) { switch (af) { @@ -241,7 +241,7 @@ emsgsize: /* * int - * inet_net_pton(af, src, dst, *bits) + * inet_net_pton_ipv4(af, src, dst, *bits) * convert network address from presentation to network format. * accepts inet_pton()'s input for this "af" plus trailing "/CIDR". * "dst" is assumed large enough for its "af". "bits" is set to the diff --git a/src/backend/utils/adt/network.c b/src/backend/utils/adt/network.c index 6b367644f90..3d536a16629 100644 --- a/src/backend/utils/adt/network.c +++ b/src/backend/utils/adt/network.c @@ -91,8 +91,8 @@ network_in(char *src, bool is_cidr) else ip_family(dst) = PGSQL_AF_INET; - bits = inet_net_pton(ip_family(dst), src, ip_addr(dst), - is_cidr ? ip_addrsize(dst) : -1); + bits = pg_inet_net_pton(ip_family(dst), src, ip_addr(dst), + is_cidr ? ip_addrsize(dst) : -1); if ((bits < 0) || (bits > ip_maxbits(dst))) ereport(ERROR, (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), @@ -145,8 +145,8 @@ network_out(inet *src, bool is_cidr) char *dst; int len; - dst = inet_net_ntop(ip_family(src), ip_addr(src), ip_bits(src), - tmp, sizeof(tmp)); + dst = pg_inet_net_ntop(ip_family(src), ip_addr(src), ip_bits(src), + tmp, sizeof(tmp)); if (dst == NULL) ereport(ERROR, (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION), @@ -1192,8 +1192,8 @@ network_host(PG_FUNCTION_ARGS) char tmp[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255/128")]; /* force display of max bits, regardless of masklen... */ - if (inet_net_ntop(ip_family(ip), ip_addr(ip), ip_maxbits(ip), - tmp, sizeof(tmp)) == NULL) + if (pg_inet_net_ntop(ip_family(ip), ip_addr(ip), ip_maxbits(ip), + tmp, sizeof(tmp)) == NULL) ereport(ERROR, (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION), errmsg("could not format inet value: %m"))); @@ -1217,8 +1217,8 @@ network_show(PG_FUNCTION_ARGS) int len; char tmp[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255/128")]; - if (inet_net_ntop(ip_family(ip), ip_addr(ip), ip_maxbits(ip), - tmp, sizeof(tmp)) == NULL) + if (pg_inet_net_ntop(ip_family(ip), ip_addr(ip), ip_maxbits(ip), + tmp, sizeof(tmp)) == NULL) ereport(ERROR, (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION), errmsg("could not format inet value: %m"))); @@ -1240,8 +1240,8 @@ inet_abbrev(PG_FUNCTION_ARGS) char *dst; char tmp[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255/128")]; - dst = inet_net_ntop(ip_family(ip), ip_addr(ip), - ip_bits(ip), tmp, sizeof(tmp)); + dst = pg_inet_net_ntop(ip_family(ip), ip_addr(ip), + ip_bits(ip), tmp, sizeof(tmp)); if (dst == NULL) ereport(ERROR, @@ -1258,8 +1258,8 @@ cidr_abbrev(PG_FUNCTION_ARGS) char *dst; char tmp[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255/128")]; - dst = inet_cidr_ntop(ip_family(ip), ip_addr(ip), - ip_bits(ip), tmp, sizeof(tmp)); + dst = pg_inet_cidr_ntop(ip_family(ip), ip_addr(ip), + ip_bits(ip), tmp, sizeof(tmp)); if (dst == NULL) ereport(ERROR, |