Skip to content

Commit

Permalink
Fixes unused mut in MemoryRegion constructors. (#487)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso committed Jul 20, 2023
1 parent d5525c2 commit 4c68373
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/memory_region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,12 @@ impl MemoryRegion {

/// Creates a new writable MemoryRegion from a mutable slice
pub fn new_writable(slice: &mut [u8], vm_addr: u64) -> Self {
Self::new(slice, vm_addr, 0, MemoryState::Writable)
Self::new(
unsafe { std::mem::transmute::<&mut [u8], &[u8]>(slice) },
vm_addr,
0,
MemoryState::Writable,
)
}

/// Creates a new copy on write MemoryRegion.
Expand All @@ -116,7 +121,12 @@ impl MemoryRegion {

/// Creates a new writable gapped MemoryRegion from a mutable slice
pub fn new_writable_gapped(slice: &mut [u8], vm_addr: u64, vm_gap_size: u64) -> Self {
Self::new(slice, vm_addr, vm_gap_size, MemoryState::Writable)
Self::new(
unsafe { std::mem::transmute::<&mut [u8], &[u8]>(slice) },
vm_addr,
vm_gap_size,
MemoryState::Writable,
)
}

/// Convert a virtual machine address into a host address
Expand Down

0 comments on commit 4c68373

Please sign in to comment.