From: David Rowley Date: Thu, 23 Apr 2026 04:49:29 +0000 (+1200) Subject: Fix new-to-v19 -Wshadow warnings X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=4f0cbc6fb5df6dec84482d0bf0ff2d2d4be58132;p=thirdparty%2Fpostgresql.git Fix new-to-v19 -Wshadow warnings There's some talk about upgrading our current -Wshadow=compatible-local up to -Wshadow. There's some pending questions as to whether the churn and extra backpatching pain are worthwhile for doing all of them. We can't use the latter argument for ones that are new to v19, providing we fix them now. So let's fix those ones so that the problem is not any worse for if we decide to fix the remainder for v20. Author: Chao Li Reviewed-by: Peter Smith Reviewed-by: Yuchen Li Discussion: https://postgr.es/m/CAApHDvp=rx5GxM=yW8QhFF3noXtYt7LkOxJ7zkaPOzpti4Gm8w@mail.gmail.com --- diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 32db5a899dc..d8d7969bf30 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -22636,7 +22636,7 @@ createTableConstraints(List **wqueue, AlteredTableInfo *tab, bool ccvalid = constr->check[ccnum].ccvalid; Node *ccbin_node; bool found_whole_row; - Constraint *constr; + Constraint *con; /* * The partitioned table can not have a NO INHERIT check constraint @@ -22658,19 +22658,19 @@ createTableConstraints(List **wqueue, AlteredTableInfo *tab, ccname, RelationGetRelationName(parent_rel)); - constr = makeNode(Constraint); - constr->contype = CONSTR_CHECK; - constr->conname = pstrdup(ccname); - constr->deferrable = false; - constr->initdeferred = false; - constr->is_enforced = ccenforced; - constr->skip_validation = !ccvalid; - constr->initially_valid = ccvalid; - constr->is_no_inherit = ccnoinherit; - constr->raw_expr = NULL; - constr->cooked_expr = nodeToString(ccbin_node); - constr->location = -1; - constraints = lappend(constraints, constr); + con = makeNode(Constraint); + con->contype = CONSTR_CHECK; + con->conname = pstrdup(ccname); + con->deferrable = false; + con->initdeferred = false; + con->is_enforced = ccenforced; + con->skip_validation = !ccvalid; + con->initially_valid = ccvalid; + con->is_no_inherit = ccnoinherit; + con->raw_expr = NULL; + con->cooked_expr = nodeToString(ccbin_node); + con->location = -1; + constraints = lappend(constraints, con); } /* Install all CHECK constraints. */ diff --git a/src/backend/commands/wait.c b/src/backend/commands/wait.c index 382d5c2d44f..40a6ffde16b 100644 --- a/src/backend/commands/wait.c +++ b/src/backend/commands/wait.c @@ -92,7 +92,7 @@ ExecWaitStmt(ParseState *pstate, WaitStmt *stmt, bool isTopLevel, { char *timeout_str; const char *hintmsg; - double result; + double dval; if (timeout_specified) errorConflictingDefElem(defel, pstate); @@ -100,7 +100,7 @@ ExecWaitStmt(ParseState *pstate, WaitStmt *stmt, bool isTopLevel, timeout_str = defGetString(defel); - if (!parse_real(timeout_str, &result, GUC_UNIT_MS, &hintmsg)) + if (!parse_real(timeout_str, &dval, GUC_UNIT_MS, &hintmsg)) { ereport(ERROR, errcode(ERRCODE_INVALID_PARAMETER_VALUE), @@ -113,20 +113,20 @@ ExecWaitStmt(ParseState *pstate, WaitStmt *stmt, bool isTopLevel, * don't fail on just-out-of-range values that would round into * range. */ - result = rint(result); + dval = rint(dval); /* Range check */ - if (unlikely(isnan(result) || !FLOAT8_FITS_IN_INT64(result))) + if (unlikely(isnan(dval) || !FLOAT8_FITS_IN_INT64(dval))) ereport(ERROR, errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), errmsg("timeout value is out of range")); - if (result < 0) + if (dval < 0) ereport(ERROR, errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("timeout cannot be negative")); - timeout = (int64) result; + timeout = (int64) dval; } else if (strcmp(defel->defname, "no_throw") == 0) { diff --git a/src/backend/postmaster/datachecksum_state.c b/src/backend/postmaster/datachecksum_state.c index b3e99170669..5556a9ca893 100644 --- a/src/backend/postmaster/datachecksum_state.c +++ b/src/backend/postmaster/datachecksum_state.c @@ -546,7 +546,7 @@ StartDataChecksumsWorkerLauncher(DataChecksumsWorkerOperation op, { BackgroundWorker bgw; BackgroundWorkerHandle *bgw_handle; - bool launcher_running; + bool running; DataChecksumsWorkerOperation launcher_running_op; #ifdef USE_ASSERT_CHECKING @@ -565,8 +565,8 @@ StartDataChecksumsWorkerLauncher(DataChecksumsWorkerOperation op, DataChecksumState->launch_cost_limit = cost_limit; /* Is the launcher already running? If so, what is it doing? */ - launcher_running = DataChecksumState->launcher_running; - if (launcher_running) + running = DataChecksumState->launcher_running; + if (running) launcher_running_op = DataChecksumState->operation; LWLockRelease(DataChecksumsWorkerLock); @@ -589,7 +589,7 @@ StartDataChecksumsWorkerLauncher(DataChecksumsWorkerOperation op, * already in the desired state, i.e. if the checksums are already enabled * and you call pg_enable_data_checksums(). */ - if (!launcher_running) + if (!running) { /* * Prepare the BackgroundWorker and launch it. diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c index 9e904f76baa..c1f43113c53 100644 --- a/src/bin/pg_dump/pg_dumpall.c +++ b/src/bin/pg_dump/pg_dumpall.c @@ -83,7 +83,7 @@ static void buildShSecLabels(PGconn *conn, PQExpBuffer buffer); static void executeCommand(PGconn *conn, const char *query); static void check_for_invalid_global_names(PGconn *conn, - SimpleStringList *database_exclude_names); + SimpleStringList *excluded_names); static void expand_dbname_patterns(PGconn *conn, SimpleStringList *patterns, SimpleStringList *names); static void read_dumpall_filters(const char *filename, SimpleStringList *pattern); @@ -2269,7 +2269,7 @@ executeCommand(PGconn *conn, const char *query) */ static void check_for_invalid_global_names(PGconn *conn, - SimpleStringList *database_exclude_names) + SimpleStringList *excluded_names) { PGresult *res; int i; @@ -2296,7 +2296,7 @@ check_for_invalid_global_names(PGconn *conn, /* Skip excluded databases since they won't be in map.dat */ if (strcmp(objtype, "database") == 0 && - simple_string_list_member(database_exclude_names, objname)) + simple_string_list_member(excluded_names, objname)) continue; if (strpbrk(objname, "\n\r")) @@ -2406,29 +2406,27 @@ read_dumpall_filters(const char *filename, SimpleStringList *pattern) static ArchiveFormat parseDumpFormat(const char *format) { - ArchiveFormat archDumpFormat; - if (pg_strcasecmp(format, "c") == 0) - archDumpFormat = archCustom; + return archCustom; else if (pg_strcasecmp(format, "custom") == 0) - archDumpFormat = archCustom; + return archCustom; else if (pg_strcasecmp(format, "d") == 0) - archDumpFormat = archDirectory; + return archDirectory; else if (pg_strcasecmp(format, "directory") == 0) - archDumpFormat = archDirectory; + return archDirectory; else if (pg_strcasecmp(format, "p") == 0) - archDumpFormat = archNull; + return archNull; else if (pg_strcasecmp(format, "plain") == 0) - archDumpFormat = archNull; + return archNull; else if (pg_strcasecmp(format, "t") == 0) - archDumpFormat = archTar; + return archTar; else if (pg_strcasecmp(format, "tar") == 0) - archDumpFormat = archTar; + return archTar; else pg_fatal("unrecognized output format \"%s\"; please specify \"c\", \"d\", \"p\", or \"t\"", format); - return archDumpFormat; + return archUnknown; } /* diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index dd1179ef927..4a1ab873260 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -1938,7 +1938,7 @@ describeOneTableDetails(const char *schemaname, */ if (tableinfo.relkind == RELKIND_PROPGRAPH) { - printQueryOpt myopt = pset.popt; + printQueryOpt popt = pset.popt; char *footers[3] = {NULL, NULL, NULL}; printfPQExpBuffer(&buf, "/* %s */\n", _("Get property graph information")); @@ -1993,12 +1993,12 @@ describeOneTableDetails(const char *schemaname, } } - myopt.footers = footers; - myopt.topt.default_footer = false; - myopt.title = title.data; - myopt.translate_header = true; + popt.footers = footers; + popt.topt.default_footer = false; + popt.title = title.data; + popt.translate_header = true; - printQuery(res, &myopt, pset.queryFout, false, pset.logfile); + printQuery(res, &popt, pset.queryFout, false, pset.logfile); free(footers[0]); free(footers[1]);