virtio-devices: 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:
Julian Schindel
2026-04-29 21:55:06 +02:00
committed by Rob Bradford
parent 8b101fb890
commit ae7113e1d4
7 changed files with 9 additions and 12 deletions
+1 -1
View File
@@ -185,7 +185,7 @@ impl BalloonEpollHandler {
let res =
// SAFETY: FFI call with valid arguments, guaranteed by VolatileSlice
unsafe {
libc::madvise(slice.ptr_guard_mut().as_ptr() as *mut libc::c_void,
libc::madvise(slice.ptr_guard_mut().as_ptr().cast(),
range_len as libc::size_t, advice) };
if res != 0 {
return Err(Error::MadviseFail(io::Error::last_os_error()));