-
Notifications
You must be signed in to change notification settings - Fork 82
fix(buf,driver): safety around set_len
#585
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
fix(buf,driver): safety around set_len
#585
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds explicit safety requirements to buffer length manipulation methods by making map_advanced and map_vec_advanced unsafe functions. This ensures callers are aware that these methods call set_len internally, which has safety requirements about the validity of the new length.
Key changes:
- Made
BufResultExt::map_advancedandVecBufResultExt::map_vec_advancedtrait methodsunsafe - Updated all call sites to wrap these method calls in
unsafeblocks - Removed
begin_or_cap()method inSlice<T>and replaced its usage withbegin_or_len()
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| compio-driver/src/op.rs | Added unsafe to trait method signatures for map_advanced and map_vec_advanced, with safety documentation explaining the requirements |
| compio-buf/src/slice.rs | Removed begin_or_cap() helper method and changed range() to use begin_or_len() instead |
| compio-process/src/windows.rs | Updated ChildStdout and ChildStderr read implementations to call map_advanced() in unsafe blocks |
| compio-process/src/unix.rs | Updated ChildStdout and ChildStderr read implementations to call map_advanced() in unsafe blocks |
| compio-net/src/socket.rs | Updated multiple socket receive methods to call map_advanced() and map_vec_advanced() in unsafe blocks |
| compio-fs/src/stdio/windows.rs | Updated Stdin read implementation to call map_advanced() in an unsafe block |
| compio-fs/src/pipe.rs | Updated Receiver read implementations to call map_advanced() and map_vec_advanced() in unsafe blocks |
| compio-fs/src/file.rs | Updated File read implementations to call map_advanced() and map_vec_advanced() in unsafe blocks |
| compio-fs/src/async_fd.rs | Updated AsyncFd read implementations to call map_advanced() and map_vec_advanced() in unsafe blocks |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Clippy suggests that we should not use |
|
@Berrysoft Sure. Sounds good to me. |
|
It's a bit massive to change the names. I chose another way to fix the CI. |
|
Ping @George-Miao |
George-Miao
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Closes #581
Closes #582