0002-more-size_t-places.patch
text/x-patch
Filename: 0002-more-size_t-places.patch
Type: text/x-patch
Part: 2
Message:
Re: Add LZ4 compression in pg_dump
Patch
Format: format-patch
Series: patch 0002
Subject: more size_t places
| File | + | − |
|---|---|---|
| src/bin/pg_dump/compress_gzip.c | 4 | 2 |
| src/bin/pg_dump/compress_lz4.c | 1 | 1 |
From cd361f4bc631a33eb7374bf8b292976aaf07799b Mon Sep 17 00:00:00 2001
From: Tomas Vondra <tomas@2ndquadrant.com>
Date: Mon, 13 Mar 2023 20:41:38 +0100
Subject: [PATCH 2/4] more size_t places
---
src/bin/pg_dump/compress_gzip.c | 6 ++++--
src/bin/pg_dump/compress_lz4.c | 2 +-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/bin/pg_dump/compress_gzip.c b/src/bin/pg_dump/compress_gzip.c
index 0af65afeb4..6b042cab5b 100644
--- a/src/bin/pg_dump/compress_gzip.c
+++ b/src/bin/pg_dump/compress_gzip.c
@@ -233,12 +233,13 @@ InitCompressorGzip(CompressorState *cs,
*----------------------
*/
-static size_t
+static size_t /* XXX issue size_t vs. int? */
Gzip_read(void *ptr, size_t size, CompressFileHandle *CFH)
{
gzFile gzfp = (gzFile) CFH->private_data;
size_t ret;
+ /* XXX this is probably wrong because gzread is "-1 for error" but this breaks that. */
ret = gzread(gzfp, ptr, size);
if (ret != size && !gzeof(gzfp))
{
@@ -252,11 +253,12 @@ Gzip_read(void *ptr, size_t size, CompressFileHandle *CFH)
return ret;
}
-static size_t
+static size_t /* XXX issue size_t vs. int? */
Gzip_write(const void *ptr, size_t size, CompressFileHandle *CFH)
{
gzFile gzfp = (gzFile) CFH->private_data;
+ /* XXX this is probably OK, because gzwrite is "or 0 in case of error" per https://zlib.net/manual.html#Basic */
return gzwrite(gzfp, ptr, size);
}
diff --git a/src/bin/pg_dump/compress_lz4.c b/src/bin/pg_dump/compress_lz4.c
index cc039f0b47..9ab57ceff3 100644
--- a/src/bin/pg_dump/compress_lz4.c
+++ b/src/bin/pg_dump/compress_lz4.c
@@ -430,7 +430,7 @@ LZ4File_write(const void *ptr, size_t size, CompressFileHandle *CFH)
if (LZ4F_isError(status))
{
fs->errcode = status;
- return -1;
+ return -1; /* FIXME size_t */
}
if (fwrite(fs->buffer, 1, status, fs->fp) != status)
--
2.39.2