Fix clippy (#3102)

* fix clippy

* libafl_frida/

* lol

* lol

---------

Co-authored-by: Toka <tokazerkje@outlook.com>
This commit is contained in:
Romain Malmain 2025-03-24 15:03:04 +01:00 committed by GitHub
parent 60d0ccb8cb
commit c863c8bd6c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
24 changed files with 47 additions and 60 deletions

View File

@ -173,6 +173,7 @@ similar_names = "allow"
too_many_lines = "allow"
comparison_chain = "allow" # This lint makes **ZERO** sense
unnecessary_debug_formatting = "allow" # :thumbsdown: :thumbsdown: :thumbsdown: :thumbsdown: :thumbsdown: :thumbsdown:
struct_field_names = "allow" # ????
[workspace.lints.rustdoc]
# Deny

View File

@ -405,8 +405,7 @@ where
..
} => {
log::debug!(
"Received {} from {client_id:?} ({client_config:?}, forward {forward_id:?})",
event_name
"Received {event_name} from {client_id:?} ({client_config:?}, forward {forward_id:?})"
);
log::debug!(

View File

@ -561,7 +561,7 @@ where
// Send this mesasge off and we are leaving.
match send_tcp_msg(&mut stream, &msg) {
Ok(()) => (),
Err(e) => log::error!("Failed to send tcp message {:#?}", e),
Err(e) => log::error!("Failed to send tcp message {e:#?}"),
}
log::debug!("Asking he broker to be disconnected");
Ok(())

View File

@ -1039,10 +1039,7 @@ where
)));
}
log::info!(
"All right - new fork server model version {} is up",
version
);
log::info!("All right - new fork server model version {version} is up");
let status = forkserver.read_st().map_err(|err| {
Error::illegal_state(format!("Reading from forkserver failed: {err:?}"))

View File

@ -505,7 +505,7 @@ impl InProcessExecutorHandlerData {
if let Ok(bsod) = bsod {
if let Ok(r) = core::str::from_utf8(&bsod) {
log::error!("{}", r);
log::error!("{r}");
}
}
}

View File

@ -247,7 +247,7 @@ pub mod unix_signal_handler {
let _ = writer.flush();
}
if let Ok(r) = core::str::from_utf8(&bsod) {
log::error!("{}", r);
log::error!("{r}");
}
}
@ -287,7 +287,7 @@ pub mod unix_signal_handler {
let _ = writer.flush();
}
if let Ok(r) = core::str::from_utf8(&bsod) {
log::error!("{}", r);
log::error!("{r}");
}
}
}

View File

@ -450,7 +450,7 @@ where
let Some(meta) = state.metadata_map().get::<CmpValuesMetadata>() else {
return Ok(MutationResult::Skipped);
};
log::trace!("meta: {:x?}", meta);
log::trace!("meta: {meta:x?}");
meta.list.len()
};
@ -648,7 +648,7 @@ where
let Some(meta) = state.metadata_map().get::<CmpValuesMetadata>() else {
return Ok(MutationResult::Skipped);
};
log::trace!("meta: {:x?}", meta);
log::trace!("meta: {meta:x?}");
let Some(cmps_len) = NonZero::new(meta.list.len()) else {
return Ok(MutationResult::Skipped);

View File

@ -107,7 +107,7 @@ where
let mut new_files = vec![];
for dir in &self.sync_dirs {
log::debug!("Syncing from dir: {:?}", dir);
log::debug!("Syncing from dir: {dir:?}");
let new_dir_files = find_new_files_rec(dir, &last)?;
new_files.extend(new_dir_files);
}
@ -134,7 +134,7 @@ where
.unwrap()
.left_to_sync
.retain(|p| p != &path);
log::debug!("Syncing and evaluating {:?}", path);
log::debug!("Syncing and evaluating {path:?}");
fuzzer.evaluate_input(state, executor, manager, &input)?;
}

View File

