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

View File

@@ -396,7 +396,7 @@ impl VsockPacket {
PacketBuffer::Borrowed { ptr, len } => {
// SAFETY: bound checks have already been performed when creating the packet
// from the virtq descriptor.
Some(unsafe { std::slice::from_raw_parts(*ptr as *const u8, *len) })
Some(unsafe { std::slice::from_raw_parts((*ptr).cast(), *len) })
}
}
}