v1-0001-buffile-use-pgoff_t-for-bytestowrite-in-BufFileDu.patch
application/octet-stream
Filename: v1-0001-buffile-use-pgoff_t-for-bytestowrite-in-BufFileDu.patch
Type: application/octet-stream
Part: 0
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 v1-0001
Subject: buffile: use pgoff_t for bytestowrite in BufFileDumpBuffer
| File | + | − |
|---|---|---|
| src/backend/storage/file/buffile.c | 3 | 3 |
From fa73b95da37af8c2ec00a07201d6c21826d9fb87 Mon Sep 17 00:00:00 2001
From: "Chao Li (Evan)" <lic@highgo.com>
Date: Tue, 23 Dec 2025 10:44:27 +0800
Subject: [PATCH v1] buffile: use pgoff_t for bytestowrite in BufFileDumpBuffer
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Avoid mixed-width arithmetic when computing the number of bytes to write
in BufFileDumpBuffer() by using pgoff_t for bytestowrite.
This removes unnecessary casts, makes the comparison clearer, and keeps
file-offset arithmetic using PostgreSQL’s portable offset type.
Author: Chao Li <lic@highgo.com>
Discussion: https://postgr.es/m/aUStrqoOCDRFAq1M@paquier.xyz
---
src/backend/storage/file/buffile.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/backend/storage/file/buffile.c b/src/backend/storage/file/buffile.c
index 85b316d879d..b24560d670c 100644
--- a/src/backend/storage/file/buffile.c
+++ b/src/backend/storage/file/buffile.c
@@ -494,7 +494,7 @@ static void
BufFileDumpBuffer(BufFile *file)
{
int wpos = 0;
- int bytestowrite;
+ pgoff_t bytestowrite;
File thisfile;
/*
@@ -524,8 +524,8 @@ BufFileDumpBuffer(BufFile *file)
bytestowrite = file->nbytes - wpos;
availbytes = MAX_PHYSICAL_FILESIZE - file->curOffset;
- if ((pgoff_t) bytestowrite > availbytes)
- bytestowrite = (int) availbytes;
+ if (bytestowrite > availbytes)
+ bytestowrite = availbytes;
thisfile = file->files[file->curFile];
--
2.39.5 (Apple Git-154)