]> granicus.if.org Git - postgresql/commitdiff
Fix possibly-uninitialized-variable warning from commit 9556aa01c.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 25 Jan 2019 16:27:44 +0000 (11:27 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 25 Jan 2019 16:27:44 +0000 (11:27 -0500)
Heikki's compiler doesn't complain about end_ptr, apparently,
but mine does.

In passing, I failed to resist the temptation to remove the
no-longer-used fldnum variable, and relocate chunk_len's
declaration to a narrower scope.

src/backend/utils/adt/varlena.c

index f23da4fa1aa249d4213d5fa20426bc851d79fc9c..693ccc5149aac274802b89a28040c750c4923140 100644 (file)
@@ -4613,8 +4613,6 @@ text_to_array_internal(PG_FUNCTION_ARGS)
                 * to search for occurrences of fldsep.
                 */
                TextPositionState state;
-               int                     fldnum;
-               int                     chunk_len;
 
                inputstring_len = VARSIZE_ANY_EXHDR(inputstring);
                fldsep_len = VARSIZE_ANY_EXHDR(fldsep);
@@ -4651,10 +4649,11 @@ text_to_array_internal(PG_FUNCTION_ARGS)
 
                start_ptr = VARDATA_ANY(inputstring);
 
-               for (fldnum = 1;; fldnum++) /* field number is 1 based */
+               for (;;)
                {
                        bool            found;
                        char       *end_ptr;
+                       int                     chunk_len;
 
                        CHECK_FOR_INTERRUPTS();
 
@@ -4663,6 +4662,7 @@ text_to_array_internal(PG_FUNCTION_ARGS)
                        {
                                /* fetch last field */
                                chunk_len = ((char *) inputstring + VARSIZE_ANY(inputstring)) - start_ptr;
+                               end_ptr = NULL; /* not used, but some compilers complain */
                        }
                        else
                        {