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

Commitf4a9da0

Browse files
committed
Use clearer notation for getnameinfo() return handling
Writing if (getnameinfo(...)) handle_error();reads quite strangely, so use something like if (getnameinfo(...) != 0) handle_error();instead.
1 parent77949a2 commitf4a9da0

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

‎src/backend/libpq/hba.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ check_hostname(hbaPort *port, const char *hostname)
569569
if (pg_getnameinfo_all(&port->raddr.addr,port->raddr.salen,
570570
remote_hostname,sizeof(remote_hostname),
571571
NULL,0,
572-
0))
572+
0)!=0)
573573
return false;
574574

575575
port->remote_hostname=pstrdup(remote_hostname);

‎src/backend/postmaster/postmaster.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3357,14 +3357,14 @@ BackendInitialize(Port *port)
33573357
if (pg_getnameinfo_all(&port->raddr.addr,port->raddr.salen,
33583358
remote_host,sizeof(remote_host),
33593359
remote_port,sizeof(remote_port),
3360-
(log_hostname ?0 :NI_NUMERICHOST) |NI_NUMERICSERV))
3360+
(log_hostname ?0 :NI_NUMERICHOST) |NI_NUMERICSERV)!=0)
33613361
{
33623362
intret=pg_getnameinfo_all(&port->raddr.addr,port->raddr.salen,
33633363
remote_host,sizeof(remote_host),
33643364
remote_port,sizeof(remote_port),
33653365
NI_NUMERICHOST |NI_NUMERICSERV);
33663366

3367-
if (ret)
3367+
if (ret!=0)
33683368
ereport(WARNING,
33693369
(errmsg_internal("pg_getnameinfo_all() failed: %s",
33703370
gai_strerror(ret))));

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ inet_client_addr(PG_FUNCTION_ARGS)
10931093
remote_host,sizeof(remote_host),
10941094
NULL,0,
10951095
NI_NUMERICHOST |NI_NUMERICSERV);
1096-
if (ret)
1096+
if (ret!=0)
10971097
PG_RETURN_NULL();
10981098

10991099
clean_ipv6_addr(port->raddr.addr.ss_family,remote_host);
@@ -1132,7 +1132,7 @@ inet_client_port(PG_FUNCTION_ARGS)
11321132
NULL,0,
11331133
remote_port,sizeof(remote_port),
11341134
NI_NUMERICHOST |NI_NUMERICSERV);
1135-
if (ret)
1135+
if (ret!=0)
11361136
PG_RETURN_NULL();
11371137

11381138
PG_RETURN_DATUM(DirectFunctionCall1(int4in,CStringGetDatum(remote_port)));
@@ -1169,7 +1169,7 @@ inet_server_addr(PG_FUNCTION_ARGS)
11691169
local_host,sizeof(local_host),
11701170
NULL,0,
11711171
NI_NUMERICHOST |NI_NUMERICSERV);
1172-
if (ret)
1172+
if (ret!=0)
11731173
PG_RETURN_NULL();
11741174

11751175
clean_ipv6_addr(port->laddr.addr.ss_family,local_host);
@@ -1208,7 +1208,7 @@ inet_server_port(PG_FUNCTION_ARGS)
12081208
NULL,0,
12091209
local_port,sizeof(local_port),
12101210
NI_NUMERICHOST |NI_NUMERICSERV);
1211-
if (ret)
1211+
if (ret!=0)
12121212
PG_RETURN_NULL();
12131213

12141214
PG_RETURN_DATUM(DirectFunctionCall1(int4in,CStringGetDatum(local_port)));

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -682,13 +682,7 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
682682
remote_host,sizeof(remote_host),
683683
remote_port,sizeof(remote_port),
684684
NI_NUMERICHOST |NI_NUMERICSERV);
685-
if (ret)
686-
{
687-
nulls[9]= true;
688-
nulls[10]= true;
689-
nulls[11]= true;
690-
}
691-
else
685+
if (ret==0)
692686
{
693687
clean_ipv6_addr(beentry->st_clientaddr.addr.ss_family,remote_host);
694688
values[9]=DirectFunctionCall1(inet_in,
@@ -699,6 +693,12 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
699693
nulls[10]= true;
700694
values[11]=Int32GetDatum(atoi(remote_port));
701695
}
696+
else
697+
{
698+
nulls[9]= true;
699+
nulls[10]= true;
700+
nulls[11]= true;
701+
}
702702
}
703703
elseif (beentry->st_clientaddr.addr.ss_family==AF_UNIX)
704704
{
@@ -939,7 +939,7 @@ pg_stat_get_backend_client_addr(PG_FUNCTION_ARGS)
939939
remote_host,sizeof(remote_host),
940940
NULL,0,
941941
NI_NUMERICHOST |NI_NUMERICSERV);
942-
if (ret)
942+
if (ret!=0)
943943
PG_RETURN_NULL();
944944

945945
clean_ipv6_addr(beentry->st_clientaddr.addr.ss_family,remote_host);
@@ -988,7 +988,7 @@ pg_stat_get_backend_client_port(PG_FUNCTION_ARGS)
988988
NULL,0,
989989
remote_port,sizeof(remote_port),
990990
NI_NUMERICHOST |NI_NUMERICSERV);
991-
if (ret)
991+
if (ret!=0)
992992
PG_RETURN_NULL();
993993

994994
PG_RETURN_DATUM(DirectFunctionCall1(int4in,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp