Replace ptr casts with typed cast() method

Replace type inferred raw pointer casts with .cast() method calls to
make intent clearer.

Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
This commit is contained in:
Manos Pitsidianakis 2025-08-01 21:06:51 +03:00 committed by Stefano Garzarella
parent 926ea9b1c8
commit 019e02b0f2
4 changed files with 7 additions and 5 deletions

View File

@ -637,7 +637,8 @@ impl VhostUserBackendMut for VhostUserCanBackend {
.config()
.as_slice()
.as_ptr()
.offset(offset as isize) as *const _ as *const _,
.offset(offset as isize)
.cast::<u8>(),
size as usize,
)
.to_vec()

View File

@ -421,7 +421,8 @@ impl<D: 'static + GpioDevice + Sync + Send> VhostUserBackendMut for VhostUserGpi
.config()
.as_slice()
.as_ptr()
.offset(offset as isize) as *const _ as *const _,
.offset(offset as isize)
.cast::<u8>(),
size as usize,
)
.to_vec()
@ -1157,7 +1158,7 @@ mod tests {
// reading its content from byte array.
unsafe {
from_raw_parts(
&config as *const _ as *const _,
(&raw const config).cast::<u8>(),
size_of::<VirtioGpioConfig>(),
)
.to_vec()

View File

@ -298,7 +298,7 @@ impl VhostUserBackendMut for VhostUserScsiBackend {
// access up to the size of the struct.
let config_slice = unsafe {
slice::from_raw_parts(
&config as *const virtio_scsi_config as *const u8,
(&raw const config).cast::<u8>(),
mem::size_of::<virtio_scsi_config>(),
)
};

View File

@ -1423,7 +1423,7 @@ mod tests {
// reading its content from byte array.
unsafe {
from_raw_parts(
&dummy_config as *const _ as *const _,
(&raw const dummy_config).cast::<u8>(),
size_of::<VirtioSpiConfig>(),
)
.to_vec()