From bfc91ab623f3bf346bb733af10fc5394787985b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Mei=C3=9Fner?= Date: Tue, 27 Feb 2024 14:16:52 +0000 Subject: [PATCH] Makes linter happy. --- src/aligned_memory.rs | 2 +- src/elf.rs | 1 - src/lib.rs | 1 + src/program.rs | 2 +- src/static_analysis.rs | 8 ++++++-- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/aligned_memory.rs b/src/aligned_memory.rs index 3247c38c..d808548d 100644 --- a/src/aligned_memory.rs +++ b/src/aligned_memory.rs @@ -212,9 +212,9 @@ pub fn is_memory_aligned(ptr: usize, align: usize) -> bool { .unwrap_or(false) } +#[allow(clippy::arithmetic_side_effects)] #[cfg(test)] mod tests { - #![allow(clippy::arithmetic_side_effects)] use {super::*, std::io::Write}; fn do_test() { diff --git a/src/elf.rs b/src/elf.rs index 14b442c3..0d465836 100644 --- a/src/elf.rs +++ b/src/elf.rs @@ -1176,7 +1176,6 @@ pub(crate) fn get_ro_region(ro_section: &Section, elf: &[u8]) -> MemoryRegion { mod test { use super::*; use crate::{ - ebpf, elf_parser::{ // FIXME consts::{ELFCLASS32, ELFDATA2MSB, ET_REL}, consts::{ELFCLASS32, ELFDATA2MSB, ET_REL}, diff --git a/src/lib.rs b/src/lib.rs index def5dcf5..a1e740ab 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -56,6 +56,7 @@ trait ErrCheckedArithmetic: Sized { fn err_checked_add(self, other: Self) -> Result; fn err_checked_sub(self, other: Self) -> Result; fn err_checked_mul(self, other: Self) -> Result; + #[allow(dead_code)] fn err_checked_div(self, other: Self) -> Result; } struct ArithmeticOverflow; diff --git a/src/program.rs b/src/program.rs index 6605814d..64752df3 100644 --- a/src/program.rs +++ b/src/program.rs @@ -345,7 +345,7 @@ macro_rules! declare_builtin_function { #[cfg(test)] mod tests { use super::*; - use crate::{program::BuiltinFunction, syscalls, vm::TestContextObject}; + use crate::{syscalls, vm::TestContextObject}; #[test] fn test_builtin_program_eq() { diff --git a/src/static_analysis.rs b/src/static_analysis.rs index 737f34ff..6bea90a1 100644 --- a/src/static_analysis.rs +++ b/src/static_analysis.rs @@ -202,7 +202,11 @@ impl<'a> Analysis<'a> { fn link_cfg_edges(&mut self, cfg_edges: Vec<(usize, Vec)>, both_directions: bool) { for (source, destinations) in cfg_edges { if both_directions { - self.cfg_nodes.get_mut(&source).unwrap().destinations = destinations.clone(); + self.cfg_nodes + .get_mut(&source) + .unwrap() + .destinations + .clone_from(&destinations); } for destination in &destinations { self.cfg_nodes @@ -350,7 +354,7 @@ impl<'a> Analysis<'a> { } if let Some(next_cfg_edge) = cfg_edge_iter.peek() { if *next_cfg_edge.0 <= cfg_node_end { - cfg_node.destinations = next_cfg_edge.1 .1.clone(); + cfg_node.destinations.clone_from(&next_cfg_edge.1 .1); cfg_edge_iter.next(); continue; }