diff --git a/src/cwe_checker_lib/src/abstract_domain/bricks.rs b/src/cwe_checker_lib/src/abstract_domain/bricks.rs index d5a01e797..ee99904d5 100644 --- a/src/cwe_checker_lib/src/abstract_domain/bricks.rs +++ b/src/cwe_checker_lib/src/abstract_domain/bricks.rs @@ -165,15 +165,13 @@ impl BricksDomain { for i in 0..long_list.len() { if empty_bricks_added >= len_diff { - new_list.push(short_list.get(0).unwrap().clone()); + new_list.push(short_list[0].clone()); short_list.remove(0); - } else if short_list.is_empty() - || short_list.get(0).unwrap() != long_list.get(i).unwrap() - { + } else if short_list.is_empty() || &short_list[0] != long_list.get(i).unwrap() { new_list.push(BrickDomain::get_empty_brick_domain()); empty_bricks_added += 1; } else { - new_list.push(short_list.get(0).unwrap().clone()); + new_list.push(short_list[0].clone()); short_list.remove(0); } } diff --git a/src/cwe_checker_lib/src/analysis/function_signature/mod.rs b/src/cwe_checker_lib/src/analysis/function_signature/mod.rs index 7a399f499..00f3fdbe1 100644 --- a/src/cwe_checker_lib/src/analysis/function_signature/mod.rs +++ b/src/cwe_checker_lib/src/analysis/function_signature/mod.rs @@ -70,7 +70,7 @@ fn generate_fixpoint_computation<'a>( // Set the node values for all function entry nodes. for node in graph.node_indices() { if let Node::BlkStart(block, sub) = graph[node] { - if let Some(entry_block) = sub.term.blocks.get(0) { + if let Some(entry_block) = sub.term.blocks.first() { if entry_block.tid == block.tid { // The node of a function entry point let calling_convention = project diff --git a/src/cwe_checker_lib/src/analysis/graph.rs b/src/cwe_checker_lib/src/analysis/graph.rs index e4839fe67..0b8f05b77 100644 --- a/src/cwe_checker_lib/src/analysis/graph.rs +++ b/src/cwe_checker_lib/src/analysis/graph.rs @@ -512,7 +512,7 @@ pub fn get_entry_nodes_of_subs(graph: &Graph) -> HashMap { let mut sub_to_entry_node_map: HashMap = HashMap::new(); for node in graph.node_indices() { if let Node::BlkStart(block, sub) = graph[node] { - if let Some(entry_block) = sub.term.blocks.get(0) { + if let Some(entry_block) = sub.term.blocks.first() { if block.tid == entry_block.tid { sub_to_entry_node_map.insert(sub.tid.clone(), node); } diff --git a/src/cwe_checker_lib/src/analysis/pointer_inference/mod.rs b/src/cwe_checker_lib/src/analysis/pointer_inference/mod.rs index 133ff8cae..b05320ff7 100644 --- a/src/cwe_checker_lib/src/analysis/pointer_inference/mod.rs +++ b/src/cwe_checker_lib/src/analysis/pointer_inference/mod.rs @@ -305,7 +305,7 @@ impl<'a> PointerInference<'a> { call: (caller_blk, _caller_sub), return_: _, } => { - let call_tid = match caller_blk.term.jmps.get(0) { + let call_tid = match caller_blk.term.jmps.first() { Some(call) => &call.tid, _ => continue, }; diff --git a/src/cwe_checker_lib/src/analysis/stack_alignment_substitution/mod.rs b/src/cwe_checker_lib/src/analysis/stack_alignment_substitution/mod.rs index 070776a4d..3404b7d14 100644 --- a/src/cwe_checker_lib/src/analysis/stack_alignment_substitution/mod.rs +++ b/src/cwe_checker_lib/src/analysis/stack_alignment_substitution/mod.rs @@ -90,7 +90,7 @@ fn journal_sp_value( /// Returns the tid of the target of the first Jmp::Branch of the provided block. fn get_first_branch_tid(blk: &Term) -> Option<&Tid> { - if let Some(jmp) = blk.term.jmps.get(0) { + if let Some(jmp) = blk.term.jmps.first() { if let Jmp::Branch(jump_to_blk) = &jmp.term { return Some(jump_to_blk); } diff --git a/src/cwe_checker_lib/src/analysis/string_abstraction/context/mod.rs b/src/cwe_checker_lib/src/analysis/string_abstraction/context/mod.rs index 3da90a116..b517e54bd 100644 --- a/src/cwe_checker_lib/src/analysis/string_abstraction/context/mod.rs +++ b/src/cwe_checker_lib/src/analysis/string_abstraction/context/mod.rs @@ -74,7 +74,7 @@ impl<'a, T: AbstractDomain + HasTop + Eq + From + DomainInsertion> Conte for (node_id, node) in pointer_inference_results.get_graph().node_references() { match node { Node::BlkStart(block, sub) => { - if let Some(def) = block.term.defs.get(0) { + if let Some(def) = block.term.defs.first() { block_start_node_map.insert((def.tid.clone(), sub.tid.clone()), node_id); block_first_def_set.insert((def.tid.clone(), sub.tid.clone())); } diff --git a/src/cwe_checker_lib/src/analysis/string_abstraction/mod.rs b/src/cwe_checker_lib/src/analysis/string_abstraction/mod.rs index ed5d65dd8..369c55a69 100644 --- a/src/cwe_checker_lib/src/analysis/string_abstraction/mod.rs +++ b/src/cwe_checker_lib/src/analysis/string_abstraction/mod.rs @@ -56,7 +56,7 @@ impl<'a, T: AbstractDomain + DomainInsertion + HasTop + Eq + From> let mut sub_to_entry_blocks_map = HashMap::new(); for sub in project.program.term.subs.values() { - if let Some(entry_block) = sub.term.blocks.get(0) { + if let Some(entry_block) = sub.term.blocks.first() { sub_to_entry_blocks_map.insert(sub.tid.clone(), entry_block.tid.clone()); } } diff --git a/src/cwe_checker_lib/src/checkers/cwe_476/context.rs b/src/cwe_checker_lib/src/checkers/cwe_476/context.rs index 6356db122..10c555031 100644 --- a/src/cwe_checker_lib/src/checkers/cwe_476/context.rs +++ b/src/cwe_checker_lib/src/checkers/cwe_476/context.rs @@ -70,7 +70,7 @@ impl<'a> Context<'a> { for (node_id, node) in graph.node_references() { match node { Node::BlkStart(block, sub) => { - if let Some(def) = block.term.defs.get(0) { + if let Some(def) = block.term.defs.first() { block_start_node_map.insert((def.tid.clone(), sub.tid.clone()), node_id); } } diff --git a/src/cwe_checker_lib/src/checkers/cwe_78.rs b/src/cwe_checker_lib/src/checkers/cwe_78.rs index 5172fa487..93460ef2e 100644 --- a/src/cwe_checker_lib/src/checkers/cwe_78.rs +++ b/src/cwe_checker_lib/src/checkers/cwe_78.rs @@ -158,7 +158,7 @@ pub fn check_system_call_parameter( if let Some(Arg::Register { expr: Expression::Var(var), .. - }) = system_symbol.parameters.get(0) + }) = system_symbol.parameters.first() { if let Some(value) = source_state.get_variable_to_pointer_map().get(var) { let contains_string_constant = value.get_absolute_value().is_some();