diff --git a/clippy.sh b/clippy.sh index 88af86df4a..17a8503766 100755 --- a/clippy.sh +++ b/clippy.sh @@ -3,13 +3,19 @@ cargo clean RUST_BACKTRACE=full cargo clippy --all -- \ -D clippy::pedantic \ - -W missing-docs \ - -W clippy::missing-errors-doc \ + -W clippy::cast_sign_loss \ -W clippy::similar-names \ + -W clippy::cast_ptr_alignment \ + -A missing-docs \ + -A clippy::doc_markdown \ + -A clippy::must-use-candidate \ + -A clippy::missing-errors-doc \ + -A clippy::cast-possible-truncation \ + -A clippy::used-underscore-binding \ + -A clippy::ptr-as-ptr \ + -A clippy::missing-panics-doc \ -A clippy::missing-docs-in-private-items \ -A clippy::unseparated-literal-suffix \ -A clippy::module-name-repetitions \ -A clippy::unreadable-literal \ -A clippy::if-not-else \ - #--allow clippy::print-with-newline \ - #--allow clippy::write-with-newline \ diff --git a/libafl/src/bolts/llmp.rs b/libafl/src/bolts/llmp.rs index cafaa589a2..4a2062fe42 100644 --- a/libafl/src/bolts/llmp.rs +++ b/libafl/src/bolts/llmp.rs @@ -86,7 +86,7 @@ use std::os::unix::{ {io::AsRawFd, prelude::RawFd}, }; -#[cfg(feature = "llmp_debug")] +#[cfg(all(feature = "llmp_debug", feature = "std"))] use backtrace::Backtrace; #[cfg(all(unix, feature = "std"))] @@ -788,9 +788,12 @@ where /// listener about it using a EOP message. unsafe fn handle_out_eop(&mut self) -> Result<(), Error> { - #[cfg(feature = "llmp_debug")] + #[cfg(all(feature = "llmp_debug", feature = "std"))] { + #[cfg(debug_assertions)] let bt = Backtrace::new(); + #[cfg(not(debug_assertions))] + let bt = ""; let shm = self.out_maps.last().unwrap(); println!( "LLMP_DEBUG: End of page reached for map {} with len {}, sending EOP, bt: {:?}", @@ -1039,7 +1042,7 @@ where // Mark the new page save to unmap also (it's mapped by us, the broker now) ptr::write_volatile(&mut (*page).save_to_unmap, 1); - #[cfg(feature = "llmp_debug")] + #[cfg(all(feature = "llmp_debug", feature = "std"))] println!( "LLMP_DEBUG: Got a new recv map {} with len {:?}", self.current_recv_map.shmem.shm_str(), @@ -1154,7 +1157,7 @@ where { /// Creates a new page, initializing the passed shared mem struct pub fn new(sender: u32, mut new_map: SH) -> Self { - #[cfg(feature = "llmp_debug")] + #[cfg(all(feature = "llmp_debug", feature = "std"))] println!( "LLMP_DEBUG: Initializing map on {} with size {}", new_map.shm_str(), @@ -1169,9 +1172,12 @@ where /// Maps and wraps an existing pub fn existing(existing_map: SH) -> Self { - #[cfg(feature = "llmp_debug")] + #[cfg(all(feature = "llmp_debug", feature = "std"))] { + #[cfg(debug_assertions)] let bt = Backtrace::new(); + #[cfg(not(debug_assertions))] + let bt = ""; println!( "LLMP_DEBUG: Using existing map {} with size {}, bt: {:?}", existing_map.shm_str(), diff --git a/libafl/src/executors/mod.rs b/libafl/src/executors/mod.rs index b0ac310a55..1ccccbf437 100644 --- a/libafl/src/executors/mod.rs +++ b/libafl/src/executors/mod.rs @@ -49,7 +49,7 @@ where } /// A simple executor that does nothing. -/// If intput len is 0, run_target will return Err +/// If intput len is 0, `run_target` will return Err struct NopExecutor { phantom: PhantomData, } diff --git a/libafl/src/executors/timeout.rs b/libafl/src/executors/timeout.rs index 6acb753032..1fbb4b84e9 100644 --- a/libafl/src/executors/timeout.rs +++ b/libafl/src/executors/timeout.rs @@ -1,4 +1,4 @@ -//! A TimeoutExecutor set a timeout before each target run +//! A `TimeoutExecutor` sets a timeout before each target run use core::{marker::PhantomData, time::Duration}; diff --git a/libafl/src/feedbacks/map.rs b/libafl/src/feedbacks/map.rs index 2f7e71fb3c..c18d6b80e0 100644 --- a/libafl/src/feedbacks/map.rs +++ b/libafl/src/feedbacks/map.rs @@ -259,7 +259,7 @@ where R: Reducer, O: MapObserver + Observer, { - /// Create new MapFeedback + /// Create new `MapFeedback` pub fn new(name: &'static str, map_size: usize) -> Self { Self { history_map: vec![T::default(); map_size], @@ -270,7 +270,7 @@ where } } - /// Create new MapFeedback for the observer type. + /// Create new `MapFeedback` for the observer type. pub fn new_with_observer(map_observer: &O) -> Self { Self { history_map: vec![T::default(); map_observer.map().len()], @@ -281,7 +281,7 @@ where } } - /// Create new MapFeedback specifying if it must track indexes of novelties + /// Create new `MapFeedback` specifying if it must track indexes of novelties pub fn new_track( name: &'static str, map_size: usize, @@ -297,7 +297,7 @@ where } } - /// Create new MapFeedback for the observer type if it must track indexes of novelties + /// Create new `MapFeedback` for the observer type if it must track indexes of novelties pub fn new_with_observer_track( map_observer: &O, track_indexes: bool, @@ -319,7 +319,7 @@ where R: Reducer, O: MapObserver, { - /// Create new MapFeedback using a map observer, and a map. + /// Create new `MapFeedback` using a map observer, and a map. /// The map can be shared. pub fn with_history_map(name: &'static str, history_map: Vec) -> Self { Self { diff --git a/libafl/src/feedbacks/mod.rs b/libafl/src/feedbacks/mod.rs index 53e2cf4b8e..be782e594a 100644 --- a/libafl/src/feedbacks/mod.rs +++ b/libafl/src/feedbacks/mod.rs @@ -24,7 +24,7 @@ pub trait Feedback: Named + serde::Serialize + serde::de::DeserializeOwned + where I: Input, { - /// is_interesting should return the "Interestingness" from 0 to 255 (percent times 2.55) + /// `is_interesting ` should return the "Interestingness" from 0 to 255 (percent times 2.55) fn is_interesting( &mut self, input: &I, diff --git a/libafl/src/fuzzer.rs b/libafl/src/fuzzer.rs index 062ae077cc..bcf75cf1f3 100644 --- a/libafl/src/fuzzer.rs +++ b/libafl/src/fuzzer.rs @@ -96,7 +96,7 @@ pub trait Fuzzer { Ok(ret) } - /// Given the last time, if stats_timeout seconds passed, send off an info/stats/heartbeat message to the broker. + /// Given the last time, if `stats_timeout` seconds passed, send off an info/stats/heartbeat message to the broker. /// Returns the new `last` time (so the old one, unless `stats_timeout` time has passed and stats have been sent) /// Will return an Error, if the stats could not be sent. fn maybe_report_stats( diff --git a/libafl/src/generators/mod.rs b/libafl/src/generators/mod.rs index 27c94a1056..b12cb76003 100644 --- a/libafl/src/generators/mod.rs +++ b/libafl/src/generators/mod.rs @@ -48,7 +48,7 @@ where Ok(BytesInput::new(random_bytes)) } - /// Generates up to DUMMY_BYTES_MAX non-random dummy bytes (0) + /// Generates up to `DUMMY_BYTES_MAX` non-random dummy bytes (0) fn generate_dummy(&self) -> BytesInput { let size = min(self.max_size, DUMMY_BYTES_MAX); BytesInput::new(vec![0; size]) @@ -90,7 +90,7 @@ where Ok(BytesInput::new(random_bytes)) } - /// Generates up to DUMMY_BYTES_MAX non-random dummy bytes (0) + /// Generates up to `DUMMY_BYTES_MAX` non-random dummy bytes (0) fn generate_dummy(&self) -> BytesInput { let size = min(self.max_size, DUMMY_BYTES_MAX); BytesInput::new(vec![0_u8; size]) diff --git a/libafl/src/mutators/mutations.rs b/libafl/src/mutators/mutations.rs index d1743572b1..0ba6cc7ffb 100644 --- a/libafl/src/mutators/mutations.rs +++ b/libafl/src/mutators/mutations.rs @@ -44,7 +44,7 @@ pub fn buffer_copy(dst: &mut [u8], src: &[u8], from: usize, to: usize, len: usiz /// A simple buffer_set. /// The compiler does the heavy lifting. -/// see https://stackoverflow.com/a/51732799/1345238 +/// see #[inline] fn buffer_set(data: &mut [u8], from: usize, len: usize, val: u8) { debug_assert!(from + len <= data.len()); diff --git a/libafl/src/utils.rs b/libafl/src/utils.rs index 88c18840ec..72b581d2ec 100644 --- a/libafl/src/utils.rs +++ b/libafl/src/utils.rs @@ -402,7 +402,7 @@ impl ChildHandle { } #[cfg(unix)] -/// The ForkResult +/// The `ForkResult` (result of a fork) pub enum ForkResult { Parent(ChildHandle), Child,