From 5be1a882633994f3a4e0630feeb6d013118c6491 Mon Sep 17 00:00:00 2001 From: "Chao Li (Evan)" Date: Tue, 2 Dec 2025 15:26:51 +0800 Subject: [PATCH v3 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 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 5e7bd933afc..da8a7609d86 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 4f666d91036..d2b8d83d1ca 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 bb451c1bae1..5dc06b4d2b9 100644 --- a/src/bin/pg_dump/pg_dumpall.c +++ b/src/bin/pg_dump/pg_dumpall.c @@ -1814,20 +1814,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 8d5d9805279..5b5249537e6 100644 --- a/src/bin/pg_resetwal/pg_resetwal.c +++ b/src/bin/pg_resetwal/pg_resetwal.c @@ -719,15 +719,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 0060ea15902..d393b0ecfb0 100644 --- a/src/bin/pg_test_fsync/pg_test_fsync.c +++ b/src/bin/pg_test_fsync/pg_test_fsync.c @@ -625,10 +625,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.39.5 (Apple Git-154)