Skip to content

Fix type mismatch on platforms where int32_t and uint32_t use long instead of int#1980

Merged
Dead2 merged 1 commit intozlib-ng:developfrom
mtl1979:intlong
Oct 22, 2025
Merged

Fix type mismatch on platforms where int32_t and uint32_t use long instead of int#1980
Dead2 merged 1 commit intozlib-ng:developfrom
mtl1979:intlong

Conversation

@mtl1979
Copy link
Copy Markdown
Collaborator

@mtl1979 mtl1979 commented Oct 9, 2025

Introduce two new private types, z_int32_tand z_uint32_t in zbuild.h to be used in C source files during compiling zlib-ng when the API differs between zlib-compat and zlib-ng, and toolchain use long instead of int for int32_t; and unsigned long instead of unsigned int for uint32_t.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Oct 9, 2025

Walkthrough

Public/exported function signatures were changed to use explicit 32-bit typedefs (z_int32_t, z_uint32_t) and z_uintmax_t where present; zbuild.h adds compatibility mappings. Mostly type-only API/test updates; test/infcover.c adds a NULL-desc early-return path in pull.

Changes

Cohort / File(s) Summary of Changes
Core compress API
compress.c
PREFIX(compress) and PREFIX(compress2) return types changed from intz_int32_t; compress2 level param changed from intz_int32_t.
Core uncompress API
uncompr.c
PREFIX(uncompress) and PREFIX(uncompress2) return types changed from intz_int32_t.
gzlib public API
gzlib.c
Exported functions gzclose, gzbuffer, gzrewind, gzeof now return z_int32_t; gzbuffer size param → z_uint32_t; gzerror errnum param → z_int32_t*.
gzread-side API
gzread.c.in
gzread, gzgetc, gzungetc, gzgets, gzdirect, gzclose_r signatures updated to z_int32_t/z_uint32_t for returns and length/char params; internal casts/returns aligned.
gzwrite-side API
gzwrite.c
Exported functions (gzwrite, gzputc, gzputs, gzvprintf, gzprintf, gzflush, gzsetparams, gzclose_w) updated to z_int32_t returns and use z_uint32_t/z_int32_t for size/level/strategy/flush params; internal casts adjusted.
Build-time integer mappings
zbuild.h
Added z_int32_t and z_uint32_t typedefs with ZLIB_COMPAT-conditional mappings (alias to int/unsigned int when compat, otherwise int32_t/uint32_t).
Utility error API
zutil.c
PREFIX(zError) parameter changed from intz_int32_t; implementation unchanged.
Tests — types & formatting
test/example.c, test/minideflate.c, test/minigzip.c, test/switchlevels.c
Test sources updated to use z_int32_t/z_uint32_t types and inttypes.h/PRIx macros for printing where needed; no logic changes.
Tests — infcover
test/infcover.c
pull now returns z_uint32_t and handles desc == NULL by resetting internal state and returning 0 (new early-exit); push return type changed to z_int32_t.

Possibly related PRs

Suggested labels

Architecture

Suggested reviewers

  • nmoinvaz
  • Dead2

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 29.03% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title "Fix type mismatch on platforms where int32_t and uint32_t use long instead of int" directly and clearly summarizes the main objective of the changeset. The raw summary confirms this is the core purpose: introducing z_int32_t and z_uint32_t type mappings in zbuild.h and updating function signatures across multiple files (compress.c, gzlib.c, gzread.c.in, gzwrite.c, uncompr.c, zutil.c) to address type mismatches on platforms where these types are typedef'd to long. The title is specific, concise, and clearly conveys the primary change without vague language or unnecessary details.
Description Check ✅ Passed The pull request description states that the changeset introduces two new private types, z_int32_t and z_uint32_t, in zbuild.h to address type mismatches on platforms where int32_t and uint32_t are typedef'd to long instead of int. This description accurately aligns with the main objective of the changeset, as evidenced by the zbuild.h additions introducing these macro definitions. The description further explains that these types will be used in C source files, which is confirmed by the extensive updates across multiple files (compress.c, gzlib.c, gzread.c.in, gzwrite.c, uncompr.c, zutil.c, and test files) where these new types replace int and unsigned int in function signatures and internal variable declarations. While the description is somewhat high-level and does not enumerate all the specific public API functions being updated, it captures the core intent of the changes and is clearly topical and related to the changeset.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov bot commented Oct 9, 2025

Codecov Report

❌ Patch coverage is 75.75758% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.88%. Comparing base (a9ef3eb) to head (9ee76d7).
⚠️ Report is 7 commits behind head on develop.

Files with missing lines Patch % Lines
test/minideflate.c 0.00% 4 Missing ⚠️
gzlib.c 80.00% 1 Missing ⚠️
gzwrite.c 90.00% 0 Missing and 1 partial ⚠️
test/switchlevels.c 0.00% 1 Missing ⚠️
zutil.c 0.00% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nmoinvaz
Copy link
Copy Markdown
Member

nmoinvaz commented Oct 9, 2025

In PR #1934, I noticed zlib-ng.h.in was changed. But in this PR, that file is not changed. Are those changes still needed or does this PR superceed #1934?

@mtl1979
Copy link
Copy Markdown
Collaborator Author

