Skip to content
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

Change everything returning libc::sockaddr_storage to use an &mut out-... #16251

Merged
merged 1 commit into from
Aug 4, 2014

Conversation

apoelstra
Copy link
Contributor

Replacement for PR #16208 (make sockaddr* struct padding explicit) to make PR #15763 (fix nested returns) merge without breaking TCP code.

@@ -66,26 +66,26 @@ fn ip_to_inaddr(ip: rtio::IpAddr) -> InAddr {
}
}

fn addr_to_sockaddr(addr: rtio::SocketAddr) -> (libc::sockaddr_storage, uint) {
fn addr_to_sockaddr(addr: rtio::SocketAddr, storage: &mut libc::sockaddr_storage)
-> libc::socklen_t {
Copy link
Member

Choose a reason for hiding this comment

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

I believe the current conventions for a return type on the next line is to line up the arrow with the name of the first argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @alexcrichton, I was very unsure of this. I'll repush.

…ut-ptr instead

The BSD socket code does some cast tricks with the `libc::sockaddr*`
structs, which causes useful data to be stored in struct padding.
Since Load/Store instructions do not copy struct padding, this makes
these structures dangerous to pass or return by value.

In particular, rust-lang#15763 changes
return semantics so that a Load instruction is used, breaking the TCP
code. Once this PR is merged, that one should merge without error.
bors added a commit that referenced this pull request Aug 4, 2014
Replacement for PR #16208 (make sockaddr* struct padding explicit) to make PR #15763 (fix nested returns) merge without breaking TCP code.
@bors bors closed this Aug 4, 2014
@bors bors merged commit 30452d4 into rust-lang:master Aug 4, 2014
@apoelstra apoelstra deleted the tcp-fix branch August 4, 2014 22:24
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