about summary refs log tree commit diff
path: root/library/std/src/os/solid
diff options
context:
space:
mode:
authorjoboet <jonasboettiger@icloud.com>2025-02-07 18:34:09 +0100
committerjoboet <jonasboettiger@icloud.com>2025-02-12 14:13:35 +0100
commit80c60fe78375cb10a2fed6540dc2b29751fc4263 (patch)
tree207a56b85129112a5c9d217777bd8fca36a35526 /library/std/src/os/solid
parentc182ce9cbc8c29ebc1b4559d027df545e6cdd287 (diff)
downloadrust-80c60fe78375cb10a2fed6540dc2b29751fc4263.tar.gz
rust-80c60fe78375cb10a2fed6540dc2b29751fc4263.zip
std: replace the `FromInner` implementation for addresses with private conversion functions
Having these implementation available crate-wide means that platforms not using sockets for their networking code have to stub out the libc definitions required to support them. This PR moves the conversions to private helper functions that are only available where actually needed.

I also fixed the signature of the function converting from a C socket address to a Rust one: taking a reference to a `sockaddr_storage` resulted in unsound usage inside  `LookupHost::next`, which could create a reference to a structure smaller than `sockaddr_storage`. Thus I've replaced the argument type with a pointer and made the function `unsafe`.
Diffstat (limited to 'library/std/src/os/solid')
-rw-r--r--library/std/src/os/solid/io.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/library/std/src/os/solid/io.rs b/library/std/src/os/solid/io.rs
index b8c3440542d..ca58a900c44 100644
--- a/library/std/src/os/solid/io.rs
+++ b/library/std/src/os/solid/io.rs
@@ -122,7 +122,7 @@ impl BorrowedFd<'_> {
     /// Creates a new `OwnedFd` instance that shares the same underlying file
     /// description as the existing `BorrowedFd` instance.
     pub fn try_clone_to_owned(&self) -> crate::io::Result<OwnedFd> {
-        let fd = sys::net::cvt(unsafe { sys::net::netc::dup(self.as_raw_fd()) })?;
+        let fd = sys::net::cvt(unsafe { crate::sys::abi::sockets::dup(self.as_raw_fd()) })?;
         Ok(unsafe { OwnedFd::from_raw_fd(fd) })
     }
 }
@@ -168,7 +168,7 @@ impl FromRawFd for OwnedFd {
 impl Drop for OwnedFd {
     #[inline]
     fn drop(&mut self) {
-        unsafe { sys::net::netc::close(self.fd.as_inner()) };
+        unsafe { crate::sys::abi::sockets::close(self.fd.as_inner()) };
     }
 }