From 0ad69de0fd3c5230bb8bab1cdd472bd165e0eb6c Mon Sep 17 00:00:00 2001 From: Gabriele Svelto Date: Mon, 9 Jan 2023 11:32:53 +0100 Subject: [PATCH] Appease clippy --- src/bin/test.rs | 2 +- src/dir_section.rs | 6 +++--- src/linux/minidump_writer.rs | 4 ++-- src/linux/sections/exception_stream.rs | 4 ++-- src/linux/sections/thread_list_stream.rs | 6 +++--- src/mem_writer.rs | 2 +- tests/ptrace_dumper.rs | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/bin/test.rs b/src/bin/test.rs index 195640fc..08a98618 100644 --- a/src/bin/test.rs +++ b/src/bin/test.rs @@ -88,7 +88,7 @@ mod linux { fn test_file_id() -> Result<()> { let ppid = getppid().as_raw(); let exe_link = format!("/proc/{}/exe", ppid); - let exe_name = std::fs::read_link(&exe_link)?.into_os_string(); + let exe_name = std::fs::read_link(exe_link)?.into_os_string(); let mut dumper = PtraceDumper::new(getppid().as_raw())?; let mut found_exe = None; for (idx, mapping) in dumper.mappings.iter().enumerate() { diff --git a/src/dir_section.rs b/src/dir_section.rs index 63b2e39c..ced5a2d1 100644 --- a/src/dir_section.rs +++ b/src/dir_section.rs @@ -2,7 +2,7 @@ use crate::{ mem_writer::{Buffer, MemoryArrayWriter, MemoryWriterError}, minidump_format::MDRawDirectory, }; -use std::io::{Error, Seek, SeekFrom, Write}; +use std::io::{Error, Seek, Write}; pub type DumpBuf = Buffer; @@ -44,7 +44,7 @@ where Ok(Self { curr_idx: 0, section: dir_section, - destination_start_offset: destination.seek(SeekFrom::Current(0))?, + destination_start_offset: destination.stream_position()?, destination, last_position_written_to_file: 0, }) @@ -65,7 +65,7 @@ where // Now write it to file // First get all the positions - let curr_file_pos = self.destination.seek(SeekFrom::Current(0))?; + let curr_file_pos = self.destination.stream_position()?; let idx_pos = self.section.location_of_index(self.curr_idx); self.curr_idx += 1; diff --git a/src/linux/minidump_writer.rs b/src/linux/minidump_writer.rs index ea42ee7b..606a8590 100644 --- a/src/linux/minidump_writer.rs +++ b/src/linux/minidump_writer.rs @@ -156,7 +156,7 @@ impl MinidumpWriter { return true; } - let (stack_ptr, stack_len) = match dumper.get_stack_info(stack_pointer as usize) { + let (stack_ptr, stack_len) = match dumper.get_stack_info(stack_pointer) { Ok(x) => x, Err(_) => { return false; @@ -173,7 +173,7 @@ impl MinidumpWriter { } }; - let sp_offset = stack_pointer as usize - stack_ptr; + let sp_offset = stack_pointer - stack_ptr; self.principal_mapping .as_ref() .unwrap() diff --git a/src/linux/sections/exception_stream.rs b/src/linux/sections/exception_stream.rs index ad929014..f7edda8d 100644 --- a/src/linux/sections/exception_stream.rs +++ b/src/linux/sections/exception_stream.rs @@ -8,9 +8,9 @@ pub fn write( ) -> Result { let exception = if let Some(context) = &config.crash_context { MDException { - exception_code: context.inner.siginfo.ssi_signo as u32, + exception_code: context.inner.siginfo.ssi_signo, exception_flags: context.inner.siginfo.ssi_code as u32, - exception_address: context.inner.siginfo.ssi_addr as u64, + exception_address: context.inner.siginfo.ssi_addr, ..Default::default() } } else { diff --git a/src/linux/sections/thread_list_stream.rs b/src/linux/sections/thread_list_stream.rs index 0e952e87..11e625d0 100644 --- a/src/linux/sections/thread_list_stream.rs +++ b/src/linux/sections/thread_list_stream.rs @@ -74,8 +74,8 @@ pub fn write( // unhelpful. if config.crash_context.is_some() && thread.thread_id == config.blamed_thread as u32 { let crash_context = config.crash_context.as_ref().unwrap(); - let instruction_ptr = crash_context.get_instruction_pointer() as usize; - let stack_pointer = crash_context.get_stack_pointer() as usize; + let instruction_ptr = crash_context.get_instruction_pointer(); + let stack_pointer = crash_context.get_stack_pointer(); fill_thread_stack( config, buffer, @@ -142,7 +142,7 @@ pub fn write( } else { MaxStackLen::None // default to no maximum for this thread }; - let instruction_ptr = info.get_instruction_pointer() as usize; + let instruction_ptr = info.get_instruction_pointer(); fill_thread_stack( config, buffer, diff --git a/src/mem_writer.rs b/src/mem_writer.rs index 25c6a59f..a703d2b1 100644 --- a/src/mem_writer.rs +++ b/src/mem_writer.rs @@ -118,7 +118,7 @@ where let position = buffer.reserve(size) as u32; Ok(Self { - position: position as u32, + position, size, phantom: std::marker::PhantomData, }) diff --git a/tests/ptrace_dumper.rs b/tests/ptrace_dumper.rs index 29426805..a69631c5 100644 --- a/tests/ptrace_dumper.rs +++ b/tests/ptrace_dumper.rs @@ -255,7 +255,7 @@ fn test_sanitize_stack_copy() { } // The instruction pointer definitely should point into an executable mapping. - let instr_ptr = thread_info.get_instruction_pointer() as usize; + let instr_ptr = thread_info.get_instruction_pointer(); let mapping_info = dumper .find_mapping_no_bias(instr_ptr) .expect("Failed to find mapping info");