v8-0005-cleanup-avoid-local-variables-shadowed-by-static-.patch
application/octet-stream
Filename: v8-0005-cleanup-avoid-local-variables-shadowed-by-static-.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 v8-0005
Subject: cleanup: avoid local variables shadowed by static file-scope ones in file_ops.c
| File | + | − |
|---|---|---|
| src/bin/pg_rewind/file_ops.c | 25 | 25 |
From a34e341962d8f181c5e9f3c509f2bcf0b3e66c43 Mon Sep 17 00:00:00 2001
From: "Chao Li (Evan)" <lic@highgo.com>
Date: Tue, 2 Dec 2025 14:59:53 +0800
Subject: [PATCH v8 05/12] cleanup: avoid local variables shadowed by static
file-scope ones in file_ops.c
This commit fixes several cases in file_ops.c where local variables used
names that conflicted with static variables defined at file scope. The
local identifiers are renamed so they are no longer shadowed by the file-
scope variables and remain unambiguous within their respective blocks.
Author: Chao Li <lic@highgo.com>
Discussion: https://postgr.es/m/CAEoWx2kQ2x5gMaj8tHLJ3=jfC+p5YXHkJyHrDTiQw2nn2FJTmQ@mail.gmail.com
---
src/bin/pg_rewind/file_ops.c | 50 ++++++++++++++++++------------------
1 file changed, 25 insertions(+), 25 deletions(-)
diff --git a/src/bin/pg_rewind/file_ops.c b/src/bin/pg_rewind/file_ops.c
index 5cfb676f41f..3279a56f531 100644
--- a/src/bin/pg_rewind/file_ops.c
+++ b/src/bin/pg_rewind/file_ops.c
@@ -186,41 +186,41 @@ create_target(file_entry_t *entry)
void
remove_target_file(const char *path, bool missing_ok)
{
- char dstpath[MAXPGPATH];
+ char pathbuf[MAXPGPATH];
if (dry_run)
return;
- snprintf(dstpath, sizeof(dstpath), "%s/%s", datadir_target, path);
- if (unlink(dstpath) != 0)
+ snprintf(pathbuf, sizeof(pathbuf), "%s/%s", datadir_target, path);
+ if (unlink(pathbuf) != 0)
{
if (errno == ENOENT && missing_ok)
return;
pg_fatal("could not remove file \"%s\": %m",
- dstpath);
+ pathbuf);
}
}
void
truncate_target_file(const char *path, off_t newsize)
{
- char dstpath[MAXPGPATH];
+ char pathbuf[MAXPGPATH];
int fd;
if (dry_run)
return;
- snprintf(dstpath, sizeof(dstpath), "%s/%s", datadir_target, path);
+ snprintf(pathbuf, sizeof(pathbuf), "%s/%s", datadir_target, path);
- fd = open(dstpath, O_WRONLY, pg_file_create_mode);
+ fd = open(pathbuf, O_WRONLY, pg_file_create_mode);
if (fd < 0)
pg_fatal("could not open file \"%s\" for truncation: %m",
- dstpath);
+ pathbuf);
if (ftruncate(fd, newsize) != 0)
pg_fatal("could not truncate file \"%s\" to %u: %m",
- dstpath, (unsigned int) newsize);
+ pathbuf, (unsigned int) newsize);
close(fd);
}
@@ -228,57 +228,57 @@ truncate_target_file(const char *path, off_t newsize)
static void
create_target_dir(const char *path)
{
- char dstpath[MAXPGPATH];
+ char pathbuf[MAXPGPATH];
if (dry_run)
return;
- snprintf(dstpath, sizeof(dstpath), "%s/%s", datadir_target, path);
- if (mkdir(dstpath, pg_dir_create_mode) != 0)
+ snprintf(pathbuf, sizeof(pathbuf), "%s/%s", datadir_target, path);
+ if (mkdir(pathbuf, pg_dir_create_mode) != 0)
pg_fatal("could not create directory \"%s\": %m",
- dstpath);
+ pathbuf);
}
static void
remove_target_dir(const char *path)
{
- char dstpath[MAXPGPATH];
+ char pathbuf[MAXPGPATH];
if (dry_run)
return;
- snprintf(dstpath, sizeof(dstpath), "%s/%s", datadir_target, path);
- if (rmdir(dstpath) != 0)
+ snprintf(pathbuf, sizeof(pathbuf), "%s/%s", datadir_target, path);
+ if (rmdir(pathbuf) != 0)
pg_fatal("could not remove directory \"%s\": %m",
- dstpath);
+ pathbuf);
}
static void
create_target_symlink(const char *path, const char *link)
{
- char dstpath[MAXPGPATH];
+ char pathbuf[MAXPGPATH];
if (dry_run)
return;
- snprintf(dstpath, sizeof(dstpath), "%s/%s", datadir_target, path);
- if (symlink(link, dstpath) != 0)
+ snprintf(pathbuf, sizeof(pathbuf), "%s/%s", datadir_target, path);
+ if (symlink(link, pathbuf) != 0)
pg_fatal("could not create symbolic link at \"%s\": %m",
- dstpath);
+ pathbuf);
}
static void
remove_target_symlink(const char *path)
{
- char dstpath[MAXPGPATH];
+ char pathbuf[MAXPGPATH];
if (dry_run)
return;
- snprintf(dstpath, sizeof(dstpath), "%s/%s", datadir_target, path);
- if (unlink(dstpath) != 0)
+ snprintf(pathbuf, sizeof(pathbuf), "%s/%s", datadir_target, path);
+ if (unlink(pathbuf) != 0)
pg_fatal("could not remove symbolic link \"%s\": %m",
- dstpath);
+ pathbuf);
}
/*
--
2.50.1 (Apple Git-155)