Skip to content

Commit b63319b

Browse files
committed
Fix misc clippy lints
1 parent 18dde29 commit b63319b

File tree

5 files changed

+19
-10
lines changed

5 files changed

+19
-10
lines changed

rust/src/enterprise.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::rc::Array;
22
use crate::string::{BnStrCompatible, BnString};
3+
use std::ffi::c_void;
34
use std::marker::PhantomData;
45
use std::time::{Duration, SystemTime, UNIX_EPOCH};
56
use thiserror::Error;
@@ -245,14 +246,14 @@ pub fn register_license_changed_callback<'a, F: FnMut(bool) + 'a>(
245246
callback: F,
246247
) -> EnterpriseServerCallback<'a> {
247248
unsafe extern "C" fn cb_license_status_changed<F: FnMut(bool)>(
248-
ctxt: *mut ::std::os::raw::c_void,
249+
ctxt: *mut c_void,
249250
still_valid: bool,
250251
) {
251252
let ctxt: &mut F = &mut *(ctxt as *mut F);
252253
ctxt(still_valid)
253254
}
254255
let mut handle = binaryninjacore_sys::BNEnterpriseServerCallbacks {
255-
context: Box::leak(Box::new(callback)) as *mut F as *mut core::ffi::c_void,
256+
context: Box::leak(Box::new(callback)) as *mut F as *mut c_void,
256257
licenseStatusChanged: Some(cb_license_status_changed::<F>),
257258
};
258259
unsafe { binaryninjacore_sys::BNRegisterEnterpriseServerNotification(&mut handle) }

rust/src/function.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@ impl NativeBlock {
139139
}
140140
}
141141

142+
impl Default for NativeBlock {
143+
fn default() -> Self {
144+
NativeBlock::new()
145+
}
146+
}
147+
142148
impl BlockContext for NativeBlock {
143149
type Instruction = u64;
144150
type InstructionIndex = u64;

rust/src/linear_view.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ impl LinearViewObjectIdentifier {
264264
}
265265
}
266266

267+
// TODO: Impl iterator?
267268
#[derive(Eq)]
268269
pub struct LinearViewCursor {
269270
pub(crate) handle: *mut BNLinearViewCursor,
@@ -333,6 +334,9 @@ impl LinearViewCursor {
333334
unsafe { BNLinearViewCursorPrevious(self.handle) }
334335
}
335336

337+
// TODO: This clippy lint is probably right? Just a lot of work and it would
338+
// TODO: make this API different from the python and C++ implementations.
339+
#[allow(clippy::should_implement_trait)]
336340
pub fn next(&mut self) -> bool {
337341
unsafe { BNLinearViewCursorNext(self.handle) }
338342
}

rust/src/low_level_il/operation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ where
585585
// LLIL_REG_STACK_POP
586586
pub struct RegStackPop;
587587

588-
impl<'func, A, M, F> Operation<'func, A, M, F, RegStackPop>
588+
impl<A, M, F> Operation<'_, A, M, F, RegStackPop>
589589
where
590590
A: Architecture,
591591
M: FunctionMutability,

rust/src/render_layer.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub fn register_render_layer<S: BnStrCompatible, T: RenderLayer>(
4040
pub trait RenderLayer: Sized {
4141
/// Apply this Render Layer to a Flow Graph.
4242
fn apply_to_flow_graph(&self, graph: &mut FlowGraph) {
43-
for node in graph.nodes() {
43+
for node in &graph.nodes() {
4444
if let Some(block) = node.basic_block(NativeBlock::new()) {
4545
let new_lines = self.apply_to_block(&block, node.lines().to_vec());
4646
node.set_lines(new_lines);
@@ -113,19 +113,18 @@ pub trait RenderLayer: Sized {
113113
let probe_line = line_block.first()?;
114114
Some((probe_line.ty, probe_line.basic_block.to_owned(), line_block))
115115
})
116-
.map(|(line_ty, basic_block, lines)| {
116+
.flat_map(|(line_ty, basic_block, lines)| {
117117
match line_ty {
118118
LinearDisassemblyLineType::CodeDisassemblyLineType => {
119119
// Dealing with code lines.
120120
let block = basic_block.expect("Code line has no basic block");
121121
let function = block.function();
122122
let text_lines = lines.into_iter().map(|line| line.contents).collect();
123123
let new_text_lines = self.apply_to_block(&block, text_lines);
124-
let new_lines = new_text_lines
124+
new_text_lines
125125
.into_iter()
126126
.map(|line| text_to_lines(&function, &block, line))
127-
.collect();
128-
new_lines
127+
.collect()
129128
}
130129
_ => {
131130
// Dealing with misc lines.
@@ -138,7 +137,6 @@ pub trait RenderLayer: Sized {
138137
}
139138
}
140139
})
141-
.flatten()
142140
.collect()
143141
}
144142

@@ -262,7 +260,7 @@ impl CoreRenderLayer {
262260
pub fn render_layer_by_name<S: BnStrCompatible>(name: S) -> Option<CoreRenderLayer> {
263261
let name_raw = name.into_bytes_with_nul();
264262
let result = unsafe { BNGetRenderLayerByName(name_raw.as_ref().as_ptr() as *const c_char) };
265-
NonNull::new(result).map(|x| Self::from_raw(x))
263+
NonNull::new(result).map(Self::from_raw)
266264
}
267265

268266
pub fn default_enable_state(&self) -> RenderLayerDefaultEnableState {

0 commit comments

Comments
 (0)