v4-0005-cleanup-avoid-local-wal_level-and-wal_segment_siz.patch
application/octet-stream
Filename: v4-0005-cleanup-avoid-local-wal_level-and-wal_segment_siz.patch
Type: application/octet-stream
Part: 4
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v4-0005
Subject: cleanup: avoid local wal_level and wal_segment_size being shadowed by globals
| File | + | − |
|---|---|---|
| src/backend/access/rmgrdesc/xlogdesc.c | 6 | 6 |
| src/backend/access/transam/xlogreader.c | 2 | 2 |
| src/bin/pg_controldata/pg_controldata.c | 2 | 2 |
From 3e024391ab366ea890a2f28b7aba66ee5de9c06a Mon Sep 17 00:00:00 2001
From: "Chao Li (Evan)" <lic@highgo.com>
Date: Tue, 2 Dec 2025 13:45:05 +0800
Subject: [PATCH v4 05/13] 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 <lic@highgo.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
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 ++--
3 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/backend/access/rmgrdesc/xlogdesc.c b/src/backend/access/rmgrdesc/xlogdesc.c
index cd6c2a2f650..bf6a120af68 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;
@@ -162,10 +162,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));
}
}
diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c
index 9cc7488e892..0ae4e05f8f2 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 30ad46912e1..8cb56f12146 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";
--
2.39.5 (Apple Git-154)