Re: Cleanup shadows variable warnings, round 1

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: Peter Smith <smithpb2250(at)gmail(dot)com>
Cc: Peter Eisentraut <peter(at)eisentraut(dot)org>, Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Cleanup shadows variable warnings, round 1
Date: 2025-12-03 06:52:14
Message-ID: 94ECEF6E-681B-40DF-8F6B-4CABE4CDB96A@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Dec 3, 2025, at 14:42, Peter Smith <smithpb2250(at)gmail(dot)com> 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/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message jian he 2025-12-03 07:38:56 domain for WITHOUT OVERLAPS
Previous Message Peter Smith 2025-12-03 06:42:33 Re: Cleanup shadows variable warnings, round 1