pgsql: Further reduce warnings with -Wshadow=compatible-local

From: David Rowley <drowley(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Further reduce warnings with -Wshadow=compatible-local
Date: 2022-08-24 00:27:36
Message-ID: E1oQeF5-000uzg-NS@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Further reduce warnings with -Wshadow=compatible-local

In a similar effort to f01592f91, here we're targetting fixing the
warnings that -Wshadow=compatible-local produces that we can fix by moving
a variable to an inner scope to stop that variable from being shadowed by
another variable declared somewhere later in the function.

All of the warnings being fixed here are changing the scope of variables
which are being used as an iterator for a "for" loop. In each instance,
the fix happens to be changing the for loop to use the C99 type
initialization. Much of this code likely pre-dates our use of C99.

Reducing the scope of the outer scoped variable seems like the safest way
to fix these. Renaming seems more likely to risk patches using the wrong
variable. Reducing the scope is more likely to result in a compilation
failure after applying some future patch rather than introducing bugs with
it.

By my count, this takes the warning count from 129 down to 114.

Author: Justin Pryzby
Discussion: https://postgr.es/m/CAApHDvrwLGBP%2BYw9vriayyf%3DXR4uPWP5jr6cQhP9au_kaDUhbA%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/421892a192b8f95ab96c5edb61d424f80a4221d0

Modified Files
--------------
src/backend/access/brin/brin.c | 3 +--
src/backend/access/brin/brin_minmax_multi.c | 3 +--
src/backend/access/gist/gist.c | 3 +--
src/backend/commands/copyfrom.c | 3 +--
src/backend/commands/indexcmds.c | 7 +++----
src/backend/executor/nodeAgg.c | 3 +--
src/backend/optimizer/path/costsize.c | 8 ++++----
src/backend/statistics/mcv.c | 11 +++++------
src/backend/storage/buffer/bufmgr.c | 5 ++---
src/bin/pg_dump/pg_dump.c | 3 +--
src/interfaces/ecpg/pgtypeslib/numeric.c | 5 ++---
11 files changed, 22 insertions(+), 32 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2022-08-24 03:57:38 pgsql: Allow parallel workers to retrieve some data from Port
Previous Message Peter Eisentraut 2022-08-23 20:22:12 pgsql: Message style adjustment