From 5e5f40eff514ed0ef325080a2d7a92a7b81f10e6 Mon Sep 17 00:00:00 2001
From: "Chao Li (Evan)" <lic@highgo.com>
Date: Tue, 2 Dec 2025 15:26:51 +0800
Subject: [PATCH v6 10/13] cleanup: avoid local variables shadowed by static
 file-scope ones in several files

This commit fixes multiple cases where local variables used names that
conflicted with static variables defined at file scope. The affected
locals are renamed so they are no longer shadowed by the file-scope
identifiers and remain unambiguous within their respective scopes.

Author: Chao Li <lic@highgo.com>
Discussion: https://postgr.es/m/CAEoWx2kQ2x5gMaj8tHLJ3=jfC+p5YXHkJyHrDTiQw2nn2FJTmQ@mail.gmail.com
---
 src/backend/executor/execExprInterp.c | 6 +++---
 src/bin/pg_ctl/pg_ctl.c               | 6 +++---
 src/bin/pg_dump/pg_dumpall.c          | 6 +++---
 src/bin/pg_resetwal/pg_resetwal.c     | 6 +++---
 src/bin/pg_test_fsync/pg_test_fsync.c | 6 +++---
 5 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/execExprInterp.c b/src/backend/executor/execExprInterp.c
index 61ff5ddc74c..cb5fb7dbba6 100644
--- a/src/backend/executor/execExprInterp.c
+++ b/src/backend/executor/execExprInterp.c
@@ -471,7 +471,7 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
 	 * This array has to be in the same order as enum ExprEvalOp.
 	 */
 #if defined(EEO_USE_COMPUTED_GOTO)
-	static const void *const dispatch_table[] = {
+	static const void *const _dispatch_table[] = {
 		&&CASE_EEOP_DONE_RETURN,
 		&&CASE_EEOP_DONE_NO_RETURN,
 		&&CASE_EEOP_INNER_FETCHSOME,
@@ -595,11 +595,11 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
 		&&CASE_EEOP_LAST
 	};
 
-	StaticAssertDecl(lengthof(dispatch_table) == EEOP_LAST + 1,
+	StaticAssertDecl(lengthof(_dispatch_table) == EEOP_LAST + 1,
 					 "dispatch_table out of whack with ExprEvalOp");
 
 	if (unlikely(state == NULL))
-		return PointerGetDatum(dispatch_table);
+		return PointerGetDatum(_dispatch_table);
 #else
 	Assert(state != NULL);
 #endif							/* EEO_USE_COMPUTED_GOTO */
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 3cc61455dcb..b1fbe1f88d2 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -873,18 +873,18 @@ trap_sigint_during_startup(SIGNAL_ARGS)
 }
 
 static char *
-find_other_exec_or_die(const char *argv0, const char *target, const char *versionstr)
+find_other_exec_or_die(const char *myargv0, const char *target, const char *versionstr)
 {
 	int			ret;
 	char	   *found_path;
 
 	found_path = pg_malloc(MAXPGPATH);
 
-	if ((ret = find_other_exec(argv0, target, versionstr, found_path)) < 0)
+	if ((ret = find_other_exec(myargv0, target, versionstr, found_path)) < 0)
 	{
 		char		full_path[MAXPGPATH];
 
-		if (find_my_exec(argv0, full_path) < 0)
+		if (find_my_exec(myargv0, full_path) < 0)
 			strlcpy(full_path, progname, sizeof(full_path));
 
 		if (ret == -1)
diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c
index 1165a0f4afe..b1334da2075 100644
--- a/src/bin/pg_dump/pg_dumpall.c
+++ b/src/bin/pg_dump/pg_dumpall.c
@@ -2344,20 +2344,20 @@ dumpTimestamp(const char *msg)
  * read_dumpall_filters - retrieve database identifier patterns from file
  *
  * Parse the specified filter file for include and exclude patterns, and add
- * them to the relevant lists.  If the filename is "-" then filters will be
+ * them to the relevant lists.  If the fname is "-" then filters will be
  * read from STDIN rather than a file.
  *
  * At the moment, the only allowed filter is for database exclusion.
  */
 static void
-read_dumpall_filters(const char *filename, SimpleStringList *pattern)
+read_dumpall_filters(const char *fname, SimpleStringList *pattern)
 {
 	FilterStateData fstate;
 	char	   *objname;
 	FilterCommandType comtype;
 	FilterObjectType objtype;
 
-	filter_init(&fstate, filename, exit);
+	filter_init(&fstate, fname, exit);
 
 	while (filter_read_item(&fstate, &objname, &comtype, &objtype))
 	{
diff --git a/src/bin/pg_resetwal/pg_resetwal.c b/src/bin/pg_resetwal/pg_resetwal.c
index ab766c34d4b..a9c0269101d 100644
--- a/src/bin/pg_resetwal/pg_resetwal.c
+++ b/src/bin/pg_resetwal/pg_resetwal.c
@@ -745,15 +745,15 @@ GuessControlValues(void)
 
 
 /*
- * Print the guessed pg_control values when we had to guess.
+ * Print the bGuessed pg_control values when we had to guess.
  *
  * NB: this display should be just those fields that will not be
  * reset by RewriteControlFile().
  */
 static void
-PrintControlValues(bool guessed)
+PrintControlValues(bool bGuessed)
 {
-	if (guessed)
+	if (bGuessed)
 		printf(_("Guessed pg_control values:\n\n"));
 	else
 		printf(_("Current pg_control values:\n\n"));
diff --git a/src/bin/pg_test_fsync/pg_test_fsync.c b/src/bin/pg_test_fsync/pg_test_fsync.c
index 4b84f86e7d7..55fca0f0a19 100644
--- a/src/bin/pg_test_fsync/pg_test_fsync.c
+++ b/src/bin/pg_test_fsync/pg_test_fsync.c
@@ -622,10 +622,10 @@ pg_fsync_writethrough(int fd)
  * print out the writes per second for tests
  */
 static void
-print_elapse(struct timeval start_t, struct timeval stop_t, int ops)
+print_elapse(struct timeval start_time, struct timeval stop_time, int ops)
 {
-	double		total_time = (stop_t.tv_sec - start_t.tv_sec) +
-		(stop_t.tv_usec - start_t.tv_usec) * 0.000001;
+	double		total_time = (stop_time.tv_sec - start_time.tv_sec) +
+		(stop_time.tv_usec - start_time.tv_usec) * 0.000001;
 	double		per_second = ops / total_time;
 	double		avg_op_time_us = (total_time / ops) * USECS_SEC;
 
-- 
2.50.1 (Apple Git-155)

