Skip to content

Commit

Permalink
Make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
techraed committed Jul 26, 2023
1 parent 66cb517 commit 275b9b2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 28 deletions.
24 changes: 9 additions & 15 deletions utils/wasm-gen/src/config/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}
}
6 changes: 3 additions & 3 deletions utils/wasm-gen/src/config/syscalls/amount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl SysCallsAmountRanges {
Self(
SysCallName::instrumentable()
.into_iter()
.map(|name| (name, (1..=1).into()))
.map(|name| (name, (1..=1)))
.collect(),
)
}
Expand All @@ -43,7 +43,7 @@ impl SysCallsAmountRanges {
Self(
SysCallName::instrumentable()
.into_iter()
.map(|name| (name, (0..=0).into()))
.map(|name| (name, (0..=0)))
.collect(),
)
}
Expand All @@ -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.
Expand Down
19 changes: 9 additions & 10 deletions utils/wasm-gen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -207,7 +207,6 @@ fn build_checked_call(
code.push(Instruction::I32Const(offset as i32));
}
}

ProcessedSysCallParams::Alloc => {
if unchecked_memory {
code.push(Instruction::I32Const(
Expand Down Expand Up @@ -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)| {
Expand Down

0 comments on commit 275b9b2

Please sign in to comment.