about summary refs log tree commit diff
path: root/src/libstd/sys
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-03-25 05:26:58 +0000
committerbors <bors@rust-lang.org>2018-03-25 05:26:58 +0000
commit482a913fb337855072a53c0d602cd19947f45285 (patch)
treeb519f553cfab319595c2ee7ed5dcd86124c9cf86 /src/libstd/sys
parente5bf0428d134e6f9c1fe54839f249c616b6b0b0b (diff)
parentfdde09c70c102058feff4c9932044ae77d341d11 (diff)
downloadrust-482a913fb337855072a53c0d602cd19947f45285.tar.gz
rust-482a913fb337855072a53c0d602cd19947f45285.zip
Auto merge of #49315 - TheDan64:smaller_unsafe_block, r=joshtriplett
Reduce scope of unsafe block in sun_path_offset

I reduced the scope of the unsafe block to the `uninitialized` call which is the only actual unsafe bit.
Diffstat (limited to 'src/libstd/sys')
-rw-r--r--src/libstd/sys/unix/ext/net.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/libstd/sys/unix/ext/net.rs b/src/libstd/sys/unix/ext/net.rs
index ad437658d14..ba80cbe47c8 100644
--- a/src/libstd/sys/unix/ext/net.rs
+++ b/src/libstd/sys/unix/ext/net.rs
@@ -51,13 +51,11 @@ use libc::MSG_NOSIGNAL;
 const MSG_NOSIGNAL: libc::c_int = 0x0;
 
 fn sun_path_offset() -> usize {
-    unsafe {
-        // Work with an actual instance of the type since using a null pointer is UB
-        let addr: libc::sockaddr_un = mem::uninitialized();
-        let base = &addr as *const _ as usize;
-        let path = &addr.sun_path as *const _ as usize;
-        path - base
-    }
+    // Work with an actual instance of the type since using a null pointer is UB
+    let addr: libc::sockaddr_un = unsafe { mem::uninitialized() };
+    let base = &addr as *const _ as usize;
+    let path = &addr.sun_path as *const _ as usize;
+    path - base
 }
 
 unsafe fn sockaddr_un(path: &Path) -> io::Result<(libc::sockaddr_un, libc::socklen_t)> {