From bb03ad08fd1389756aa1a6c700752f84ab7d17f6 Mon Sep 17 00:00:00 2001 From: "Chao Li (Evan)" Date: Tue, 2 Dec 2025 13:45:05 +0800 Subject: [PATCH v7 04/12] 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 Reviewed-by: Andres Freund Discussion: https://postgr.es/m/CAEoWx2kQ2x5gMaj8tHLJ3=jfC+p5YXHkJyHrDTiQw2nn2FJTmQ@mail.gmail.com --- src/backend/access/rmgrdesc/xlogdesc.c | 12 ++++++------ src/backend/access/transam/xlogreader.c | 4 ++-- src/bin/pg_controldata/pg_controldata.c | 4 ++-- src/include/access/xlogreader.h | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/backend/access/rmgrdesc/xlogdesc.c b/src/backend/access/rmgrdesc/xlogdesc.c index ff078f22264..d293c6c7e4d 100644 --- a/src/backend/access/rmgrdesc/xlogdesc.c +++ b/src/backend/access/rmgrdesc/xlogdesc.c @@ -34,17 +34,17 @@ const struct config_enum_entry wal_level_options[] = { }; /* - * Find a string representation for wal_level + * Find a string representation for wal level */ static const char * -get_wal_level_string(int wal_level) +get_wal_level_string(int level) { const struct config_enum_entry *entry; const char *wal_level_str = "?"; for (entry = wal_level_options; entry->name; entry++) { - if (entry->val == wal_level) + if (entry->val == level) { wal_level_str = entry->name; break; @@ -163,10 +163,10 @@ xlog_desc(StringInfo buf, XLogReaderState *record) } else if (info == XLOG_CHECKPOINT_REDO) { - int wal_level; + int level; - memcpy(&wal_level, rec, sizeof(int)); - appendStringInfo(buf, "wal_level %s", get_wal_level_string(wal_level)); + memcpy(&level, rec, sizeof(int)); + appendStringInfo(buf, "wal_level %s", get_wal_level_string(level)); } else if (info == XLOG_LOGICAL_DECODING_STATUS_CHANGE) { diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index 03ada8aa0c5..e378bca0220 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -104,7 +104,7 @@ XLogReaderSetDecodeBuffer(XLogReaderState *state, void *buffer, size_t size) * Returns NULL if the xlogreader couldn't be allocated. */ XLogReaderState * -XLogReaderAllocate(int wal_segment_size, const char *waldir, +XLogReaderAllocate(int wal_seg_size, const char *waldir, XLogReaderRoutine *routine, void *private_data) { XLogReaderState *state; @@ -134,7 +134,7 @@ XLogReaderAllocate(int wal_segment_size, const char *waldir, } /* Initialize segment info. */ - WALOpenSegmentInit(&state->seg, &state->segcxt, wal_segment_size, + WALOpenSegmentInit(&state->seg, &state->segcxt, wal_seg_size, waldir); /* system_identifier initialized to zeroes above */ diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c index a4060309ae0..f48985fd9cc 100644 --- a/src/bin/pg_controldata/pg_controldata.c +++ b/src/bin/pg_controldata/pg_controldata.c @@ -70,9 +70,9 @@ dbState(DBState state) } static const char * -wal_level_str(WalLevel wal_level) +wal_level_str(WalLevel level) { - switch (wal_level) + switch (level) { case WAL_LEVEL_MINIMAL: return "minimal"; diff --git a/src/include/access/xlogreader.h b/src/include/access/xlogreader.h index 80f1a548e08..43aefb94263 100644 --- a/src/include/access/xlogreader.h +++ b/src/include/access/xlogreader.h @@ -327,7 +327,7 @@ XLogReaderHasQueuedRecordOrError(XLogReaderState *state) } /* Get a new XLogReader */ -extern XLogReaderState *XLogReaderAllocate(int wal_segment_size, +extern XLogReaderState *XLogReaderAllocate(int wal_seg_size, const char *waldir, XLogReaderRoutine *routine, void *private_data); -- 2.50.1 (Apple Git-155)