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

View File

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

View File

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