Skip to content

Commit

Permalink
fix a bunch of warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrmaxmeier committed May 8, 2024
1 parent 0fb4a5b commit d63b622
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
4 changes: 2 additions & 2 deletions lain/src/mutatable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 314,7 @@ where
mutator: &mut Mutator<R>,
constraints: Option<&Constraints<Self::RangeType>>,
) {
let mut constraints = constraints.and_then(|c| {
let constraints = constraints.and_then(|c| {
if c.max_size.is_none() {
None
} else {
Expand Down Expand Up @@ -630,7 630,7 @@ where
}
None => {
if mutator.gen_chance(CHANCE_TO_FLIP_OPTION_STATE) {
let mut new_item = T::new_fuzzed(mutator, constraints);
let new_item = T::new_fuzzed(mutator, constraints);

*self = Some(new_item);
}
Expand Down
4 changes: 2 additions & 2 deletions lain/src/new_fuzzed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 774,7 @@ macro_rules! impl_new_fuzzed_array {
type RangeType = usize;

fn new_fuzzed<R: Rng>(mutator: &mut Mutator<R>, constraints: Option<&Constraints<Self::RangeType>>) -> [T; $size] {
let mut per_item_max_size: Option<usize> = constraints.and_then(|c| c.max_size.as_ref().and_then(|size| Some(*size / $size)));
let per_item_max_size: Option<usize> = constraints.and_then(|c| c.max_size.as_ref().and_then(|size| Some(*size / $size)));

let mut output: MaybeUninit<[T; $size]> = MaybeUninit::uninit();
let arr_ptr = output.as_mut_ptr() as *mut T;
Expand Down Expand Up @@ -828,7 828,7 @@ macro_rules! impl_new_fuzzed_array {
default type RangeType = usize;

default fn new_fuzzed<R: Rng>(mutator: &mut Mutator<R>, constraints: Option<&Constraints<Self::RangeType>>) -> [T; $size] {
let mut per_item_max_size: Option<usize> = constraints.and_then(|c| c.max_size.as_ref().and_then(|size| Some(*size / $size)));
let per_item_max_size: Option<usize> = constraints.and_then(|c| c.max_size.as_ref().and_then(|size| Some(*size / $size)));

let mut output: MaybeUninit<[T; $size]> = MaybeUninit::uninit();
let arr_ptr = output.as_mut_ptr() as *mut T;
Expand Down
6 changes: 3 additions & 3 deletions testsuite/benches/benchmark_generating_fuzzed_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 52,7 @@ fn bench_new_fuzzed_1000(c: &mut Criterion) {
c.bench(
function_name.as_ref(),
Benchmark::new("fuzz", move |b| {
let mut mutator = Mutator::new(lain::rand::rngs::SmallRng::from_seed([0u8; 16]));
let mut mutator = Mutator::new(lain::rand::rngs::SmallRng::from_seed([0u8; 32]));
b.iter(|| {
let s = NestedStruct::new_fuzzed(&mut mutator, None);
black_box(s);
Expand All @@ -69,8 69,8 @@ fn bench_in_place_mutation(c: &mut Criterion) {
c.bench(
function_name.as_ref(),
Benchmark::new("fuzz", move |b| {
let mut mutator = Mutator::new(lain::rand::rngs::SmallRng::from_seed([0u8; 16]));
let mut s = NestedStruct::new_fuzzed(&mut mutator, None);
let mut mutator = Mutator::new(lain::rand::rngs::SmallRng::from_seed([0u8; 32]));
let s = NestedStruct::new_fuzzed(&mut mutator, None);
b.iter(|| {
let mut s = s.clone();
let state = mutator.get_corpus_state();
Expand Down
15 changes: 7 additions & 8 deletions testsuite/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 232,10 @@ mod test {
b: u8,
}

let mut instance;
let mut mutator = get_mutator();

for _i in 0..10000 {
instance = Foo::new_fuzzed(&mut mutator, None);
Foo::new_fuzzed(&mut mutator, None);
}
}

Expand Down Expand Up @@ -792,7 791,7 @@ mod test {
b: u32,
}

let mut s = IncompleteBitfield { a: 0, b: 1 };
let s = IncompleteBitfield { a: 0, b: 1 };

assert_eq!(IncompleteBitfield::min_nonzero_elements_size(), 4);

Expand Down Expand Up @@ -906,8 905,8 @@ mod test {

let mut mutator = get_mutator();

let mut obj = Foo::new_fuzzed(&mut mutator, Some(&constraints));
for i in 0..1000 {
let mut obj;
for _i in 0..1000 {
obj = Foo::new_fuzzed(&mut mutator, Some(&constraints));
assert!(obj.serialized_size() <= MAX_SIZE);

Expand All @@ -924,8 923,8 @@ mod test {
);
}

let mut baz = Baz::new_fuzzed(&mut mutator, Some(&constraints));
for i in 0..1000 {
let mut baz;
for _i in 0..1000 {
baz = Baz::new_fuzzed(&mut mutator, Some(&constraints));
assert!(baz.serialized_size() <= MAX_SIZE);

Expand Down Expand Up @@ -971,7 970,7 @@ mod test {

// this breaks at 72 iterations which is fine. would break at a different iteration
// with a different seed
for i in 0..50 {
for _i in 0..50 {
let prev_obj = obj.clone();
obj.mutate(&mut mutator, None);

Expand Down

0 comments on commit d63b622

Please sign in to comment.