Skip to content

Conversation

xizheyin
Copy link
Member

As discussion in #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

@rustbot
Copy link
Collaborator

rustbot commented Feb 10, 2025

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 (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added O-unix Operating system: Unix-like S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Feb 10, 2025
@rust-log-analyzer

This comment has been minimized.

Copy link
Member

@joboet joboet left a 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.

@bors
Copy link
Collaborator

bors commented Feb 13, 2025

☔ The latest upstream changes (presumably #136954) made this pull request unmergeable. Please resolve the merge conflicts.

@xizheyin
Copy link
Member Author

That makes sense! I have removed assume_init. As far as I understand it, there is no difference in program behavior between using as_mut_ptr/as_ptr directly and using assume_init, but there is a difference in terms of intent. One does not assume that C performs the initialization, the other assumes that C must perform the initialization. So, we should just pass the pointer to C's API, and then C fills it, and it's not up to us to consider whether it's init or not. Is that correct? @thomcc

@xizheyin xizheyin requested a review from thomcc February 19, 2025 07:53
Signed-off-by: xizheyin <[email protected]>
@xizheyin xizheyin requested a review from joboet February 19, 2025 12:17
@thomcc
Copy link
Member

thomcc commented Feb 22, 2025

@bors r+

@bors
Copy link
Collaborator

bors commented Feb 22, 2025

📌 Commit 70f11ee has been approved by thomcc

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 22, 2025
@bors bors merged commit 4493159 into rust-lang:master Feb 23, 2025
6 checks passed
@rustbot rustbot added this to the 1.87.0 milestone Feb 23, 2025
@xizheyin xizheyin deleted the issue-136737 branch March 11, 2025 05:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-unix Operating system: Unix-like S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants