clippy
This commit is contained in:
parent
9ae13eb5da
commit
e719e85aba
@ -310,6 +310,7 @@ where
|
|||||||
S: HasMetadata + HasRand<R> + HasMaxSize,
|
S: HasMetadata + HasRand<R> + HasMaxSize,
|
||||||
R: Rand,
|
R: Rand,
|
||||||
{
|
{
|
||||||
|
#[allow(clippy::too_many_lines)]
|
||||||
fn mutate(
|
fn mutate(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut S,
|
state: &mut S,
|
||||||
@ -343,13 +344,13 @@ where
|
|||||||
let mut result = MutationResult::Skipped;
|
let mut result = MutationResult::Skipped;
|
||||||
match cmp_values {
|
match cmp_values {
|
||||||
CmpValues::U8(v) => {
|
CmpValues::U8(v) => {
|
||||||
for i in off..len {
|
for byte in bytes.iter_mut().take(len).skip(off) {
|
||||||
if bytes[i] == v.0 {
|
if *byte == v.0 {
|
||||||
bytes[i] = v.1;
|
*byte = v.1;
|
||||||
result = MutationResult::Mutated;
|
result = MutationResult::Mutated;
|
||||||
break;
|
break;
|
||||||
} else if bytes[i] == v.1 {
|
} else if *byte == v.1 {
|
||||||
bytes[i] = v.0;
|
*byte = v.0;
|
||||||
result = MutationResult::Mutated;
|
result = MutationResult::Mutated;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -25,29 +25,28 @@ pub enum CmpValues {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl CmpValues {
|
impl CmpValues {
|
||||||
|
#[must_use]
|
||||||
pub fn is_numeric(&self) -> bool {
|
pub fn is_numeric(&self) -> bool {
|
||||||
match self {
|
matches!(
|
||||||
CmpValues::U8(_) => true,
|
self,
|
||||||
CmpValues::U16(_) => true,
|
CmpValues::U8(_) | CmpValues::U16(_) | CmpValues::U32(_) | CmpValues::U64(_)
|
||||||
CmpValues::U32(_) => true,
|
)
|
||||||
CmpValues::U64(_) => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
pub fn to_u64_tuple(&self) -> Option<(u64, u64)> {
|
pub fn to_u64_tuple(&self) -> Option<(u64, u64)> {
|
||||||
match self {
|
match self {
|
||||||
CmpValues::U8(t) => Some((u64::from(t.0), u64::from(t.1))),
|
CmpValues::U8(t) => Some((u64::from(t.0), u64::from(t.1))),
|
||||||
CmpValues::U16(t) => Some((u64::from(t.0), u64::from(t.1))),
|
CmpValues::U16(t) => Some((u64::from(t.0), u64::from(t.1))),
|
||||||
CmpValues::U32(t) => Some((u64::from(t.0), u64::from(t.1))),
|
CmpValues::U32(t) => Some((u64::from(t.0), u64::from(t.1))),
|
||||||
CmpValues::U64(t) => Some((u64::from(t.0), u64::from(t.1))),
|
CmpValues::U64(t) => Some(*t),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A state metadata holding a list of values logged from comparisons
|
/// A state metadata holding a list of values logged from comparisons
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Default, Serialize, Deserialize)]
|
||||||
pub struct CmpValuesMetadata {
|
pub struct CmpValuesMetadata {
|
||||||
/// A `list` of values.
|
/// A `list` of values.
|
||||||
pub list: Vec<CmpValues>,
|
pub list: Vec<CmpValues>,
|
||||||
@ -76,10 +75,19 @@ pub trait CmpMap: Serialize + DeserializeOwned {
|
|||||||
/// Get the number of cmps
|
/// Get the number of cmps
|
||||||
fn len(&self) -> usize;
|
fn len(&self) -> usize;
|
||||||
|
|
||||||
|
/// Get if it is empty
|
||||||
|
#[must_use]
|
||||||
|
fn is_empty(&self) -> bool {
|
||||||
|
self.len() == 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the number of executions for a cmp
|
||||||
fn executions_for(&self, idx: usize) -> usize;
|
fn executions_for(&self, idx: usize) -> usize;
|
||||||
|
|
||||||
|
// Get the number of logged executions for a cmp
|
||||||
fn usable_executions_for(&self, idx: usize) -> usize;
|
fn usable_executions_for(&self, idx: usize) -> usize;
|
||||||
|
|
||||||
|
// Get the logged values for a cmp
|
||||||
fn values_of(&self, idx: usize, execution: usize) -> CmpValues;
|
fn values_of(&self, idx: usize, execution: usize) -> CmpValues;
|
||||||
|
|
||||||
/// Reset the state
|
/// Reset the state
|
||||||
@ -94,10 +102,14 @@ where
|
|||||||
/// Get the number of usable cmps (all by default)
|
/// Get the number of usable cmps (all by default)
|
||||||
fn usable_count(&self) -> usize;
|
fn usable_count(&self) -> usize;
|
||||||
|
|
||||||
|
/// Get the `CmpMap`
|
||||||
fn map(&self) -> &CM;
|
fn map(&self) -> &CM;
|
||||||
|
|
||||||
|
/// Get the `CmpMap` (mut)
|
||||||
fn map_mut(&mut self) -> &mut CM;
|
fn map_mut(&mut self) -> &mut CM;
|
||||||
|
|
||||||
|
/// Add [`CmpValuesMetadata`] to the State including the logged values.
|
||||||
|
/// This routine does a basic loop filtering because loop index cmps are not interesting.
|
||||||
fn add_cmpvalues_meta<S>(&mut self, state: &mut S)
|
fn add_cmpvalues_meta<S>(&mut self, state: &mut S)
|
||||||
where
|
where
|
||||||
S: HasMetadata,
|
S: HasMetadata,
|
||||||
@ -221,7 +233,7 @@ impl<'a, CM> StdCmpObserver<'a, CM>
|
|||||||
where
|
where
|
||||||
CM: CmpMap,
|
CM: CmpMap,
|
||||||
{
|
{
|
||||||
/// Creates a new [`StdCmpObserver`] with the given name.
|
/// Creates a new [`StdCmpObserver`] with the given name and map.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn new(name: &'static str, map: &'a mut CM) -> Self {
|
pub fn new(name: &'static str, map: &'a mut CM) -> Self {
|
||||||
Self {
|
Self {
|
||||||
@ -231,5 +243,13 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO with_size
|
/// Creates a new [`StdCmpObserver`] with the given name, map and reference to variable size.
|
||||||
|
#[must_use]
|
||||||
|
pub fn with_size(name: &'static str, map: &'a mut CM, size: &'a mut usize) -> Self {
|
||||||
|
Self {
|
||||||
|
name: name.to_string(),
|
||||||
|
size: Some(OwnedRefMut::Ref(size)),
|
||||||
|
map: OwnedRefMut::Ref(map),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ pub static mut libafl_cmplog_enabled: u8 = 0;
|
|||||||
|
|
||||||
pub use libafl_cmplog_enabled as CMPLOG_ENABLED;
|
pub use libafl_cmplog_enabled as CMPLOG_ENABLED;
|
||||||
|
|
||||||
/// A [`CmpObserver`] observer for CmpLog
|
/// A [`CmpObserver`] observer for `CmpLog`
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
pub struct CmpLogObserver<'a> {
|
pub struct CmpLogObserver<'a> {
|
||||||
map: OwnedRefMut<'a, CmpLogMap>,
|
map: OwnedRefMut<'a, CmpLogMap>,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
//! [`LLVM` `PcGuard`](https://clang.llvm.org/docs/SanitizerCoverage.html#tracing-pcs-with-guards) runtime for `LibAFL`.
|
//! [`LLVM` `PcGuard`](https://clang.llvm.org/docs/SanitizerCoverage.html#tracing-pcs-with-guards) runtime for `LibAFL`.
|
||||||
|
|
||||||
use crate::coverage::*;
|
use crate::coverage::{EDGES_MAP, EDGES_MAP_SIZE, MAX_EDGES_NUM};
|
||||||
|
|
||||||
#[cfg(all(feature = "sancov_pcguard_edges", feature = "sancov_pcguard_hitcounts"))]
|
#[cfg(all(feature = "sancov_pcguard_edges", feature = "sancov_pcguard_hitcounts"))]
|
||||||
#[cfg(not(any(doc, feature = "clippy")))]
|
#[cfg(not(any(doc, feature = "clippy")))]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user