/*
* Data read callback for use with CreateBlockRefTableReader.
*/
-int
-ReadWalSummary(void *wal_summary_io, void *data, int length)
+size_t
+ReadWalSummary(void *wal_summary_io, void *data, size_t length)
{
WalSummaryIO *io = wal_summary_io;
- int nbytes;
+ ssize_t nbytes;
nbytes = FileRead(io->file, data, length, io->filepos,
WAIT_EVENT_WAL_SUMMARY_READ);
/*
* Data write callback for use with WriteBlockRefTable.
*/
-int
-WriteWalSummary(void *wal_summary_io, void *data, int length)
+size_t
+WriteWalSummary(void *wal_summary_io, void *data, size_t length)
{
WalSummaryIO *io = wal_summary_io;
- int nbytes;
+ ssize_t nbytes;
nbytes = FileWrite(io->file, data, length, io->filepos,
WAIT_EVENT_WAL_SUMMARY_WRITE);
if (nbytes != length)
ereport(ERROR,
(errcode_for_file_access(),
- errmsg("could not write file \"%s\": wrote only %d of %d bytes at offset %lld",
+ errmsg("could not write file \"%s\": wrote only %zd of %zu bytes at offset %lld",
FilePathName(io->file), nbytes,
length, (long long) io->filepos),
errhint("Check free disk space.")));
BlockRefTableReader *reader);
static void help(const char *progname);
static int compare_block_numbers(const void *a, const void *b);
-static int walsummary_read_callback(void *callback_arg, void *data,
- int length);
+static size_t walsummary_read_callback(void *callback_arg, void *data,
+ size_t length);
static void walsummary_error_callback(void *callback_arg, char *fmt, ...) pg_attribute_printf(2, 3);
/*
/*
* Read callback.
*/
-int
-walsummary_read_callback(void *callback_arg, void *data, int length)
+size_t
+walsummary_read_callback(void *callback_arg, void *data, size_t length)
{
ws_file_info *ws = callback_arg;
- int rc;
+ ssize_t rc;
if ((rc = read(ws->fd, data, length)) < 0)
pg_fatal("could not read file \"%s\": %m", ws->filename);
io_callback_fn io_callback;
void *io_callback_arg;
char data[BUFSIZE];
- int used;
- int cursor;
+ size_t used;
+ size_t cursor;
pg_crc32c crc;
} BlockRefTableBuffer;
static int BlockRefTableComparator(const void *a, const void *b);
static void BlockRefTableFlush(BlockRefTableBuffer *buffer);
static void BlockRefTableRead(BlockRefTableReader *reader, void *data,
- int length);
+ size_t length);
static void BlockRefTableWrite(BlockRefTableBuffer *buffer, void *data,
- int length);
+ size_t length);
static void BlockRefTableFileTerminate(BlockRefTableBuffer *buffer);
/*
* buffered but not yet actually returned).
*/
static void
-BlockRefTableRead(BlockRefTableReader *reader, void *data, int length)
+BlockRefTableRead(BlockRefTableReader *reader, void *data, size_t length)
{
BlockRefTableBuffer *buffer = &reader->buffer;
* If any buffered data is available, use that to satisfy as much
* of the request as possible.
*/
- int bytes_to_copy = Min(length, buffer->used - buffer->cursor);
+ size_t bytes_to_copy = Min(length, buffer->used - buffer->cursor);
memcpy(data, &buffer->data[buffer->cursor], bytes_to_copy);
COMP_CRC32C(buffer->crc, &buffer->data[buffer->cursor],
* If the request length is long, read directly into caller's
* buffer.
*/
- int bytes_read;
+ size_t bytes_read;
bytes_read = buffer->io_callback(buffer->io_callback_arg,
data, length);
* and update the running CRC calculation for that data.
*/
static void
-BlockRefTableWrite(BlockRefTableBuffer *buffer, void *data, int length)
+BlockRefTableWrite(BlockRefTableBuffer *buffer, void *data, size_t length)
{
/* Update running CRC calculation. */
COMP_CRC32C(buffer->crc, data, length);
extern void RemoveWalSummaryIfOlderThan(WalSummaryFile *ws,
time_t cutoff_time);
-extern int ReadWalSummary(void *wal_summary_io, void *data, int length);
-extern int WriteWalSummary(void *wal_summary_io, void *data, int length);
+extern size_t ReadWalSummary(void *wal_summary_io, void *data, size_t length);
+extern size_t WriteWalSummary(void *wal_summary_io, void *data, size_t length);
extern void ReportWalSummaryError(void *callback_arg, char *fmt, ...) pg_attribute_printf(2, 3);
#endif /* WALSUMMARY_H */
*
* report_error_fn should not return.
*/
-typedef int (*io_callback_fn) (void *callback_arg, void *data, int length);
+typedef size_t (*io_callback_fn) (void *callback_arg, void *data, size_t length);
typedef void (*report_error_fn) (void *callback_arg, char *msg, ...) pg_attribute_printf(2, 3);