clippy (#1851)
This commit is contained in:
parent
af97033d85
commit
973c4358e6
@ -361,21 +361,23 @@ pub mod pybind {
|
|||||||
fn get(&self, idx: CorpusId) -> Result<&RefCell<Testcase<BytesInput>>, Error> {
|
fn get(&self, idx: CorpusId) -> Result<&RefCell<Testcase<BytesInput>>, Error> {
|
||||||
let ptr = unwrap_me!(self.wrapper, c, {
|
let ptr = unwrap_me!(self.wrapper, c, {
|
||||||
c.get(idx)
|
c.get(idx)
|
||||||
.map(|v| v as *const RefCell<Testcase<BytesInput>>)
|
.map(core::ptr::from_ref::<RefCell<Testcase<BytesInput>>>)
|
||||||
})?;
|
})?;
|
||||||
Ok(unsafe { ptr.as_ref().unwrap() })
|
Ok(unsafe { ptr.as_ref().unwrap() })
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn current(&self) -> &Option<CorpusId> {
|
fn current(&self) -> &Option<CorpusId> {
|
||||||
let ptr = unwrap_me!(self.wrapper, c, { c.current() as *const Option<CorpusId> });
|
let ptr = unwrap_me!(self.wrapper, c, {
|
||||||
|
core::ptr::from_ref::<Option<CorpusId>>(c.current())
|
||||||
|
});
|
||||||
unsafe { ptr.as_ref().unwrap() }
|
unsafe { ptr.as_ref().unwrap() }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn current_mut(&mut self) -> &mut Option<CorpusId> {
|
fn current_mut(&mut self) -> &mut Option<CorpusId> {
|
||||||
let ptr = unwrap_me_mut!(self.wrapper, c, {
|
let ptr = unwrap_me_mut!(self.wrapper, c, {
|
||||||
c.current_mut() as *mut Option<CorpusId>
|
core::ptr::from_mut::<Option<CorpusId>>(c.current_mut())
|
||||||
});
|
});
|
||||||
unsafe { ptr.as_mut().unwrap() }
|
unsafe { ptr.as_mut().unwrap() }
|
||||||
}
|
}
|
||||||
|
@ -205,8 +205,8 @@ where
|
|||||||
|
|
||||||
impl<A, B, DOT> ProxyObserversTuple<A, B, DOT> {
|
impl<A, B, DOT> ProxyObserversTuple<A, B, DOT> {
|
||||||
fn set(&mut self, primary: &A, secondary: &B) {
|
fn set(&mut self, primary: &A, secondary: &B) {
|
||||||
self.primary = OwnedMutPtr::Ptr(primary as *const A as *mut A);
|
self.primary = OwnedMutPtr::Ptr(core::ptr::from_ref::<A>(primary) as *mut A);
|
||||||
self.secondary = OwnedMutPtr::Ptr(secondary as *const B as *mut B);
|
self.secondary = OwnedMutPtr::Ptr(core::ptr::from_ref::<B>(secondary) as *mut B);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,7 +299,7 @@ impl TimerStruct {
|
|||||||
let data = addr_of_mut!(GLOBAL_STATE);
|
let data = addr_of_mut!(GLOBAL_STATE);
|
||||||
write_volatile(
|
write_volatile(
|
||||||
addr_of_mut!((*data).executor_ptr),
|
addr_of_mut!((*data).executor_ptr),
|
||||||
self as *mut _ as *mut c_void,
|
core::ptr::from_mut(self) as *mut c_void,
|
||||||
);
|
);
|
||||||
|
|
||||||
if self.executions == 0 {
|
if self.executions == 0 {
|
||||||
|
@ -178,25 +178,25 @@ where
|
|||||||
let data = addr_of_mut!(GLOBAL_STATE);
|
let data = addr_of_mut!(GLOBAL_STATE);
|
||||||
write_volatile(
|
write_volatile(
|
||||||
addr_of_mut!((*data).current_input_ptr),
|
addr_of_mut!((*data).current_input_ptr),
|
||||||
input as *const _ as *const c_void,
|
core::ptr::from_ref(input) as *const c_void,
|
||||||
);
|
);
|
||||||
write_volatile(
|
write_volatile(
|
||||||
addr_of_mut!((*data).executor_ptr),
|
addr_of_mut!((*data).executor_ptr),
|
||||||
self as *const _ as *const c_void,
|
core::ptr::from_ref(self) as *const c_void,
|
||||||
);
|
);
|
||||||
// Direct raw pointers access /aliasing is pretty undefined behavior.
|
// Direct raw pointers access /aliasing is pretty undefined behavior.
|
||||||
// Since the state and event may have moved in memory, refresh them right before the signal may happen
|
// Since the state and event may have moved in memory, refresh them right before the signal may happen
|
||||||
write_volatile(
|
write_volatile(
|
||||||
addr_of_mut!((*data).state_ptr),
|
addr_of_mut!((*data).state_ptr),
|
||||||
state as *mut _ as *mut c_void,
|
core::ptr::from_mut(state) as *mut c_void,
|
||||||
);
|
);
|
||||||
write_volatile(
|
write_volatile(
|
||||||
addr_of_mut!((*data).event_mgr_ptr),
|
addr_of_mut!((*data).event_mgr_ptr),
|
||||||
mgr as *mut _ as *mut c_void,
|
core::ptr::from_mut(mgr) as *mut c_void,
|
||||||
);
|
);
|
||||||
write_volatile(
|
write_volatile(
|
||||||
addr_of_mut!((*data).fuzzer_ptr),
|
addr_of_mut!((*data).fuzzer_ptr),
|
||||||
fuzzer as *mut _ as *mut c_void,
|
core::ptr::from_mut(fuzzer) as *mut c_void,
|
||||||
);
|
);
|
||||||
compiler_fence(Ordering::SeqCst);
|
compiler_fence(Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
@ -252,7 +252,8 @@ where
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new in mem executor with the default timeout and use batch mode(5 sec)
|
/// Create a new in mem executor with the default timeout and use batch mode (5 sec)
|
||||||
|
/// Do not use batched mode timeouts with cmplog cores. It is not supported
|
||||||
#[cfg(all(feature = "std", target_os = "linux"))]
|
#[cfg(all(feature = "std", target_os = "linux"))]
|
||||||
pub fn batched_timeouts<EM, OF, Z>(
|
pub fn batched_timeouts<EM, OF, Z>(
|
||||||
harness_fn: &'a mut H,
|
harness_fn: &'a mut H,
|
||||||
|
@ -278,15 +278,15 @@ where
|
|||||||
let data = addr_of_mut!(FORK_EXECUTOR_GLOBAL_DATA);
|
let data = addr_of_mut!(FORK_EXECUTOR_GLOBAL_DATA);
|
||||||
write_volatile(
|
write_volatile(
|
||||||
addr_of_mut!((*data).executor_ptr),
|
addr_of_mut!((*data).executor_ptr),
|
||||||
self as *const _ as *const c_void,
|
core::ptr::from_ref(self) as *const c_void,
|
||||||
);
|
);
|
||||||
write_volatile(
|
write_volatile(
|
||||||
addr_of_mut!((*data).current_input_ptr),
|
addr_of_mut!((*data).current_input_ptr),
|
||||||
input as *const _ as *const c_void,
|
core::ptr::from_ref(input) as *const c_void,
|
||||||
);
|
);
|
||||||
write_volatile(
|
write_volatile(
|
||||||
addr_of_mut!((*data).state_ptr),
|
addr_of_mut!((*data).state_ptr),
|
||||||
state as *mut _ as *mut c_void,
|
core::ptr::from_mut(state) as *mut c_void,
|
||||||
);
|
);
|
||||||
compiler_fence(Ordering::SeqCst);
|
compiler_fence(Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
|
@ -498,7 +498,7 @@ pub mod pybind {
|
|||||||
#[inline]
|
#[inline]
|
||||||
fn observers(&self) -> &PythonObserversTuple {
|
fn observers(&self) -> &PythonObserversTuple {
|
||||||
let ptr = unwrap_me!(self.wrapper, e, {
|
let ptr = unwrap_me!(self.wrapper, e, {
|
||||||
e.observers() as *const PythonObserversTuple
|
core::ptr::from_ref::<PythonObserversTuple>(e.observers())
|
||||||
});
|
});
|
||||||
unsafe { ptr.as_ref().unwrap() }
|
unsafe { ptr.as_ref().unwrap() }
|
||||||
}
|
}
|
||||||
@ -506,7 +506,7 @@ pub mod pybind {
|
|||||||
#[inline]
|
#[inline]
|
||||||
fn observers_mut(&mut self) -> &mut PythonObserversTuple {
|
fn observers_mut(&mut self) -> &mut PythonObserversTuple {
|
||||||
let ptr = unwrap_me_mut!(self.wrapper, e, {
|
let ptr = unwrap_me_mut!(self.wrapper, e, {
|
||||||
e.observers_mut() as *mut PythonObserversTuple
|
core::ptr::from_mut::<PythonObserversTuple>(e.observers_mut())
|
||||||
});
|
});
|
||||||
unsafe { ptr.as_mut().unwrap() }
|
unsafe { ptr.as_mut().unwrap() }
|
||||||
}
|
}
|
||||||
|
@ -1187,9 +1187,9 @@ pub mod pybind {
|
|||||||
// # Safety
|
// # Safety
|
||||||
// We use this observer in Python ony when the ObserverTuple is PythonObserversTuple
|
// We use this observer in Python ony when the ObserverTuple is PythonObserversTuple
|
||||||
let dont_look_at_this: &PythonObserversTuple =
|
let dont_look_at_this: &PythonObserversTuple =
|
||||||
unsafe { &*(observers as *const OT as *const PythonObserversTuple) };
|
unsafe { &*(core::ptr::from_ref::<OT>(observers) as *const PythonObserversTuple) };
|
||||||
let dont_look_at_this2: &PythonEventManager =
|
let dont_look_at_this2: &PythonEventManager =
|
||||||
unsafe { &*(manager as *mut EM as *const PythonEventManager) };
|
unsafe { &*(core::ptr::from_mut::<EM>(manager) as *const PythonEventManager) };
|
||||||
Ok(Python::with_gil(|py| -> PyResult<bool> {
|
Ok(Python::with_gil(|py| -> PyResult<bool> {
|
||||||
let r: bool = self
|
let r: bool = self
|
||||||
.inner
|
.inner
|
||||||
@ -1221,7 +1221,7 @@ pub mod pybind {
|
|||||||
// # Safety
|
// # Safety
|
||||||
// We use this observer in Python ony when the ObserverTuple is PythonObserversTuple
|
// We use this observer in Python ony when the ObserverTuple is PythonObserversTuple
|
||||||
let dont_look_at_this: &PythonObserversTuple =
|
let dont_look_at_this: &PythonObserversTuple =
|
||||||
unsafe { &*(observers as *const OT as *const PythonObserversTuple) };
|
unsafe { &*(core::ptr::from_ref::<OT>(observers) as *const PythonObserversTuple) };
|
||||||
Python::with_gil(|py| -> PyResult<()> {
|
Python::with_gil(|py| -> PyResult<()> {
|
||||||
self.inner.call_method1(
|
self.inner.call_method1(
|
||||||
py,
|
py,
|
||||||
|
@ -1407,14 +1407,14 @@ pub mod pybind {
|
|||||||
impl Monitor for PythonMonitor {
|
impl Monitor for PythonMonitor {
|
||||||
fn client_stats_mut(&mut self) -> &mut Vec<ClientStats> {
|
fn client_stats_mut(&mut self) -> &mut Vec<ClientStats> {
|
||||||
let ptr = unwrap_me_mut!(self.wrapper, m, {
|
let ptr = unwrap_me_mut!(self.wrapper, m, {
|
||||||
m.client_stats_mut() as *mut Vec<ClientStats>
|
core::ptr::from_mut::<Vec<ClientStats>>(m.client_stats_mut())
|
||||||
});
|
});
|
||||||
unsafe { ptr.as_mut().unwrap() }
|
unsafe { ptr.as_mut().unwrap() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn client_stats(&self) -> &[ClientStats] {
|
fn client_stats(&self) -> &[ClientStats] {
|
||||||
let ptr = unwrap_me!(self.wrapper, m, {
|
let ptr = unwrap_me!(self.wrapper, m, {
|
||||||
m.client_stats() as *const [ClientStats]
|
core::ptr::from_ref::<[ClientStats]>(m.client_stats())
|
||||||
});
|
});
|
||||||
unsafe { ptr.as_ref().unwrap() }
|
unsafe { ptr.as_ref().unwrap() }
|
||||||
}
|
}
|
||||||
|
@ -1047,7 +1047,7 @@ pub mod pybind {
|
|||||||
|
|
||||||
impl Named for PythonObserver {
|
impl Named for PythonObserver {
|
||||||
fn name(&self) -> &str {
|
fn name(&self) -> &str {
|
||||||
let ptr = unwrap_me!(self.wrapper, o, { o.name() as *const str });
|
let ptr = unwrap_me!(self.wrapper, o, { core::ptr::from_ref::<str>(o.name()) });
|
||||||
unsafe { ptr.as_ref().unwrap() }
|
unsafe { ptr.as_ref().unwrap() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1266,7 +1266,7 @@ pub mod pybind {
|
|||||||
}
|
}
|
||||||
PythonObserverWrapper::Python(py_wrapper) => {
|
PythonObserverWrapper::Python(py_wrapper) => {
|
||||||
if type_eq::<PyObjectObserver, T>() && py_wrapper.name() == name {
|
if type_eq::<PyObjectObserver, T>() && py_wrapper.name() == name {
|
||||||
r = (py_wrapper as *const _ as *const T).as_ref();
|
r = (core::ptr::from_ref(py_wrapper) as *const T).as_ref();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1359,7 +1359,7 @@ pub mod pybind {
|
|||||||
}
|
}
|
||||||
PythonObserverWrapper::Python(py_wrapper) => {
|
PythonObserverWrapper::Python(py_wrapper) => {
|
||||||
if type_eq::<PyObjectObserver, T>() && py_wrapper.name() == name {
|
if type_eq::<PyObjectObserver, T>() && py_wrapper.name() == name {
|
||||||
r = (py_wrapper as *mut _ as *mut T).as_mut();
|
r = (core::ptr::from_mut(py_wrapper) as *mut T).as_mut();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1942,7 +1942,7 @@ impl AsanRuntime {
|
|||||||
;->accessed_address:
|
;->accessed_address:
|
||||||
; .dword 0x0
|
; .dword 0x0
|
||||||
; self_addr:
|
; self_addr:
|
||||||
; .qword self as *mut _ as *mut c_void as i64
|
; .qword core::ptr::from_mut(self) as *mut c_void as i64
|
||||||
; self_regs_addr:
|
; self_regs_addr:
|
||||||
; .qword addr_of_mut!(self.regs) as i64
|
; .qword addr_of_mut!(self.regs) as i64
|
||||||
; trap_func:
|
; trap_func:
|
||||||
|
@ -1700,7 +1700,7 @@ impl Emulator {
|
|||||||
pub fn add_gdb_cmd(&self, callback: Box<dyn FnMut(&Self, &str) -> bool>) {
|
pub fn add_gdb_cmd(&self, callback: Box<dyn FnMut(&Self, &str) -> bool>) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let fat: Box<FatPtr> = Box::new(transmute(callback));
|
let fat: Box<FatPtr> = Box::new(transmute(callback));
|
||||||
libafl_qemu_add_gdb_cmd(gdb_cmd, &*fat as *const _ as *const ());
|
libafl_qemu_add_gdb_cmd(gdb_cmd, core::ptr::from_ref(&*fat) as *const ());
|
||||||
GDB_COMMANDS.push(fat);
|
GDB_COMMANDS.push(fat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ pub unsafe fn inproc_qemu_crash_handler<E, EM, OF, Z>(
|
|||||||
Z: HasObjective<Objective = OF, State = E::State>,
|
Z: HasObjective<Objective = OF, State = E::State>,
|
||||||
{
|
{
|
||||||
let puc = match &mut context {
|
let puc = match &mut context {
|
||||||
Some(v) => (*v) as *mut ucontext_t as *mut c_void,
|
Some(v) => core::ptr::from_mut::<ucontext_t>(*v) as *mut c_void,
|
||||||
None => core::ptr::null_mut(),
|
None => core::ptr::null_mut(),
|
||||||
};
|
};
|
||||||
libafl_qemu_handle_crash(signal as i32, info, puc);
|
libafl_qemu_handle_crash(signal as i32, info, puc);
|
||||||
|
@ -481,7 +481,7 @@ impl Serialize for AFLppCmpLogMap {
|
|||||||
{
|
{
|
||||||
let slice = unsafe {
|
let slice = unsafe {
|
||||||
core::slice::from_raw_parts(
|
core::slice::from_raw_parts(
|
||||||
(self as *const Self) as *const u8,
|
(core::ptr::from_ref::<Self>(self)) as *const u8,
|
||||||
core::mem::size_of::<Self>(),
|
core::mem::size_of::<Self>(),
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user