Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
williballenthin committed Mar 9, 2024
1 parent 305023e commit cae2ae8
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 17 deletions.
4 changes: 1 addition & 3 deletions bin/src/bin/jh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,7 @@ fn extract_workspace_features(ws: &dyn lancelot::workspace::Workspace) -> Result
return None;
}

let Some(name) = ws.analysis().names.names_by_address.get(&va) else {
return None;
};
let name = ws.analysis().names.names_by_address.get(&va)?;

let Ok(features) = extract_function_features(ws, va) else {
return None;
Expand Down
7 changes: 3 additions & 4 deletions core/src/analysis/pe/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,9 @@ pub fn find_functions(pe: &PE) -> Result<Vec<Function>> {
pub fn find_function_starts(pe: &PE) -> Result<Vec<VA>> {
Ok(find_functions(pe)?
.into_iter()
.filter(|f| matches!(f, Function::Local(_)))
.map(|f| match f {
Function::Local(va) => va,
_ => unreachable!(),
.filter_map(|f| match f {
Function::Local(va) => Some(va),
_ => None,
})
.collect())
}
4 changes: 2 additions & 2 deletions core/src/analysis/pe/patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ lazy_static! {
// 0xC2 ......00 0x00
// let RET_LONGFORM =

let PREPATTERN = format!("(?P<prepattern>{})", vec![
let PREPATTERN = format!("(?P<prepattern>{})", [
CC,
CCCC,
NOP,
Expand Down Expand Up @@ -160,7 +160,7 @@ lazy_static! {
\x48 \x83 \xEC . # sub rsp, ??
";

let POSTPATTERN = format!("(?P<postpattern>{})", vec![
let POSTPATTERN = format!("(?P<postpattern>{})", [
P0,
P6,
P18,
Expand Down
4 changes: 2 additions & 2 deletions core/src/workspace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ impl NameIndex {
}

pub fn contains_address(&self, va: VA) -> bool {
return self.names_by_address.get(&va).is_some();
self.names_by_address.contains_key(&va)
}

pub fn contains_name(&self, name: &str) -> bool {
return self.addresses_by_name.get(name).is_some();
self.addresses_by_name.contains_key(name)
}
}

Expand Down
7 changes: 3 additions & 4 deletions jslancelot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,9 @@ impl PE {
Ok(lancelot::analysis::pe::find_functions(&self.inner)
.map_err(to_js_err)?
.into_iter()
.filter(|f| matches!(f, lancelot::analysis::pe::Function::Local(_)))
.map(|f| match f {
lancelot::analysis::pe::Function::Local(va) => va,
_ => unreachable!(),
.filter_map(|f| match f {
lancelot::analysis::pe::Function::Local(va) => Some(va),
_ => None,
})
.collect())
}
Expand Down
2 changes: 1 addition & 1 deletion pyflirt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use anyhow::Error;
use lancelot_flirt::{pat, sig};
use pyo3::{self, prelude::*, types::*, wrap_pyfunction};
use pyo3::{prelude::*, types::*, wrap_pyfunction};

/// ValueError -> "you're doing something wrong"
fn to_value_error(e: anyhow::Error) -> PyErr {
Expand Down
2 changes: 1 addition & 1 deletion pylancelot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use ::lancelot::{
VA,
};
use anyhow::Error;
use pyo3::{self, prelude::*, types::*, wrap_pyfunction};
use pyo3::{prelude::*, types::*, wrap_pyfunction};

/// ValueError -> "you're doing something wrong"
fn to_value_error(e: anyhow::Error) -> PyErr {
Expand Down

0 comments on commit cae2ae8

Please sign in to comment.