pgsql: postgres_fdw: Fix "may be used uninitialized" warning in foreign - Mailing list pgsql-committers

From Alexander Korotkov
Subject pgsql: postgres_fdw: Fix "may be used uninitialized" warning in foreign
Date
Msg-id E1x1kQ4-00000003BAd-1GfK@gemulon.postgresql.org
Whole thread
List pgsql-committers
postgres_fdw: Fix "may be used uninitialized" warning in foreign_join_ok()

Commit 0ee83dd4a99 detected the mixed foreign x function-RTE cases in one
if/else chain that only set a pair of bool flags, then acted on those flags in
a second chain.  fpinfo_o and fpinfo_i are each assigned in one chain and read
in the other, so proving them initialized requires correlating the flags with
the assignments.  gcc 13 with -Og does not manage that and reports fpinfo_i as
possibly uninitialized; clang's -Wconditional-uninitialized likewise reports
both variables.

The flags served no purpose beyond deferring the work, so merge the two chains
and read both fdw_private pointers up front, unconditionally.  A function rel
never has an fdw_private of its own, so the pointer is simply NULL until the
stub replaces it, and each branch now assigns and uses the two variables in one
place.

Reported-by: Karina Litskevich <litskevichkarina@gmail.com>
Reported-by: Marina Polyakova <m.polyakova@postgrespro.ru>
Reviewed-by: Marina Polyakova <m.polyakova@postgrespro.ru>
Discussion: https://postgr.es/m/CACiT8iamoL-%3D792e6JK2uCVvwDhfCg7DXHhvqN0P33jhGg2-8A%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/0fb258d1f2ca65b7299ba7c47045634df05efbff

Modified Files
--------------
contrib/postgres_fdw/postgres_fdw.c | 53 +++++++++++++------------------------
1 file changed, 19 insertions(+), 34 deletions(-)


pgsql-committers by date:

Previous
From: Fujii Masao
Date:
Subject: pgsql: Fix checkpointer restartpoint assertion failure
Next
From: Fujii Masao
Date:
Subject: pgsql: Stabilize recovery conflict stats checks in 031_recovery_conflic