Skip to content

Commit 4d02380

Browse files
oech3cakebaker
authored andcommitted
hostname: reduce range of unsafe
1 parent 3dec656 commit 4d02380

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

src/uu/hostname/src/hostname.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,8 @@ mod wsa {
3838
pub(super) struct WsaHandle(());
3939

4040
pub(super) fn start() -> io::Result<WsaHandle> {
41-
let err = unsafe {
42-
let mut data = std::mem::MaybeUninit::<WSADATA>::uninit();
43-
WSAStartup(0x0202, data.as_mut_ptr())
44-
};
41+
let mut data = std::mem::MaybeUninit::<WSADATA>::uninit();
42+
let err = unsafe { WSAStartup(0x0202, data.as_mut_ptr()) };
4543
if err == 0 {
4644
Ok(WsaHandle(()))
4745
} else {
@@ -51,10 +49,8 @@ mod wsa {
5149

5250
impl Drop for WsaHandle {
5351
fn drop(&mut self) {
54-
unsafe {
55-
// This possibly returns an error but we can't handle it
56-
let _err = WSACleanup();
57-
}
52+
// This possibly returns an error but we can't handle it
53+
let _ = unsafe { WSACleanup() };
5854
}
5955
}
6056
}

0 commit comments

Comments
 (0)