Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielT committed Feb 1, 2024
1 parent 1056ee3 commit 2f7b4c3
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 42 deletions.
4 changes: 2 additions & 2 deletions src/dwarf/typereader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<String, (TypeInfo, u64)>::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 {
Expand Down Expand Up @@ -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 {
Expand Down
38 changes: 19 additions & 19 deletions src/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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}")
}
Expand Down Expand Up @@ -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}")
}
Expand Down Expand Up @@ -390,22 +390,22 @@ fn build_maps(module: &&mut Module) -> (HashMap<String, ItemType>, HashMap<Strin
sym_map.insert(sym_link.symbol_name.clone(), ItemType::Measurement(idx));
}
}
for (idx, inst) in module.instance.iter().enumerate() {
name_map.insert(inst.name.clone(), ItemType::Instance(idx));
for inst in &module.instance {
name_map.insert(inst.name.clone(), ItemType::Instance);
if let Some(sym_link) = &inst.symbol_link {
sym_map.insert(sym_link.symbol_name.clone(), ItemType::Instance(idx));
sym_map.insert(sym_link.symbol_name.clone(), ItemType::Instance);
}
}
for (idx, blob) in module.blob.iter().enumerate() {
name_map.insert(blob.name.clone(), ItemType::Blob(idx));
for blob in &module.blob {
name_map.insert(blob.name.clone(), ItemType::Blob);
if let Some(sym_link) = &blob.symbol_link {
sym_map.insert(sym_link.symbol_name.clone(), ItemType::Blob(idx));
sym_map.insert(sym_link.symbol_name.clone(), ItemType::Blob);
}
}
for (idx, axis_pts) in module.axis_pts.iter().enumerate() {
name_map.insert(axis_pts.name.clone(), ItemType::AxisPts(idx));
for axis_pts in &module.axis_pts {
name_map.insert(axis_pts.name.clone(), ItemType::AxisPts);
if let Some(sym_link) = &axis_pts.symbol_link {
sym_map.insert(sym_link.symbol_name.clone(), ItemType::AxisPts(idx));
sym_map.insert(sym_link.symbol_name.clone(), ItemType::AxisPts);
}
}

Expand Down Expand Up @@ -438,7 +438,7 @@ pub(crate) fn insert_many(
Err(error) => 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);
Expand Down
28 changes: 8 additions & 20 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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,
Expand Down Expand Up @@ -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::<String>("TARGET_GROUP")
.map(|group| &**group);
Expand Down Expand Up @@ -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
Expand All @@ -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(())
}
Expand Down
2 changes: 1 addition & 1 deletion src/update/ifdata_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2f7b4c3

Please sign in to comment.