diff options
| author | KyleMiles <krm504@nyu.edu> | 2023-01-05 17:29:14 -0500 |
|---|---|---|
| committer | KyleMiles <krm504@nyu.edu> | 2023-01-06 16:29:58 -0500 |
| commit | a154e45cce79b0c2264c1e1cd37a3d1bf5bc6154 (patch) | |
| tree | 11f436b720edfdf37819e9e83e7131d220687074 /rust/src/llil | |
| parent | 52edc39a7081fd6662e14fbcd473adabbbc36c7a (diff) | |
Rust API: Lots and lots of clippy changes
Diffstat (limited to 'rust/src/llil')
| -rw-r--r-- | rust/src/llil/function.rs | 6 | ||||
| -rw-r--r-- | rust/src/llil/instruction.rs | 4 | ||||
| -rw-r--r-- | rust/src/llil/lifting.rs | 58 | ||||
| -rw-r--r-- | rust/src/llil/operation.rs | 12 |
4 files changed, 43 insertions, 37 deletions
diff --git a/rust/src/llil/function.rs b/rust/src/llil/function.rs index 1c2b7df0..20d2cb04 100644 --- a/rust/src/llil/function.rs +++ b/rust/src/llil/function.rs @@ -103,7 +103,7 @@ where use binaryninjacore_sys::BNLowLevelILGetInstructionStart; let loc: Location = loc.into(); - let arch_handle = loc.arch.unwrap_or_else(|| *self.arch().as_ref()); + let arch_handle = loc.arch.unwrap_or(*self.arch().as_ref()); unsafe { let instr_idx = BNLowLevelILGetInstructionStart(self.handle, arch_handle.0, loc.addr); @@ -113,7 +113,7 @@ where } else { Some(Instruction { function: self, - instr_idx: instr_idx, + instr_idx, }) } } @@ -128,7 +128,7 @@ where Instruction { function: self, - instr_idx: instr_idx, + instr_idx, } } } diff --git a/rust/src/llil/instruction.rs b/rust/src/llil/instruction.rs index ad7ce274..20cc545b 100644 --- a/rust/src/llil/instruction.rs +++ b/rust/src/llil/instruction.rs @@ -115,13 +115,13 @@ where } LLIL_SYSCALL => InstrInfo::Syscall(Operation::new(self.function, op)), _ => { - common_info(self.function, op).unwrap_or_else(|| { + common_info(self.function, op).unwrap_or({ // Hopefully this is a bare value. If it isn't (expression // from wrong function form or similar) it won't really cause // any problems as it'll come back as undefined when queried. let expr = Expression { function: self.function, - expr_idx: expr_idx, + expr_idx, _ty: PhantomData, }; diff --git a/rust/src/llil/lifting.rs b/rust/src/llil/lifting.rs index 216b3bbd..bd87b9bc 100644 --- a/rust/src/llil/lifting.rs +++ b/rust/src/llil/lifting.rs @@ -59,7 +59,7 @@ impl<R: ArchReg> RegisterOrConstant<R> { RegisterOrConstant::Constant(_, value) => BNRegisterOrConstant { constant: true, reg: 0, - value: value, + value, }, } } @@ -385,7 +385,7 @@ where Expression { function: il, - expr_idx: expr_idx, + expr_idx, _ty: PhantomData, } } @@ -410,7 +410,7 @@ where Expression { function: il, - expr_idx: expr_idx, + expr_idx, _ty: PhantomData, } } @@ -663,7 +663,7 @@ where Expression { function: self.function, - expr_idx: expr_idx, + expr_idx, _ty: PhantomData, } } @@ -723,7 +723,7 @@ macro_rules! no_arg_lifter { Expression { function: self, - expr_idx: expr_idx, + expr_idx, _ty: PhantomData, } } @@ -738,7 +738,7 @@ macro_rules! sized_no_arg_lifter { ExpressionBuilder { function: self, op: $op, - size: size, + size, flags: 0, op1: 0, op2: 0, @@ -770,7 +770,7 @@ macro_rules! unsized_unary_op_lifter { Expression { function: self, - expr_idx: expr_idx, + expr_idx, _ty: PhantomData, } } @@ -790,7 +790,7 @@ macro_rules! sized_unary_op_lifter { ExpressionBuilder { function: self, op: $op, - size: size, + size, flags: 0, op1: expr.expr_idx as u64, op2: 0, @@ -815,7 +815,7 @@ macro_rules! size_changing_unary_op_lifter { ExpressionBuilder { function: self, op: $op, - size: size, + size, flags: 0, op1: expr.expr_idx as u64, op2: 0, @@ -847,7 +847,7 @@ macro_rules! binary_op_lifter { ExpressionBuilder { function: self, op: $op, - size: size, + size, flags: 0, op1: left.expr_idx as u64, op2: right.expr_idx as u64, @@ -882,7 +882,7 @@ macro_rules! binary_op_carry_lifter { ExpressionBuilder { function: self, op: $op, - size: size, + size, flags: 0, op1: left.expr_idx as u64, op2: right.expr_idx as u64, @@ -946,7 +946,7 @@ where Expression { function: self, - expr_idx: expr_idx, + expr_idx, _ty: PhantomData, } } @@ -964,7 +964,7 @@ where Expression { function: self, - expr_idx: expr_idx, + expr_idx, _ty: PhantomData, } } @@ -981,7 +981,7 @@ where Expression { function: self, - expr_idx: expr_idx, + expr_idx, _ty: PhantomData, } } @@ -1023,7 +1023,7 @@ where Expression { function: self, - expr_idx: expr_idx, + expr_idx, _ty: PhantomData, } } @@ -1038,7 +1038,7 @@ where Expression { function: self, - expr_idx: expr_idx, + expr_idx, _ty: PhantomData, } } @@ -1062,7 +1062,7 @@ where Expression { function: self, - expr_idx: expr_idx, + expr_idx, _ty: PhantomData, } } @@ -1090,7 +1090,7 @@ where ExpressionBuilder { function: self, op: LLIL_SET_REG, - size: size, + size, flags: 0, op1: dest_reg as u64, op2: expr.expr_idx as u64, @@ -1131,7 +1131,7 @@ where ExpressionBuilder { function: self, op: LLIL_SET_REG_SPLIT, - size: size, + size, flags: 0, op1: hi_reg as u64, op2: lo_reg as u64, @@ -1151,7 +1151,7 @@ where Expression { function: self, - expr_idx: expr_idx, + expr_idx, _ty: PhantomData, } } @@ -1169,7 +1169,7 @@ where Expression { function: self, - expr_idx: expr_idx, + expr_idx, _ty: PhantomData, } } @@ -1197,7 +1197,7 @@ where Expression { function: self, - expr_idx: expr_idx, + expr_idx, _ty: PhantomData, } } @@ -1245,7 +1245,7 @@ where ExpressionBuilder { function: self, op: LLIL_LOAD, - size: size, + size, flags: 0, op1: expr.expr_idx as u64, op2: 0, @@ -1273,7 +1273,7 @@ where ExpressionBuilder { function: self, op: LLIL_STORE, - size: size, + size, flags: 0, op1: dest_mem.expr_idx as u64, op2: value.expr_idx as u64, @@ -1353,7 +1353,7 @@ where use binaryninjacore_sys::BNLowLevelILSetCurrentAddress; let loc: Location = loc.into(); - let arch = loc.arch.unwrap_or_else(|| *self.arch().as_ref()); + let arch = loc.arch.unwrap_or(*self.arch().as_ref()); unsafe { BNLowLevelILSetCurrentAddress(self.handle, arch.0, loc.addr); @@ -1364,7 +1364,7 @@ where use binaryninjacore_sys::BNGetLowLevelILLabelForAddress; let loc: Location = loc.into(); - let arch = loc.arch.unwrap_or_else(|| *self.arch().as_ref()); + let arch = loc.arch.unwrap_or(*self.arch().as_ref()); let res = unsafe { BNGetLowLevelILLabelForAddress(self.handle, arch.0, loc.addr) }; @@ -1400,3 +1400,9 @@ impl Label { } } } + +impl Default for Label { + fn default() -> Self { + Label::new() + } +} diff --git a/rust/src/llil/operation.rs b/rust/src/llil/operation.rs index f7d59ef6..296a45db 100644 --- a/rust/src/llil/operation.rs +++ b/rust/src/llil/operation.rs @@ -40,8 +40,8 @@ where { pub(crate) fn new(function: &'func Function<A, M, F>, op: BNLowLevelILInstruction) -> Self { Self { - function: function, - op: op, + function, + op, _args: PhantomData, } } @@ -108,7 +108,7 @@ where .arch() .register_from_id(raw_id) .map(Register::ArchReg) - .unwrap_or_else(|| { + .unwrap_or({ error!( "got garbage register from LLIL_SET_REG @ 0x{:x}", self.op.address @@ -151,7 +151,7 @@ where .arch() .register_from_id(raw_id) .map(Register::ArchReg) - .unwrap_or_else(|| { + .unwrap_or({ error!( "got garbage register from LLIL_SET_REG_SPLIT @ 0x{:x}", self.op.address @@ -172,7 +172,7 @@ where .arch() .register_from_id(raw_id) .map(Register::ArchReg) - .unwrap_or_else(|| { + .unwrap_or({ error!( "got garbage register from LLIL_SET_REG_SPLIT @ 0x{:x}", self.op.address @@ -285,7 +285,7 @@ where .arch() .register_from_id(raw_id) .map(Register::ArchReg) - .unwrap_or_else(|| { + .unwrap_or({ error!( "got garbage register from LLIL_REG @ 0x{:x}", self.op.address |
