remove more args (#1934)

This commit is contained in:
Dongjia "toka" Zhang 2024-03-13 16:17:46 +01:00 committed by GitHub
parent 2763d945a3
commit 44aec56f7e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 58 deletions

View File

@ -12,23 +12,15 @@ where
{
/// The hook that runs before `handle_in_client`
/// Return false if you want to cancel the subsequent event handling
fn pre_exec<E, Z>(
fn pre_exec(
&mut self,
fuzzer: &mut Z,
executor: &mut E,
state: &mut S,
client_id: ClientId,
event: &Event<S::Input>,
) -> Result<bool, Error>;
/// The hook that runs after `handle_in_client`
/// Return false if you want to cancel the subsequent event handling
fn post_exec<E, Z>(
&mut self,
fuzzer: &mut Z,
executor: &mut E,
state: &mut S,
client_id: ClientId,
) -> Result<bool, Error>;
fn post_exec(&mut self, state: &mut S, client_id: ClientId) -> Result<bool, Error>;
}
/// The tuples contains hooks to be executed for `handle_in_client`
@ -37,22 +29,14 @@ where
S: State,
{
/// The hook that runs before `handle_in_client`
fn pre_exec_all<E, Z>(
fn pre_exec_all(
&mut self,
fuzzer: &mut Z,
executor: &mut E,
state: &mut S,
client_id: ClientId,
event: &Event<S::Input>,
) -> Result<bool, Error>;
/// The hook that runs after `handle_in_client`
fn post_exec_all<E, Z>(
&mut self,
fuzzer: &mut Z,
executor: &mut E,
state: &mut S,
client_id: ClientId,
) -> Result<bool, Error>;
fn post_exec_all(&mut self, state: &mut S, client_id: ClientId) -> Result<bool, Error>;
}
impl<S> EventManagerHooksTuple<S> for ()
@ -60,10 +44,8 @@ where
S: State,
{
/// The hook that runs before `handle_in_client`
fn pre_exec_all<E, Z>(
fn pre_exec_all(
&mut self,
_fuzzer: &mut Z,
_executor: &mut E,
_state: &mut S,
_client_id: ClientId,
_event: &Event<S::Input>,
@ -71,13 +53,7 @@ where
Ok(true)
}
/// The hook that runs after `handle_in_client`
fn post_exec_all<E, Z>(
&mut self,
_fuzzer: &mut Z,
_executor: &mut E,
_state: &mut S,
_client_id: ClientId,
) -> Result<bool, Error> {
fn post_exec_all(&mut self, _state: &mut S, _client_id: ClientId) -> Result<bool, Error> {
Ok(true)
}
}
@ -89,30 +65,20 @@ where
S: State,
{
/// The hook that runs before `handle_in_client`
fn pre_exec_all<E, Z>(
fn pre_exec_all(
&mut self,
fuzzer: &mut Z,
executor: &mut E,
state: &mut S,
client_id: ClientId,
event: &Event<S::Input>,
) -> Result<bool, Error> {
let first = self.0.pre_exec(fuzzer, executor, state, client_id, event)?;
let second = self
.1
.pre_exec_all(fuzzer, executor, state, client_id, event)?;
let first = self.0.pre_exec(state, client_id, event)?;
let second = self.1.pre_exec_all(state, client_id, event)?;
Ok(first & second)
}
/// The hook that runs after `handle_in_client`
fn post_exec_all<E, Z>(
&mut self,
fuzzer: &mut Z,
executor: &mut E,
state: &mut S,
client_id: ClientId,
) -> Result<bool, Error> {
let first = self.0.post_exec(fuzzer, executor, state, client_id)?;
let second = self.1.post_exec_all(fuzzer, executor, state, client_id)?;
fn post_exec_all(&mut self, state: &mut S, client_id: ClientId) -> Result<bool, Error> {
let first = self.0.post_exec(state, client_id)?;
let second = self.1.post_exec_all(state, client_id)?;
Ok(first & second)
}
}

View File

@ -610,10 +610,7 @@ where
for<'a> E::Observers: Deserialize<'a>,
Z: ExecutionProcessor<E::Observers, State = S> + EvaluatorObservers<E::Observers>,
{
if self
.hooks
.pre_exec_all(fuzzer, executor, state, client_id, &event)?
{
if self.hooks.pre_exec_all(state, client_id, &event)? {
return Ok(());
}
match event {
@ -672,8 +669,7 @@ where
)));
}
}
self.hooks
.post_exec_all(fuzzer, executor, state, client_id)?;
self.hooks.post_exec_all(state, client_id)?;
Ok(())
}
}

View File

@ -621,10 +621,7 @@ where
for<'a> E::Observers: Deserialize<'a>,
Z: ExecutionProcessor<E::Observers, State = S> + EvaluatorObservers<E::Observers>,
{
if !self
.hooks
.pre_exec_all(fuzzer, executor, state, client_id, &event)?
{
if !self.hooks.pre_exec_all(state, client_id, &event)? {
return Ok(());
}
match event {
@ -677,8 +674,7 @@ where
)))
}
}
self.hooks
.post_exec_all(fuzzer, executor, state, client_id)?;
self.hooks.post_exec_all(state, client_id)?;
Ok(())
}
}