mirror of https://github.com/encounter/objdiff.git
Cargo clippy & cargo deny fixes
This commit is contained in:
parent
771a141110
commit
a0371dd110
|
@ -80,6 +80,7 @@ allow = [
|
|||
"MPL-2.0",
|
||||
"Unicode-DFS-2016",
|
||||
"Zlib",
|
||||
"0BSD",
|
||||
]
|
||||
# List of explictly disallowed licenses
|
||||
# See https://spdx.org/licenses/ for list of possible licenses
|
||||
|
@ -203,7 +204,7 @@ allow-git = []
|
|||
|
||||
[sources.allow-org]
|
||||
# 1 or more github.com organizations to allow git sources for
|
||||
github = ["encounter", "terorie"]
|
||||
github = ["encounter"]
|
||||
# 1 or more gitlab.com organizations to allow git sources for
|
||||
#gitlab = [""]
|
||||
# 1 or more bitbucket.org organizations to allow git sources for
|
||||
|
|
10
src/app.rs
10
src/app.rs
|
@ -333,10 +333,8 @@ impl eframe::App for App {
|
|||
for (idx, color) in view_state.view_config.diff_colors.iter_mut().enumerate() {
|
||||
ui.horizontal(|ui| {
|
||||
ui.color_edit_button_srgba(color);
|
||||
if num_colors > 1 {
|
||||
if ui.small_button("-").clicked() {
|
||||
remove_at = Some(idx);
|
||||
}
|
||||
if num_colors > 1 && ui.small_button("-").clicked() {
|
||||
remove_at = Some(idx);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -483,7 +481,7 @@ impl eframe::App for App {
|
|||
if let Some(project_dir) = &config.project_dir {
|
||||
match create_watcher(self.modified.clone(), project_dir) {
|
||||
Ok(watcher) => self.watcher = Some(watcher),
|
||||
Err(e) => eprintln!("Failed to create watcher: {}", e),
|
||||
Err(e) => eprintln!("Failed to create watcher: {e}"),
|
||||
}
|
||||
config.project_dir_change = false;
|
||||
self.modified.store(true, Ordering::Relaxed);
|
||||
|
@ -534,7 +532,7 @@ fn create_watcher(
|
|||
}
|
||||
}
|
||||
}
|
||||
Err(e) => println!("watch error: {:?}", e),
|
||||
Err(e) => println!("watch error: {e:?}"),
|
||||
})?;
|
||||
watcher.watch(project_dir, RecursiveMode::Recursive)?;
|
||||
Ok(watcher)
|
||||
|
|
14
src/diff.rs
14
src/diff.rs
|
@ -14,9 +14,9 @@ use crate::{
|
|||
|
||||
fn no_diff_code(
|
||||
arch: ObjArchitecture,
|
||||
data: &Vec<u8>,
|
||||
data: &[u8],
|
||||
symbol: &mut ObjSymbol,
|
||||
relocs: &Vec<ObjReloc>,
|
||||
relocs: &[ObjReloc],
|
||||
) -> Result<()> {
|
||||
let code =
|
||||
&data[symbol.section_address as usize..(symbol.section_address + symbol.size) as usize];
|
||||
|
@ -241,7 +241,7 @@ fn arg_eq(
|
|||
) -> bool {
|
||||
return match left {
|
||||
ObjInsArg::PpcArg(l) => match right {
|
||||
ObjInsArg::PpcArg(r) => format!("{}", l) == format!("{}", r),
|
||||
ObjInsArg::PpcArg(r) => format!("{l}") == format!("{r}"),
|
||||
_ => false,
|
||||
},
|
||||
ObjInsArg::Reloc => {
|
||||
|
@ -312,10 +312,10 @@ fn compare_ins(
|
|||
state.diff_count += 1;
|
||||
}
|
||||
let a_str = match a {
|
||||
ObjInsArg::PpcArg(arg) => format!("{}", arg),
|
||||
ObjInsArg::PpcArg(arg) => format!("{arg}"),
|
||||
ObjInsArg::Reloc | ObjInsArg::RelocWithBase => String::new(),
|
||||
ObjInsArg::MipsArg(str) => str.clone(),
|
||||
ObjInsArg::BranchOffset(arg) => format!("{}", arg),
|
||||
ObjInsArg::BranchOffset(arg) => format!("{arg}"),
|
||||
};
|
||||
let a_diff = if let Some(idx) = state.left_args_idx.get(&a_str) {
|
||||
ObjInsArgDiff { idx: *idx }
|
||||
|
@ -326,10 +326,10 @@ fn compare_ins(
|
|||
ObjInsArgDiff { idx }
|
||||
};
|
||||
let b_str = match b {
|
||||
ObjInsArg::PpcArg(arg) => format!("{}", arg),
|
||||
ObjInsArg::PpcArg(arg) => format!("{arg}"),
|
||||
ObjInsArg::Reloc | ObjInsArg::RelocWithBase => String::new(),
|
||||
ObjInsArg::MipsArg(str) => str.clone(),
|
||||
ObjInsArg::BranchOffset(arg) => format!("{}", arg),
|
||||
ObjInsArg::BranchOffset(arg) => format!("{arg}"),
|
||||
};
|
||||
let b_diff = if let Some(idx) = state.right_args_idx.get(&b_str) {
|
||||
ObjInsArgDiff { idx: *idx }
|
||||
|
|
|
@ -67,7 +67,7 @@ fn run_make(cwd: &Path, arg: &Path, config: &AppConfig) -> BuildStatus {
|
|||
let stderr = from_utf8(&output.stderr).context("Failed to process stderr")?;
|
||||
Ok(BuildStatus {
|
||||
success: output.status.code().unwrap_or(-1) == 0,
|
||||
log: format!("{}\n{}", stdout, stderr),
|
||||
log: format!("{stdout}\n{stderr}"),
|
||||
})
|
||||
})() {
|
||||
Ok(status) => status,
|
||||
|
@ -102,26 +102,26 @@ fn run_build(
|
|||
|
||||
let total = if config.build_target { 5 } else { 4 };
|
||||
let first_status = if config.build_target {
|
||||
update_status(status, format!("Building target {}", obj_path), 0, total, &cancel)?;
|
||||
update_status(status, format!("Building target {obj_path}"), 0, total, &cancel)?;
|
||||
run_make(project_dir, target_path_rel, &config)
|
||||
} else {
|
||||
BuildStatus { success: true, log: String::new() }
|
||||
};
|
||||
|
||||
update_status(status, format!("Building base {}", obj_path), 1, total, &cancel)?;
|
||||
update_status(status, format!("Building base {obj_path}"), 1, total, &cancel)?;
|
||||
let second_status = run_make(project_dir, base_path_rel, &config);
|
||||
|
||||
let time = OffsetDateTime::now_utc();
|
||||
|
||||
let mut first_obj = if first_status.success {
|
||||
update_status(status, format!("Loading target {}", obj_path), 2, total, &cancel)?;
|
||||
update_status(status, format!("Loading target {obj_path}"), 2, total, &cancel)?;
|
||||
Some(elf::read(&target_path)?)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let mut second_obj = if second_status.success {
|
||||
update_status(status, format!("Loading base {}", obj_path), 3, total, &cancel)?;
|
||||
update_status(status, format!("Loading base {obj_path}"), 3, total, &cancel)?;
|
||||
Some(elf::read(&base_path)?)
|
||||
} else {
|
||||
None
|
||||
|
|
|
@ -26,7 +26,7 @@ fn run_update(status: &Status, cancel: Receiver<()>) -> Result<Box<UpdateResult>
|
|||
.assets
|
||||
.iter()
|
||||
.find(|a| a.name == BIN_NAME)
|
||||
.ok_or(anyhow::Error::msg(formatcp!("No release asset for {}", BIN_NAME)))?;
|
||||
.ok_or_else(|| anyhow::Error::msg(formatcp!("No release asset for {}", BIN_NAME)))?;
|
||||
|
||||
update_status(status, "Downloading release".to_string(), 1, 3, &cancel)?;
|
||||
let tmp_dir = tempfile::Builder::new().prefix("update").tempdir_in(current_dir()?)?;
|
||||
|
@ -46,7 +46,7 @@ fn run_update(status: &Status, cancel: Receiver<()>) -> Result<Box<UpdateResult>
|
|||
{
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
let mut perms = fs::metadata(&target_file)?.permissions();
|
||||
perms.set_mode(0755);
|
||||
perms.set_mode(0o755);
|
||||
fs::set_permissions(&target_file, perms)?;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ fn main() {
|
|||
let result = exec::Command::new(path)
|
||||
.args(&std::env::args().collect::<Vec<String>>())
|
||||
.exec();
|
||||
eprintln!("Failed to relaunch: {:?}", result);
|
||||
eprintln!("Failed to relaunch: {result:?}");
|
||||
} else {
|
||||
let result = std::process::Command::new(path)
|
||||
.args(std::env::args())
|
||||
|
|
|
@ -22,14 +22,14 @@ fn to_obj_section_kind(kind: SectionKind) -> ObjSectionKind {
|
|||
SectionKind::Text => ObjSectionKind::Code,
|
||||
SectionKind::Data | SectionKind::ReadOnlyData => ObjSectionKind::Data,
|
||||
SectionKind::UninitializedData => ObjSectionKind::Bss,
|
||||
_ => panic!("Unhandled section kind {:?}", kind),
|
||||
_ => panic!("Unhandled section kind {kind:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
fn to_obj_symbol(obj_file: &File<'_>, symbol: &Symbol<'_, '_>, addend: i64) -> Result<ObjSymbol> {
|
||||
let mut name = symbol.name().context("Failed to process symbol name")?;
|
||||
if name.is_empty() {
|
||||
println!("Found empty sym: {:?}", symbol);
|
||||
println!("Found empty sym: {symbol:?}");
|
||||
name = "?";
|
||||
}
|
||||
let mut flags = ObjSymbolFlagSet(ObjSymbolFlags::none());
|
||||
|
@ -220,8 +220,7 @@ fn relocations_by_section(
|
|||
R_PPC_EMB_SDA21 => ObjRelocKind::PpcEmbSda21,
|
||||
_ => {
|
||||
return Err(anyhow::Error::msg(format!(
|
||||
"Unhandled PPC relocation type: {}",
|
||||
kind
|
||||
"Unhandled PPC relocation type: {kind}"
|
||||
)))
|
||||
}
|
||||
},
|
||||
|
@ -231,8 +230,7 @@ fn relocations_by_section(
|
|||
R_MIPS_LO16 => ObjRelocKind::MipsLo16,
|
||||
_ => {
|
||||
return Err(anyhow::Error::msg(format!(
|
||||
"Unhandled MIPS relocation type: {}",
|
||||
kind
|
||||
"Unhandled MIPS relocation type: {kind}"
|
||||
)))
|
||||
}
|
||||
},
|
||||
|
@ -271,8 +269,7 @@ fn relocations_by_section(
|
|||
let addend = reloc.addend();
|
||||
if addend < 0 {
|
||||
return Err(anyhow::Error::msg(format!(
|
||||
"Negative addend in section reloc: {}",
|
||||
addend
|
||||
"Negative addend in section reloc: {addend}"
|
||||
)));
|
||||
}
|
||||
addend as u32
|
||||
|
|
|
@ -81,16 +81,13 @@ pub fn config_ui(ui: &mut egui::Ui, config: &Arc<RwLock<AppConfig>>, view_state:
|
|||
if state.update_available {
|
||||
ui.colored_label(Color32::LIGHT_GREEN, "Update available");
|
||||
ui.horizontal(|ui| {
|
||||
if state.found_binary {
|
||||
if ui
|
||||
if state.found_binary && ui
|
||||
.button("Automatic")
|
||||
.on_hover_text_at_pointer(
|
||||
"Automatically download and replace the current build",
|
||||
)
|
||||
.clicked()
|
||||
{
|
||||
view_state.jobs.push(queue_update());
|
||||
}
|
||||
.clicked() {
|
||||
view_state.jobs.push(queue_update());
|
||||
}
|
||||
if ui
|
||||
.button("Manual")
|
||||
|
|
|
@ -23,7 +23,7 @@ fn data_row_ui(ui: &mut egui::Ui, address: usize, diffs: &[ObjDataDiff], config:
|
|||
}
|
||||
let mut job = LayoutJob::default();
|
||||
write_text(
|
||||
format!("{:08X}: ", address).as_str(),
|
||||
format!("{address:08X}: ").as_str(),
|
||||
Color32::GRAY,
|
||||
&mut job,
|
||||
config.code_font.clone(),
|
||||
|
@ -44,7 +44,7 @@ fn data_row_ui(ui: &mut egui::Ui, address: usize, diffs: &[ObjDataDiff], config:
|
|||
} else {
|
||||
let mut text = String::new();
|
||||
for byte in &diff.data {
|
||||
text.push_str(format!("{:02X} ", byte).as_str());
|
||||
text.push_str(format!("{byte:02X} ").as_str());
|
||||
cur_addr += 1;
|
||||
if cur_addr % 8 == 0 {
|
||||
text.push(' ');
|
||||
|
|
|
@ -20,7 +20,7 @@ fn write_reloc_name(reloc: &ObjReloc, color: Color32, job: &mut LayoutJob, font_
|
|||
let name = reloc.target.demangled_name.as_ref().unwrap_or(&reloc.target.name);
|
||||
write_text(name, Color32::LIGHT_GRAY, job, font_id.clone());
|
||||
if reloc.target.addend != 0 {
|
||||
write_text(&format!("+{:X}", reloc.target.addend), color, job, font_id.clone());
|
||||
write_text(&format!("+{:X}", reloc.target.addend), color, job, font_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,35 +28,35 @@ fn write_reloc(reloc: &ObjReloc, color: Color32, job: &mut LayoutJob, font_id: F
|
|||
match reloc.kind {
|
||||
ObjRelocKind::PpcAddr16Lo => {
|
||||
write_reloc_name(reloc, color, job, font_id.clone());
|
||||
write_text("@l", color, job, font_id.clone());
|
||||
write_text("@l", color, job, font_id);
|
||||
}
|
||||
ObjRelocKind::PpcAddr16Hi => {
|
||||
write_reloc_name(reloc, color, job, font_id.clone());
|
||||
write_text("@h", color, job, font_id.clone());
|
||||
write_text("@h", color, job, font_id);
|
||||
}
|
||||
ObjRelocKind::PpcAddr16Ha => {
|
||||
write_reloc_name(reloc, color, job, font_id.clone());
|
||||
write_text("@ha", color, job, font_id.clone());
|
||||
write_text("@ha", color, job, font_id);
|
||||
}
|
||||
ObjRelocKind::PpcEmbSda21 => {
|
||||
write_reloc_name(reloc, color, job, font_id.clone());
|
||||
write_text("@sda21", color, job, font_id.clone());
|
||||
write_text("@sda21", color, job, font_id);
|
||||
}
|
||||
ObjRelocKind::MipsHi16 => {
|
||||
write_text("%hi(", color, job, font_id.clone());
|
||||
write_reloc_name(reloc, color, job, font_id.clone());
|
||||
write_text(")", color, job, font_id.clone());
|
||||
write_text(")", color, job, font_id);
|
||||
}
|
||||
ObjRelocKind::MipsLo16 => {
|
||||
write_text("%lo(", color, job, font_id.clone());
|
||||
write_reloc_name(reloc, color, job, font_id.clone());
|
||||
write_text(")", color, job, font_id.clone());
|
||||
write_text(")", color, job, font_id);
|
||||
}
|
||||
ObjRelocKind::Absolute
|
||||
| ObjRelocKind::PpcRel24
|
||||
| ObjRelocKind::PpcRel14
|
||||
| ObjRelocKind::Mips26 => {
|
||||
write_reloc_name(reloc, color, job, font_id.clone());
|
||||
write_reloc_name(reloc, color, job, font_id);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -102,16 +102,16 @@ fn write_ins(
|
|||
match arg {
|
||||
ObjInsArg::PpcArg(arg) => match arg {
|
||||
Argument::Offset(val) => {
|
||||
write_text(&format!("{}", val), color, job, config.code_font.clone());
|
||||
write_text(&format!("{val}"), color, job, config.code_font.clone());
|
||||
write_text("(", base_color, job, config.code_font.clone());
|
||||
writing_offset = true;
|
||||
continue;
|
||||
}
|
||||
Argument::Uimm(_) | Argument::Simm(_) => {
|
||||
write_text(&format!("{}", arg), color, job, config.code_font.clone());
|
||||
write_text(&format!("{arg}"), color, job, config.code_font.clone());
|
||||
}
|
||||
_ => {
|
||||
write_text(&format!("{}", arg), color, job, config.code_font.clone());
|
||||
write_text(&format!("{arg}"), color, job, config.code_font.clone());
|
||||
}
|
||||
},
|
||||
ObjInsArg::Reloc => {
|
||||
|
@ -133,7 +133,7 @@ fn write_ins(
|
|||
}
|
||||
ObjInsArg::BranchOffset(offset) => {
|
||||
let addr = offset + ins.address as i32 - base_addr as i32;
|
||||
write_text(&format!("{:x}", addr), color, job, config.code_font.clone());
|
||||
write_text(&format!("{addr:x}"), color, job, config.code_font.clone());
|
||||
}
|
||||
}
|
||||
if writing_offset {
|
||||
|
@ -171,7 +171,7 @@ fn ins_hover_ui(ui: &mut egui::Ui, ins: &ObjIns) {
|
|||
ui.label(format!("Relocation type: {:?}", reloc.kind));
|
||||
ui.colored_label(Color32::WHITE, format!("Name: {}", reloc.target.name));
|
||||
if let Some(section) = &reloc.target_section {
|
||||
ui.colored_label(Color32::WHITE, format!("Section: {}", section));
|
||||
ui.colored_label(Color32::WHITE, format!("Section: {section}"));
|
||||
ui.colored_label(Color32::WHITE, format!("Address: {:x}", reloc.target.address));
|
||||
ui.colored_label(Color32::WHITE, format!("Size: {:x}", reloc.target.size));
|
||||
} else {
|
||||
|
@ -192,8 +192,8 @@ fn ins_context_menu(ui: &mut egui::Ui, ins: &ObjIns) {
|
|||
if let ObjInsArg::PpcArg(arg) = arg {
|
||||
match arg {
|
||||
Argument::Uimm(v) => {
|
||||
if ui.button(format!("Copy \"{}\"", v)).clicked() {
|
||||
ui.output().copied_text = format!("{}", v);
|
||||
if ui.button(format!("Copy \"{v}\"")).clicked() {
|
||||
ui.output().copied_text = format!("{v}");
|
||||
ui.close_menu();
|
||||
}
|
||||
if ui.button(format!("Copy \"{}\"", v.0)).clicked() {
|
||||
|
@ -202,8 +202,8 @@ fn ins_context_menu(ui: &mut egui::Ui, ins: &ObjIns) {
|
|||
}
|
||||
}
|
||||
Argument::Simm(v) => {
|
||||
if ui.button(format!("Copy \"{}\"", v)).clicked() {
|
||||
ui.output().copied_text = format!("{}", v);
|
||||
if ui.button(format!("Copy \"{v}\"")).clicked() {
|
||||
ui.output().copied_text = format!("{v}");
|
||||
ui.close_menu();
|
||||
}
|
||||
if ui.button(format!("Copy \"{}\"", v.0)).clicked() {
|
||||
|
@ -212,8 +212,8 @@ fn ins_context_menu(ui: &mut egui::Ui, ins: &ObjIns) {
|
|||
}
|
||||
}
|
||||
Argument::Offset(v) => {
|
||||
if ui.button(format!("Copy \"{}\"", v)).clicked() {
|
||||
ui.output().copied_text = format!("{}", v);
|
||||
if ui.button(format!("Copy \"{v}\"")).clicked() {
|
||||
ui.output().copied_text = format!("{v}");
|
||||
ui.close_menu();
|
||||
}
|
||||
if ui.button(format!("Copy \"{}\"", v.0)).clicked() {
|
||||
|
@ -227,7 +227,7 @@ fn ins_context_menu(ui: &mut egui::Ui, ins: &ObjIns) {
|
|||
}
|
||||
if let Some(reloc) = &ins.reloc {
|
||||
if let Some(name) = &reloc.target.demangled_name {
|
||||
if ui.button(format!("Copy \"{}\"", name)).clicked() {
|
||||
if ui.button(format!("Copy \"{name}\"")).clicked() {
|
||||
ui.output().copied_text = name.clone();
|
||||
ui.close_menu();
|
||||
}
|
||||
|
@ -399,7 +399,7 @@ pub fn function_diff_ui(ui: &mut egui::Ui, view_state: &mut ViewState) -> bool {
|
|||
{
|
||||
ui.colored_label(
|
||||
match_color_for_symbol(match_percent),
|
||||
&format!("{:.0}%", match_percent),
|
||||
&format!("{match_percent:.0}%"),
|
||||
);
|
||||
}
|
||||
ui.label("Diff base:");
|
||||
|
|
|
@ -15,7 +15,7 @@ pub fn jobs_ui(ui: &mut egui::Ui, view_state: &mut ViewState) {
|
|||
if job.handle.is_some() {
|
||||
job.should_remove = true;
|
||||
if let Err(e) = job.cancel.send(()) {
|
||||
eprintln!("Failed to cancel job: {:?}", e);
|
||||
eprintln!("Failed to cancel job: {e:?}");
|
||||
}
|
||||
} else {
|
||||
remove_job = Some(idx);
|
||||
|
|
|
@ -26,7 +26,7 @@ fn symbol_context_menu_ui(ui: &mut Ui, symbol: &ObjSymbol) {
|
|||
ui.style_mut().wrap = Some(false);
|
||||
|
||||
if let Some(name) = &symbol.demangled_name {
|
||||
if ui.button(format!("Copy \"{}\"", name)).clicked() {
|
||||
if ui.button(format!("Copy \"{name}\"")).clicked() {
|
||||
ui.output().copied_text = name.clone();
|
||||
ui.close_menu();
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ fn symbol_ui(
|
|||
if let Some(match_percent) = symbol.match_percent {
|
||||
write_text("(", Color32::GRAY, &mut job, config.code_font.clone());
|
||||
write_text(
|
||||
&format!("{:.0}%", match_percent),
|
||||
&format!("{match_percent:.0}%"),
|
||||
match_color_for_symbol(match_percent),
|
||||
&mut job,
|
||||
config.code_font.clone(),
|
||||
|
@ -121,6 +121,7 @@ fn symbol_matches_search(symbol: &ObjSymbol, search_str: &str) -> bool {
|
|||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn symbol_list_ui(
|
||||
ui: &mut Ui,
|
||||
obj: &ObjInfo,
|
||||
|
|
Loading…
Reference in New Issue