summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-01-31 16:15:14 -0500
committerMason Reed <mason@vector35.com>2025-01-31 16:17:30 -0500
commitb63319bba9d95d41dae9e20a2035318628bef67f (patch)
tree9ae97907aa3f30aebb8654dcec9ab68472f7fbfc
parent18dde29a06847598d97a5166e3badb14a779c001 (diff)
Fix misc clippy lints
-rw-r--r--rust/src/enterprise.rs5
-rw-r--r--rust/src/function.rs6
-rw-r--r--rust/src/linear_view.rs4
-rw-r--r--rust/src/low_level_il/operation.rs2
-rw-r--r--rust/src/render_layer.rs12
5 files changed, 19 insertions, 10 deletions
diff --git a/rust/src/enterprise.rs b/rust/src/enterprise.rs
index aecbf974..6a4088dc 100644
--- a/rust/src/enterprise.rs
+++ b/rust/src/enterprise.rs
@@ -1,5 +1,6 @@
use crate::rc::Array;
use crate::string::{BnStrCompatible, BnString};
+use std::ffi::c_void;
use std::marker::PhantomData;
use std::time::{Duration, SystemTime, UNIX_EPOCH};
use thiserror::Error;
@@ -245,14 +246,14 @@ pub fn register_license_changed_callback<'a, F: FnMut(bool) + 'a>(
callback: F,
) -> EnterpriseServerCallback<'a> {
unsafe extern "C" fn cb_license_status_changed<F: FnMut(bool)>(
- ctxt: *mut ::std::os::raw::c_void,
+ ctxt: *mut c_void,
still_valid: bool,
) {
let ctxt: &mut F = &mut *(ctxt as *mut F);
ctxt(still_valid)
}
let mut handle = binaryninjacore_sys::BNEnterpriseServerCallbacks {
- context: Box::leak(Box::new(callback)) as *mut F as *mut core::ffi::c_void,
+ context: Box::leak(Box::new(callback)) as *mut F as *mut c_void,
licenseStatusChanged: Some(cb_license_status_changed::<F>),
};
unsafe { binaryninjacore_sys::BNRegisterEnterpriseServerNotification(&mut handle) }
diff --git a/rust/src/function.rs b/rust/src/function.rs
index 63ebc82e..f122aeff 100644
--- a/rust/src/function.rs
+++ b/rust/src/function.rs
@@ -139,6 +139,12 @@ impl NativeBlock {
}
}
+impl Default for NativeBlock {
+ fn default() -> Self {
+ NativeBlock::new()
+ }
+}
+
impl BlockContext for NativeBlock {
type Instruction = u64;
type InstructionIndex = u64;
diff --git a/rust/src/linear_view.rs b/rust/src/linear_view.rs
index 6d2347b3..1c92ddaa 100644
--- a/rust/src/linear_view.rs
+++ b/rust/src/linear_view.rs
@@ -264,6 +264,7 @@ impl LinearViewObjectIdentifier {
}
}
+// TODO: Impl iterator?
#[derive(Eq)]
pub struct LinearViewCursor {
pub(crate) handle: *mut BNLinearViewCursor,
@@ -333,6 +334,9 @@ impl LinearViewCursor {
unsafe { BNLinearViewCursorPrevious(self.handle) }
}
+ // TODO: This clippy lint is probably right? Just a lot of work and it would
+ // TODO: make this API different from the python and C++ implementations.
+ #[allow(clippy::should_implement_trait)]
pub fn next(&mut self) -> bool {
unsafe { BNLinearViewCursorNext(self.handle) }
}
diff --git a/rust/src/low_level_il/operation.rs b/rust/src/low_level_il/operation.rs
index 46d99a97..f3c075ad 100644
--- a/rust/src/low_level_il/operation.rs
+++ b/rust/src/low_level_il/operation.rs
@@ -585,7 +585,7 @@ where
// LLIL_REG_STACK_POP
pub struct RegStackPop;
-impl<'func, A, M, F> Operation<'func, A, M, F, RegStackPop>
+impl<A, M, F> Operation<'_, A, M, F, RegStackPop>
where
A: Architecture,
M: FunctionMutability,
diff --git a/rust/src/render_layer.rs b/rust/src/render_layer.rs
index fa617fe7..0a118b05 100644
--- a/rust/src/render_layer.rs
+++ b/rust/src/render_layer.rs
@@ -40,7 +40,7 @@ pub fn register_render_layer<S: BnStrCompatible, T: RenderLayer>(
pub trait RenderLayer: Sized {
/// Apply this Render Layer to a Flow Graph.
fn apply_to_flow_graph(&self, graph: &mut FlowGraph) {
- for node in graph.nodes() {
+ for node in &graph.nodes() {
if let Some(block) = node.basic_block(NativeBlock::new()) {
let new_lines = self.apply_to_block(&block, node.lines().to_vec());
node.set_lines(new_lines);
@@ -113,7 +113,7 @@ pub trait RenderLayer: Sized {
let probe_line = line_block.first()?;
Some((probe_line.ty, probe_line.basic_block.to_owned(), line_block))
})
- .map(|(line_ty, basic_block, lines)| {
+ .flat_map(|(line_ty, basic_block, lines)| {
match line_ty {
LinearDisassemblyLineType::CodeDisassemblyLineType => {
// Dealing with code lines.
@@ -121,11 +121,10 @@ pub trait RenderLayer: Sized {
let function = block.function();
let text_lines = lines.into_iter().map(|line| line.contents).collect();
let new_text_lines = self.apply_to_block(&block, text_lines);
- let new_lines = new_text_lines
+ new_text_lines
.into_iter()
.map(|line| text_to_lines(&function, &block, line))
- .collect();
- new_lines
+ .collect()
}
_ => {
// Dealing with misc lines.
@@ -138,7 +137,6 @@ pub trait RenderLayer: Sized {
}
}
})
- .flatten()
.collect()
}
@@ -262,7 +260,7 @@ impl CoreRenderLayer {
pub fn render_layer_by_name<S: BnStrCompatible>(name: S) -> Option<CoreRenderLayer> {
let name_raw = name.into_bytes_with_nul();
let result = unsafe { BNGetRenderLayerByName(name_raw.as_ref().as_ptr() as *const c_char) };
- NonNull::new(result).map(|x| Self::from_raw(x))
+ NonNull::new(result).map(Self::from_raw)
}
pub fn default_enable_state(&self) -> RenderLayerDefaultEnableState {