mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user