Skip to content

Commit fda1596

Browse files
authored
Use nonzero! macro (#2589)
* nonzero_lit * nonzero * std instead of core * a * l * test * import * api * api * aaaaa * apiapi * api * api * api * mm * api * non zero * FMT * pls * nnnaaasdfadsfafdsa * pls * MM * fix * a * sat add * aa * mistake * unreachable * no generic * api change * a
1 parent 3b31b4d commit fda1596

File tree

51 files changed

+282
-286
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+282
-286
lines changed

docs/listings/baby_fuzzer/listing-04/src/main.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ extern crate libafl;
33
extern crate libafl_bolts;
44

55
use std::path::PathBuf;
6-
76
use libafl::{
87
corpus::{InMemoryCorpus, OnDiskCorpus},
98
events::SimpleEventManager,
@@ -15,7 +14,7 @@ use libafl::{
1514
schedulers::QueueScheduler,
1615
state::StdState,
1716
};
18-
use libafl_bolts::{rands::StdRand, tuples::tuple_list, AsSlice};
17+
use libafl_bolts::{rands::StdRand, tuples::tuple_list, AsSlice, nonzero};
1918
/* ANCHOR_END: use */
2019

2120
fn main() {
@@ -77,7 +76,7 @@ fn main() {
7776

7877
/* ANCHOR: generator */
7978
// Generator of printable bytearrays of max size 32
80-
let mut generator = RandPrintablesGenerator::new(32).unwrap();
79+
let mut generator = RandPrintablesGenerator::new(nonzero!(32));
8180

8281
// Generate 8 initial inputs
8382
state

docs/listings/baby_fuzzer/listing-05/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use libafl::{
1515
schedulers::QueueScheduler,
1616
state::StdState,
1717
};
18-
use libafl_bolts::{rands::StdRand, tuples::tuple_list, AsSlice};
18+
use libafl_bolts::{rands::StdRand, tuples::tuple_list, AsSlice, nonzero};
1919
use std::path::PathBuf;
2020
/* ANCHOR_END: use */
2121

@@ -105,7 +105,7 @@ fn main() {
105105
/* ANCHOR_END: executor_with_observer */
106106

107107
// Generator of printable bytearrays of max size 32
108-
let mut generator = RandPrintablesGenerator::new(32).unwrap();
108+
let mut generator = RandPrintablesGenerator::new(nonzero!(32));
109109

110110
// Generate 8 initial inputs
111111
state

docs/listings/baby_fuzzer/listing-06/src/main.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* ANCHOR: use */
22
extern crate libafl;
33
extern crate libafl_bolts;
4+
use std::num::NonZeroUsize;
45

56
use libafl::{
67
corpus::{InMemoryCorpus, OnDiskCorpus},
@@ -17,7 +18,7 @@ use libafl::{
1718
stages::mutational::StdMutationalStage,
1819
state::StdState,
1920
};
20-
use libafl_bolts::{rands::StdRand, tuples::tuple_list, AsSlice};
21+
use libafl_bolts::{rands::StdRand, tuples::tuple_list, AsSlice, nonzero};
2122
use std::path::PathBuf;
2223
/* ANCHOR_END: use */
2324

@@ -97,7 +98,7 @@ fn main() {
9798
.expect("Failed to create the Executor");
9899

99100
// Generator of printable bytearrays of max size 32
100-
let mut generator = RandPrintablesGenerator::new(32).unwrap();
101+
let mut generator = RandPrintablesGenerator::new(nonzero!(32));
101102

102103
// Generate 8 initial inputs
103104
state

fuzzers/baby/baby_fuzzer/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use libafl::{
2020
stages::mutational::StdMutationalStage,
2121
state::StdState,
2222
};
23-
use libafl_bolts::{current_nanos, rands::StdRand, tuples::tuple_list, AsSlice};
23+
use libafl_bolts::{current_nanos, nonzero, rands::StdRand, tuples::tuple_list, AsSlice};
2424

2525
/// Coverage map with explicit assignments due to the lack of instrumentation
2626
static mut SIGNALS: [u8; 16] = [0; 16];
@@ -116,7 +116,7 @@ pub fn main() {
116116
.expect("Failed to create the Executor");
117117

118118
// Generator of printable bytearrays of max size 32
119-
let mut generator = RandPrintablesGenerator::new(32).unwrap();
119+
let mut generator = RandPrintablesGenerator::new(nonzero!(32));
120120

121121
// Generate 8 initial inputs
122122
state

fuzzers/baby/baby_fuzzer_minimizing/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ pub fn main() -> Result<(), Error> {
8686
.expect("Failed to create the Executor");
8787

8888
// Generator of printable bytearrays of max size 32
89-
let mut generator = RandPrintablesGenerator::new(32).unwrap();
89+
let mut generator = RandPrintablesGenerator::new(nonzero!(32));
9090

9191
// Generate 8 initial inputs
9292
state

fuzzers/baby/baby_fuzzer_swap_differential/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use libafl::{
2323
stages::mutational::StdMutationalStage,
2424
state::{HasSolutions, StdState},
2525
};
26-
use libafl_bolts::{rands::StdRand, tuples::tuple_list, AsSlice};
26+
use libafl_bolts::{nonzero, rands::StdRand, tuples::tuple_list, AsSlice};
2727
use libafl_targets::{edges_max_num, DifferentialAFLMapSwapObserver};
2828
#[cfg(not(miri))]
2929
use mimalloc::MiMalloc;
@@ -247,7 +247,7 @@ pub fn main() {
247247
);
248248

249249
// Generator of printable bytearrays of max size 32
250-
let mut generator = RandPrintablesGenerator::new(32).unwrap();
250+
let mut generator = RandPrintablesGenerator::new(nonzero!(32));
251251

252252
// Generate 8 initial inputs
253253
state

fuzzers/baby/backtrace_baby_fuzzers/c_code_with_fork_executor/src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use libafl::{
1717
state::StdState,
1818
};
1919
use libafl_bolts::{
20+
nonzero,
2021
ownedref::OwnedRefMut,
2122
rands::StdRand,
2223
shmem::{ShMemProvider, StdShMemProvider},
@@ -103,7 +104,7 @@ pub fn main() {
103104
.expect("Failed to create the Executor");
104105

105106
// Generator of printable bytearrays of max size 32
106-
let mut generator = RandPrintablesGenerator::new(32).unwrap();
107+
let mut generator = RandPrintablesGenerator::new(nonzero!(32));
107108

108109
// Generate 8 initial inputs
109110
state

fuzzers/baby/backtrace_baby_fuzzers/c_code_with_inprocess_executor/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use libafl::{
1616
stages::mutational::StdMutationalStage,
1717
state::StdState,
1818
};
19-
use libafl_bolts::{rands::StdRand, tuples::tuple_list, AsSlice};
19+
use libafl_bolts::{nonzero, rands::StdRand, tuples::tuple_list, AsSlice};
2020
use libc::c_uchar;
2121
extern crate libc;
2222

@@ -89,7 +89,7 @@ pub fn main() {
8989
.expect("Failed to create the Executor");
9090

9191
// Generator of printable bytearrays of max size 32
92-
let mut generator = RandPrintablesGenerator::new(32).unwrap();
92+
let mut generator = RandPrintablesGenerator::new(nonzero!(32));
9393

9494
// Generate 8 initial inputs
9595
state

fuzzers/baby/backtrace_baby_fuzzers/command_executor/src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use libafl::{
2525
Error,
2626
};
2727
use libafl_bolts::{
28+
nonzero,
2829
rands::StdRand,
2930
shmem::{unix_shmem, ShMem, ShMemId, ShMemProvider},
3031
tuples::tuple_list,
@@ -112,7 +113,7 @@ pub fn main() {
112113
let mut executor = MyExecutor { shmem_id }.into_executor(tuple_list!(observer, bt_observer));
113114

114115
// Generator of printable bytearrays of max size 32
115-
let mut generator = RandPrintablesGenerator::new(32).unwrap();
116+
let mut generator = RandPrintablesGenerator::new(nonzero!(32));
116117

117118
// Generate 8 initial inputs
118119
state

fuzzers/baby/backtrace_baby_fuzzers/forkserver_executor/src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use libafl_bolts::shmem::StdShMemProvider;
2121
#[cfg(target_vendor = "apple")]
2222
use libafl_bolts::shmem::UnixShMemProvider;
2323
use libafl_bolts::{
24+
nonzero,
2425
rands::StdRand,
2526
shmem::{ShMem, ShMemProvider},
2627
tuples::tuple_list,
@@ -97,7 +98,7 @@ pub fn main() {
9798
.unwrap();
9899

99100
// Generator of printable bytearrays of max size 32
100-
let mut generator = RandPrintablesGenerator::new(3).unwrap();
101+
let mut generator = RandPrintablesGenerator::new(nonzero!(32));
101102

102103
// Generate 8 initial inputs
103104
state

0 commit comments

Comments
 (0)