Fix type mismatch on platforms where int32_t and uint32_t use long instead of int#1980
Fix type mismatch on platforms where int32_t and uint32_t use long instead of int#1980Dead2 merged 1 commit intozlib-ng:developfrom
Conversation
WalkthroughPublic/exported function signatures were changed to use explicit 32-bit typedefs ( Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1980 +/- ##
============================================
+ Coverage 39.28% 80.88% +41.60%
============================================
Files 73 161 +88
Lines 7904 13748 +5844
Branches 1280 3121 +1841
============================================
+ Hits 3105 11120 +8015
+ Misses 4575 1597 -2978
- Partials 224 1031 +807 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This PR pretty much supercedes #1934 as changing existing function signatures in |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (4)
gzlib.c (1)
320-341: Add upper bound to size to prevent overflow in allocationssize is z_uint32_t but later flows into int computations (gz_buffer_alloc: int want = state->want). For very large size (> INT_MAX), this can overflow and lead to UB or misallocation. Cap size to INT_MAX before assignment.
Apply:
z_int32_t Z_EXPORT PREFIX(gzbuffer)(gzFile file, z_uint32_t size) { @@ - /* check and set requested size */ + /* check and set requested size */ + /* avoid overflow in later int-based computations and allocations */ + if (size > (z_uint32_t)INT_MAX) + return -1; if ((size << 1) < size) return -1; /* need to be able to double it */ if (size < 8) size = 8; /* needed to behave well with flushing */ state->want = size; return 0; }And add once near the includes:
#include <limits.h>gzread.c.in (1)
343-372: Use z_int32_t casts to match updated API widthAvoid casting through plain int now that the API uses z_int32_t. This prevents subtle width mismatches on platforms where int32_t is not int.
z_int32_t Z_EXPORT PREFIX(gzread)(gzFile file, void *buf, z_uint32_t len) { @@ - if ((int)len < 0) { + if ((z_int32_t)len < 0) { gz_error(state, Z_STREAM_ERROR, "request does not fit in an int"); return -1; } @@ - /* return the number of bytes read (this is assured to fit in an int) */ - return (int)len; + /* return the number of bytes read (fits in z_int32_t) */ + return (z_int32_t)len; }gzwrite.c (2)
218-239: Align casts with z_int32_t in gzwriteUse z_int32_t for range check and return cast to match the updated API type.
z_int32_t Z_EXPORT PREFIX(gzwrite)(gzFile file, void const *buf, z_uint32_t len) { @@ - if ((int)len < 0) { + if ((z_int32_t)len < 0) { gz_error(state, Z_DATA_ERROR, "requested length does not fit in int"); return 0; } @@ - return (int)gz_write(state, buf, len); + return (z_int32_t)gz_write(state, buf, len); }
316-337: Return cast should use z_int32_tAvoid narrowing to int before returning z_int32_t.
- return put < len ? -1 : (int)len; + return put < len ? -1 : (z_int32_t)len;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
compress.c(2 hunks)gzlib.c(5 hunks)gzread.c.in(6 hunks)gzwrite.c(8 hunks)uncompr.c(2 hunks)zbuild.h(1 hunks)zutil.c(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- zbuild.h
- zutil.c
🧰 Additional context used
🧬 Code graph analysis (5)
uncompr.c (1)
deflate.c (2)
Z_EXPORT(1304-1375)Z_EXPORT(1378-1422)
gzlib.c (2)
deflate.c (2)
Z_EXPORT(1304-1375)Z_EXPORT(1378-1422)gzguts.h (2)
PREFIX3(101-134)struct gzFile_s(103-103)
gzread.c.in (1)
gzguts.h (2)
struct gzFile_s(103-103)PREFIX3(101-134)
gzwrite.c (1)
gzguts.h (2)
struct gzFile_s(103-103)PREFIX3(101-134)
compress.c (2)
deflate.c (2)
Z_EXPORT(1304-1375)Z_EXPORT(1378-1422)test/test_compress_bound.cc (2)
level(23-51)level(23-23)
🔇 Additional comments (18)
compress.c (1)
73-75: Wrapper return-type update aligns with compress2No issues.
uncompr.c (2)
25-26: uncompress2 return type update is consistentNo functional change; aligns with fixed-width API.
78-80: uncompress wrapper updated — OKConsistent with uncompress2.
gzlib.c (4)
305-317: gzclose signature updated — OKBehavior unchanged, return type now z_int32_t.
344-361: gzrewind signature update — OKReturn codes/behavior unchanged.
502-514: gzeof signature update — OKStill returns 0/1; no issues.
517-531: gzerror errnum type updated — OKPointer now z_int32_t*, assignment from state->err remains safe.
gzread.c.in (5)
407-430: gzgetc signature/logic — OKError handling and return values preserved.
438-495: gzungetc signature/logic — OKAccepts z_int32_t c; bounds and buffer logic unchanged.
498-556: gzgets signature/logic — OKParameter len now z_int32_t; checks and behavior intact.
559-575: gzdirect signature/logic — OKReturn type updated; semantics unchanged.
578-603: gzclose_r signature/logic — OKReturn codes preserved.
gzwrite.c (6)
271-313: gzputc signature/logic — OKReturn values (-1 or 0..255) consistent with z_int32_t.
340-394: gzvprintf signature/logic — OKImplicit conversion from int to z_int32_t on return is fine.
396-404: gzprintf signature/logic — OKNo issues.
407-433: gzflush signature/logic — OKReturn/param types updated; behavior unchanged.
436-471: gzsetparams signature/logic — OKTypes updated; semantics preserved.
474-509: gzclose_w signature/logic — OKReturn type change consistent; behavior unchanged.
|
Rewrote the comment in |
53c1f08 to
f472052
Compare
|
@ccawley2011 Could you verify whether this works for you? |
|
I'm gonna try building gcc-newlib to test if there is some code in tests or benchmarks that need adjusting... I'm pretty confident that those are the only places it can fail... Building full gcc takes few hours on even decently modern PC. |
|
Had to disable GoogleTest and benchmarks as those depend on features not available on newlib... Some tests not disabled also fail due to "unimplemented" features... |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
test/example.c (1)
656-690: Fix hardcoded allocation size.Line 677 uses a hardcoded allocation of 4 bytes instead of
sizeof(z_uint32_t). While z_uint32_t is typically 4 bytes, usingsizeofis more portable and maintainable.Apply this diff:
- dictLen = (z_uint32_t *)calloc(4, 1); + dictLen = (z_uint32_t *)calloc(1, sizeof(z_uint32_t));Or alternatively:
- dictLen = (z_uint32_t *)calloc(4, 1); + dictLen = calloc(1, sizeof(*dictLen));
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (12)
compress.c(2 hunks)gzlib.c(5 hunks)gzread.c.in(8 hunks)gzwrite.c(9 hunks)test/example.c(4 hunks)test/infcover.c(2 hunks)test/minideflate.c(3 hunks)test/minigzip.c(1 hunks)test/switchlevels.c(2 hunks)uncompr.c(2 hunks)zbuild.h(1 hunks)zutil.c(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
- zutil.c
- zbuild.h
- uncompr.c
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: mtl1979
PR: zlib-ng/zlib-ng#1980
File: compress.c:31-33
Timestamp: 2025-10-12T17:01:13.630Z
Learning: In zlib-ng, when ZLIB_COMPAT is defined, z_int32_t is typedef'd as `int` (not int32_t), and zlib.h is included (which uses `int` in function signatures). This allows the implementation to use z_int32_t while maintaining backwards compatibility with the original zlib API that uses `int`. When ZLIB_COMPAT is not defined, z_int32_t is typedef'd as int32_t and zlib-ng.h is used instead.
📚 Learning: 2025-10-12T17:01:13.630Z
Learnt from: mtl1979
PR: zlib-ng/zlib-ng#1980
File: compress.c:31-33
Timestamp: 2025-10-12T17:01:13.630Z
Learning: In zlib-ng, when ZLIB_COMPAT is defined, z_int32_t is typedef'd as `int` (not int32_t), and zlib.h is included (which uses `int` in function signatures). This allows the implementation to use z_int32_t while maintaining backwards compatibility with the original zlib API that uses `int`. When ZLIB_COMPAT is not defined, z_int32_t is typedef'd as int32_t and zlib-ng.h is used instead.
Applied to files:
test/switchlevels.ccompress.ctest/example.cgzlib.c
📚 Learning: 2025-05-13T06:56:12.407Z
Learnt from: samrussell
PR: zlib-ng/zlib-ng#1914
File: arch/generic/crc32_chorba_c.c:30-32
Timestamp: 2025-05-13T06:56:12.407Z
Learning: In zlib-ng, pointer casts between z_word_t* and uint64_t* are safe because: 1) On 64-bit platforms, z_word_t is defined as uint64_t, making the cast a no-op; 2) On 32-bit platforms where z_word_t is uint32_t, the code paths using uint64_t* are skipped in favor of 32-bit specific implementations.
Applied to files:
test/switchlevels.ccompress.c
🧬 Code graph analysis (4)
compress.c (2)
deflate.c (2)
deflateInit2(243-379)deflateParams(596-636)test/test_compress_bound.cc (2)
level(23-51)level(23-23)
gzread.c.in (1)
gzguts.h (2)
PREFIX3(101-134)struct gzFile_s(103-103)
gzlib.c (1)
gzguts.h (2)
PREFIX3(101-134)struct gzFile_s(103-103)
gzwrite.c (1)
gzguts.h (1)
PREFIX3(101-134)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (200)
- GitHub Check: EL10 GCC S390X DFLTCC UBSAN
- GitHub Check: Ubuntu GCC RISC-V
- GitHub Check: Ubuntu GCC PPC64LE Power9
- GitHub Check: Ubuntu Clang PPC64LE Power9
- GitHub Check: Ubuntu Clang PPC64 Power9
- GitHub Check: Ubuntu GCC PPC64LE No VSX
- GitHub Check: Ubuntu GCC SSSE3 UBSAN
- GitHub Check: Ubuntu GCC No CTZLL
- GitHub Check: Ubuntu GCC No CTZ
- GitHub Check: Ubuntu GCC ARM HF Compat No Opt UBSAN
- GitHub Check: Ubuntu GCC No PCLMULQDQ UBSAN
- GitHub Check: Ubuntu GCC ARM SF ASAN
- GitHub Check: Ubuntu GCC SSE2 UBSAN
- GitHub Check: Ubuntu GCC Native Instructions (AVX)
- GitHub Check: Ubuntu GCC C23
- GitHub Check: Ubuntu GCC Symbol Prefix
- GitHub Check: Ubuntu GCC 32-bit
- GitHub Check: Ubuntu GCC Compat Symbol Prefix
- GitHub Check: Ubuntu GCC Native Instructions
- GitHub Check: Ubuntu GCC -O3 OSB add_subdirectory
- GitHub Check: EL10 GCC S390X DFLTCC UBSAN
- GitHub Check: Ubuntu GCC RISC-V
- GitHub Check: Ubuntu GCC PPC64LE Power9
- GitHub Check: Ubuntu Clang PPC64LE Power9
- GitHub Check: Ubuntu Clang PPC64 Power9
- GitHub Check: Ubuntu GCC PPC64LE No VSX
- GitHub Check: Ubuntu GCC SSSE3 UBSAN
- GitHub Check: Ubuntu GCC No CTZLL
- GitHub Check: Ubuntu GCC No CTZ
- GitHub Check: Ubuntu GCC ARM HF Compat No Opt UBSAN
- GitHub Check: Ubuntu GCC No PCLMULQDQ UBSAN
- GitHub Check: Ubuntu GCC ARM SF ASAN
- GitHub Check: Ubuntu GCC SSE2 UBSAN
- GitHub Check: Ubuntu GCC Native Instructions (AVX)
- GitHub Check: Ubuntu GCC C23
- GitHub Check: Ubuntu GCC Symbol Prefix
- GitHub Check: Ubuntu GCC 32-bit
- GitHub Check: Ubuntu GCC Compat Symbol Prefix
- GitHub Check: Ubuntu GCC Native Instructions
- GitHub Check: Ubuntu GCC -O3 OSB add_subdirectory
- GitHub Check: EL10 GCC S390X DFLTCC UBSAN
- GitHub Check: Ubuntu GCC RISC-V
- GitHub Check: Ubuntu GCC PPC64LE Power9
- GitHub Check: Ubuntu Clang PPC64LE Power9
- GitHub Check: Ubuntu Clang PPC64 Power9
- GitHub Check: Ubuntu GCC PPC64LE No VSX
- GitHub Check: Ubuntu GCC SSSE3 UBSAN
- GitHub Check: Ubuntu GCC No CTZLL
- GitHub Check: Ubuntu GCC No CTZ
- GitHub Check: Ubuntu GCC ARM HF Compat No Opt UBSAN
- GitHub Check: Ubuntu GCC No PCLMULQDQ UBSAN
- GitHub Check: Ubuntu GCC ARM SF ASAN
- GitHub Check: Ubuntu GCC SSE2 UBSAN
- GitHub Check: Ubuntu GCC Native Instructions (AVX)
- GitHub Check: Ubuntu GCC C23
- GitHub Check: Ubuntu GCC Symbol Prefix
- GitHub Check: Ubuntu GCC 32-bit
- GitHub Check: Ubuntu GCC Compat Symbol Prefix
- GitHub Check: Ubuntu GCC Native Instructions
- GitHub Check: Ubuntu GCC -O3 OSB add_subdirectory
- GitHub Check: EL10 GCC S390X DFLTCC UBSAN
- GitHub Check: Ubuntu GCC RISC-V
- GitHub Check: Ubuntu GCC PPC64LE Power9
- GitHub Check: Ubuntu Clang PPC64LE Power9
- GitHub Check: Ubuntu Clang PPC64 Power9
- GitHub Check: Ubuntu GCC PPC64LE No VSX
- GitHub Check: Ubuntu GCC SSSE3 UBSAN
- GitHub Check: Ubuntu GCC No CTZLL
- GitHub Check: Ubuntu GCC No CTZ
- GitHub Check: Ubuntu GCC ARM HF Compat No Opt UBSAN
- GitHub Check: Ubuntu GCC No PCLMULQDQ UBSAN
- GitHub Check: Ubuntu GCC ARM SF ASAN
- GitHub Check: Ubuntu GCC SSE2 UBSAN
- GitHub Check: Ubuntu GCC Native Instructions (AVX)
- GitHub Check: Ubuntu GCC C23
- GitHub Check: Ubuntu GCC Symbol Prefix
- GitHub Check: Ubuntu GCC 32-bit
- GitHub Check: Ubuntu GCC Compat Symbol Prefix
- GitHub Check: Ubuntu GCC Native Instructions
- GitHub Check: Ubuntu GCC -O3 OSB add_subdirectory
- GitHub Check: EL10 GCC S390X DFLTCC UBSAN
- GitHub Check: Ubuntu GCC RISC-V
- GitHub Check: Ubuntu GCC PPC64LE Power9
- GitHub Check: Ubuntu Clang PPC64LE Power9
- GitHub Check: Ubuntu Clang PPC64 Power9
- GitHub Check: Ubuntu GCC PPC64LE No VSX
- GitHub Check: Ubuntu GCC SSSE3 UBSAN
- GitHub Check: Ubuntu GCC No CTZLL
- GitHub Check: Ubuntu GCC No CTZ
- GitHub Check: Ubuntu GCC ARM HF Compat No Opt UBSAN
- GitHub Check: Ubuntu GCC No PCLMULQDQ UBSAN
- GitHub Check: Ubuntu GCC ARM SF ASAN
- GitHub Check: Ubuntu GCC SSE2 UBSAN
- GitHub Check: Ubuntu GCC Native Instructions (AVX)
- GitHub Check: Ubuntu GCC C23
- GitHub Check: Ubuntu GCC Symbol Prefix
- GitHub Check: Ubuntu GCC 32-bit
- GitHub Check: Ubuntu GCC Compat Symbol Prefix
- GitHub Check: Ubuntu GCC Native Instructions
- GitHub Check: Ubuntu GCC -O3 OSB add_subdirectory
- GitHub Check: EL10 GCC S390X DFLTCC UBSAN
- GitHub Check: Ubuntu GCC RISC-V
- GitHub Check: Ubuntu GCC PPC64LE Power9
- GitHub Check: Ubuntu Clang PPC64LE Power9
- GitHub Check: Ubuntu Clang PPC64 Power9
- GitHub Check: Ubuntu GCC PPC64LE No VSX
- GitHub Check: Ubuntu GCC SSSE3 UBSAN
- GitHub Check: Ubuntu GCC No CTZLL
- GitHub Check: Ubuntu GCC No CTZ
- GitHub Check: Ubuntu GCC ARM HF Compat No Opt UBSAN
- GitHub Check: Ubuntu GCC No PCLMULQDQ UBSAN
- GitHub Check: Ubuntu GCC ARM SF ASAN
- GitHub Check: Ubuntu GCC SSE2 UBSAN
- GitHub Check: Ubuntu GCC Native Instructions (AVX)
- GitHub Check: Ubuntu GCC C23
- GitHub Check: Ubuntu GCC Symbol Prefix
- GitHub Check: Ubuntu GCC 32-bit
- GitHub Check: Ubuntu GCC Compat Symbol Prefix
- GitHub Check: Ubuntu GCC Native Instructions
- GitHub Check: Ubuntu GCC -O3 OSB add_subdirectory
- GitHub Check: EL10 GCC S390X DFLTCC UBSAN
- GitHub Check: Ubuntu GCC RISC-V
- GitHub Check: Ubuntu GCC PPC64LE Power9
- GitHub Check: Ubuntu Clang PPC64LE Power9
- GitHub Check: Ubuntu Clang PPC64 Power9
- GitHub Check: Ubuntu GCC PPC64LE No VSX
- GitHub Check: Ubuntu GCC SSSE3 UBSAN
- GitHub Check: Ubuntu GCC No CTZLL
- GitHub Check: Ubuntu GCC No CTZ
- GitHub Check: Ubuntu GCC ARM HF Compat No Opt UBSAN
- GitHub Check: Ubuntu GCC No PCLMULQDQ UBSAN
- GitHub Check: Ubuntu GCC ARM SF ASAN
- GitHub Check: Ubuntu GCC SSE2 UBSAN
- GitHub Check: Ubuntu GCC Native Instructions (AVX)
- GitHub Check: Ubuntu GCC C23
- GitHub Check: Ubuntu GCC Symbol Prefix
- GitHub Check: Ubuntu GCC 32-bit
- GitHub Check: Ubuntu GCC Compat Symbol Prefix
- GitHub Check: Ubuntu GCC Native Instructions
- GitHub Check: Ubuntu GCC -O3 OSB add_subdirectory
- GitHub Check: EL10 GCC S390X DFLTCC UBSAN
- GitHub Check: Ubuntu GCC RISC-V
- GitHub Check: Ubuntu GCC PPC64LE Power9
- GitHub Check: Ubuntu Clang PPC64LE Power9
- GitHub Check: Ubuntu Clang PPC64 Power9
- GitHub Check: Ubuntu GCC PPC64LE No VSX
- GitHub Check: Ubuntu GCC SSSE3 UBSAN
- GitHub Check: Ubuntu GCC No CTZLL
- GitHub Check: Ubuntu GCC No CTZ
- GitHub Check: Ubuntu GCC ARM HF Compat No Opt UBSAN
- GitHub Check: Ubuntu GCC No PCLMULQDQ UBSAN
- GitHub Check: Ubuntu GCC ARM SF ASAN
- GitHub Check: Ubuntu GCC SSE2 UBSAN
- GitHub Check: Ubuntu GCC Native Instructions (AVX)
- GitHub Check: Ubuntu GCC C23
- GitHub Check: Ubuntu GCC Symbol Prefix
- GitHub Check: Ubuntu GCC 32-bit
- GitHub Check: Ubuntu GCC Compat Symbol Prefix
- GitHub Check: Ubuntu GCC Native Instructions
- GitHub Check: Ubuntu GCC -O3 OSB add_subdirectory
- GitHub Check: EL10 GCC S390X DFLTCC UBSAN
- GitHub Check: Ubuntu GCC RISC-V
- GitHub Check: Ubuntu GCC PPC64LE Power9
- GitHub Check: Ubuntu Clang PPC64LE Power9
- GitHub Check: Ubuntu Clang PPC64 Power9
- GitHub Check: Ubuntu GCC PPC64LE No VSX
- GitHub Check: Ubuntu GCC SSSE3 UBSAN
- GitHub Check: Ubuntu GCC No CTZLL
- GitHub Check: Ubuntu GCC No CTZ
- GitHub Check: Ubuntu GCC ARM HF Compat No Opt UBSAN
- GitHub Check: Ubuntu GCC No PCLMULQDQ UBSAN
- GitHub Check: Ubuntu GCC ARM SF ASAN
- GitHub Check: Ubuntu GCC SSE2 UBSAN
- GitHub Check: Ubuntu GCC Native Instructions (AVX)
- GitHub Check: Ubuntu GCC C23
- GitHub Check: Ubuntu GCC Symbol Prefix
- GitHub Check: Ubuntu GCC 32-bit
- GitHub Check: Ubuntu GCC Compat Symbol Prefix
- GitHub Check: Ubuntu GCC Native Instructions
- GitHub Check: Ubuntu GCC -O3 OSB add_subdirectory
- GitHub Check: EL10 GCC S390X DFLTCC UBSAN
- GitHub Check: Ubuntu GCC RISC-V
- GitHub Check: Ubuntu GCC PPC64LE Power9
- GitHub Check: Ubuntu Clang PPC64LE Power9
- GitHub Check: Ubuntu Clang PPC64 Power9
- GitHub Check: Ubuntu GCC PPC64LE No VSX
- GitHub Check: Ubuntu GCC SSSE3 UBSAN
- GitHub Check: Ubuntu GCC No CTZLL
- GitHub Check: Ubuntu GCC No CTZ
- GitHub Check: Ubuntu GCC ARM HF Compat No Opt UBSAN
- GitHub Check: Ubuntu GCC No PCLMULQDQ UBSAN
- GitHub Check: Ubuntu GCC ARM SF ASAN
- GitHub Check: Ubuntu GCC SSE2 UBSAN
- GitHub Check: Ubuntu GCC Native Instructions (AVX)
- GitHub Check: Ubuntu GCC C23
- GitHub Check: Ubuntu GCC Symbol Prefix
- GitHub Check: Ubuntu GCC 32-bit
- GitHub Check: Ubuntu GCC Compat Symbol Prefix
- GitHub Check: Ubuntu GCC Native Instructions
- GitHub Check: Ubuntu GCC -O3 OSB add_subdirectory
🔇 Additional comments (29)
test/minigzip.c (1)
76-76: LGTM: Type alignment with updated API.The change from
inttoz_int32_tcorrectly aligns with the updatedgzerrorsignature that now expects az_int32_t*parameter.test/minideflate.c (2)
8-8: LGTM: Required header for PRId32 macro.The inclusion of
inttypes.his necessary for thePRId32format macro used in lines 52, 57, 138, and 143.
52-52: LGTM: Correct format specifier for int32_t.The use of
PRId32ensures correct printing ofint32_tvalues across all platforms, including those whereint32_tis defined aslonginstead ofint.Also applies to: 57-57, 138-138, 143-143
test/infcover.c (2)
460-464: LGTM: Return type updated to z_int32_t.The return type change from
inttoz_int32_taligns with the broader type migration in this PR.
445-458: Review comment is based on incorrect premise.The NULL check at lines 450-453 is not new to this PR. Git blame shows the
if (desc == NULL)block was introduced in commit 602531c (April 2016), and this has been in the codebase for approximately 9 years. The current PR (commit b397f87) only changes the function's return type fromunsignedtoz_uint32_tand does not modify the NULL check logic.Likely an incorrect or invalid review comment.
gzlib.c (5)
305-317: LGTM: Updated return type for API consistency.The return type change from
inttoz_int32_tmaintains compatibility while addressing platform-specific type mismatches. Based on learnings.
320-341: LGTM: Updated signature for 32-bit type consistency.Both the return type and parameter type changes align with the PR's goal of explicit 32-bit width types across the API surface.
344-361: LGTM: Updated return type.Consistent with the broader API surface migration to z_int32_t.
502-514: LGTM: Updated return type.The z_int32_t return type aligns with the API migration pattern.
517-531: LGTM: Updated parameter type pointer.The
errnumparameter type change fromint*toz_int32_t*is necessary for callers to correctly receive error codes with the new typedef.gzread.c.in (6)
343-372: LGTM: Updated gzread signature and implementation.The function signature and internal type checks correctly migrate to z_int32_t/z_uint32_t. The overflow check at line 358 and return cast at line 371 are properly updated.
407-429: LGTM: Updated gzgetc return type.The return type change to z_int32_t maintains consistency with the API migration.
438-495: LGTM: Updated gzungetc signature.Both the return type and parameter
care correctly updated to z_int32_t.
498-556: LGTM: Updated gzgets signature.The return type remains
char*while thelenparameter is correctly updated to z_int32_t.
559-575: LGTM: Updated gzdirect return type.Consistent with the API migration to z_int32_t.
578-603: LGTM: Updated gzclose_r return type.The return type change to z_int32_t aligns with other gz* function updates.
gzwrite.c (8)
218-239: LGTM: Updated gzwrite signature and implementation.The function signature updates return type to z_int32_t and parameter
lento z_uint32_t. The overflow check (line 232) and return cast (line 238) are correctly updated.
271-313: LGTM: Updated gzputc signature.Both the return type and parameter
care correctly changed to z_int32_t.
316-337: LGTM: Updated gzputs return type.Consistent with the API migration pattern.
340-394: LGTM: Updated gzvprintf return type.The return type change to z_int32_t maintains API consistency.
396-404: LGTM: Updated gzprintf return type.Wrapper function correctly returns z_int32_t.
407-433: LGTM: Updated gzflush signature.Both return type and
flushparameter correctly updated to z_int32_t.
436-471: LGTM: Updated gzsetparams signature.Return type and both parameters (
level,strategy) correctly changed to z_int32_t.
474-509: LGTM: Updated gzclose_w return type.Consistent with API migration to z_int32_t.
test/switchlevels.c (1)
12-12: LGTM: Required header for PRId32 macro.The inclusion of
inttypes.his necessary for the format macro used at line 99.test/example.c (2)
77-77: LGTM: Updated error variable type.Correctly changed to z_int32_t to match the updated
gzerrorsignature.
698-741: LGTM: Updated pointer types for deflatePending.The parameter types for
bitsandpedare correctly updated toz_int32_t*andz_uint32_t*respectively, matching the updateddeflatePendingsignature.compress.c (2)
73-73: LGTM – consistent withcompress2changes.The return type change to
z_int32_tcorrectly matches the updatedcompress2signature that this function delegates to.
31-32: Signature changes are correct and test files remain compatible.The switch to
z_int32_tproperly addresses the platform-specific type mismatch issue. The typedef approach inzbuild.hensures safe type mapping:z_int32_tresolves tointwhenZLIB_COMPATis defined, andint32_totherwise. Test files passingint levelwill safely implicitly convert toz_int32_tthrough the macro definition.
…stead of int * Based on PR zlib-ng#1934
Introduce two new private types,
z_int32_tandz_uint32_tinzbuild.hto be used in C source files during compiling zlib-ng when the API differs between zlib-compat and zlib-ng, and toolchain uselonginstead ofintforint32_t; andunsigned longinstead ofunsigned intforuint32_t.