mirror of
https://github.com/postgres/postgres.git
synced 2025-06-14 18:42:34 +03:00
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.
This commit is contained in:
@ -682,13 +682,7 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
|
||||
remote_host, sizeof(remote_host),
|
||||
remote_port, sizeof(remote_port),
|
||||
NI_NUMERICHOST | NI_NUMERICSERV);
|
||||
if (ret)
|
||||
{
|
||||
nulls[9] = true;
|
||||
nulls[10] = true;
|
||||
nulls[11] = true;
|
||||
}
|
||||
else
|
||||
if (ret == 0)
|
||||
{
|
||||
clean_ipv6_addr(beentry->st_clientaddr.addr.ss_family, remote_host);
|
||||
values[9] = DirectFunctionCall1(inet_in,
|
||||
@ -699,6 +693,12 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
|
||||
nulls[10] = true;
|
||||
values[11] = Int32GetDatum(atoi(remote_port));
|
||||
}
|
||||
else
|
||||
{
|
||||
nulls[9] = true;
|
||||
nulls[10] = true;
|
||||
nulls[11] = true;
|
||||
}
|
||||
}
|
||||
else if (beentry->st_clientaddr.addr.ss_family == AF_UNIX)
|
||||
{
|
||||
@ -939,7 +939,7 @@ pg_stat_get_backend_client_addr(PG_FUNCTION_ARGS)
|
||||
remote_host, sizeof(remote_host),
|
||||
NULL, 0,
|
||||
NI_NUMERICHOST | NI_NUMERICSERV);
|
||||
if (ret)
|
||||
if (ret != 0)
|
||||
PG_RETURN_NULL();
|
||||
|
||||
clean_ipv6_addr(beentry->st_clientaddr.addr.ss_family, remote_host);
|
||||
@ -988,7 +988,7 @@ pg_stat_get_backend_client_port(PG_FUNCTION_ARGS)
|
||||
NULL, 0,
|
||||
remote_port, sizeof(remote_port),
|
||||
NI_NUMERICHOST | NI_NUMERICSERV);
|
||||
if (ret)
|
||||
if (ret != 0)
|
||||
PG_RETURN_NULL();
|
||||
|
||||
PG_RETURN_DATUM(DirectFunctionCall1(int4in,
|
||||
|
Reference in New Issue
Block a user