more no_std compatibility

This commit is contained in:
Dominik Maier 2020-11-21 17:53:10 +01:00
parent 41d3711ac7
commit db3215f6be
4 changed files with 10 additions and 6 deletions

View File

@ -169,7 +169,7 @@ where
pub fn load_input(&mut self) -> Result<&I, AflError> { pub fn load_input(&mut self) -> Result<&I, AflError> {
if self.input.is_none() { if self.input.is_none() {
let input = I::from_file(self.filename.as_ref().ok_or(AflError::EmptyOptional( let input = I::from_file(self.filename.as_ref().ok_or(AflError::EmptyOptional(
"filename not specified".to_string(), "filename not specified".into(),
))?)?; ))?)?;
self.input = Some(input); self.input = Some(input);
} }

View File

@ -199,6 +199,7 @@ where
fn fuzz_one(&mut self, state: &mut S) -> Result<usize, AflError> { fn fuzz_one(&mut self, state: &mut S) -> Result<usize, AflError> {
let (testcase, idx) = state.corpus_mut().next()?; let (testcase, idx) = state.corpus_mut().next()?;
#[cfg(feature = "std")]
println!("Cur entry: {}\tExecutions: {}", idx, state.executions()); println!("Cur entry: {}\tExecutions: {}", idx, state.executions());
for stage in self.stages_mut() { for stage in self.stages_mut() {
stage.perform(testcase.clone(), state)?; stage.perform(testcase.clone(), state)?;

View File

@ -79,8 +79,9 @@ impl EventManager for LoggerEventManager {
} }
} }
fn fire<E: Event>(&mut self, event: E) -> Result<(), AflError> { fn fire<E: Event>(&mut self, _event: E) -> Result<(), AflError> {
println!("{}", event); #[cfg(feature = "std")]
println!("{}", _event);
Ok(()) Ok(())
} }

View File

@ -1,10 +1,12 @@
use alloc::rc::Rc;
use alloc::vec::Vec;
use core::cell::RefCell;
use core::cmp::min;
use crate::inputs::bytes::BytesInput; use crate::inputs::bytes::BytesInput;
use crate::inputs::Input; use crate::inputs::Input;
use crate::utils::{HasRand, Rand}; use crate::utils::{HasRand, Rand};
use crate::AflError; use crate::AflError;
use alloc::rc::Rc;
use core::cell::RefCell;
use core::cmp::min;
pub trait Generator<I>: HasRand pub trait Generator<I>: HasRand
where where