diff --git a/src/dwarf/typereader.rs b/src/dwarf/typereader.rs index eb47056..d18e899 100644 --- a/src/dwarf/typereader.rs +++ b/src/dwarf/typereader.rs @@ -206,7 +206,7 @@ impl<'elffile> DebugDataReader<'elffile> { let entries_tree_node2 = entries_tree2.root().unwrap(); let inheritance = self .get_class_inheritance(entries_tree_node2, current_unit) - .unwrap_or(IndexMap::::new()); + .unwrap_or_default(); let mut members = self.get_struct_or_union_members(entries_tree_node, current_unit)?; for (baseclass_type, baseclass_offset) in inheritance.values() { if let TypeInfo::Class { @@ -287,7 +287,7 @@ impl<'elffile> DebugDataReader<'elffile> { if data_bit_offset >= type_size_bits { // Dwarf 4 / 5: re-calculate offset offset += (data_bit_offset / type_size_bits) * type_size; - data_bit_offset = data_bit_offset % type_size_bits; + data_bit_offset %= type_size_bits; } // these values should be independent of Endianness membertype = TypeInfo::Bitfield { diff --git a/src/insert.rs b/src/insert.rs index 2e97247..9a89580 100644 --- a/src/insert.rs +++ b/src/insert.rs @@ -13,9 +13,9 @@ use regex::Regex; enum ItemType { Measurement(usize), Characteristic(usize), - Instance(usize), - Blob(usize), - AxisPts(usize), + Instance, + Blob, + AxisPts, } pub(crate) fn insert_items( @@ -325,9 +325,9 @@ fn make_unique_measurement_name( } Some( ItemType::Characteristic(_) - | ItemType::Instance(_) - | ItemType::Blob(_) - | ItemType::AxisPts(_), + | ItemType::Instance + | ItemType::Blob + | ItemType::AxisPts, ) => { format!("MEASUREMENT.{cleaned_sym}") } @@ -360,9 +360,9 @@ fn make_unique_characteristic_name( } Some( ItemType::Measurement(_) - | ItemType::Instance(_) - | ItemType::Blob(_) - | ItemType::AxisPts(_), + | ItemType::Instance + | ItemType::Blob + | ItemType::AxisPts, ) => { format!("CHARACTERISTIC.{cleaned_sym}") } @@ -390,22 +390,22 @@ fn build_maps(module: &&mut Module) -> (HashMap, HashMap println!("Invalid regex \"{expr}\": {error}"), } } - let minor_ver = a2l_file.asap2_version.as_ref().map(|v| v.upgrade_no).unwrap_or(50); + let minor_ver = a2l_file.asap2_version.as_ref().map_or(50, |v| v.upgrade_no); let use_new_arrays = minor_ver >= 70; let module = &mut a2l_file.project.module[0]; let (name_map, sym_map) = build_maps(&module); diff --git a/src/main.rs b/src/main.rs index 077de22..05fff95 100644 --- a/src/main.rs +++ b/src/main.rs @@ -145,7 +145,7 @@ fn core() -> Result<(), String> { ext_println!( verbose, now, - "Consistency check complete. No problems found.".to_string() + "Consistency check complete. No problems found." ); } else { for msg in &log_msgs { @@ -245,11 +245,7 @@ fn core() -> Result<(), String> { // merge includes if merge_includes { a2l_file.merge_includes(); - cond_print!( - verbose, - now, - "Include directives have been merged\n".to_string() - ); + cond_print!(verbose, now, "Include directives have been merged\n"); } if let Some(debugdata) = &elf_info { @@ -263,7 +259,7 @@ fn core() -> Result<(), String> { cond_print!(verbose, now, msg); } - cond_print!(verbose, now, "Address update done\nSummary:".to_string()); + cond_print!(verbose, now, "Address update done\nSummary:"); cond_print!( verbose, now, @@ -346,11 +342,7 @@ fn core() -> Result<(), String> { || arg_matches.contains_id("INSERT_CHARACTERISTIC_REGEX") || arg_matches.contains_id("INSERT_MEASUREMENT_REGEX") { - cond_print!( - verbose, - now, - "Inserting new items from range/regex".to_string() - ); + cond_print!(verbose, now, "Inserting new items from range/regex"); let target_group = arg_matches .get_one::("TARGET_GROUP") .map(|group| &**group); @@ -393,20 +385,20 @@ fn core() -> Result<(), String> { cond_print!( verbose, now, - "Cleanup of unused items and empty groups is complete".to_string() + "Cleanup of unused items and empty groups is complete" ); } // remove unknown IF_DATA if ifdata_cleanup { a2l_file.ifdata_cleanup(); - cond_print!(verbose, now, "Unknown ifdata removal is done".to_string()); + cond_print!(verbose, now, "Unknown ifdata removal is done"); } // sort all elements in the file if sort { a2l_file.sort(); - cond_print!(verbose, now, "All objects have been sorted".to_string()); + cond_print!(verbose, now, "All objects have been sorted"); } // output @@ -425,11 +417,7 @@ fn core() -> Result<(), String> { } } - cond_print!( - verbose, - now, - "\nRun complete. Have a nice day!\n\n".to_string() - ); + cond_print!(verbose, now, "\nRun complete. Have a nice day!\n\n"); Ok(()) } diff --git a/src/update/ifdata_update.rs b/src/update/ifdata_update.rs index 216f1df..e1bb4b0 100644 --- a/src/update/ifdata_update.rs +++ b/src/update/ifdata_update.rs @@ -109,7 +109,7 @@ fn update_ifdata_canape_ext( link_map.datatype_valid = 1; } TypeInfo::Array { arraytype, .. } => { - update_ifdata_canape_ext(canape_ext, address, symbol_name, &arraytype); + update_ifdata_canape_ext(canape_ext, address, symbol_name, arraytype); } _ => { link_map.datatype = 0;