Skip to content

Commit

Permalink
Clippy: Add type annotations for mem::transmute
Browse files Browse the repository at this point in the history
  • Loading branch information
r3dlight committed Jul 8, 2024
1 parent 3137369 commit ac0bb67
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ impl<D> UdpMessages<D> {
sin_port: addr4.port().to_be(),
..unsafe { mem::zeroed() }
});
unsafe { mem::transmute(sockaddr_in) }
unsafe {
mem::transmute::<
std::boxed::Box<libc::sockaddr_in>,
std::boxed::Box<libc::sockaddr>,
>(sockaddr_in)
}
}
net::SocketAddr::V6(addr6) => {
let sockaddr_in6 = Box::new(libc::sockaddr_in6 {
Expand All @@ -66,7 +71,12 @@ impl<D> UdpMessages<D> {
},
sin6_scope_id: addr6.scope_id(),
});
unsafe { mem::transmute(sockaddr_in6) }
unsafe {
mem::transmute::<
std::boxed::Box<libc::sockaddr_in6>,
std::boxed::Box<libc::sockaddr>,
>(sockaddr_in6)
}
}
});

Expand Down Expand Up @@ -169,15 +179,15 @@ impl UdpMessages<UdpSend> {

thread::sleep(sleep_duration);
}
}else {
} else {
let to_send = bufchunk.len();

for (i, buf) in bufchunk.iter_mut().enumerate() {
self.msgvec[i].msg_len = buf.len() as u32;
self.iovecs[i].iov_base = buf.as_mut_ptr().cast::<libc::c_void>();
self.iovecs[i].iov_len = buf.len();
}

let nb_msg;
unsafe {
nb_msg = libc::sendmmsg(
Expand Down

0 comments on commit ac0bb67

Please sign in to comment.