Skip to content

Commit

Permalink
Fix clippy warnings introduced in Rust 1.75 (#437)
Browse files Browse the repository at this point in the history
  • Loading branch information
Enkelmann authored Jan 2, 2024
1 parent de827cc commit 2a3702f
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 13 deletions.
8 changes: 3 additions & 5 deletions src/cwe_checker_lib/src/abstract_domain/bricks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/cwe_checker_lib/src/analysis/function_signature/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/cwe_checker_lib/src/analysis/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ pub fn get_entry_nodes_of_subs(graph: &Graph) -> HashMap<Tid, NodeIndex> {
let mut sub_to_entry_node_map: HashMap<Tid, NodeIndex> = 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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/cwe_checker_lib/src/analysis/pointer_inference/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Blk>) -> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl<'a, T: AbstractDomain + HasTop + Eq + From<String> + 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()));
}
Expand Down
2 changes: 1 addition & 1 deletion src/cwe_checker_lib/src/analysis/string_abstraction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl<'a, T: AbstractDomain + DomainInsertion + HasTop + Eq + From<String>>

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());
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/cwe_checker_lib/src/checkers/cwe_476/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/cwe_checker_lib/src/checkers/cwe_78.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 2a3702f

Please sign in to comment.