diff --git a/libafl/src/schedulers/mod.rs b/libafl/src/schedulers/mod.rs index 2fdd19de84..e3664e8b35 100644 --- a/libafl/src/schedulers/mod.rs +++ b/libafl/src/schedulers/mod.rs @@ -300,7 +300,10 @@ where /// Gets the next entry at random fn next(&mut self, state: &mut Self::State) -> Result { if state.corpus().count() == 0 { - Err(Error::empty("No entries in corpus. This often implies the target is not properly instrumented.".to_owned())) + Err(Error::empty( + "No entries in corpus. This often implies the target is not properly instrumented." + .to_owned(), + )) } else { let id = random_corpus_id!(state.corpus(), state.rand_mut()); self.set_current_scheduled(state, Some(id))?; diff --git a/libafl/src/schedulers/powersched.rs b/libafl/src/schedulers/powersched.rs index a0782faf5a..8eade59576 100644 --- a/libafl/src/schedulers/powersched.rs +++ b/libafl/src/schedulers/powersched.rs @@ -259,7 +259,9 @@ where fn next(&mut self, state: &mut Self::State) -> Result { if state.corpus().count() == 0 { - Err(Error::empty(String::from("No entries in corpus. This often implies the target is not properly instrumented."))) + Err(Error::empty(String::from( + "No entries in corpus. This often implies the target is not properly instrumented.", + ))) } else { let id = match state.corpus().current() { Some(cur) => { diff --git a/libafl/src/schedulers/probabilistic_sampling.rs b/libafl/src/schedulers/probabilistic_sampling.rs index d4b5c69ad3..11764f604e 100644 --- a/libafl/src/schedulers/probabilistic_sampling.rs +++ b/libafl/src/schedulers/probabilistic_sampling.rs @@ -158,7 +158,9 @@ where #[allow(clippy::cast_precision_loss)] fn next(&mut self, state: &mut Self::State) -> Result { if state.corpus().count() == 0 { - Err(Error::empty(String::from("No entries in corpus. This often implies the target is not properly instrumented."))) + Err(Error::empty(String::from( + "No entries in corpus. This often implies the target is not properly instrumented.", + ))) } else { let rand_prob: f64 = (state.rand_mut().below(100) as f64) / 100.0; let meta = state.metadata_map().get::().unwrap(); diff --git a/libafl/src/schedulers/queue.rs b/libafl/src/schedulers/queue.rs index d7cc5d62bf..0608f453c1 100644 --- a/libafl/src/schedulers/queue.rs +++ b/libafl/src/schedulers/queue.rs @@ -44,7 +44,10 @@ where /// Gets the next entry in the queue fn next(&mut self, state: &mut Self::State) -> Result { if state.corpus().count() == 0 { - Err(Error::empty("No entries in corpus. This often implies the target is not properly instrumented.".to_owned())) + Err(Error::empty( + "No entries in corpus. This often implies the target is not properly instrumented." + .to_owned(), + )) } else { let id = state .corpus() diff --git a/libafl/src/schedulers/tuneable.rs b/libafl/src/schedulers/tuneable.rs index 61e25cd81a..7a2df0fc7b 100644 --- a/libafl/src/schedulers/tuneable.rs +++ b/libafl/src/schedulers/tuneable.rs @@ -119,7 +119,10 @@ where /// Gets the next entry in the queue fn next(&mut self, state: &mut Self::State) -> Result { if state.corpus().count() == 0 { - return Err(Error::empty("No entries in corpus. This often implies the target is not properly instrumented.".to_owned())); + return Err(Error::empty( + "No entries in corpus. This often implies the target is not properly instrumented." + .to_owned(), + )); } let id = if let Some(next) = Self::get_next(state) { // next was set diff --git a/libafl/src/schedulers/weighted.rs b/libafl/src/schedulers/weighted.rs index d4e95956e5..7a26628f76 100644 --- a/libafl/src/schedulers/weighted.rs +++ b/libafl/src/schedulers/weighted.rs @@ -303,7 +303,9 @@ where fn next(&mut self, state: &mut S) -> Result { let corpus_counts = state.corpus().count(); if corpus_counts == 0 { - Err(Error::empty(String::from("No entries in corpus. This often implies the target is not properly instrumented."))) + Err(Error::empty(String::from( + "No entries in corpus. This often implies the target is not properly instrumented.", + ))) } else { let s = random_corpus_id!(state.corpus(), state.rand_mut()); diff --git a/libafl_bolts/Cargo.toml b/libafl_bolts/Cargo.toml index 8ff8e5ab6b..741d69f8e9 100644 --- a/libafl_bolts/Cargo.toml +++ b/libafl_bolts/Cargo.toml @@ -86,6 +86,7 @@ rustversion = "1.0" [dependencies] libafl_derive = { version = "0.11.2", optional = true, path = "../libafl_derive" } +static_assertions = "1.1.0" rustversion = "1.0" tuple_list = { version = "0.1.3" } diff --git a/libafl_bolts/src/anymap.rs b/libafl_bolts/src/anymap.rs index 7fbda67127..2c2bf16673 100644 --- a/libafl_bolts/src/anymap.rs +++ b/libafl_bolts/src/anymap.rs @@ -49,7 +49,7 @@ macro_rules! impl_asany { #[must_use] pub const fn pack_type_id(id: u128) -> TypeId { // TypeId size of other sizes is not yet supported" - assert!(size_of::() == 16, "Unsupported size for TypeId"); + static_assertions::const_assert!(size_of::() == 16); unsafe { *(addr_of!(id) as *const TypeId) } } @@ -64,7 +64,7 @@ pub const fn pack_type_id(id: u128) -> TypeId { pub const fn unpack_type_id(id: TypeId) -> u128 { // see any.rs, it's alway u128 hence 16 bytes. // TypeId size of other sizes is not yet supported" - assert!(size_of::() == 16, "Unsupported size for TypeId"); + static_assertions::const_assert!(size_of::() == 16); let ret: u128 = unsafe { read_unaligned::(addr_of!(id) as *const u128) }; ret }