From ea4d2d05350511d5576dd7c40799eb2497e25b92 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Tue, 3 Mar 2020 00:26:18 +0100 Subject: [PATCH] Return *mut u8 in GuestPtrMut::as_raw Currently, we create an immutable `GuestPtr` from `self` and call `as_raw` on it which correctly returns `*const u8`. However, since we're dealing with `GuestPtrMut` I thought it might make more sense to return `*mut u8` directly instead. This will be needed (and will save us from silly casts `*const _ as *mut _`) in plugging in `Iovec<'_>` into `std::io::IoSliceMut` in `fd_read` and `fd_pread` calls. --- crates/runtime/src/memory/ptr.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/runtime/src/memory/ptr.rs b/crates/runtime/src/memory/ptr.rs index a09068ae25..54a80e8ab4 100644 --- a/crates/runtime/src/memory/ptr.rs +++ b/crates/runtime/src/memory/ptr.rs @@ -162,8 +162,8 @@ where } } - pub fn as_raw(&self) -> *const u8 { - self.as_immut().as_raw() + pub fn as_raw(&self) -> *mut u8 { + (self.mem.ptr as usize + self.region.start as usize) as *mut u8 } pub fn elem(&self, elements: i32) -> Result {