Re: Cleanup shadows variable warnings, round 1

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Cleanup shadows variable warnings, round 1
Date: 2025-12-03 10:56:33
Message-ID: CAEoWx2nhiC5gOZP90KZkUnaB2HcEEj3AnRzxw6piBC03r1XGFg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Dec 3, 2025 at 10:28 AM Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> wrote:

>
> 0001 - simple cases of local variable shadowing local variable by changing
> inner variable to for loop variable (also need to rename the for loop var)
> 0002 - simple cases of local variable shadowing local variable by renaming
> inner variable
> 0003 - simple cases of local variable shadowing local variable by renaming
> outer variable. In this commit, outer local variables are used much less
> than inner variables, thus renaming outer is simpler than renaming inner.
> 0004 - still local shadows local, but caused by a macro definition, only
> in inval.c
> 0005 - cases of global wal_level and wal_segment_size shadow local ones,
> fixed by renaming local variables
> 0006 - in xlogrecovery.c, some static file-scope variables shadow local
> variables, fixed by renaming local variables
> 0007 - cases of global progname shadows local, fixed by renaming local to
> myprogname
> 0008 - in file_ops.c, some static file-scope variables shadow local, fixed
> by renaming local variables
> 0009 - simple cases of local variables are shadowed by global, fixed by
> renaming local variables
> 0010 - a few more cases of static file-scope variables shadow local
> variables, fixed by renaming local variables
> 0011 - cases of global conn shadows local variables, fixed by renaming
> local conn to myconn
> 0012 - fixed shadowing in ecpg.header
> 0013 - fixed shadowing in all time-related modules. Heikki had a concern
> where there is a global named “days”, so there could be some discussions
> for this commit. For now, I just renamed local variables to avoid shadowing.
>
>
c252d37d8 fixed one shadow warning individually, which caused a conflict to
this patch, thus rebased to v3.

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

Attachment Content-Type Size
v3-0001-cleanup-rename-loop-variables-to-avoid-local-shad.patch application/octet-stream 2.9 KB
v3-0002-cleanup-rename-inner-variables-to-avoid-shadowing.patch application/octet-stream 36.0 KB
v3-0003-cleanup-rename-outer-variables-to-avoid-shadowing.patch application/octet-stream 6.4 KB
v3-0005-cleanup-avoid-local-wal_level-and-wal_segment_siz.patch application/octet-stream 3.5 KB
v3-0004-cleanup-fix-macro-induced-variable-shadowing-in-i.patch application/octet-stream 6.1 KB
v3-0008-cleanup-avoid-local-variables-shadowed-by-static-.patch application/octet-stream 4.0 KB
v3-0006-cleanup-avoid-local-variables-shadowed-by-static-.patch application/octet-stream 13.6 KB
v3-0009-cleanup-avoid-local-variables-shadowed-by-globals.patch application/octet-stream 6.8 KB
v3-0007-cleanup-rename-local-progname-variables-to-avoid-.patch application/octet-stream 25.4 KB
v3-0010-cleanup-avoid-local-variables-shadowed-by-static-.patch application/octet-stream 5.4 KB
v3-0011-cleanup-rename-local-conn-variables-to-avoid-shad.patch application/octet-stream 30.4 KB
v3-0012-cleanup-avoid-local-variables-shadowed-by-globals.patch application/octet-stream 2.5 KB
v3-0013-cleanup-avoid-local-variables-shadowed-by-globals.patch application/octet-stream 20.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Zhijie Hou (Fujitsu) 2025-12-03 10:57:03 RE: Fix START_REPLICATION failure with publication names containing backslashes
Previous Message Peter Eisentraut 2025-12-03 10:54:39 Re: List TAP test files in makefiles