crosvm/common/data_model
Daniel Verkamp 13505b2b9e data_model: eliminate unsafe code in zerocopy_from_reader()
Rather than using MaybeUninit to create a zeroed instance of a type and
std::slice::from_raw_parts_mut() to get a mutable &[u8] referring to it,
we can use the zerocopy 0.7 FromZeroes trait new_zeroed() function and
the AsBytes + FromBytes as_bytes_mut() function to read from the reader
into the type as a mutable &[u8].

This removes all of the unsafe code in the zerocopy_from_reader()
function.

BUG=None
TEST=tools/dev_container tools/presubmit

Change-Id: I76b12b69b02e807a3e52ac9b9e7e7165ee1f55f4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4939612
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-10-16 17:49:03 +00:00
..
src data_model: eliminate unsafe code in zerocopy_from_reader() 2023-10-16 17:49:03 +00:00
Cargo.toml
LICENSE