From 71def598906637866f1b165bc9113defdd36983c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Pawe=C5=82=20Stefaniak?= <3462925+pstef@users.noreply.github.com> Date: Sun, 7 Apr 2024 13:04:26 +0200 Subject: [PATCH] Fix zlibWrapper build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Just after a clone I'm getting this: ~/zstd/zlibWrapper$ cc -c zstd_zlibwrapper.o gz*.c -lz -lzstd -DSTDC gzwrite.c: In function ‘gz_write’: gzwrite.c:226:43: error: ‘z_uInt’ undeclared (first use in this function); did you mean ‘uInt’? 226 | state.state->strm.avail_in = (z_uInt)n; | ^~~~~~ | uInt gzwrite.c:226:43: note: each undeclared identifier is reported only once for each function it appears in gzwrite.c:226:50: error: expected ‘;’ before ‘n’ 226 | state.state->strm.avail_in = (z_uInt)n; | ^ | ; z_uInt is never used directly, zconf.h redefines uInt to z_uInt under the condition that Z_PREFIX is set. All examples use uInt, and the type of avail_in is also uInt. In this commit I modify the cast to refer to the same type as the type of lvalue. Arguably, the real fix here is to handle possible overflows, but that's beyond the scope of this commit. --- zlibWrapper/gzwrite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zlibWrapper/gzwrite.c b/zlibWrapper/gzwrite.c index 81da15314a9..67f5eda6c34 100644 --- a/zlibWrapper/gzwrite.c +++ b/zlibWrapper/gzwrite.c @@ -223,7 +223,7 @@ local z_size_t gz_write(gz_statep state, voidpc buf, z_size_t len) { z_size_t n = (unsigned)-1; if (n > len) n = len; - state.state->strm.avail_in = (z_uInt)n; + state.state->strm.avail_in = (uInt)n; state.state->x.pos += n; if (gz_comp(state, Z_NO_FLUSH) == -1) return 0;