Re: Cleanup shadows variable warnings, round 1
Peter Smith <smithpb2250@gmail.com>
From: Peter Smith <smithpb2250@gmail.com>
To: Chao Li <li.evan.chao@gmail.com>
Cc: Álvaro Herrera <alvherre@kurilemu.de>, David Rowley <dgrowleyml@gmail.com>, Postgres hackers <pgsql-hackers@lists.postgresql.org>, Peter Eisentraut <peter@eisentraut.org>
Date: 2026-04-22T06:32:25Z
Lists: pgsql-hackers
Hi Chao-San.
A couple of comments for your v1-0001 cleanup patch.
======
src/bin/pg_dump/pg_dumpall.c
I guess you were just making the minimal changes, but I thought
parseDumpFormat could have been simplified more by removing that local
variable entirely.
BEFORE
if (pg_strcasecmp(format, "c") == 0)
archFormat = archCustom;
else if (pg_strcasecmp(format, "custom") == 0)
archFormat = archCustom;
else if (pg_strcasecmp(format, "d") == 0)
archFormat = archDirectory;
else if (pg_strcasecmp(format, "directory") == 0)
archFormat = archDirectory;
else if (pg_strcasecmp(format, "p") == 0)
archFormat = archNull;
else if (pg_strcasecmp(format, "plain") == 0)
archFormat = archNull;
else if (pg_strcasecmp(format, "t") == 0)
archFormat = archTar;
else if (pg_strcasecmp(format, "tar") == 0)
archFormat = archTar;
SUGGESTION
if (pg_strcasecmp(format, "c") == 0 ||
pg_strcasecmp(format, "custom") == 0)
return archCustom;
if (pg_strcasecmp(format, "d") == 0 ||
pg_strcasecmp(format, "directory") == 0)
return archDirectory;
if (pg_strcasecmp(format, "p") == 0 ||
pg_strcasecmp(format, "plain") == 0)
return archNull;
if (pg_strcasecmp(format, "t") == 0 ||
pg_strcasecmp(format, "tar") == 0)
return archTar;
======
src/bin/psql/describe.c
I know you were addressing only "new" issues, but it seemed a bit
strange to fix only this one when there was the same issue earlier
(~line 1780) in the same function.
if (tableinfo.relkind == RELKIND_SEQUENCE)
{
PGresult *result = NULL;
printQueryOpt myopt = pset.popt;
======
Kind Regards,
Peter Smith.
Fujitsu Australia
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix new-to-v19 -Wshadow warnings
- 4f0cbc6fb5df 19 (unreleased) landed
-
Reduce scope of for-loop-local variables to avoid shadowing
- cece37c9843c 19 (unreleased) landed
-
Fix local-variable shadowing in pg_trgm's printSourceNFA().
- cdaa67565867 19 (unreleased) cited