Skip to content

Commit

Permalink
rands: remove RandomSeed trait
Browse files Browse the repository at this point in the history
  • Loading branch information
flyingmutant committed Apr 28, 2024
1 parent 45897bb commit 961356c
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 24 deletions.
2 changes: 1 addition & 1 deletion fuzzers/nyx_libxml2_parallel/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use libafl::{
};
use libafl_bolts::{
core_affinity::{CoreId, Cores},
rands::{RandomSeed, StdRand},
rands::StdRand,
shmem::{ShMemProvider, StdShMemProvider},
tuples::tuple_list,
};
Expand Down
5 changes: 1 addition & 4 deletions fuzzers/nyx_libxml2_standalone/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ use libafl::{
state::StdState,
Fuzzer, StdFuzzer,
};
use libafl_bolts::{
rands::{RandomSeed, StdRand},
tuples::tuple_list,
};
use libafl_bolts::{rands::StdRand, tuples::tuple_list};
use libafl_nyx::{executor::NyxExecutor, helper::NyxHelper, settings::NyxSettings};

fn main() {
Expand Down
5 changes: 1 addition & 4 deletions fuzzers/tinyinst_simple/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ use libafl_bolts::shmem::UnixShMemProvider;
#[cfg(windows)]
use libafl_bolts::shmem::Win32ShMemProvider;
use libafl_bolts::{
ownedref::OwnedMutPtr,
rands::{RandomSeed, StdRand},
shmem::ShMemProvider,
tuples::tuple_list,
ownedref::OwnedMutPtr, rands::StdRand, shmem::ShMemProvider, tuples::tuple_list,
};
use libafl_tinyinst::executor::TinyInstExecutorBuilder;
static mut COVERAGE: Vec<u64> = vec![];
Expand Down
19 changes: 7 additions & 12 deletions libafl_bolts/src/rands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,7 @@ pub trait Rand: Debug + Serialize + DeserializeOwned {
}
}

/// Initialize Rand types from a source of randomness.
pub trait RandomSeed: Rand + Default {
/// Creates a new [`RandomSeed`].
fn new() -> Self;
}

macro_rules! impl_default_seed {
macro_rules! impl_default_new {
($rand: ty) => {
impl Default for $rand {
/// Creates a generator seeded with [`random_seed`].
Expand All @@ -156,18 +150,19 @@ macro_rules! impl_default_seed {
}
}

impl RandomSeed for $rand {
impl $rand {
/// Creates a generator seeded with [`random_seed`].
fn new() -> Self {
#[must_use]
pub fn new() -> Self {
Self::with_seed(random_seed())
}
}
};
}

impl_default_seed!(Xoshiro256PlusPlusRand);
impl_default_seed!(RomuDuoJrRand);
impl_default_seed!(Sfc64Rand);
impl_default_new!(Xoshiro256PlusPlusRand);
impl_default_new!(RomuDuoJrRand);
impl_default_new!(Sfc64Rand);

macro_rules! impl_rng_core {
($rand: ty) => {
Expand Down
2 changes: 1 addition & 1 deletion libafl_bolts/src/shmem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ pub mod unix_shmem {
};

use crate::{
rands::{Rand, RandomSeed, StdRand},
rands::{Rand, StdRand},
shmem::{ShMem, ShMemId, ShMemProvider},
Error,
};
Expand Down
2 changes: 1 addition & 1 deletion libafl_libfuzzer/libafl_libfuzzer_runtime/src/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use libafl::{
Error, HasScheduler, StdFuzzer,
};
use libafl_bolts::{
rands::{Rand, RandomSeed, StdRand},
rands::{Rand, StdRand},
shmem::{ShMemProvider, StdShMemProvider},
tuples::tuple_list,
AsSlice,
Expand Down
2 changes: 1 addition & 1 deletion libafl_libfuzzer/libafl_libfuzzer_runtime/src/tmin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use libafl::{
Error, Fuzzer, StdFuzzer,
};
use libafl_bolts::{
rands::{RandomSeed, RomuDuoJrRand, StdRand},
rands::{RomuDuoJrRand, StdRand},
shmem::{ShMemProvider, StdShMemProvider},
tuples::tuple_list,
AsSlice, HasLen,
Expand Down

0 comments on commit 961356c

Please sign in to comment.