diff options
| author | Daniel Kolsoi <dkolsoi@pixability.com> | 2018-03-23 17:01:34 -0400 |
|---|---|---|
| committer | Daniel Kolsoi <dkolsoi@pixability.com> | 2018-03-23 17:01:34 -0400 |
| commit | fdde09c70c102058feff4c9932044ae77d341d11 (patch) | |
| tree | ac2d34f83f6964ccae5f41f486342279062708db /src/libstd/sys | |
| parent | 55e1104dd918a809d2751d325c11d59c85485a2e (diff) | |
| download | rust-fdde09c70c102058feff4c9932044ae77d341d11.tar.gz rust-fdde09c70c102058feff4c9932044ae77d341d11.zip | |
Reduce scope of unsafe block in sun_path_offset
Diffstat (limited to 'src/libstd/sys')
| -rw-r--r-- | src/libstd/sys/unix/ext/net.rs | 12 |
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)> { |
