mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-05 18:20:34 +00:00
devices: remove use of mem::uninitialized
mem::uninitialized is unsafe, and we already replaced most instances of it with alternate implementations; however, another one slipped in since then. Replace it with Default::default() as a safe alterantive. BUG=None TEST=./build_test Change-Id: Idacdcb0ebe197cc93fba4b15c3dda774bb56e73e Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1691233 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
da52468b34
commit
bb5a4f1843
1 changed files with 2 additions and 4 deletions
|
@ -4,7 +4,6 @@
|
|||
|
||||
use std::cmp;
|
||||
use std::io;
|
||||
use std::mem;
|
||||
use std::os::unix::io::AsRawFd;
|
||||
|
||||
use data_model::DataInit;
|
||||
|
@ -171,9 +170,8 @@ impl<'a> Reader<'a> {
|
|||
}
|
||||
|
||||
/// Reads an object from the descriptor chain buffer.
|
||||
pub fn read_obj<T: DataInit>(&mut self) -> Result<T> {
|
||||
// Safe because DataInit types are safe to initialize from raw data.
|
||||
let mut object: T = unsafe { mem::uninitialized() };
|
||||
pub fn read_obj<T: DataInit + Default>(&mut self) -> Result<T> {
|
||||
let mut object: T = Default::default();
|
||||
self.read_exact(object.as_mut_slice()).map(|_| object)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue