Do not zero-init struct in QEMU (#758)

* New Clippy fixes for QEMU

* no need to 0-initialize mem

* clippy
This commit is contained in:
Dominik Maier 2022-09-03 08:27:41 +02:00 committed by GitHub
parent 87fdd55125
commit 1f5189a6a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 10 deletions

View File

@ -64,11 +64,8 @@
//!``` //!```
#[cfg(feature = "frida_cli")] #[cfg(feature = "frida_cli")]
use alloc::boxed::Box; use alloc::{boxed::Box, string::ToString};
use alloc::{ use alloc::{string::String, vec::Vec};
string::{String, ToString},
vec::Vec,
};
#[cfg(feature = "frida_cli")] #[cfg(feature = "frida_cli")]
use std::error; use std::error;
use std::{net::SocketAddr, path::PathBuf, time::Duration}; use std::{net::SocketAddr, path::PathBuf, time::Duration};

View File

@ -1,12 +1,12 @@
//! Expose QEMU user `LibAFL` C api to Rust //! Expose QEMU user `LibAFL` C api to Rust
#[cfg(feature = "usermode")]
use core::ptr::copy_nonoverlapping;
use core::{ use core::{
convert::Into, convert::Into,
ffi::c_void, ffi::c_void,
ptr::{addr_of, addr_of_mut, null}, ptr::{addr_of, addr_of_mut, null},
}; };
#[cfg(feature = "usermode")]
use core::{mem::MaybeUninit, ptr::copy_nonoverlapping};
use std::{slice::from_raw_parts, str::from_utf8_unchecked}; use std::{slice::from_raw_parts, str::from_utf8_unchecked};
#[cfg(feature = "usermode")] #[cfg(feature = "usermode")]
@ -391,12 +391,12 @@ impl Iterator for GuestMaps {
return None; return None;
} }
unsafe { unsafe {
let mut ret = core::mem::zeroed(); let mut ret = MaybeUninit::uninit();
self.c_iter = libafl_maps_next(self.c_iter, addr_of_mut!(ret)); self.c_iter = libafl_maps_next(self.c_iter, ret.as_mut_ptr());
if self.c_iter.is_null() { if self.c_iter.is_null() {
None None
} else { } else {
Some(ret) Some(ret.assume_init())
} }
} }
} }