Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit927f34c

Browse files
committed
Avoid conflicts with library versions of inet_net_ntop() and friends.
Prefix inet_net_ntop and sibling routines with "pg_" to ensure thatthey aren't mistaken for C-library functions. This fixes warningsfrom cpluspluscheck on some platforms, and should help reduce readerconfusion everywhere, since our functions aren't exactly interchangeablewith the library versions (they may have different ideas about addressfamily codes).This shouldn't be fixing any actual bugs, unless somebody's linkeris misbehaving, so no need to back-patch.Discussion:https://postgr.es/m/20518.1559494394@sss.pgh.pa.us
1 parent232720b commit927f34c

File tree

8 files changed

+39
-38
lines changed

8 files changed

+39
-38
lines changed

‎src/backend/utils/adt/inet_cidr_ntop.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static char *inet_cidr_ntop_ipv6(const u_char *src, int bits,
4444

4545
/*
4646
* char *
47-
*inet_cidr_ntop(af, src, bits, dst, size)
47+
*pg_inet_cidr_ntop(af, src, bits, dst, size)
4848
*convert network number from network to presentation format.
4949
*generates CIDR style result always.
5050
* return:
@@ -53,7 +53,7 @@ static char *inet_cidr_ntop_ipv6(const u_char *src, int bits,
5353
*Paul Vixie (ISC), July 1996
5454
*/
5555
char*
56-
inet_cidr_ntop(intaf,constvoid*src,intbits,char*dst,size_tsize)
56+
pg_inet_cidr_ntop(intaf,constvoid*src,intbits,char*dst,size_tsize)
5757
{
5858
switch (af)
5959
{

‎src/backend/utils/adt/inet_net_pton.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static intinet_cidr_pton_ipv6(const char *src, u_char *dst, size_t size);
4242

4343
/*
4444
* int
45-
*inet_net_pton(af, src, dst, size)
45+
*pg_inet_net_pton(af, src, dst, size)
4646
*convert network number from presentation to network format.
4747
*accepts hex octets, hex strings, decimal octets, and /CIDR.
4848
*"size" is in bytes and describes "dst".
@@ -59,7 +59,7 @@ static intinet_cidr_pton_ipv6(const char *src, u_char *dst, size_t size);
5959
*
6060
*/
6161
int
62-
inet_net_pton(intaf,constchar*src,void*dst,size_tsize)
62+
pg_inet_net_pton(intaf,constchar*src,void*dst,size_tsize)
6363
{
6464
switch (af)
6565
{
@@ -241,7 +241,7 @@ inet_cidr_pton_ipv4(const char *src, u_char *dst, size_t size)
241241

242242
/*
243243
* int
244-
*inet_net_pton(af, src, dst, *bits)
244+
*inet_net_pton_ipv4(af, src, dst, *bits)
245245
*convert network address from presentation to network format.
246246
*accepts inet_pton()'s input for this "af" plus trailing "/CIDR".
247247
*"dst" is assumed large enough for its "af". "bits" is set to the

‎src/backend/utils/adt/network.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ network_in(char *src, bool is_cidr)
9191
else
9292
ip_family(dst)=PGSQL_AF_INET;
9393

94-
bits=inet_net_pton(ip_family(dst),src,ip_addr(dst),
95-
is_cidr ?ip_addrsize(dst) :-1);
94+
bits=pg_inet_net_pton(ip_family(dst),src,ip_addr(dst),
95+
is_cidr ?ip_addrsize(dst) :-1);
9696
if ((bits<0)|| (bits>ip_maxbits(dst)))
9797
ereport(ERROR,
9898
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
@@ -145,8 +145,8 @@ network_out(inet *src, bool is_cidr)
145145
char*dst;
146146
intlen;
147147

148-
dst=inet_net_ntop(ip_family(src),ip_addr(src),ip_bits(src),
149-
tmp,sizeof(tmp));
148+
dst=pg_inet_net_ntop(ip_family(src),ip_addr(src),ip_bits(src),
149+
tmp,sizeof(tmp));
150150
if (dst==NULL)
151151
ereport(ERROR,
152152
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
@@ -1192,8 +1192,8 @@ network_host(PG_FUNCTION_ARGS)
11921192
chartmp[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255/128")];
11931193

11941194
/* force display of max bits, regardless of masklen... */
1195-
if (inet_net_ntop(ip_family(ip),ip_addr(ip),ip_maxbits(ip),
1196-
tmp,sizeof(tmp))==NULL)
1195+
if (pg_inet_net_ntop(ip_family(ip),ip_addr(ip),ip_maxbits(ip),
1196+
tmp,sizeof(tmp))==NULL)
11971197
ereport(ERROR,
11981198
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
11991199
errmsg("could not format inet value: %m")));
@@ -1217,8 +1217,8 @@ network_show(PG_FUNCTION_ARGS)
12171217
intlen;
12181218
chartmp[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255/128")];
12191219

1220-
if (inet_net_ntop(ip_family(ip),ip_addr(ip),ip_maxbits(ip),
1221-
tmp,sizeof(tmp))==NULL)
1220+
if (pg_inet_net_ntop(ip_family(ip),ip_addr(ip),ip_maxbits(ip),
1221+
tmp,sizeof(tmp))==NULL)
12221222
ereport(ERROR,
12231223
(errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
12241224
errmsg("could not format inet value: %m")));
@@ -1240,8 +1240,8 @@ inet_abbrev(PG_FUNCTION_ARGS)
12401240
char*dst;
12411241
chartmp[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255/128")];
12421242

1243-
dst=inet_net_ntop(ip_family(ip),ip_addr(ip),
1244-
ip_bits(ip),tmp,sizeof(tmp));
1243+
dst=pg_inet_net_ntop(ip_family(ip),ip_addr(ip),
1244+
ip_bits(ip),tmp,sizeof(tmp));
12451245

12461246
if (dst==NULL)
12471247
ereport(ERROR,
@@ -1258,8 +1258,8 @@ cidr_abbrev(PG_FUNCTION_ARGS)
12581258
char*dst;
12591259
chartmp[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255/128")];
12601260

1261-
dst=inet_cidr_ntop(ip_family(ip),ip_addr(ip),
1262-
ip_bits(ip),tmp,sizeof(tmp));
1261+
dst=pg_inet_cidr_ntop(ip_family(ip),ip_addr(ip),
1262+
ip_bits(ip),tmp,sizeof(tmp));
12631263

12641264
if (dst==NULL)
12651265
ereport(ERROR,

‎src/include/port.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,8 @@ extern intpg_codepage_to_encoding(UINT cp);
503503
#endif
504504

505505
/* port/inet_net_ntop.c */
506-
externchar*inet_net_ntop(intaf,constvoid*src,intbits,
507-
char*dst,size_tsize);
506+
externchar*pg_inet_net_ntop(intaf,constvoid*src,intbits,
507+
char*dst,size_tsize);
508508

509509
/* port/pg_strong_random.c */
510510
externboolpg_strong_random(void*buf,size_tlen);

‎src/include/utils/builtins.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@ extern void text_to_cstring_buffer(const text *src, char *dst, size_t dst_len);
8787
externintxidComparator(constvoid*arg1,constvoid*arg2);
8888

8989
/* inet_cidr_ntop.c */
90-
externchar*inet_cidr_ntop(intaf,constvoid*src,intbits,
91-
char*dst,size_tsize);
90+
externchar*pg_inet_cidr_ntop(intaf,constvoid*src,intbits,
91+
char*dst,size_tsize);
9292

9393
/* inet_net_pton.c */
94-
externintinet_net_pton(intaf,constchar*src,
95-
void*dst,size_tsize);
94+
externintpg_inet_net_pton(intaf,constchar*src,
95+
void*dst,size_tsize);
9696

9797
/* network.c */
9898
externdoubleconvert_network_to_scalar(Datumvalue,Oidtypid,bool*failure);

‎src/interfaces/libpq/fe-connect.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,19 +1539,19 @@ getHostaddr(PGconn *conn, char *host_addr, int host_addr_len)
15391539

15401540
if (addr->ss_family==AF_INET)
15411541
{
1542-
if (inet_net_ntop(AF_INET,
1543-
&((structsockaddr_in*)addr)->sin_addr.s_addr,
1544-
32,
1545-
host_addr,host_addr_len)==NULL)
1542+
if (pg_inet_net_ntop(AF_INET,
1543+
&((structsockaddr_in*)addr)->sin_addr.s_addr,
1544+
32,
1545+
host_addr,host_addr_len)==NULL)
15461546
host_addr[0]='\0';
15471547
}
15481548
#ifdefHAVE_IPV6
15491549
elseif (addr->ss_family==AF_INET6)
15501550
{
1551-
if (inet_net_ntop(AF_INET6,
1552-
&((structsockaddr_in6*)addr)->sin6_addr.s6_addr,
1553-
128,
1554-
host_addr,host_addr_len)==NULL)
1551+
if (pg_inet_net_ntop(AF_INET6,
1552+
&((structsockaddr_in6*)addr)->sin6_addr.s6_addr,
1553+
128,
1554+
host_addr,host_addr_len)==NULL)
15551555
host_addr[0]='\0';
15561556
}
15571557
#endif

‎src/port/getaddrinfo.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,10 @@ getnameinfo(const struct sockaddr *sa, int salen,
387387
{
388388
if (sa->sa_family==AF_INET)
389389
{
390-
if (inet_net_ntop(AF_INET,&((structsockaddr_in*)sa)->sin_addr,
391-
sa->sa_family==AF_INET ?32 :128,
392-
node,nodelen)==NULL)
390+
if (pg_inet_net_ntop(AF_INET,
391+
&((structsockaddr_in*)sa)->sin_addr,
392+
sa->sa_family==AF_INET ?32 :128,
393+
node,nodelen)==NULL)
393394
returnEAI_MEMORY;
394395
}
395396
else

‎src/port/inet_net_ntop.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static const char rcsid[] = "Id: inet_net_ntop.c,v 1.1.2.2 2004/03/09 09:17:27 m
3636
#else
3737
/*
3838
* In a frontend build, we can't include inet.h, but we still need to have
39-
* sensible definitions of these two constants. Note thatinet_net_ntop()
39+
* sensible definitions of these two constants. Note thatpg_inet_net_ntop()
4040
* assumes that PGSQL_AF_INET is equal to AF_INET.
4141
*/
4242
#definePGSQL_AF_INET(AF_INET + 0)
@@ -61,20 +61,20 @@ static char *inet_net_ntop_ipv6(const u_char *src, int bits,
6161

6262
/*
6363
* char *
64-
*inet_net_ntop(af, src, bits, dst, size)
64+
*pg_inet_net_ntop(af, src, bits, dst, size)
6565
*convert host/network address from network to presentation format.
6666
*"src"'s size is determined from its "af".
6767
* return:
6868
*pointer to dst, or NULL if an error occurred (check errno).
6969
* note:
7070
*192.5.5.1/28 has a nonzero host part, which means it isn't a network
71-
*as called for byinet_net_pton() but it can be a host address with
71+
*as called for bypg_inet_net_pton() but it can be a host address with
7272
*an included netmask.
7373
* author:
7474
*Paul Vixie (ISC), October 1998
7575
*/
7676
char*
77-
inet_net_ntop(intaf,constvoid*src,intbits,char*dst,size_tsize)
77+
pg_inet_net_ntop(intaf,constvoid*src,intbits,char*dst,size_tsize)
7878
{
7979
/*
8080
* We need to cover both the address family constants used by the PG inet

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp