-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Replace mem::zeroed with mem::MaybeUninit::uninit for large struct in Unix #136826
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @thomcc (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
This comment has been minimized.
This comment has been minimized.
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.
I thought about this a bit. We probably can't use .assume_init()
as often as I thought since the C libraries neither guarantee that the structure can be moved, nor that it is fully initialized.
☔ The latest upstream changes (presumably #136954) made this pull request unmergeable. Please resolve the merge conflicts. |
… unix Signed-off-by: xizheyin <[email protected]>
Signed-off-by: xizheyin <[email protected]>
2dc051f
to
c1ecdf1
Compare
Signed-off-by: xizheyin <[email protected]>
That makes sense! I have removed |
Signed-off-by: xizheyin <[email protected]>
@bors r+ |
Rollup of 9 pull requests Successful merges: - rust-lang#135354 ([Debuginfo] Add MSVC Synthetic and Summary providers to LLDB) - rust-lang#136826 (Replace mem::zeroed with mem::MaybeUninit::uninit for large struct in Unix) - rust-lang#137194 (More const {} init in thread_local) - rust-lang#137334 (Greatly simplify lifetime captures in edition 2024) - rust-lang#137382 (bootstrap: add doc for vendor build step) - rust-lang#137423 (Improve a bit HIR pretty printer) - rust-lang#137435 (Fix "missing match arm body" suggestion involving `!`) - rust-lang#137448 (Fix bugs due to unhandled `ControlFlow` in compiler) - rust-lang#137458 (Fix missing self subst when rendering `impl Fn*<T>` with no output type) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#136826 - xizheyin:issue-136737, r=thomcc Replace mem::zeroed with mem::MaybeUninit::uninit for large struct in Unix As discussion in rust-lang#136737. - Replace `mem::zeroed()` with `MaybeUninit::uninit()` for `sockaddr_storage` in `accept()` and `recvfrom()` since these functions fill in the address structure - Replace `mem::zeroed()` with `MaybeUninit::uninit()` for `pthread_attr_t` in thread-related functions since `pthread_attr_init()` initializes the structure - Add references to man pages to document this behavior
…, r=ChrisDenton Fix `attr` cast for espidf rust-lang#136826 broke ESP-IDF builds with: https://github.com/esp-rs/esp-idf-template/actions/runs/13516221587/job/37765336588. This PR fixes it. cc: `@ivmarkov` `@xizheyin`
…, r=ChrisDenton Fix `attr` cast for espidf rust-lang#136826 broke ESP-IDF builds with: https://github.com/esp-rs/esp-idf-template/actions/runs/13516221587/job/37765336588. This PR fixes it. cc: ``@ivmarkov`` ``@xizheyin``
Rollup merge of rust-lang#137620 - SergioGasquez:fix/espidf-maybeunit, r=ChrisDenton Fix `attr` cast for espidf rust-lang#136826 broke ESP-IDF builds with: https://github.com/esp-rs/esp-idf-template/actions/runs/13516221587/job/37765336588. This PR fixes it. cc: ``@ivmarkov`` ``@xizheyin``
As discussion in #136737.
mem::zeroed()
withMaybeUninit::uninit()
forsockaddr_storage
inaccept()
andrecvfrom()
since these functions fill in the address structuremem::zeroed()
withMaybeUninit::uninit()
forpthread_attr_t
in thread-related functions sincepthread_attr_init()
initializes the structure