mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
misc: replace as <pointer> casts with safer alternatives
`as` casts can change mutability, which quickly leads to undefined behavior. Signed-off-by: Julian Schindel <mail@arctic-alpaca.de>
This commit is contained in:
committed by
Rob Bradford
parent
c97d635d40
commit
032f29da29
@@ -84,7 +84,7 @@ pub fn drain_completions(async_io: &mut dyn AsyncIo, count: usize) {
|
||||
/// Build an iovec suitable for a read into `buf`.
|
||||
pub fn read_iovec(buf: &mut [u8]) -> libc::iovec {
|
||||
libc::iovec {
|
||||
iov_base: buf.as_mut_ptr() as *mut libc::c_void,
|
||||
iov_base: buf.as_mut_ptr().cast(),
|
||||
iov_len: buf.len(),
|
||||
}
|
||||
}
|
||||
@@ -92,7 +92,7 @@ pub fn read_iovec(buf: &mut [u8]) -> libc::iovec {
|
||||
/// Build an iovec suitable for a write from `buf`.
|
||||
pub fn write_iovec(buf: &[u8]) -> libc::iovec {
|
||||
libc::iovec {
|
||||
iov_base: buf.as_ptr() as *mut libc::c_void,
|
||||
iov_base: buf.as_ptr().cast::<libc::c_void>().cast_mut(),
|
||||
iov_len: buf.len(),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user