Unsafe misaligned pointer
sunfishcode opened this issue · 1 comments
sunfishcode commented
Clippy reports this:
error: casting from `*const u8` to a more-strictly-aligned pointer (`*const wasi::wasi_unstable::raw::__wasi_dirent_t`)
--> src/bin/fd_readdir.rs:37:30
|
37 | let dirent_ptr = self.buf.as_ptr() as *const wasi_unstable::Dirent;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[deny(clippy::cast_ptr_alignment)] on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_ptr_alignment
The underlying buffer is allocated as
let mut buf: [u8; BUF_LEN] = [0; BUF_LEN];
which indeed may not be aligned for a Dirent
.
sunfishcode commented
Oops; wrong repo.