From: Tomas Vondra Date: Thu, 8 Jun 2017 16:21:46 +0000 (+0200) Subject: Fix warnings about uninitialized vars in pg_dump.c X-Git-Tag: XL_10_R1BETA1~265^2~12 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=42cc79c34b228da47c45c479f629c7d2035783d2;p=postgres-xl.git Fix warnings about uninitialized vars in pg_dump.c Three XL-specific fields in getTables() were initialized and used in two independent if blocks looking like this: if (fout->isPostgresXL) { i_pgxclocatortype = PQfnumber(res, "pgxclocatortype"); i_pgxcattnum = PQfnumber(res, "pgxcattnum"); i_pgxc_node_names = PQfnumber(res, "pgxc_node_names"); } if (fout->isPostgresXL) { ... use the variables ... } Which however confuses the compiler (gcc 5.3.1) which then complains that the variables are maybe used uninitialized. The fix is simple, just make the initialization unconditional - if there are no such columns then PQfnumber() will return -1, but we'll not use the value anyway. --- diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index a527bfca5d..1d237e3056 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -5930,12 +5930,9 @@ getTables(Archive *fout, int *numTables) i_owning_tab = PQfnumber(res, "owning_tab"); i_owning_col = PQfnumber(res, "owning_col"); #ifdef PGXC - if (fout->isPostgresXL) - { - i_pgxclocatortype = PQfnumber(res, "pgxclocatortype"); - i_pgxcattnum = PQfnumber(res, "pgxcattnum"); - i_pgxc_node_names = PQfnumber(res, "pgxc_node_names"); - } + i_pgxclocatortype = PQfnumber(res, "pgxclocatortype"); + i_pgxcattnum = PQfnumber(res, "pgxcattnum"); + i_pgxc_node_names = PQfnumber(res, "pgxc_node_names"); #endif i_reltablespace = PQfnumber(res, "reltablespace"); i_reloptions = PQfnumber(res, "reloptions");