Fix misplaced right paren bugs in pgstatfuncs.c.
Fix misplaced right paren bugs in pgstatfuncs.c.

The bug would only show up if the C sockaddr structure contained
zero in the first byte for a valid address; otherwise it would
fail to fail, which is probably why it went unnoticed for so long.

Patch submitted by Joel Jacobson after seeing an article by Andrey
Karpov in which he reports finding this through static code
analysis using PVS-Studio.  While I was at it I moved a definition
of a local variable referenced in the buggy code to a more local
context.

Backpatch to all supported branches.

ashwinstar/gpdb,adam8157/gpdb,jmcatamney/gpdb,xinzweb/gpdb,lisakowen/gpdb,50wu/gpdb,xinzweb/gpdb,jmcatamney/gpdb,50wu/gpdb,jmcatamney/gpdb,jmcatamney/gpdb,lisakowen/gpdb,greenplum-db/gpdb,greenplum-db/gpdb,ashwinstar/gpdb,adam8157/gpdb,xinzweb/gpdb,jmcatamney/gpdb,50wu/gpdb,jmcatamney/gpdb,xinzweb/gpdb,ashwinstar/gpdb,greenplum-db/gpdb,xinzweb/gpdb,lisakowen/gpdb,adam8157/gpdb,lisakowen/gpdb,50wu/gpdb,adam8157/gpdb,jmcatamney/gpdb,ashwinstar/gpdb,adam8157/gpdb,lisakowen/gpdb,greenplum-db/gpdb,50wu/gpdb,adam8157/gpdb,greenplum-db/gpdb,lisakowen/gpdb,jmcatamney/gpdb,xinzweb/gpdb,xinzweb/gpdb,50wu/gpdb,lisakowen/gpdb,50wu/gpdb,greenplum-db/gpdb,greenplum-db/gpdb,lisakowen/gpdb,xinzweb/gpdb,adam8157/gpdb,50wu/gpdb,ashwinstar/gpdb,ashwinstar/gpdb,ashwinstar/gpdb,greenplum-db/gpdb,ashwinstar/gpdb,adam8157/gpdb