public inbox for [email protected]  
help / color / mirror / Atom feed
From: Chao Li <[email protected]>
To: Peter Smith <[email protected]>
Cc: Peter Eisentraut <[email protected]>
Cc: Postgres hackers <[email protected]>
Subject: Re: Cleanup shadows variable warnings, round 1
Date: Wed, 3 Dec 2025 14:52:14 +0800
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAHut+PvrcSUabnsuH+77+yEwvjiLHy0XJiLuTtVHWed_MHdwMw@mail.gmail.com>
References: <CAEoWx2kQ2x5gMaj8tHLJ3=jfC+p5YXHkJyHrDTiQw2nn2FJTmQ@mail.gmail.com>
	<[email protected]>
	<CAEoWx2kjuQTQg=ZO76R7yKSj27zEHqehhL15UaK2D=vAw2JgYw@mail.gmail.com>
	<CAHut+PvrcSUabnsuH+77+yEwvjiLHy0XJiLuTtVHWed_MHdwMw@mail.gmail.com>



> On Dec 3, 2025, at 14:42, Peter Smith <[email protected]> wrote:
> 
> Patch v2-0001.
> 
> src/backend/backup/basebackup_incremental.c:
> PrepareForIncrementalBackup:
> 
> Instead of changing the var name from 'i' to 'u', you can fix this one
> by changing all the for loops to declare 'i' within the 'for ('.
> That way kills two birds with one stone: it removes the shadow warning
> and at the same time improves the scope of the loop variables.
> 
> 
> -       int                     i;
> 
> -       for (i = 0; i < num_wal_ranges; ++i)
> +       for (int i = 0; i < num_wal_ranges; ++i)
> 
> -       for (i = 0; i < num_wal_ranges; ++i)
> +       for (int i = 0; i < num_wal_ranges; ++i)
> 
> -       unsigned        i;
> 
> -               for (i = 0; i < nblocks; ++i)
> +               for (unsigned i = 0; i < nblocks; ++i)

Unfortunately that doesn’t work for my compiler (clang on MacOS), that’s why I renamed “I" to “u”.

By the way, Peter (S), thank you very much for reviewing.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/









view thread (30+ messages)  latest in thread

reply

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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected]
  Subject: Re: Cleanup shadows variable warnings, round 1
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox