Fix type mismatch with Windows GCC.#1965
Conversation
WalkthroughFunction 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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
🧪 Generate unit tests
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 |
There was a problem hiding this comment.
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
📒 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.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
z_uintmax_t *notz_size_t *orsize_t *.Summary by CodeRabbit