Skip to content

Implement gzputc and gzputs #351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 24, 2025
Merged

Conversation

brian-pane
Copy link

No description provided.

Copy link

codecov bot commented Apr 23, 2025

Codecov Report

Attention: Patch coverage is 90.66667% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
libz-rs-sys/src/gz.rs 90.66% 7 Missing ⚠️
Flag Coverage Δ
fuzz-compress ?
fuzz-decompress ?
test-aarch64-apple-darwin 88.99% <90.66%> (+0.39%) ⬆️
test-x86_64-apple-darwin 86.99% <90.66%> (-0.08%) ⬇️
test-x86_64-unknown-linux-gnu 90.20% <90.66%> (+<0.01%) ⬆️

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 93.33% <90.66%> (+2.17%) ⬆️

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

@brian-pane brian-pane marked this pull request as draft April 23, 2025 19:35
@brian-pane
Copy link
Author

There are a couple of test coverage gaps that I want to fix, and then I'll move this PR out of draft state.

Comment on lines 1795 to 1798
if unsafe { gz_write(state, buf.as_ptr().cast::<c_void>(), 1) } != 1 {
return -1;
}
c & 0xff
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if unsafe { gz_write(state, buf.as_ptr().cast::<c_void>(), 1) } != 1 {
return -1;
}
c & 0xff
match unsafe { gz_write(state, buf.as_ptr().cast::<c_void>(), 1) } {
1 => c & 0xff,
_ => -1,
}

Comment on lines 1839 to 1863
if put < len as _ {
-1
} else {
len as _
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if put < len as _ {
-1
} else {
len as _
}
match put.cmp(&len) {
Ordering::Less => -1,
Ordering::Equal | Ordering::Greater => len as _,
}

unsafe {
gz_error(
state,
Some((Z_STREAM_ERROR, "string length does not fit in int")),
Copy link
Collaborator

Choose a reason for hiding this comment

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

using let msg = "..." should reduce the linecount here

Comment on lines 1776 to 1782
let have = unsafe {
state
.stream
.next_in
.add(state.stream.avail_in as usize)
.offset_from(state.input)
} as usize;
Copy link
Collaborator

Choose a reason for hiding this comment

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

We already have this bit of code somewhere else right? Maybe this can be a method on state?

Copy link
Author

Choose a reason for hiding this comment

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

I just pushed an update where this is encapsulated in a function. I made a small change to gz_write to simplify the safety conditions for this function. Let me know if the safety comments make sense.

@brian-pane brian-pane marked this pull request as ready for review April 24, 2025 03:53
@folkertdev folkertdev merged commit ab26d5a into trifectatechfoundation:main Apr 24, 2025
24 checks passed
@brian-pane brian-pane deleted the gzput branch April 29, 2025 15:47
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