From 275b9b265e0fe3aa317e0d0deb8560051889e27f Mon Sep 17 00:00:00 2001 From: Sabaun Taraki Date: Wed, 26 Jul 2023 12:48:04 +0300 Subject: [PATCH] Make clippy happy --- utils/wasm-gen/src/config/generator.rs | 24 ++++++++------------ utils/wasm-gen/src/config/syscalls/amount.rs | 6 ++--- utils/wasm-gen/src/lib.rs | 19 ++++++++-------- 3 files changed, 21 insertions(+), 28 deletions(-) diff --git a/utils/wasm-gen/src/config/generator.rs b/utils/wasm-gen/src/config/generator.rs index 08f8ba82011..70fb7506fea 100644 --- a/utils/wasm-gen/src/config/generator.rs +++ b/utils/wasm-gen/src/config/generator.rs @@ -113,33 +113,27 @@ pub enum EntryPointsSet { impl EntryPointsSet { /// Checks whether the set has ***init*** entry point. pub fn has_init(&self) -> bool { - match self { - EntryPointsSet::Init + matches!(self, EntryPointsSet::Init | EntryPointsSet::InitHandle | EntryPointsSet::InitHandleReply - | EntryPointsSet::InitHandleHandleReply => true, - _ => false, - } + | EntryPointsSet::InitHandleHandleReply + ) } /// Checks whether the set has ***handle*** entry point. pub fn has_handle(&self) -> bool { - match self { - EntryPointsSet::InitHandle + matches!(self, EntryPointsSet::InitHandle | EntryPointsSet::InitHandleHandleReply | EntryPointsSet::Handle - | EntryPointsSet::HandleHandleReply => true, - _ => false, - } + | EntryPointsSet::HandleHandleReply + ) } /// Checks whether the set has ***handle_reply*** entry point. pub fn has_handle_reply(&self) -> bool { - match self { - EntryPointsSet::InitHandleReply + matches!(self, EntryPointsSet::InitHandleReply | EntryPointsSet::InitHandleHandleReply - | EntryPointsSet::HandleHandleReply => true, - _ => false, - } + | EntryPointsSet::HandleHandleReply + ) } } diff --git a/utils/wasm-gen/src/config/syscalls/amount.rs b/utils/wasm-gen/src/config/syscalls/amount.rs index a8a8215fd3b..af3e53d93ac 100644 --- a/utils/wasm-gen/src/config/syscalls/amount.rs +++ b/utils/wasm-gen/src/config/syscalls/amount.rs @@ -33,7 +33,7 @@ impl SysCallsAmountRanges { Self( SysCallName::instrumentable() .into_iter() - .map(|name| (name, (1..=1).into())) + .map(|name| (name, (1..=1))) .collect(), ) } @@ -43,7 +43,7 @@ impl SysCallsAmountRanges { Self( SysCallName::instrumentable() .into_iter() - .map(|name| (name, (0..=0).into())) + .map(|name| (name, (0..=0))) .collect(), ) } @@ -66,7 +66,7 @@ impl SysCallsAmountRanges { /// Sets possible amount range for the the sys-call. pub fn set(&mut self, name: SysCallName, min: u32, max: u32) { - self.0.insert(name, (min..=max).into()); + self.0.insert(name, min..=max); } /// Same as [`SysCallsAmountRanges::set`], but sets amount ranges for multiple sys-calls. diff --git a/utils/wasm-gen/src/lib.rs b/utils/wasm-gen/src/lib.rs index eb117542f4a..ac56dfb882a 100644 --- a/utils/wasm-gen/src/lib.rs +++ b/utils/wasm-gen/src/lib.rs @@ -153,17 +153,18 @@ fn build_checked_call( } }; let instr = if let Some(allowed_values) = allowed_values { - is_i32 - .then_some(Instruction::I32Const(allowed_values.get_i32(u).unwrap())) - .unwrap_or(Instruction::I64Const(allowed_values.get_i64(u).unwrap())) + if is_i32 { + Instruction::I32Const(allowed_values.get_i32(u).unwrap()) + } else { + Instruction::I64Const(allowed_values.get_i64(u).unwrap()) + } + } else if is_i32 { + Instruction::I32Const(u.arbitrary().unwrap()) } else { - is_i32 - .then_some(Instruction::I32Const(u.arbitrary().unwrap())) - .unwrap_or(Instruction::I64Const(u.arbitrary().unwrap())) + Instruction::I64Const(u.arbitrary().unwrap()) }; code.push(instr); } - ProcessedSysCallParams::MemoryArray => { if unchecked_memory { code.push(Instruction::I32Const( @@ -189,7 +190,6 @@ fn build_checked_call( code.push(Instruction::I32Const((pointer_beyond - offset) as i32)); } } - ProcessedSysCallParams::MemoryPtrValue => { if unchecked_memory { code.push(Instruction::I32Const( @@ -207,7 +207,6 @@ fn build_checked_call( code.push(Instruction::I32Const(offset as i32)); } } - ProcessedSysCallParams::Alloc => { if unchecked_memory { code.push(Instruction::I32Const( @@ -577,7 +576,7 @@ impl<'a> WasmGen<'a> { } let import_count = module.import_count(ImportCountType::Function); let mut module_builder = builder::from_module(module); - let sys_calls_table = sys_calls_table(&self.config.sys_calls_config.params_config()); + let sys_calls_table = sys_calls_table(self.config.sys_calls_config.params_config()); for (i, (name, info, sys_call_amount)) in sys_calls_table .into_iter() .filter_map(|(name, info)| {