From e18387e8785a4832c265f28831f2c1e6f8f35672 Mon Sep 17 00:00:00 2001 From: Valentin Obst Date: Fri, 27 Sep 2024 10:16:36 +0200 Subject: [PATCH] Run `cargo fmt` --- src/caller/src/main.rs | 2 +- src/cwe_checker_lib/src/analysis/graph.rs | 2 +- .../src/analysis/graph/intraprocedural_cfg.rs | 9 +++++---- .../graph/intraprocedural_cfg/natural_loops.rs | 2 +- .../src/ghidra_pcode/instruction/mod.rs | 2 +- .../src/ghidra_pcode/ir_passes/fn_start_blocks.rs | 5 ++++- .../src/intermediate_representation/def.rs | 14 ++++++-------- .../src/intermediate_representation/expression.rs | 4 +++- .../dead_variable_elim/fixpoint_computation.rs | 2 +- src/cwe_checker_lib/src/utils/debug.rs | 1 - 10 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/caller/src/main.rs b/src/caller/src/main.rs index 25063bf98..217a257d5 100644 --- a/src/caller/src/main.rs +++ b/src/caller/src/main.rs @@ -18,8 +18,8 @@ use cwe_checker_lib::utils::read_config_file; use std::collections::{BTreeSet, HashSet}; use std::convert::From; -use std::path::PathBuf; use std::ops::Deref; +use std::path::PathBuf; mod cfg_stats; diff --git a/src/cwe_checker_lib/src/analysis/graph.rs b/src/cwe_checker_lib/src/analysis/graph.rs index ef734bd6c..d86501e63 100644 --- a/src/cwe_checker_lib/src/analysis/graph.rs +++ b/src/cwe_checker_lib/src/analysis/graph.rs @@ -67,8 +67,8 @@ use petgraph::{ }; pub mod algo; -pub mod intraprocedural_cfg; pub mod call; +pub mod intraprocedural_cfg; /// The graph type of an interprocedural control flow graph pub type Graph<'a> = DiGraph, Edge<'a>>; diff --git a/src/cwe_checker_lib/src/analysis/graph/intraprocedural_cfg.rs b/src/cwe_checker_lib/src/analysis/graph/intraprocedural_cfg.rs index d3239c977..59efd1cbd 100644 --- a/src/cwe_checker_lib/src/analysis/graph/intraprocedural_cfg.rs +++ b/src/cwe_checker_lib/src/analysis/graph/intraprocedural_cfg.rs @@ -13,9 +13,9 @@ use crate::intermediate_representation::{Blk, Jmp, Program, SinkType, Sub as Fun use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; -mod properties; mod dom; mod natural_loops; +mod properties; use dom::*; use natural_loops::*; @@ -327,9 +327,10 @@ impl<'a> IntraproceduralCfg<'a> { /// Returns the total number of instructions (defs and jmps) in this /// function. pub fn num_insn(&self) -> u64 { - self.blk_tid_to_idx_map.values().map(|blk_idx| { - self.graph()[blk_idx.0].get_block().num_insn() - }).sum() + self.blk_tid_to_idx_map + .values() + .map(|blk_idx| self.graph()[blk_idx.0].get_block().num_insn()) + .sum() } /// Returns the start and end index of this block. diff --git a/src/cwe_checker_lib/src/analysis/graph/intraprocedural_cfg/natural_loops.rs b/src/cwe_checker_lib/src/analysis/graph/intraprocedural_cfg/natural_loops.rs index ce65246ba..ca1443862 100644 --- a/src/cwe_checker_lib/src/analysis/graph/intraprocedural_cfg/natural_loops.rs +++ b/src/cwe_checker_lib/src/analysis/graph/intraprocedural_cfg/natural_loops.rs @@ -1,6 +1,6 @@ //! Natural loops. use crate::analysis::graph::intraprocedural_cfg::IntraproceduralCfg; -use crate::analysis::graph::{Graph, Edge}; +use crate::analysis::graph::{Edge, Graph}; use crate::intermediate_representation::Tid; use std::collections::BTreeSet; diff --git a/src/cwe_checker_lib/src/ghidra_pcode/instruction/mod.rs b/src/cwe_checker_lib/src/ghidra_pcode/instruction/mod.rs index 5ff3d4b07..6cecdbc1d 100644 --- a/src/cwe_checker_lib/src/ghidra_pcode/instruction/mod.rs +++ b/src/cwe_checker_lib/src/ghidra_pcode/instruction/mod.rs @@ -94,7 +94,7 @@ impl Instruction { pub fn contains_term_index(&self, index: u64) -> bool { index < (self.terms().len() as u64) } - + /// Returns true iff this instruction is in a MIPS jump delay slot. pub fn is_mips_jump_delay_slot(&self) -> bool { self.mnemonic().starts_with("_") diff --git a/src/cwe_checker_lib/src/ghidra_pcode/ir_passes/fn_start_blocks.rs b/src/cwe_checker_lib/src/ghidra_pcode/ir_passes/fn_start_blocks.rs index 40c3aebc9..9684dceea 100644 --- a/src/cwe_checker_lib/src/ghidra_pcode/ir_passes/fn_start_blocks.rs +++ b/src/cwe_checker_lib/src/ghidra_pcode/ir_passes/fn_start_blocks.rs @@ -78,7 +78,10 @@ impl IrPass for ReorderFnBlocksPass { }) ); // 2. This block is in the first position in the block array. - assert!(Self::is_fn_start_blk(&f.tid, &f.blocks().next().unwrap().tid)); + assert!(Self::is_fn_start_blk( + &f.tid, + &f.blocks().next().unwrap().tid + )); } } } diff --git a/src/cwe_checker_lib/src/intermediate_representation/def.rs b/src/cwe_checker_lib/src/intermediate_representation/def.rs index 5bb0eef54..4e08fe326 100644 --- a/src/cwe_checker_lib/src/intermediate_representation/def.rs +++ b/src/cwe_checker_lib/src/intermediate_representation/def.rs @@ -108,15 +108,13 @@ impl Def { Def::Store { address: expr0, value: expr1, - } => { - match (expr0.referenced_constants(), expr1.referenced_constants()) { - (None, c) | (c, None) => c, - (Some(mut c0), Some(c1)) => { - c0.extend(c1); - Some(c0) - } + } => match (expr0.referenced_constants(), expr1.referenced_constants()) { + (None, c) | (c, None) => c, + (Some(mut c0), Some(c1)) => { + c0.extend(c1); + Some(c0) } - } + }, } } } diff --git a/src/cwe_checker_lib/src/intermediate_representation/expression.rs b/src/cwe_checker_lib/src/intermediate_representation/expression.rs index 5f721e2b8..0f97fef2f 100644 --- a/src/cwe_checker_lib/src/intermediate_representation/expression.rs +++ b/src/cwe_checker_lib/src/intermediate_representation/expression.rs @@ -188,7 +188,9 @@ impl Expression { } } } - UnOp { arg, .. } | Cast { arg, .. } | Subpiece { arg, .. } => arg.referenced_constants(), + UnOp { arg, .. } | Cast { arg, .. } | Subpiece { arg, .. } => { + arg.referenced_constants() + } } } diff --git a/src/cwe_checker_lib/src/intermediate_representation/project/ir_passes/dead_variable_elim/fixpoint_computation.rs b/src/cwe_checker_lib/src/intermediate_representation/project/ir_passes/dead_variable_elim/fixpoint_computation.rs index e21db29e8..614d5a47c 100644 --- a/src/cwe_checker_lib/src/intermediate_representation/project/ir_passes/dead_variable_elim/fixpoint_computation.rs +++ b/src/cwe_checker_lib/src/intermediate_representation/project/ir_passes/dead_variable_elim/fixpoint_computation.rs @@ -179,7 +179,7 @@ impl<'a> AliveVariables<'a> { if let Vars(vars) = vars { vars.insert(var); } - }, + } _ => (), } } diff --git a/src/cwe_checker_lib/src/utils/debug.rs b/src/cwe_checker_lib/src/utils/debug.rs index 649ee4e25..5b083dfdf 100644 --- a/src/cwe_checker_lib/src/utils/debug.rs +++ b/src/cwe_checker_lib/src/utils/debug.rs @@ -180,7 +180,6 @@ impl Settings { } } - /// Displays the `obj`ect if the stage is being debugged. /// /// This is a possible cancellation point depending on the termination