Use ptr::cast instead of as casts in several places. (#3507)

`ptr::cast` has the advantage of being unable to silently cast
`*const T` to `*mut T`. This turned up several places that were
performing such casts, which this PR also fixes.
This commit is contained in:
Dan Gohman
2022-01-21 13:03:17 -08:00
committed by GitHub
parent a9d209732d
commit 881c19473d
14 changed files with 64 additions and 58 deletions

View File

@@ -1553,7 +1553,7 @@ fn dirent_bytes(dirent: types::Dirent) -> Vec<u8> {
.expect("Dirent is smaller than 2^32");
let mut bytes = Vec::with_capacity(size);
bytes.resize(size, 0);
let ptr = bytes.as_mut_ptr() as *mut types::Dirent;
let ptr = bytes.as_mut_ptr().cast::<types::Dirent>();
let guest_dirent = types::Dirent {
d_ino: dirent.d_ino.to_le(),
d_namlen: dirent.d_namlen.to_le(),