Skip to content

fast_io.rs: replace the unsafe libc::copy_file_range call by rustix#458

Open
Franklin-Qi wants to merge 1 commit into
uutils:mainfrom
Franklin-Qi:fix-#442-replace-unsafe-libc-function-by-rustix
Open

fast_io.rs: replace the unsafe libc::copy_file_range call by rustix#458
Franklin-Qi wants to merge 1 commit into
uutils:mainfrom
Franklin-Qi:fix-#442-replace-unsafe-libc-function-by-rustix

Conversation

@Franklin-Qi

Copy link
Copy Markdown

Replace the unsafe libc::copy_file_range call with the safe rustix::fs::copy_file_range
API to improve safety and reduce unsafe code surface.

Closes: #442

@Franklin-Qi Franklin-Qi changed the title Replace the unsafe libc::copy_file_range call by rustix fast_io.rs: replace the unsafe libc::copy_file_range call by rustix Jun 5, 2026
@Franklin-Qi Franklin-Qi force-pushed the fix-#442-replace-unsafe-libc-function-by-rustix branch from 178f2d9 to 115b6b6 Compare June 5, 2026 08:10
@codecov

codecov Bot commented Jun 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.33333% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.31%. Comparing base (b90c599) to head (bd40e9e).

Files with missing lines Patch % Lines
src/sed/fast_io.rs 93.33% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #458      +/-   ##
==========================================
+ Coverage   83.12%   83.31%   +0.18%     
==========================================
  Files          13       13              
  Lines        5885     5939      +54     
  Branches      339      336       -3     
==========================================
+ Hits         4892     4948      +56     
+ Misses        990      988       -2     
  Partials        3        3              
Flag Coverage Δ
macos_latest 83.80% <100.00%> (+<0.01%) ⬆️
ubuntu_latest 84.06% <93.25%> (+0.18%) ⬆️
windows_latest 0.00% <ø> (ø)

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

☔ View full report in Codecov by Harness.
📢 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.

Comment thread src/sed/fast_io.rs Outdated
Comment thread src/sed/fast_io.rs Outdated
@sylvestre

Copy link
Copy Markdown
Contributor

@Franklin-Qi ping ? :)

@Franklin-Qi Franklin-Qi force-pushed the fix-#442-replace-unsafe-libc-function-by-rustix branch 3 times, most recently from a278deb to fb6ca00 Compare June 15, 2026 09:12
@sylvestre

Copy link
Copy Markdown
Contributor

not happy on mac:


error: unused import: `std::os::unix::io::AsFd`
    --> src/sed/fast_io.rs:1053:9
     |
1053 |     use std::os::unix::io::AsFd;
     |         ^^^^^^^^^^^^^^^^^^^^^^^
     |
     = note: `-D unused-imports` implied by `-D warnings`
     = help: to override `-D warnings` add `#[allow(unused_imports)]`


Replace the unsafe `libc::copy_file_range` call with the safe `rustix::fs::copy_file_range`.

Closes: uutils#442
@Franklin-Qi Franklin-Qi force-pushed the fix-#442-replace-unsafe-libc-function-by-rustix branch from fb6ca00 to bd40e9e Compare June 15, 2026 09:55
@Franklin-Qi

Copy link
Copy Markdown
Author

Thanks for the feedback; I’ve modified the compilation conditions. I don’t have a Mac here, so please take a look.

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.

replace unsafe libc::copy_file_range by rustix

2 participants