mirror of
https://github.com/rust-vmm/vhost-device.git
synced 2026-01-01 21:26:48 +00:00
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:
parent
926ea9b1c8
commit
019e02b0f2
@ -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()
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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>(),
|
||||
)
|
||||
};
|
||||
|
||||
@ -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()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user