Skip to content

Fix type mismatch with Windows GCC.#1965

Merged
Dead2 merged 1 commit intozlib-ng:developfrom
mtl1979:wingcc
Sep 9, 2025
Merged

Fix type mismatch with Windows GCC.#1965
Dead2 merged 1 commit intozlib-ng:developfrom
mtl1979:wingcc

Conversation

@mtl1979
Copy link
Copy Markdown
Collaborator

@mtl1979 mtl1979 commented Sep 6, 2025

  • compress2()/uncompress() use z_uintmax_t * not z_size_t * or size_t *.

Summary by CodeRabbit

  • Tests
    • Fuzz tests for compression/decompression updated to better handle very large payloads by improving length handling.
    • Increased robustness against overflow and edge cases, reducing false negatives in test runs.
    • No changes to runtime behavior, performance, or public APIs; users should see no functional differences.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Sep 6, 2025

Walkthrough

Function parameter types in test/fuzz/fuzzer_compress.c were widened to z_uintmax_t for length arguments in check_compress_level and check_decompress. Calls to PREFIX(compress2) and PREFIX(uncompress) still pass addresses of these variables. No other logic or API usage changed.

Changes

Cohort / File(s) Summary of Changes
Type widenings in fuzzer
test/fuzz/fuzzer_compress.c
Widened length parameters: check_compress_level(comprLen, uncomprLen) and check_decompress(comprLen) now use z_uintmax_t instead of z_size_t/size_t; call sites unchanged aside from variable types.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

Warnings fix

Suggested reviewers

  • Dead2
  • nmoinvaz

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bde51c6 and 5883c09.

📒 Files selected for processing (1)
  • test/fuzz/fuzzer_compress.c (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/fuzz/fuzzer_compress.c
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • 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.

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: 0

🧹 Nitpick comments (4)
test/fuzz/fuzzer_compress.c (4)

17-18: Check return codes from compress2/uncompress.

Capture and assert return values so failures are attributed to the fuzzer, not hidden by later asserts.

-    PREFIX(compress2)(compr, &comprLen, data, dataLen, level);
-    PREFIX(uncompress)(uncompr, &uncomprLen, compr, comprLen);
+    int cr = PREFIX(compress2)(compr, &comprLen, data, dataLen, level);
+    assert(cr == Z_OK);
+    int ur = PREFIX(uncompress)(uncompr, &uncomprLen, compr, comprLen);
+    assert(ur == Z_OK);

40-51: Type consistency: avoid implicit size_t → z_uintmax_t conversion.

Passing copyLen (size_t) to uncompress (expects z_uintmax_t) is safe but can warn under -Wconversion. Make the cast explicit.

-    PREFIX(uncompress)(compr, &comprLen, copy, copyLen);
+    PREFIX(uncompress)(compr, &comprLen, copy, (z_uintmax_t)copyLen);

1-9: Add missing standard headers for memcpy/memcmp/malloc/free.

Some builds rely on transitive includes; be explicit to avoid implicit declarations.

 #include <stdio.h>
 #include <assert.h>
+#include <string.h>  /* memcpy, memcmp */
+#include <stdlib.h>  /* malloc, free   */

59-61: Minor: const instead of static for kMaxSize.

It’s not mutated; const communicates intent and allows better optimization.

-    static size_t kMaxSize = 1024 * 1024;
+    const size_t kMaxSize = 1024u * 1024u;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 83a84fa and bde51c6.

📒 Files selected for processing (1)
  • test/fuzz/fuzzer_compress.c (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
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.
⏰ 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). (7)
  • GitHub Check: EL9 Clang S390X DFLTCC MSAN
  • GitHub Check: EL9 Clang S390X DFLTCC MSAN
  • GitHub Check: EL9 Clang S390X DFLTCC MSAN
  • GitHub Check: EL9 Clang S390X DFLTCC MSAN
  • GitHub Check: EL9 Clang S390X DFLTCC MSAN
  • GitHub Check: EL9 Clang S390X DFLTCC MSAN
  • GitHub Check: EL9 Clang S390X DFLTCC MSAN
🔇 Additional comments (2)
test/fuzz/fuzzer_compress.c (2)

14-16: Good fix: z_uintmax_t eliminates Windows GCC pointer-mismatch.

Widening comprLen/uncomprLen to z_uintmax_t aligns with the library prototypes and resolves the size_t*/z_size_t* vs z_uintmax_t* mismatch on Windows. Looks correct.


14-16: Resolved: all compress2/uncompress calls use z_uintmax_t Verified that in both test/fuzz/fuzzer_compress.c and test/example.c every call to compress2/uncompress passes a z_uintmax_t * for the length parameter—no size_t * remains.

@mtl1979
Copy link
Copy Markdown
Collaborator Author

mtl1979 commented Sep 6, 2025

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Sep 6, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@codecov
Copy link
Copy Markdown

codecov bot commented Sep 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.59%. Comparing base (83a84fa) to head (5883c09).
⚠️ Report is 3 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1965      +/-   ##
===========================================
- Coverage    81.59%   81.59%   -0.01%     
===========================================
  Files          163      163              
  Lines        14073    14074       +1     
  Branches      3164     3166       +2     
===========================================
  Hits         11483    11483              
+ Misses        1608     1579      -29     
- Partials       982     1012      +30     

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

@Dead2 Dead2 merged commit e0c008c into zlib-ng:develop Sep 9, 2025
146 of 150 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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants