pgsql: Fix -Wshadow=local warnings

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix -Wshadow=local warnings
Date: 2026-09-08 07:13:08
Message-ID: E1x3q0x-00000003xFK-2bZl@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix -Wshadow=local warnings

This fixes issues with the same variable name being used in the same
function for two different variables. (In some cases, one of the uses
is a function argument.) The fix is in most cases to rename one or
both of them. The individual choice depends on conventions in the
surrounding code. Often, making both variable names more specific is
the best choice. In a few cases, the fix is to move one of the
variables to a lower scope, so that it no longer conflicts with the
other.

Since these are all local-variable conflicts, the changes in different
files in this patch are independent of each other.

These issues correspond to the gcc warning option -Wshadow=local,
which is not currently used but could be activated after this.

Reviewed-by: Peter Geoghegan <pg(at)bowt(dot)ie>
Reviewed-by: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Discussion: https://www.postgresql.org/message-id/flat/84b6f128-91f5-480e-8a9e-7d0e8f538cea%40eisentraut.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/f9fc9a78a36517122c0325fd31db5ba6066d82ea

Modified Files
--------------
contrib/postgres_fdw/postgres_fdw.c | 22 ++---
src/backend/access/brin/brin.c | 8 +-
src/backend/access/gist/gistbuild.c | 16 ++--
src/backend/catalog/objectaddress.c | 30 +++---
src/backend/catalog/pg_constraint.c | 32 +++----
src/backend/commands/extension.c | 8 +-
src/backend/commands/schemacmds.c | 4 +-
src/backend/commands/statscmds.c | 6 +-
src/backend/commands/tablecmds.c | 14 +--
src/backend/commands/trigger.c | 12 +--
src/backend/executor/nodeAgg.c | 16 ++--
src/backend/executor/nodeValuesscan.c | 4 +-
src/backend/optimizer/path/equivclass.c | 6 +-
src/backend/optimizer/plan/createplan.c | 44 ++++-----
src/backend/partitioning/partdesc.c | 12 +--
src/backend/statistics/dependencies.c | 30 +++---
src/backend/statistics/extended_stats.c | 6 +-
src/backend/storage/aio/read_stream.c | 14 +--
src/backend/storage/buffer/bufmgr.c | 14 +--
src/backend/utils/adt/jsonpath_exec.c | 48 +++++-----
src/backend/utils/adt/pg_upgrade_support.c | 6 +-
src/backend/utils/adt/timestamp.c | 20 ++--
src/backend/utils/adt/varlena.c | 20 ++--
src/backend/utils/cache/inval.c | 48 +++++-----
src/backend/utils/mmgr/freepage.c | 42 ++++-----
src/bin/pg_basebackup/pg_receivewal.c | 6 +-
src/bin/pgbench/pgbench.c | 62 ++++++------
src/bin/psql/describe.c | 18 ++--
src/bin/psql/prompt.c | 39 ++++----
src/bin/psql/prompt.h | 2 +-
src/fe_utils/print.c | 22 ++---
src/include/lib/radixtree.h | 16 ++--
src/include/optimizer/paths.h | 2 +-
src/include/storage/sinval.h | 4 +-
.../ecpg/test/expected/pgtypeslib-num_test2.c | 3 +-
src/interfaces/ecpg/test/pgtypeslib/num_test2.pgc | 3 +-
src/interfaces/libpq/fe-connect.c | 12 ++-
src/interfaces/libpq/fe-secure-openssl.c | 104 ++++++++++-----------
38 files changed, 393 insertions(+), 382 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2026-09-08 07:49:57 pgsql: Stabilize 026_overwrite_contrecord test
Previous Message Amit Kapila 2026-09-08 05:22:48 pgsql: Fix buildfarm failure introduced by 6168c65ddc.