From 0df7f493f8ab5d9878e08ff0019b04be85954a7d Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Sat, 24 Sep 2005 23:07:18 +0000
Subject: [PATCH] Clean up possibly-uninitialized-variable warnings reported by
 gcc 4.x.

---
 contrib/intarray/_int_bool.c | 2 ++
 contrib/ltree/ltxtquery_io.c | 8 ++++----
 contrib/tsearch2/query.c     | 8 ++++----
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/contrib/intarray/_int_bool.c b/contrib/intarray/_int_bool.c
index 06759c44e34..824dc5b6775 100644
--- a/contrib/intarray/_int_bool.c
+++ b/contrib/intarray/_int_bool.c
@@ -58,6 +58,8 @@ gettoken(WORKSTATE * state, int4 *val)
 	char		nnn[16],
 			   *curnnn;
 
+	*val = 0;					/* default result */
+
 	curnnn = nnn;
 	while (1)
 	{
diff --git a/contrib/ltree/ltxtquery_io.c b/contrib/ltree/ltxtquery_io.c
index ade0c4c0332..1f72e719702 100644
--- a/contrib/ltree/ltxtquery_io.c
+++ b/contrib/ltree/ltxtquery_io.c
@@ -197,13 +197,13 @@ pushval_asis(QPRS_STATE * state, int type, char *strval, int lenval, uint16 flag
 static int4
 makepol(QPRS_STATE * state)
 {
-	int4		val,
+	int4		val = 0,
 				type;
-	int4		lenval;
-	char	   *strval;
+	int4		lenval = 0;
+	char	   *strval = NULL;
 	int4		stack[STACKDEPTH];
 	int4		lenstack = 0;
-	uint16		flag;
+	uint16		flag = 0;
 
 	while ((type = gettoken_query(state, &val, &lenval, &strval, &flag)) != END)
 	{
diff --git a/contrib/tsearch2/query.c b/contrib/tsearch2/query.c
index db45de56be1..96812729256 100644
--- a/contrib/tsearch2/query.c
+++ b/contrib/tsearch2/query.c
@@ -317,13 +317,13 @@ pushval_morph(QPRS_STATE * state, int typeval, char *strval, int lenval, int2 we
 static int4
 makepol(QPRS_STATE * state, void (*pushval) (QPRS_STATE *, int, char *, int, int2))
 {
-	int4		val,
+	int4		val = 0,
 				type;
-	int4		lenval;
-	char	   *strval;
+	int4		lenval = 0;
+	char	   *strval = NULL;
 	int4		stack[STACKDEPTH];
 	int4		lenstack = 0;
-	int2		weight;
+	int2		weight = 0;
 
 	while ((type = gettoken_query(state, &val, &lenval, &strval, &weight)) != END)
 	{
-- 
GitLab