mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 05:35:20 +00:00
build: Fix beta clippy issue (unnecessary_cast)
warning: casting raw pointers to the same type and constness is unnecessary (`*const protocol::MemoryRange` -> `*const protocol::MemoryRange`) --> vm-migration/src/protocol.rs:280:17 | 280 | self.data.as_ptr() as *const MemoryRange as *const u8, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `self.data.as_ptr()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast = note: `#[warn(clippy::unnecessary_cast)]` on by default Signed-off-by: Yu Li <liyu.yukiteru@bytedance.com>
This commit is contained in:
parent
9abf8d6868
commit
aac614e2ec
@ -73,7 +73,7 @@ impl AsyncIo for RawFileSync {
|
||||
let result = unsafe {
|
||||
libc::preadv(
|
||||
self.fd as libc::c_int,
|
||||
iovecs.as_ptr() as *const libc::iovec,
|
||||
iovecs.as_ptr(),
|
||||
iovecs.len() as libc::c_int,
|
||||
offset,
|
||||
)
|
||||
@ -98,7 +98,7 @@ impl AsyncIo for RawFileSync {
|
||||
let result = unsafe {
|
||||
libc::pwritev(
|
||||
self.fd as libc::c_int,
|
||||
iovecs.as_ptr() as *const libc::iovec,
|
||||
iovecs.as_ptr(),
|
||||
iovecs.len() as libc::c_int,
|
||||
offset,
|
||||
)
|
||||
|
@ -87,7 +87,7 @@ impl TxVirtio {
|
||||
let result = unsafe {
|
||||
libc::writev(
|
||||
tap.as_raw_fd() as libc::c_int,
|
||||
iovecs.as_ptr() as *const libc::iovec,
|
||||
iovecs.as_ptr(),
|
||||
iovecs.len() as libc::c_int,
|
||||
)
|
||||
};
|
||||
@ -226,7 +226,7 @@ impl RxVirtio {
|
||||
let result = unsafe {
|
||||
libc::readv(
|
||||
tap.as_raw_fd() as libc::c_int,
|
||||
iovecs.as_ptr() as *const libc::iovec,
|
||||
iovecs.as_ptr(),
|
||||
iovecs.len() as libc::c_int,
|
||||
)
|
||||
};
|
||||
|
@ -136,7 +136,7 @@ impl VsockPacket {
|
||||
.translate_gva(access_platform, head.len() as usize),
|
||||
VSOCK_PKT_HDR_SIZE,
|
||||
)
|
||||
.ok_or(VsockError::GuestMemory)? as *mut u8,
|
||||
.ok_or(VsockError::GuestMemory)?,
|
||||
buf: None,
|
||||
buf_size: 0,
|
||||
};
|
||||
@ -175,7 +175,7 @@ impl VsockPacket {
|
||||
.translate_gva(access_platform, buf_desc.len() as usize),
|
||||
pkt.buf_size,
|
||||
)
|
||||
.ok_or(VsockError::GuestMemory)? as *mut u8,
|
||||
.ok_or(VsockError::GuestMemory)?,
|
||||
);
|
||||
|
||||
Ok(pkt)
|
||||
@ -221,7 +221,7 @@ impl VsockPacket {
|
||||
.translate_gva(access_platform, head.len() as usize),
|
||||
VSOCK_PKT_HDR_SIZE,
|
||||
)
|
||||
.ok_or(VsockError::GuestMemory)? as *mut u8,
|
||||
.ok_or(VsockError::GuestMemory)?,
|
||||
buf: Some(
|
||||
get_host_address_range(
|
||||
desc_chain.memory(),
|
||||
@ -230,7 +230,7 @@ impl VsockPacket {
|
||||
.translate_gva(access_platform, buf_desc.len() as usize),
|
||||
buf_size,
|
||||
)
|
||||
.ok_or(VsockError::GuestMemory)? as *mut u8,
|
||||
.ok_or(VsockError::GuestMemory)?,
|
||||
),
|
||||
buf_size,
|
||||
})
|
||||
@ -428,8 +428,8 @@ mod tests {
|
||||
|
||||
fn set_pkt_len(len: u32, guest_desc: &GuestQDesc, mem: &GuestMemoryMmap) {
|
||||
let hdr_gpa = guest_desc.addr.get();
|
||||
let hdr_ptr = get_host_address_range(mem, GuestAddress(hdr_gpa), VSOCK_PKT_HDR_SIZE)
|
||||
.unwrap() as *mut u8;
|
||||
let hdr_ptr =
|
||||
get_host_address_range(mem, GuestAddress(hdr_gpa), VSOCK_PKT_HDR_SIZE).unwrap();
|
||||
let len_ptr = unsafe { hdr_ptr.add(HDROFF_LEN) };
|
||||
|
||||
LittleEndian::write_u32(unsafe { std::slice::from_raw_parts_mut(len_ptr, 4) }, len);
|
||||
|
@ -276,10 +276,7 @@ impl MemoryRangeTable {
|
||||
pub fn write_to(&self, fd: &mut dyn Write) -> Result<(), MigratableError> {
|
||||
// SAFETY: the slice is construted with the correct arguments
|
||||
fd.write_all(unsafe {
|
||||
std::slice::from_raw_parts(
|
||||
self.data.as_ptr() as *const MemoryRange as *const u8,
|
||||
self.length() as usize,
|
||||
)
|
||||
std::slice::from_raw_parts(self.data.as_ptr() as *const u8, self.length() as usize)
|
||||
})
|
||||
.map_err(MigratableError::MigrateSocket)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user