Skip to content

Commit

Permalink
deny unsafe in unsafe in pal/windows/net.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisDenton committed Jul 15, 2024
1 parent b221712 commit 4202856
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions library/std/src/sys/pal/windows/net.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![unstable(issue = "none", feature = "windows_net")]
#![deny(unsafe_op_in_unsafe_fn)]

use crate::cmp;
use crate::io::{self, BorrowedBuf, BorrowedCursor, IoSlice, IoSliceMut, Read};
Expand Down Expand Up @@ -92,7 +93,7 @@ pub mod netc {
}

pub unsafe fn send(socket: SOCKET, buf: *const c_void, len: c_int, flags: c_int) -> c_int {
c::send(socket, buf.cast::<u8>(), len, flags)
unsafe { c::send(socket, buf.cast::<u8>(), len, flags) }
}
pub unsafe fn sendto(
socket: SOCKET,
Expand All @@ -102,15 +103,15 @@ pub mod netc {
addr: *const SOCKADDR,
addrlen: c_int,
) -> c_int {
c::sendto(socket, buf.cast::<u8>(), len, flags, addr, addrlen)
unsafe { c::sendto(socket, buf.cast::<u8>(), len, flags, addr, addrlen) }
}
pub unsafe fn getaddrinfo(
node: *const c_char,
service: *const c_char,
hints: *const ADDRINFOA,
res: *mut *mut ADDRINFOA,
) -> c_int {
c::getaddrinfo(node.cast::<u8>(), service.cast::<u8>(), hints, res)
unsafe { c::getaddrinfo(node.cast::<u8>(), service.cast::<u8>(), hints, res) }
}
}

Expand Down Expand Up @@ -523,7 +524,7 @@ impl Socket {
pub unsafe fn from_raw(raw: c::SOCKET) -> Self {
debug_assert_eq!(mem::size_of::<c::SOCKET>(), mem::size_of::<RawSocket>());
debug_assert_eq!(mem::align_of::<c::SOCKET>(), mem::align_of::<RawSocket>());
Self::from_raw_socket(raw as RawSocket)
unsafe { Self::from_raw_socket(raw as RawSocket) }
}
}

Expand Down Expand Up @@ -573,6 +574,6 @@ impl IntoRawSocket for Socket {

impl FromRawSocket for Socket {
unsafe fn from_raw_socket(raw_socket: RawSocket) -> Self {
Self(FromRawSocket::from_raw_socket(raw_socket))
unsafe { Self(FromRawSocket::from_raw_socket(raw_socket)) }
}
}

0 comments on commit 4202856

Please sign in to comment.