From 3d11a00d70c98015c17f34b73eb0fa4f54942f11 Mon Sep 17 00:00:00 2001 From: Dominik Maier Date: Sat, 16 Nov 2024 02:48:43 -0300 Subject: [PATCH] New clippy lint --- fuzzers/binary_only/qemu_launcher/src/options.rs | 6 +++--- libafl/src/mutators/grimoire.rs | 4 ++-- libafl/src/mutators/unicode/mod.rs | 2 +- libafl/src/schedulers/accounting.rs | 2 +- libafl/src/schedulers/testcase_score.rs | 4 ++-- libafl/src/state/mod.rs | 2 +- libafl_cc/src/clang.rs | 2 +- libafl_libfuzzer/build.rs | 6 +++--- libafl_libfuzzer/runtime/src/corpus.rs | 2 +- libafl_qemu/libafl_qemu_build/src/lib.rs | 2 +- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/fuzzers/binary_only/qemu_launcher/src/options.rs b/fuzzers/binary_only/qemu_launcher/src/options.rs index 56c25fed27..466ff67461 100644 --- a/fuzzers/binary_only/qemu_launcher/src/options.rs +++ b/fuzzers/binary_only/qemu_launcher/src/options.rs @@ -125,19 +125,19 @@ impl FuzzerOptions { pub fn is_asan_core(&self, core_id: CoreId) -> bool { self.asan_cores .as_ref() - .map_or(false, |c| c.contains(core_id)) + .is_some_and(|c| c.contains(core_id)) } pub fn is_asan_guest_core(&self, core_id: CoreId) -> bool { self.asan_guest_cores .as_ref() - .map_or(false, |c| c.contains(core_id)) + .is_some_and(|c| c.contains(core_id)) } pub fn is_cmplog_core(&self, core_id: CoreId) -> bool { self.cmplog_cores .as_ref() - .map_or(false, |c| c.contains(core_id)) + .is_some_and(|c| c.contains(core_id)) } pub fn input_dir(&self) -> PathBuf { diff --git a/libafl/src/mutators/grimoire.rs b/libafl/src/mutators/grimoire.rs index b9cf3e131e..1a8300d41f 100644 --- a/libafl/src/mutators/grimoire.rs +++ b/libafl/src/mutators/grimoire.rs @@ -291,7 +291,7 @@ where while bytes .len() .checked_sub(token_1.len()) - .map_or(false, |len| i < len) + .is_some_and(|len| i < len) { if bytes[i..].starts_with(token_1) { bytes.splice(i..(i + token_1.len()), token_2.iter().copied()); @@ -314,7 +314,7 @@ where while bytes .len() .checked_sub(token_1.len()) - .map_or(false, |len| i < len) + .is_some_and(|len| i < len) { if bytes[i..].starts_with(token_1) { bytes.splice(i..(i + token_1.len()), token_2.iter().copied()); diff --git a/libafl/src/mutators/unicode/mod.rs b/libafl/src/mutators/unicode/mod.rs index 073afa54d5..d73e5fd58a 100644 --- a/libafl/src/mutators/unicode/mod.rs +++ b/libafl/src/mutators/unicode/mod.rs @@ -78,7 +78,7 @@ fn choose_start( if idx .checked_sub(*start) // idx adjusted to start .and_then(|idx| (idx < range.len()).then(|| range[idx])) // idx in range - .map_or(false, |r| r) + .is_some_and(|r| r) { options.push((*start, range)); } diff --git a/libafl/src/schedulers/accounting.rs b/libafl/src/schedulers/accounting.rs index ad75cca600..13c167cd99 100644 --- a/libafl/src/schedulers/accounting.rs +++ b/libafl/src/schedulers/accounting.rs @@ -138,7 +138,7 @@ where if state .metadata_map() .get::() - .map_or(false, |x| x.changed) + .is_some_and(|x| x.changed) { self.accounting_cull(state)?; } else { diff --git a/libafl/src/schedulers/testcase_score.rs b/libafl/src/schedulers/testcase_score.rs index c08454903a..d406bc4233 100644 --- a/libafl/src/schedulers/testcase_score.rs +++ b/libafl/src/schedulers/testcase_score.rs @@ -264,7 +264,7 @@ where perf_score = HAVOC_MAX_MULT * 100.0; } - if entry.objectives_found() > 0 && psmeta.strat().map_or(false, |s| s.avoid_crash()) { + if entry.objectives_found() > 0 && psmeta.strat().is_some_and(|s| s.avoid_crash()) { perf_score *= 0.00; } @@ -342,7 +342,7 @@ where weight *= 2.0; } - if entry.objectives_found() > 0 && psmeta.strat().map_or(false, |s| s.avoid_crash()) { + if entry.objectives_found() > 0 && psmeta.strat().is_some_and(|s| s.avoid_crash()) { weight *= 0.00; } diff --git a/libafl/src/state/mod.rs b/libafl/src/state/mod.rs index e38dfc580c..0237aa8712 100644 --- a/libafl/src/state/mod.rs +++ b/libafl/src/state/mod.rs @@ -648,7 +648,7 @@ where if filename.starts_with('.') // || filename // .rsplit_once('-') - // .map_or(false, |(_, s)| u64::from_str(s).is_ok()) + // .is_some_and(|(_, s)| u64::from_str(s).is_ok()) { continue; } diff --git a/libafl_cc/src/clang.rs b/libafl_cc/src/clang.rs index 56bad90685..42d5b137b8 100644 --- a/libafl_cc/src/clang.rs +++ b/libafl_cc/src/clang.rs @@ -171,7 +171,7 @@ impl ToolWrapper for ClangWrapper { if arg_as_path .extension() - .map_or(false, |ext| ext.eq_ignore_ascii_case("s")) + .is_some_and(|ext| ext.eq_ignore_ascii_case("s")) { self.is_asm = true; } diff --git a/libafl_libfuzzer/build.rs b/libafl_libfuzzer/build.rs index 3d960f7ce1..6d0a0b51da 100644 --- a/libafl_libfuzzer/build.rs +++ b/libafl_libfuzzer/build.rs @@ -135,7 +135,7 @@ fn main() -> Result<(), Box> { } assert!( - command.status().map_or(false, |s| s.success()), + command.status().is_some_and(|s| s.success()), "Couldn't build runtime crate! Did you remember to use nightly? (`rustup default nightly` to install)" ); @@ -199,7 +199,7 @@ fn main() -> Result<(), Box> { drop(redefinitions_file); assert!( - nm_child.wait().map_or(false, |s| s.success()), + nm_child.wait().is_some_and(|s| s.success()), "Couldn't link runtime crate! Do you have the llvm-tools component installed? (`rustup component add llvm-tools-preview` to install)" ); @@ -242,7 +242,7 @@ fn main() -> Result<(), Box> { .args([&archive_path, &redefined_archive_path]); assert!( - objcopy_command.status().map_or(false, |s| s.success()), + objcopy_command.status().is_some_and(|s| s.success()), "Couldn't rename allocators in the runtime crate! Do you have the llvm-tools component installed? (`rustup component add llvm-tools-preview` to install)" ); diff --git a/libafl_libfuzzer/runtime/src/corpus.rs b/libafl_libfuzzer/runtime/src/corpus.rs index b250cfa78b..a5ec612193 100644 --- a/libafl_libfuzzer/runtime/src/corpus.rs +++ b/libafl_libfuzzer/runtime/src/corpus.rs @@ -341,7 +341,7 @@ where .count .checked_sub(1) .map(CorpusId::from) - .map_or(false, |last| last == id) + .is_some_and(|last| last == id) { self.last.as_ref() } else { diff --git a/libafl_qemu/libafl_qemu_build/src/lib.rs b/libafl_qemu/libafl_qemu_build/src/lib.rs index 3ec004bf7f..57445cfe46 100644 --- a/libafl_qemu/libafl_qemu_build/src/lib.rs +++ b/libafl_qemu/libafl_qemu_build/src/lib.rs @@ -192,7 +192,7 @@ fn qemu_bindgen_clang_args( entry["output"] == main_obj || entry["file"] .as_str() - .map_or(false, |file| file.ends_with(main_file)) + .is_some_and(|file| file.ends_with(main_file)) }) .expect("Didn't find compile command for qemu-system-arm");