Skip to content
This repository was archived by the owner on Jan 10, 2025. It is now read-only.

Commit 4c68373

Browse files
authored
Fixes unused mut in MemoryRegion constructors. (#487)
1 parent d5525c2 commit 4c68373

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/memory_region.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,12 @@ impl MemoryRegion {
104104

105105
/// Creates a new writable MemoryRegion from a mutable slice
106106
pub fn new_writable(slice: &mut [u8], vm_addr: u64) -> Self {
107-
Self::new(slice, vm_addr, 0, MemoryState::Writable)
107+
Self::new(
108+
unsafe { std::mem::transmute::<&mut [u8], &[u8]>(slice) },
109+
vm_addr,
110+
0,
111+
MemoryState::Writable,
112+
)
108113
}
109114

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

117122
/// Creates a new writable gapped MemoryRegion from a mutable slice
118123
pub fn new_writable_gapped(slice: &mut [u8], vm_addr: u64, vm_gap_size: u64) -> Self {
119-
Self::new(slice, vm_addr, vm_gap_size, MemoryState::Writable)
124+
Self::new(
125+
unsafe { std::mem::transmute::<&mut [u8], &[u8]>(slice) },
126+
vm_addr,
127+
vm_gap_size,
128+
MemoryState::Writable,
129+
)
120130
}
121131

122132
/// Convert a virtual machine address into a host address

0 commit comments

Comments
 (0)