From 35fe3475104defdc205f2103e03b3d89e330df84 Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Wed, 21 Aug 2024 07:24:51 -0400 Subject: [PATCH] Misc formatting and clippy lints --- .../dwarf/dwarf_import/src/dwarfdebuginfo.rs | 3 +-- rust/src/binaryview.rs | 2 +- rust/src/callingconvention.rs | 24 +++++-------------- rust/src/enterprise.rs | 4 +++- 4 files changed, 11 insertions(+), 22 deletions(-) diff --git a/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs b/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs index 4f08fcf7ce..a977deded4 100644 --- a/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs +++ b/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs @@ -285,8 +285,7 @@ impl DebugInfoBuilder { return Some(*idx); } - } - else { + } else { debug!("Function entry in DWARF without full or raw name."); return None; } diff --git a/rust/src/binaryview.rs b/rust/src/binaryview.rs index 37c2518343..cb6d6310e4 100644 --- a/rust/src/binaryview.rs +++ b/rust/src/binaryview.rs @@ -1371,7 +1371,7 @@ pub trait BinaryViewExt: BinaryViewBase { let ranges = unsafe { let mut count = 0; let reloc_ranges_ptr = BNGetRelocationRanges(self.as_ref().handle, &mut count); - let ranges = std::slice::from_raw_parts(reloc_ranges_ptr, count).clone(); + let ranges = std::slice::from_raw_parts(reloc_ranges_ptr, count); BNFreeRelocationRanges(reloc_ranges_ptr); ranges }; diff --git a/rust/src/callingconvention.rs b/rust/src/callingconvention.rs index 2406579270..aab6633573 100644 --- a/rust/src/callingconvention.rs +++ b/rust/src/callingconvention.rs @@ -305,11 +305,8 @@ where C: CallingConventionBase, { ffi_wrap!("CallingConvention::incoming_reg_value", unsafe { - //let ctxt = &*(ctxt as *mut CustomCallingConventionContext); - let val = &mut *val; - - val.state = BNRegisterValueType::EntryValue; - val.value = _reg as i64; + (*val).state = BNRegisterValueType::EntryValue; + (*val).value = _reg as i64; }) } @@ -323,11 +320,8 @@ where C: CallingConventionBase, { ffi_wrap!("CallingConvention::incoming_flag_value", unsafe { - //let ctxt = &*(ctxt as *mut CustomCallingConventionContext); - let val = &mut *val; - - val.state = BNRegisterValueType::EntryValue; - val.value = _flag as i64; + (*val).state = BNRegisterValueType::EntryValue; + (*val).value = _flag as i64; }) } @@ -341,10 +335,7 @@ where { ffi_wrap!("CallingConvention::incoming_var_for_param", unsafe { let ctxt = &*(ctxt as *mut CustomCallingConventionContext); - ptr::write( - param, - BNGetDefaultIncomingVariableForParameterVariable(ctxt.raw_handle, var), - ); + *param = BNGetDefaultIncomingVariableForParameterVariable(ctxt.raw_handle, var); }) } @@ -358,10 +349,7 @@ where { ffi_wrap!("CallingConvention::incoming_param_for_var", unsafe { let ctxt = &*(ctxt as *mut CustomCallingConventionContext); - ptr::write( - param, - BNGetDefaultParameterVariableForIncomingVariable(ctxt.raw_handle, var), - ); + *param = BNGetDefaultParameterVariableForIncomingVariable(ctxt.raw_handle, var); }) } diff --git a/rust/src/enterprise.rs b/rust/src/enterprise.rs index 232526dcb1..82d4d37943 100644 --- a/rust/src/enterprise.rs +++ b/rust/src/enterprise.rs @@ -15,7 +15,9 @@ pub fn server_url() -> BnString { pub fn set_server_url(url: S) -> Result<(), ()> { let url = url.into_bytes_with_nul(); let result = unsafe { - binaryninjacore_sys::BNSetEnterpriseServerUrl(url.as_ref().as_ptr() as *const std::os::raw::c_char) + binaryninjacore_sys::BNSetEnterpriseServerUrl( + url.as_ref().as_ptr() as *const std::os::raw::c_char + ) }; if result { Ok(())