@ -977,10 +977,7 @@ where
self.reset_initial_files_state();
self.canonicalize_input_dirs(in_dirs)?;
if cores.ids.len() > corpus_size {
log::info!(
"low intial corpus count ({}), no parallelism required.",
corpus_size
);
log::info!("low intial corpus count ({corpus_size}), no parallelism required.");
} else {
let core_index = cores
.ids

View File

@ -1106,7 +1106,7 @@ mod windows_logging {
// Get the handle to standard output
let h_stdout: HANDLE = get_stdout_handle();
if h_stdout == INVALID_HANDLE_VALUE {
if ptr::eq(h_stdout, INVALID_HANDLE_VALUE) {
eprintln!("Failed to get standard output handle");
return;
}

View File

@ -1587,7 +1587,7 @@ where
unsafe {
// log::info!("Sending msg {:?}", msg);
assert!(self.last_msg_sent != msg, "Message sent twice!");
assert!(!ptr::eq(self.last_msg_sent, msg), "Message sent twice!");
assert!(
(*msg).tag != LLMP_TAG_UNSET,
"No tag set on message with id {:?}",
@ -2276,7 +2276,7 @@ impl SignalHandler for LlmpShutdownSignalHandler {
#[cfg(all(windows, feature = "std"))]
impl CtrlHandler for LlmpShutdownSignalHandler {
fn handle(&mut self, ctrl_type: u32) -> bool {
log::info!("LLMP: Received shutdown signal, ctrl_type {:?}", ctrl_type);
log::info!("LLMP: Received shutdown signal, ctrl_type {ctrl_type:?}");
unsafe {
ptr::write_volatile(&mut self.shutting_down, true);
}
@ -2421,7 +2421,7 @@ impl Brokers {
} else {
log::info!(
"{}: Broker successfully setup control handlers",
std::process::id().to_string()
std::process::id()
);
}
}
@ -2694,7 +2694,7 @@ where
for idx in (0..self.inner.llmp_clients.len()).rev() {
let client_id = self.inner.llmp_clients[idx].id;
if self.inner.clients_to_remove.contains(&client_id) {
log::info!("Client {:#?} wants to exit. Removing.", client_id);
log::info!("Client {client_id:#?} wants to exit. Removing.");
self.inner.llmp_clients.remove(idx);
}
}
@ -2777,8 +2777,7 @@ where
let exitinfo = (*msg).buf.as_mut_ptr() as *mut LlmpClientExitInfo;
let client_id = ClientId((*exitinfo).client_id);
log::info!(
"Client exit message received!, we are removing clients whose client_group_id is {:#?}",
client_id
"Client exit message received!, we are removing clients whose client_group_id is {client_id:#?}"
);
self.inner.clients_to_remove.push(client_id);
@ -2890,7 +2889,7 @@ where
} else {
log::info!(
"{}: Broker successfully setup control handlers",
std::process::id().to_string()
std::process::id()
);
}
}

View File

@ -508,7 +508,7 @@ pub unsafe extern "system" fn handle_exception(
.ExceptionCode
};
let exception_code = From::from(code.0);
log::info!("Received exception; code: {}", exception_code);
log::info!("Received exception; code: {exception_code}");
unsafe { internal_handle_exception(exception_code, exception_pointers) }
}

View File

@ -771,7 +771,7 @@ pub mod unix_shmem {
shm_fd,
0,
);
if map == libc::MAP_FAILED || map.is_null() {
if ptr::eq(map, libc::MAP_FAILED) {
close(shm_fd);
shm_unlink(filename_path.as_ptr() as *const _);
return Err(Error::last_os_error(format!(
@ -845,7 +845,7 @@ pub mod unix_shmem {
shm_fd,
0,
);
if map == libc::MAP_FAILED || map.is_null() {
if ptr::eq(map, libc::MAP_FAILED) {
close(shm_fd);
return Err(Error::last_os_error(format!(
"mmap() failed for map with fd {shm_fd:?}"
@ -1081,7 +1081,7 @@ pub mod unix_shmem {
let id_int: i32 = id.into();
let map = shmat(id_int, ptr::null(), 0) as *mut c_uchar;
if map.is_null() || map == ptr::null_mut::<c_uchar>().wrapping_sub(1) {
if ptr::eq(map, ptr::null_mut::<c_uchar>().wrapping_sub(1)) {
return Err(Error::last_os_error(format!(
"Failed to map the shared mapping with id {id_int}"
)));
@ -1250,7 +1250,7 @@ pub mod unix_shmem {
fd,
0,
);
if map == usize::MAX as *mut c_void {
if ptr::eq(map, usize::MAX as *mut c_void) {
close(fd);
return Err(Error::unknown(
"Failed to map the ashmem mapping".to_string(),
@ -1285,7 +1285,7 @@ pub mod unix_shmem {
fd,
0,
);
if map == usize::MAX as *mut c_void {
if ptr::eq(map, usize::MAX as *mut c_void) {
close(fd);
return Err(Error::unknown(
"Failed to map the ashmem mapping".to_string(),
@ -1392,9 +1392,7 @@ pub mod unix_shmem {
};
use std::os::fd::IntoRawFd;
use libc::{
MAP_SHARED, PROT_READ, PROT_WRITE, c_void, close, fstat, ftruncate, mmap, munmap,
};
use libc::{MAP_SHARED, PROT_READ, PROT_WRITE, close, fstat, ftruncate, mmap, munmap};
use nix::sys::memfd::{MemFdCreateFlag, memfd_create};
use crate::{
@ -1436,7 +1434,7 @@ pub mod unix_shmem {
fd,
0,
);
if map == usize::MAX as *mut c_void {
if ptr::eq(map, libc::MAP_FAILED) {
close(fd);
return Err(Error::unknown(
"Failed to map the memfd mapping".to_string(),
@ -1473,7 +1471,7 @@ pub mod unix_shmem {
fd,
0,
);
if map == usize::MAX as *mut c_void {
if ptr::eq(map, libc::MAP_FAILED) {
return Err(Error::last_os_error(format!(
"mmap() failed for map with fd {fd:?}"
)));

View File

@ -594,7 +594,7 @@ impl Allocator {
.any(|r| r.start <= start && r.end >= start + size);
if !valid {
log::error!("Not a valid shadow: {:#x}!", start);
log::error!("Not a valid shadow: {start:#x}!");
}
valid
}
@ -720,7 +720,7 @@ impl Allocator {
&mut |range: &RangeDetails| -> bool {
let start = range.memory_range().base_address().0 as usize;
let end = start + range.memory_range().size();
log::trace!("New range: {:#x}-{:#x}", start, end);
log::trace!("New range: {start:#x}-{end:#x}");
#[cfg(target_vendor = "apple")]
if start >= 0x600000000000 {
@ -762,7 +762,7 @@ impl Allocator {
}
}
log::trace!("max bit: {}", maxbit);
log::trace!("max bit: {maxbit}");
{
for try_shadow_bit in 44..=maxbit {
@ -773,7 +773,7 @@ impl Allocator {
// check if the proposed shadow bit overlaps with occupied ranges.
for (start, end) in &occupied_ranges {
if (shadow_start <= *end) && (*start <= shadow_end) {
log::trace!("{:x} {:x}, {:x} {:x}", shadow_start, shadow_end, start, end);
log::trace!("{shadow_start:x} {shadow_end:x}, {start:x} {end:x}");
log::warn!("shadow_bit {try_shadow_bit:} is not suitable");
good_candidate = false;
break;

View File

@ -527,10 +527,7 @@ impl AsanRuntime {
});
if start == 0 {
log::error!(
"range_for_address: no range found for address {:#x}",
address
);
log::error!("range_for_address: no range found for address {address:#x}");
}
(start, end)
}
@ -1529,7 +1526,7 @@ impl AsanRuntime {
let insn = instructions[0]; // This is the very instruction that has triggered fault
log::info!(
"Fault Instruction: {}",
insn.display_with(DisplayStyle::Intel).to_string()
insn.display_with(DisplayStyle::Intel)
);
let operand_count = insn.operand_count();
@ -2478,7 +2475,7 @@ impl AsanRuntime {
let result = frida_to_cs(decoder, instr);
if let Err(e) = result {
log::error!("{}", e);
log::error!("{e}");
return None;
}
@ -2520,7 +2517,7 @@ impl AsanRuntime {
// println!("{:#?} {:#?} {:#?}", cs_instr, cs_instr.to_string(), operand);
// println!("{:#?}", (memsz, basereg, indexreg, scale, disp));
log::trace!("ASAN Interesting operand {:#?}", operand);
log::trace!("ASAN Interesting operand {operand:#?}");
log::trace!("{:#?}", (memsz, basereg, indexreg, scale, disp));
return Some((memsz, basereg, indexreg, scale, disp));
}
@ -2699,7 +2696,7 @@ impl AsanRuntime {
writer.put_nop();
}
} else {
log::trace!("Cannot check instructions for {:?} bytes.", width);
log::trace!("Cannot check instructions for {width:?} bytes.");
}
writer.put_pop_reg(X86Register::Rdi);

View File

@ -1608,7 +1608,7 @@ impl AsanRuntime {
) -> *mut c_void {
log::trace!("hook_mmap");
let res = original(addr, length, prot, flags, fd, offset);
if res != (-1_isize as *mut c_void) {
if !ptr::eq(res, -1_isize as *mut c_void) {
self.allocator_mut()
.map_shadow_for_region(res as usize, res as usize + length, true);
}

View File

@ -101,7 +101,7 @@ where
// so that Stalker knows to pick it despite the module being excluded
let harness_fn_ref: &H = self.base.harness();
let ptr: *const H = harness_fn_ref as *const H;
log::info!("Activating Stalker for {:p}", ptr);
log::info!("Activating Stalker for {ptr:p}");
self.stalker.activate(NativePointer(ptr as *mut c_void));
}
let res = self.base.run_target(fuzzer, state, mgr, input);

View File

@ -460,7 +460,7 @@ impl FridaInstrumentationHelperBuilder {
.remove(range.start as u64..range.end as u64),
SkipRange::ModuleRelative { name, range } => {
if name.eq(&module.name()) {
log::trace!("Skipping {:?} {:?}", name, range);
log::trace!("Skipping {name:?} {range:?}");
let module_details = Module::load(gum, &name.to_string());
let lib_start = module_details.range().base_address().0 as u64;
ranges.borrow_mut().remove(

View File

@ -443,7 +443,7 @@ mod tests {
// Run the tests for each function
for test in tests {
let (function_name, expected_error) = test;
log::info!("Testing with harness function {}", function_name);
log::info!("Testing with harness function {function_name}");
let mut corpus = InMemoryCorpus::<BytesInput>::new();

View File

@ -170,7 +170,7 @@ where
let prev = unsafe { pthread_introspection_hook_install(pthread_introspection_hook as _) };
// Allow because we're sure this isn't from a different code generation unit.
if !(prev).is_null() && prev != pthread_introspection_hook as _ {
if !(prev).is_null() && !core::ptr::eq(prev, pthread_introspection_hook as _) {
unsafe {
(*previous_hook_ptr_mut()).set(prev as *const pthread_introspection_hook_t);
}

View File

@ -471,8 +471,7 @@ impl IntelPT {
if e.code() != PtErrorCode::Eos {
let offset = decoder.offset().map_err(error_from_pt_error)?;
log::info!(
"PT error in block next {e:?} trace offset {offset:x} last decoded block end {:x}",
previous_block_end_ip
"PT error in block next {e:?} trace offset {offset:x} last decoded block end {previous_block_end_ip:x}"
);
}
break 'block;

View File

@ -145,7 +145,7 @@ pub unsafe fn inproc_qemu_crash_handler<E, EM, ET, I, OF, S, Z>(
if let Ok(bsod) = bsod {
if let Ok(bsod_str) = str::from_utf8(&bsod) {
log::error!("\n{}", bsod_str);
log::error!("\n{bsod_str}");
} else {
log::error!("convert minibsod to string failed");
}

View File

@ -383,7 +383,7 @@ impl SnapshotModule {
}
}
} else {
log::warn!("\tpage not found @addr 0x{:x}", addr);
log::warn!("\tpage not found @addr 0x{addr:x}");
}
addr += SNAPSHOT_PAGE_SIZE as GuestAddr;
@ -963,7 +963,7 @@ where
}
SYS_brk => {
// We don't handle brk here. It is handled in the reset function only when it's needed.
log::debug!("New brk ({:#x?}) received.", result);
log::debug!("New brk ({result:#x?}) received.");
}
// mmap syscalls
sys_const => {

View File

@ -266,7 +266,7 @@ pub unsafe extern "C" fn __sanitizer_cov_trace_pc_guard_init(mut start: *mut u32
EDGES_MAP_PTR = &raw mut EDGES_MAP as *mut u8;
}
if start == stop || *start != 0 {
if core::ptr::eq(start, stop) || *start != 0 {
return;
}