From a35d67824d3279bd3ace5c2408b0ffaccb438553 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Mon, 29 Jun 2026 13:37:54 +0200 Subject: [PATCH v1 10/15] Clean up pg_pread() return type analogous to the previous changes for read() --- src/backend/access/transam/xlogreader.c | 4 ++-- src/backend/access/transam/xlogrecovery.c | 4 ++-- src/backend/access/transam/xlogutils.c | 4 ++-- src/bin/pg_combinebackup/reconstruct.c | 6 +++--- src/bin/pg_waldump/pg_waldump.c | 4 ++-- src/include/access/xlogreader.h | 6 +++--- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index 9d64ae34932..946907a2507 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -1548,8 +1548,8 @@ WALRead(XLogReaderState *state, while (nbytes > 0) { uint32 startoff; - int segbytes; - int readbytes; + size_t segbytes; + ssize_t readbytes; startoff = XLogSegmentOffset(recptr, state->segcxt.ws_segsize); diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c index c0ae4d3f63f..a9ebac2d0ef 100644 --- a/src/backend/access/transam/xlogrecovery.c +++ b/src/backend/access/transam/xlogrecovery.c @@ -3282,7 +3282,7 @@ XLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr, int reqLen, int emode = private->emode; uint32 targetPageOff; XLogSegNo targetSegNo PG_USED_FOR_ASSERTS_ONLY; - int r; + ssize_t r; instr_time io_start; Assert(AmStartupProcess() || !IsUnderPostmaster); @@ -3408,7 +3408,7 @@ XLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr, int reqLen, else ereport(emode_for_corrupt_record(emode, targetPagePtr + reqLen), (errcode(ERRCODE_DATA_CORRUPTED), - errmsg("could not read from WAL segment %s, LSN %X/%08X, offset %u: read %d of %zu", + errmsg("could not read from WAL segment %s, LSN %X/%08X, offset %u: read %zd of %zu", fname, LSN_FORMAT_ARGS(targetPagePtr), readOff, r, (Size) XLOG_BLCKSZ))); goto next_record_is_invalid; diff --git a/src/backend/access/transam/xlogutils.c b/src/backend/access/transam/xlogutils.c index fdc341d8fa4..e235872b164 100644 --- a/src/backend/access/transam/xlogutils.c +++ b/src/backend/access/transam/xlogutils.c @@ -1032,14 +1032,14 @@ WALReadRaiseError(WALReadError *errinfo) errno = errinfo->wre_errno; ereport(ERROR, (errcode_for_file_access(), - errmsg("could not read from WAL segment %s, offset %d: %m", + errmsg("could not read from WAL segment %s, offset %u: %m", fname, errinfo->wre_off))); } else if (errinfo->wre_read == 0) { ereport(ERROR, (errcode(ERRCODE_DATA_CORRUPTED), - errmsg("could not read from WAL segment %s, offset %d: read %d of %d", + errmsg("could not read from WAL segment %s, offset %u: read %zd of %zu", fname, errinfo->wre_off, errinfo->wre_read, errinfo->wre_req))); } diff --git a/src/bin/pg_combinebackup/reconstruct.c b/src/bin/pg_combinebackup/reconstruct.c index b98f37aa430..1448c62c775 100644 --- a/src/bin/pg_combinebackup/reconstruct.c +++ b/src/bin/pg_combinebackup/reconstruct.c @@ -778,7 +778,7 @@ write_block(int fd, const char *output_filename, static void read_block(const rfile *s, off_t off, uint8 *buffer) { - int rb; + ssize_t rb; /* Read the block from the correct source, except if dry-run. */ rb = pg_pread(s->fd, buffer, BLCKSZ, off); @@ -787,7 +787,7 @@ read_block(const rfile *s, off_t off, uint8 *buffer) if (rb < 0) pg_fatal("could not read from file \"%s\": %m", s->filename); else - pg_fatal("could not read from file \"%s\", offset %lld: read %d of %d", - s->filename, (long long) off, rb, BLCKSZ); + pg_fatal("could not read from file \"%s\", offset %lld: read %zd of %zu", + s->filename, (long long) off, rb, (size_t) BLCKSZ); } } diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c index 855e4f84813..cf760d8b236 100644 --- a/src/bin/pg_waldump/pg_waldump.c +++ b/src/bin/pg_waldump/pg_waldump.c @@ -430,11 +430,11 @@ WALDumpReadPage(XLogReaderState *state, XLogRecPtr targetPagePtr, int reqLen, if (errinfo.wre_errno != 0) { errno = errinfo.wre_errno; - pg_fatal("could not read from file \"%s\", offset %d: %m", + pg_fatal("could not read from file \"%s\", offset %u: %m", fname, errinfo.wre_off); } else - pg_fatal("could not read from file \"%s\", offset %d: read %d of %d", + pg_fatal("could not read from file \"%s\", offset %u: read %zd of %zu", fname, errinfo.wre_off, errinfo.wre_read, errinfo.wre_req); } diff --git a/src/include/access/xlogreader.h b/src/include/access/xlogreader.h index 97eae2c1dab..4a9a687e879 100644 --- a/src/include/access/xlogreader.h +++ b/src/include/access/xlogreader.h @@ -382,9 +382,9 @@ extern void XLogReaderResetError(XLogReaderState *state); typedef struct WALReadError { int wre_errno; /* errno set by the last pg_pread() */ - int wre_off; /* Offset we tried to read from. */ - int wre_req; /* Bytes requested to be read. */ - int wre_read; /* Bytes read by the last read(). */ + uint32 wre_off; /* Offset we tried to read from. */ + size_t wre_req; /* Bytes requested to be read. */ + ssize_t wre_read; /* Bytes read by the last read(). */ WALOpenSegment wre_seg; /* Segment we tried to read from. */ } WALReadError; -- 2.54.0