Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vQobm-000yaR-03 for pgsql-hackers@arkaria.postgresql.org; Wed, 03 Dec 2025 15:17:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vQobl-00E1DB-04 for pgsql-hackers@arkaria.postgresql.org; Wed, 03 Dec 2025 15:17:33 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vQobk-00E1D0-1x for pgsql-hackers@lists.postgresql.org; Wed, 03 Dec 2025 15:17:33 +0000 Received: from fhigh-b8-smtp.messagingengine.com ([202.12.124.159]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vQobi-002wg0-0p for pgsql-hackers@lists.postgresql.org; Wed, 03 Dec 2025 15:17:32 +0000 Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.stl.internal (Postfix) with ESMTP id 6ABDF7A0050; Wed, 3 Dec 2025 10:17:30 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Wed, 03 Dec 2025 10:17:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1764775050; x=1764861450; bh=z3CJwD9u4m3LCG6c7/XSsfX0mBadJPjaI7vs9PnaPAI=; b= J46AmyFFYJvWL067t0fKFfDLfGIdoTWg1eQAH+x0gxxGSjGRERTaGuZESobTznbj 7dl8r1KUYOrDFigcJN42ka7M7f14jOtVkrzGS3AblcsAJRVQ9btwO3yjyHO/cOZM 54O6ot1+5M7JHy19NjwPUspnHgIJFpL6cHm4XeaFT4dH0saxCXRbuDRtGFFFPSG7 lhut/p7GzWJW7OibuoRAB+gvfqdHUyEZiIIWc0GNvC21FGU4GaqIoQyiVwD8WQbt hy4juLPwKHFhASdCioMjXTOvd+YiM2Hhliox0J19LuQDw62u/YILLle3fdQdcsyQ 0HizRSoc9iMRxyDjTMLn3Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1764775050; x= 1764861450; bh=z3CJwD9u4m3LCG6c7/XSsfX0mBadJPjaI7vs9PnaPAI=; b=P lj1oQV3xgYRj6w9LehrCPKWzkVZDaRSOTrXPenGTywK5NuMTbr66HW6g0XmaPgL5 JLhs9b6ijUm77Cd1Fd4jFfmuP7sXx+HRAPY2IjnuxdsmQE7VQpBmFjCydn58kqYB Vx0th6BtIdK0uDNQCNeWoKWb0Eso2HgsakHFjEItNuR0JPoCQK+6DqSzwFu9V2J+ nqBDLmbmUdR0HeNgZKhwsn83cqAMUQ/vH/bD3yZ4L34V6sYEE4cm/eZS7v9PZVgm 3NGT6cdpznOX9CGfhAK/xp15bCWQmff1U1lb2kHkKKXHaPFpHyiw4V4jFr6RXBCt UsBpr8Kk1fLeg0atCPi+w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdefudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceurghi lhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurh epfffhvfevuffkfhggtggugfgjsehtkefstddttdejnecuhfhrohhmpeetnhgurhgvshcu hfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucggtffrrghtth gvrhhnpeeluefgueegfeevvddttddtieegveelkeetgfeuhefhvdfhueetudehhfdtgffg ieenucffohhmrghinhepphhoshhtghhrrdgvshenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpegrnhgurhgvshesrghnrghrrgiivghlrdguvgdp nhgspghrtghpthhtohepfedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepphgvth gvrhesvghishgvnhhtrhgruhhtrdhorhhgpdhrtghpthhtoheplhhirdgvvhgrnhdrtghh rghosehgmhgrihhlrdgtohhmpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrsheslh hishhtshdrphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 3 Dec 2025 10:17:29 -0500 (EST) Date: Wed, 3 Dec 2025 10:17:28 -0500 From: Andres Freund To: Chao Li Cc: Peter Eisentraut , Postgres hackers Subject: Re: Cleanup shadows variable warnings, round 1 Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2025-12-03 10:28:36 +0800, Chao Li wrote: > I know -Wshadow=compatible-local is not supported by all compilers, some > compilers may fallback to -Wshadow and some may just ignore it. This patch > set has cleaned up all shadow-variable warnings, once the cleanup is done, > in theory, we should be able to enable -Wshadow. > > 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. This seems like a *lot* of noise / backpatching pain for relatively little gain. > From 0cddee282a08c79214fa72a21a548b73cc6256fe Mon Sep 17 00:00:00 2001 > From: "Chao Li (Evan)" > Date: Tue, 2 Dec 2025 13:45:05 +0800 > Subject: [PATCH v2 05/13] cleanup: avoid local wal_level and wal_segment_size > being shadowed by globals > > This commit fixes cases where local variables named wal_level and > wal_segment_size were shadowed by global identifiers of the same names. > The local variables are renamed so they are no longer shadowed by the > globals. > > Author: Chao Li > Discussion: https://postgr.es/m/CAEoWx2kQ2x5gMaj8tHLJ3=jfC+p5YXHkJyHrDTiQw2nn2FJTmQ@mail.gmail.com > --- > src/backend/access/rmgrdesc/xlogdesc.c | 18 +++++++++--------- > src/backend/access/transam/xlogreader.c | 4 ++-- > src/bin/pg_controldata/pg_controldata.c | 4 ++-- > 3 files changed, 13 insertions(+), 13 deletions(-) > > diff --git a/src/backend/access/rmgrdesc/xlogdesc.c b/src/backend/access/rmgrdesc/xlogdesc.c > index cd6c2a2f650..6241d87c647 100644 > --- a/src/backend/access/rmgrdesc/xlogdesc.c > +++ b/src/backend/access/rmgrdesc/xlogdesc.c > @@ -34,24 +34,24 @@ const struct config_enum_entry wal_level_options[] = { > }; > > /* > - * Find a string representation for wal_level > + * Find a string representation for wallevel > */ > static const char * > -get_wal_level_string(int wal_level) > +get_wal_level_string(int wallevel) > { > const struct config_enum_entry *entry; > - const char *wal_level_str = "?"; > + const char *wallevel_str = "?"; This sounds like it's talking about walls not, the WAL. Greetings, Andres Freund