mtl1979 commented Oct 9, 2025

In PR #1934, I noticed zlib-ng.h.in was changed. But in this PR, that file is not changed. Are those changes still needed or does this PR superceed #1934?

This PR pretty much supercedes #1934 as changing existing function signatures in zlib-ng.h.in is a bad idea as it breaks the externally visible API.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (4)
gzlib.c (1)

320-341: Add upper bound to size to prevent overflow in allocations

size 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 width

Avoid 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 gzwrite

Use 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_t

Avoid 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

📥 Commits

Reviewing files that changed from the base of the PR and between 1f3e6b5 and d6e4b8c.

📒 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 compress2

No issues.

uncompr.c (2)

25-26: uncompress2 return type update is consistent

No functional change; aligns with fixed-width API.


78-80: uncompress wrapper updated — OK

Consistent with uncompress2.

gzlib.c (4)

305-317: gzclose signature updated — OK

Behavior unchanged, return type now z_int32_t.


344-361: gzrewind signature update — OK

Return codes/behavior unchanged.


502-514: gzeof signature update — OK

Still returns 0/1; no issues.


517-531: gzerror errnum type updated — OK

Pointer now z_int32_t*, assignment from state->err remains safe.

gzread.c.in (5)

407-430: gzgetc signature/logic — OK

Error handling and return values preserved.


438-495: gzungetc signature/logic — OK

Accepts z_int32_t c; bounds and buffer logic unchanged.


498-556: gzgets signature/logic — OK

Parameter len now z_int32_t; checks and behavior intact.


559-575: gzdirect signature/logic — OK

Return type updated; semantics unchanged.


578-603: gzclose_r signature/logic — OK

Return codes preserved.

gzwrite.c (6)

271-313: gzputc signature/logic — OK

Return values (-1 or 0..255) consistent with z_int32_t.


340-394: gzvprintf signature/logic — OK

Implicit conversion from int to z_int32_t on return is fine.


396-404: gzprintf signature/logic — OK

No issues.


407-433: gzflush signature/logic — OK

Return/param types updated; behavior unchanged.


436-471: gzsetparams signature/logic — OK

Types updated; semantics preserved.


474-509: gzclose_w signature/logic — OK

Return type change consistent; behavior unchanged.

@mtl1979
Copy link
Copy Markdown
Collaborator Author

mtl1979 commented Oct 12, 2025

Rewrote the comment in zbuild.h... The comment is now a lot longer, but hopefully less ambiguous in meaning...

@mtl1979 mtl1979 force-pushed the intlong branch 4 times, most recently from 53c1f08 to f472052 Compare October 12, 2025 18:32
@Dead2
Copy link
Copy Markdown
Member

Dead2 commented Oct 13, 2025

@ccawley2011 Could you verify whether this works for you?

@Dead2 Dead2 added the Compatibility API/ABI Compatibility issue label Oct 17, 2025
@mtl1979
Copy link
Copy Markdown
Collaborator Author

mtl1979 commented Oct 21, 2025

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.

@mtl1979
Copy link
Copy Markdown
Collaborator Author

mtl1979 commented Oct 21, 2025

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...

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, using sizeof is 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

📥 Commits

Reviewing files that changed from the base of the PR and between f472052 and b397f87.

📒 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.c
  • compress.c
  • test/example.c
  • gzlib.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.c
  • compress.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 int to z_int32_t correctly aligns with the updated gzerror signature that now expects a z_int32_t* parameter.

test/minideflate.c (2)

8-8: LGTM: Required header for PRId32 macro.

The inclusion of inttypes.h is necessary for the PRId32 format macro used in lines 52, 57, 138, and 143.


52-52: LGTM: Correct format specifier for int32_t.

The use of PRId32 ensures correct printing of int32_t values across all platforms, including those where int32_t is defined as long instead of int.

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 int to z_int32_t aligns 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 from unsigned to z_uint32_t and 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 int to z_int32_t maintains 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 errnum parameter type change from int* to z_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 c are correctly updated to z_int32_t.


498-556: LGTM: Updated gzgets signature.

The return type remains char* while the len parameter 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 len to 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 c are 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 flush parameter 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.h is 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 gzerror signature.


698-741: LGTM: Updated pointer types for deflatePending.

The parameter types for bits and ped are correctly updated to z_int32_t* and z_uint32_t* respectively, matching the updated deflatePending signature.

compress.c (2)

73-73: LGTM – consistent with compress2 changes.

The return type change to z_int32_t correctly matches the updated compress2 signature that this function delegates to.


31-32: Signature changes are correct and test files remain compatible.

The switch to z_int32_t properly addresses the platform-specific type mismatch issue. The typedef approach in zbuild.h ensures safe type mapping: z_int32_t resolves to int when ZLIB_COMPAT is defined, and int32_t otherwise. Test files passing int level will safely implicitly convert to z_int32_t through the macro definition.

Copy link
Copy Markdown
Member

@Dead2 Dead2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Dead2 Dead2 merged commit 7b29794 into zlib-ng:develop Oct 22, 2025
156 checks passed
@Dead2 Dead2 mentioned this pull request Nov 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Compatibility API/ABI Compatibility issue Warnings fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants