Further reduce warnings with -Wshadow=compatible-local
authorDavid Rowley <[email protected]>
Wed, 24 Aug 2022 00:27:12 +0000 (12:27 +1200)
committerDavid Rowley <[email protected]>
Wed, 24 Aug 2022 00:27:12 +0000 (12:27 +1200)
commit421892a192b8f95ab96c5edb61d424f80a4221d0
tree74b077cee1c0c21fef0faec5ff0a63d050f991ca
parent869e56a39976a42a393adc2d69df3abce7eff18f
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
src/backend/access/brin/brin.c
src/backend/access/brin/brin_minmax_multi.c
src/backend/access/gist/gist.c
src/backend/commands/copyfrom.c
src/backend/commands/indexcmds.c
src/backend/executor/nodeAgg.c
src/backend/optimizer/path/costsize.c
src/backend/statistics/mcv.c
src/backend/storage/buffer/bufmgr.c
src/bin/pg_dump/pg_dump.c
src/interfaces/ecpg/pgtypeslib/numeric.c