diff --git a/lib/execute/src/invoke.rs b/lib/execute/src/invoke.rs index fc52a5582d..5d49228b2e 100644 --- a/lib/execute/src/invoke.rs +++ b/lib/execute/src/invoke.rs @@ -207,7 +207,7 @@ fn call_through_wrapper( .as_ptr(); code.publish(); - let func = unsafe { mem::transmute::<_, fn()>(exec_code_buf) }; + let func: fn() = unsafe { mem::transmute(exec_code_buf) }; Ok(match call_wasm(func) { Ok(()) => { diff --git a/lib/execute/src/memory.rs b/lib/execute/src/memory.rs index 31dc5c4014..3c71cdfc1d 100644 --- a/lib/execute/src/memory.rs +++ b/lib/execute/src/memory.rs @@ -110,8 +110,8 @@ impl LinearMemory { guard_bytes, region::Protection::None, ) - .expect("unable to make memory inaccessible"); } + .expect("unable to make memory inaccessible"); let copy_len = self.mmap.len() - self.offset_guard_size; new_mmap.as_mut_slice()[..copy_len].copy_from_slice(&self.mmap.as_slice()[..copy_len]); diff --git a/lib/execute/src/mmap.rs b/lib/execute/src/mmap.rs index 6b9fdab071..29fb3ca75e 100644 --- a/lib/execute/src/mmap.rs +++ b/lib/execute/src/mmap.rs @@ -4,7 +4,6 @@ use errno; use libc; use region; -use std::mem; use std::ptr; use std::slice; use std::string::String; @@ -36,23 +35,23 @@ impl Mmap { pub fn with_size(size: usize) -> Result { let page_size = region::page::size(); let alloc_size = round_up_to_page_size(size, page_size); - unsafe { - let ptr = libc::mmap( + let ptr = unsafe { + libc::mmap( ptr::null_mut(), alloc_size, libc::PROT_READ | libc::PROT_WRITE, libc::MAP_PRIVATE | libc::MAP_ANON, -1, 0, - ); - if mem::transmute::<_, isize>(ptr) != -1isize { - Ok(Self { - ptr: ptr as *mut u8, - len: alloc_size, - }) - } else { - Err(errno::errno().to_string()) - } + ) + }; + if ptr as isize == -1isize { + Err(errno::errno().to_string()) + } else { + Ok(Self { + ptr: ptr as *mut u8, + len: alloc_size, + }) } } diff --git a/lib/execute/src/vmcontext.rs b/lib/execute/src/vmcontext.rs index ebe520d792..95067d4d65 100644 --- a/lib/execute/src/vmcontext.rs +++ b/lib/execute/src/vmcontext.rs @@ -266,15 +266,13 @@ impl VMGlobal { /// Construct a `VMGlobalDefinition` variant of `VMGlobal`. pub fn definition(global: &Global) -> Self { let mut result = VMGlobalDefinition { storage: [0; 8] }; - unsafe { - match global.initializer { - GlobalInit::I32Const(x) => *result.as_i32() = x, - GlobalInit::I64Const(x) => *result.as_i64() = x, - GlobalInit::F32Const(x) => *result.as_f32_bits() = x, - GlobalInit::F64Const(x) => *result.as_f64_bits() = x, - GlobalInit::GetGlobal(_x) => unimplemented!("globals init with get_global"), - GlobalInit::Import => panic!("attempting to initialize imported global"), - } + match global.initializer { + GlobalInit::I32Const(x) => *unsafe { result.as_i32() } = x, + GlobalInit::I64Const(x) => *unsafe { result.as_i64() } = x, + GlobalInit::F32Const(x) => *unsafe { result.as_f32_bits() } = x, + GlobalInit::F64Const(x) => *unsafe { result.as_f64_bits() } = x, + GlobalInit::GetGlobal(_x) => unimplemented!("globals init with get_global"), + GlobalInit::Import => panic!("attempting to initialize imported global"), } Self { definition: result } }