Skip to content

Conversation

brian-pane
Copy link

No description provided.

Copy link

codecov bot commented May 1, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Flag Coverage Δ
fuzz-compress ?
fuzz-decompress ?
test-aarch64-apple-darwin 88.48% <100.00%> (+0.04%) ⬆️
test-x86_64-apple-darwin 85.87% <0.00%> (-0.29%) ⬇️
test-x86_64-unknown-linux-gnu 87.68% <0.00%> (-0.32%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
libz-rs-sys/src/gz.rs 92.29% <100.00%> (+0.18%) ⬆️

... and 6 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines +2288 to +2294
let Ok(strategy) = Strategy::try_from(strategy) else {
return Z_STREAM_ERROR;
};
Copy link
Author

Choose a reason for hiding this comment

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

This check isn't in zlib-ng, but I needed it for the Rust version because we use a Strategy enum to hold the strategy internally. I return Z_STREAM_ERROR here to for consistency with the Rust version of deflateParams.

@brian-pane
Copy link
Author

@folkertdev this isn't an issue for this PR, but do you have a preferred way to implement C FFI varargs? One of the few gz functions left to implement is:

Z_EXTERN int Z_EXPORTVA gzprintf(gzFile file, const char *format, ...);

There's a va_list in core:ffi that I could use for this, but it's still experimental in the current Rust version.

}
// Safety: Because `state` is in write mode and `state.input` is non-null, `state.stream`
// was initialized using `deflateInit2` in `gz_init`.
unsafe { super::deflateParams(&mut state.stream, level, strategy as c_int) };
Copy link
Collaborator

Choose a reason for hiding this comment

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

it's really odd that the return value of this function is ignored. Basically, the user is responsible for providing values that are within the allowed ranges, and otherwise this function just silently fails.

Can you add a comment to that effect to the documentation of this function?

@folkertdev
Copy link
Collaborator

@folkertdev this isn't an issue for this PR, but do you have a preferred way to implement C FFI varargs? One of the few gz functions left to implement is:

Z_EXTERN int Z_EXPORTVA gzprintf(gzFile file, const char *format, ...);

There's a va_list in core:ffi that I could use for this, but it's still experimental in the current Rust version.

Hmm yeah that won't work. That feature is experimental, and I don't think it's anywhere near stabilization.

So I think there are 3 options

  • add a "nightly" feature flag, that can use nightly features.
  • just don't support this function
  • do something cursed with global_asm!

None of those are good options, really. @bjorn3 do you have thoughts here?

@folkertdev folkertdev merged commit 525490f into trifectatechfoundation:main May 1, 2025
24 checks passed
@brian-pane brian-pane deleted the gzsetparams branch May 3, 2025 18:40
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.

3 participants