Sync with lucet-wasi (#106)

* Open /dev/null for writing as well as reading.

Port this fix to wasi-common:

b905c44483

* Remove all remaining uses of `std::mem::uninitialized`.

Patch inspired by:

2d6519d051

* Replace libc::memcpy() calls with std::ptr::copy_nonoverlapping()

Port this fix to wasi-common:

a3f3a33e9b

* Pass `WasiError` by value.

It's a `u16` underneath, so we can pass it by value.

* Avoid unnecessary explicit lifetime parameters.

* Use immutable references rather than mutable references.

Patch inspired by:

54baa4c38c
This commit is contained in:
Dan Gohman
2019-09-30 10:22:11 -07:00
committed by Jakub Konka
parent d33036a3b5
commit a679412dd0
9 changed files with 46 additions and 29 deletions

View File

@@ -110,7 +110,7 @@ pub(crate) fn enc_slice_of<T>(
// get the pointer into guest memory, and copy the bytes
let ptr = dec_ptr_mut(memory, ptr, len_bytes)? as *mut libc::c_void;
unsafe {
libc::memcpy(ptr, slice.as_ptr() as *const libc::c_void, len_bytes);
ptr::copy_nonoverlapping(slice.as_ptr() as *const libc::c_void, ptr, len_bytes);
}
Ok(())