From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
Date: Fri, 9 Jun 2017 18:50:35 +0000 (+0300)
Subject: Silence warning about uninitialized 'ret' variable on some compilers.
X-Git-Tag: REL_10_BETA2~191
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=493490cbcb19c5232038827b114a4ec72aa3e731;p=postgresql

Silence warning about uninitialized 'ret' variable on some compilers.

If the compiler doesn't notice that the switch-statement handles all
possible values of the enum, it might complain that 'ret' is being used
without initialization. Jeff Janes reported that on gcc 4.4.7.

Discussion: https://www.postgresql.org/message-id/CAMkU=1x31RvP+cpooFbmc8K8nt-gNO8woGFhXcgQYYZ5ozYpFA@mail.gmail.com
---

diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index c1dfa5eb97..7a339d67ef 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -1668,6 +1668,7 @@ connectDBStart(PGconn *conn)
 		snprintf(portstr, sizeof(portstr), "%d", thisport);
 
 		/* Use pg_getaddrinfo_all() to resolve the address */
+		ret = 1;
 		switch (ch->type)
 		{
 			case CHT_HOST_NAME: