From: David Rowley <drowley@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Further reduce warnings with -Wshadow=compatible-local
Date: Wed, 24 Aug 2022 00:27:36 +0000
Message-ID: <E1oQeF5-000uzg-NS@gemulon.postgresql.org> (raw)
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(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: drowley@postgresql.org
Subject: Re: pgsql: Further reduce warnings with -Wshadow=compatible-local
In-Reply-To: <E1oQeF5-000uzg-NS@gemulon.postgresql.org>
References: <E1oQeF5-000uzg-NS@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox