Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit cc0e7eb

Browse files
committed
reindexdb: Fix warning about uninitialized indices_tables_cell
Initialize indices_tables_cell with NULL to silence the warning. Also, refactor the place of the first assignment of indices_tables_cell. Reported-by: Thomas Munro, David Rowley, Tom Lane, Richard Guo Discussion: https://postgr.es/m/2348025.1711332418%40sss.pgh.pa.us Discussion: https://postgr.es/m/E1roXs4-005UdX-1V%40gemulon.postgresql.org
1 parent 6190d82 commit cc0e7eb

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/bin/scripts/reindexdb.c

+14-6
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ reindex_one_database(ConnParams *cparams, ReindexType type,
277277
{
278278
PGconn *conn;
279279
SimpleStringListCell *cell;
280-
SimpleStringListCell *indices_tables_cell;
280+
SimpleStringListCell *indices_tables_cell = NULL;
281281
bool parallel = concurrentCons > 1;
282282
SimpleStringList *process_list = user_list;
283283
SimpleStringList *indices_tables_list = NULL;
@@ -366,12 +366,20 @@ reindex_one_database(ConnParams *cparams, ReindexType type,
366366
indices_tables_list = get_parallel_object_list(conn, process_type,
367367
user_list, echo);
368368

369-
if (indices_tables_list)
370-
indices_tables_cell = indices_tables_list->head;
371-
372-
/* Bail out if nothing to process */
373-
if (process_list == NULL)
369+
/*
370+
* Bail out if nothing to process. 'user_list' was modified
371+
* in-place, so check if it has at least one cell.
372+
*/
373+
if (user_list->head == NULL)
374374
return;
375+
376+
/*
377+
* Assuming 'user_list' is not empty, 'indices_tables_list'
378+
* shouldn't be empty as well.
379+
*/
380+
Assert(indices_tables_list != NULL);
381+
indices_tables_cell = indices_tables_list->head;
382+
375383
break;
376384

377385
case REINDEX_SYSTEM:

0 commit comments

Comments
 (0)