From 6354d3d14f94133e516d55b3c758654f67ad960c Mon Sep 17 00:00:00 2001 From: Brandon Fish Date: Sun, 9 Dec 2018 01:02:26 -0600 Subject: [PATCH 1/3] Fix clippy warnings unused imports --- src/apis/emscripten/process.rs | 2 +- src/apis/emscripten/syscalls.rs | 8 ++++---- src/apis/emscripten/utils.rs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/apis/emscripten/process.rs b/src/apis/emscripten/process.rs index a21e33814..09eeb4053 100644 --- a/src/apis/emscripten/process.rs +++ b/src/apis/emscripten/process.rs @@ -1,4 +1,4 @@ -use libc::{abort, c_char, pid_t, c_int, fork, exit}; +use libc::{abort, c_char, pid_t, c_int, exit}; use crate::webassembly::Instance; use std::ffi::CStr; diff --git a/src/apis/emscripten/syscalls.rs b/src/apis/emscripten/syscalls.rs index 51106b926..6bd800b10 100644 --- a/src/apis/emscripten/syscalls.rs +++ b/src/apis/emscripten/syscalls.rs @@ -25,7 +25,7 @@ use libc::{ getsockname, getsockopt, gid_t, - iovec, + // iovec, listen, lseek, mkdir, @@ -36,7 +36,7 @@ use libc::{ pread, pwrite, read, - readv, + // readv, recvfrom, recvmsg, sendmsg, @@ -50,7 +50,7 @@ use libc::{ uname, utsname, write, - writev, + // writev, select, FIONBIO, setpgid, @@ -58,7 +58,7 @@ use libc::{ sa_family_t, in_port_t, in_addr_t, - sockaddr_in, + // sockaddr_in, FIOCLEX, SOL_SOCKET, TIOCGWINSZ, diff --git a/src/apis/emscripten/utils.rs b/src/apis/emscripten/utils.rs index ba5277c60..2c84c20a9 100644 --- a/src/apis/emscripten/utils.rs +++ b/src/apis/emscripten/utils.rs @@ -2,7 +2,7 @@ use byteorder::{ByteOrder, LittleEndian}; use crate::webassembly::module::Module; use crate::webassembly::Instance; use libc::stat; -use std::ffi::{CStr, CString}; +use std::ffi::CStr; use std::os::raw::c_char; use std::slice; use std::mem::size_of; From a857bca9ead36ecd7e1ac867cffd17db347614d6 Mon Sep 17 00:00:00 2001 From: Brandon Fish Date: Sun, 9 Dec 2018 01:05:22 -0600 Subject: [PATCH 2/3] Fix clippy warnings manual implementation of an assign operation --- src/apis/emscripten/syscalls.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/apis/emscripten/syscalls.rs b/src/apis/emscripten/syscalls.rs index 6bd800b10..c47209b7a 100644 --- a/src/apis/emscripten/syscalls.rs +++ b/src/apis/emscripten/syscalls.rs @@ -592,7 +592,7 @@ pub extern "C" fn ___syscall145( if curr < 0 { return -1 } - ret = ret + curr; + ret += curr; } // debug!(" => ret: {}", ret); ret @@ -628,7 +628,7 @@ pub extern "C" fn ___syscall146( if curr < 0 { return -1 } - ret = ret + curr; + ret += curr; } // debug!(" => ret: {}", ret); ret From e7c4e25e77d7fb2181125d8e0ee6a0c28c1fca81 Mon Sep 17 00:00:00 2001 From: Brandon Fish Date: Sun, 9 Dec 2018 01:13:47 -0600 Subject: [PATCH 3/3] Fix clippy warnings returning the result of a let binding from a block --- src/webassembly/instance.rs | 11 ++++------- src/webassembly/module.rs | 16 ++++++---------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/webassembly/instance.rs b/src/webassembly/instance.rs index 301125513..9f2a511f3 100644 --- a/src/webassembly/instance.rs +++ b/src/webassembly/instance.rs @@ -61,12 +61,11 @@ fn get_function_addr( ) -> *const u8 { let index = func_index.index(); let len = import_functions.len(); - let func_pointer = if index < len { + if index < len { import_functions[index] } else { (functions[index - len]).as_ptr() - }; - func_pointer + } } pub struct EmscriptenData { @@ -668,12 +667,10 @@ extern "C" fn grow_memory(size: u32, memory_index: u32, instance: &mut Instance) "non-default memory_index (0) not supported yet" ); - let old_mem_size = instance + instance .memory_mut(memory_index as usize) .grow(size) - .unwrap_or(-1); - - old_mem_size + .unwrap_or(-1) } extern "C" fn current_memory(memory_index: u32, instance: &mut Instance) -> u32 { diff --git a/src/webassembly/module.rs b/src/webassembly/module.rs index f8191613c..13c2be646 100644 --- a/src/webassembly/module.rs +++ b/src/webassembly/module.rs @@ -389,15 +389,13 @@ impl<'environment> FuncEnvironmentTrait for FuncEnvironment<'environment> { }); // Create table based on the data above - let table = func.create_table(ir::TableData { + func.create_table(ir::TableData { base_gv, min_size: Imm64::new(0), bound_gv, element_size: Imm64::new(i64::from(self.pointer_bytes())), index_type: I64, - }); - - table + }) } // TODO: offsets should be based on the architecture the wasmer was compiled for. @@ -432,7 +430,7 @@ impl<'environment> FuncEnvironmentTrait for FuncEnvironment<'environment> { }); // Create table based on the data above - let heap = func.create_heap(ir::HeapData { + func.create_heap(ir::HeapData { base: heap_base, min_size: 0.into(), guard_size: (LinearMemory::DEFAULT_GUARD_SIZE as i64).into(), @@ -440,9 +438,7 @@ impl<'environment> FuncEnvironmentTrait for FuncEnvironment<'environment> { bound: (LinearMemory::DEFAULT_HEAP_SIZE as i64).into(), }, index_type: I32, - }); - - heap + }) } fn make_global( @@ -518,8 +514,8 @@ impl<'environment> FuncEnvironmentTrait for FuncEnvironment<'environment> { // pos.ins().imul_imm(callee, 4) callee } else { - let ext = pos.ins().uextend(ptr, callee); - ext + pos.ins().uextend(ptr, callee) + // let ext = pos.ins().uextend(ptr, callee); // pos.ins().imul_imm(ext, 4) }; // let entry_size = native_pointer_size() as i64 * 2;