From 62f2dd7c6c89ca44f2096f535962b63f26f57730 Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Sat, 19 Oct 2024 20:53:10 -0400 Subject: Remove ability to panic on pre-initialized logger in rust Typically this would never occur, however due to the mystical nature of linkers this somehow has happened outside of demo builds --- rust/examples/dwarf/dwarf_export/src/lib.rs | 2 +- rust/examples/dwarf/dwarf_import/src/lib.rs | 2 +- rust/examples/idb_import/src/lib.rs | 2 +- rust/examples/minidump/src/lib.rs | 2 +- rust/examples/pdb-ng/src/lib.rs | 2 +- rust/examples/test_demangler/src/lib.rs | 2 +- rust/examples/workflow/src/lib.rs | 3 +-- 7 files changed, 7 insertions(+), 8 deletions(-) (limited to 'rust/examples') diff --git a/rust/examples/dwarf/dwarf_export/src/lib.rs b/rust/examples/dwarf/dwarf_export/src/lib.rs index 057abe27..05592f5f 100644 --- a/rust/examples/dwarf/dwarf_export/src/lib.rs +++ b/rust/examples/dwarf/dwarf_export/src/lib.rs @@ -781,7 +781,7 @@ impl Command for MyCommand { #[no_mangle] pub extern "C" fn CorePluginInit() -> bool { - init(LevelFilter::Debug).expect("Unable to initialize logger"); + init(LevelFilter::Debug); register( "Export as DWARF", diff --git a/rust/examples/dwarf/dwarf_import/src/lib.rs b/rust/examples/dwarf/dwarf_import/src/lib.rs index b04c04db..20076d0c 100644 --- a/rust/examples/dwarf/dwarf_import/src/lib.rs +++ b/rust/examples/dwarf/dwarf_import/src/lib.rs @@ -658,7 +658,7 @@ impl CustomDebugInfoParser for DWARFParser { #[no_mangle] pub extern "C" fn CorePluginInit() -> bool { - logger::init(LevelFilter::Debug).unwrap(); + logger::init(LevelFilter::Debug); let settings = Settings::new(""); diff --git a/rust/examples/idb_import/src/lib.rs b/rust/examples/idb_import/src/lib.rs index 4bd75c79..0de688be 100644 --- a/rust/examples/idb_import/src/lib.rs +++ b/rust/examples/idb_import/src/lib.rs @@ -337,7 +337,7 @@ fn parse_id0_section_info( #[allow(non_snake_case)] #[no_mangle] pub extern "C" fn CorePluginInit() -> bool { - let _logger = logger::init(LevelFilter::Error); + logger::init(LevelFilter::Error); DebugInfoParser::register("IDB Parser", IDBDebugInfoParser); DebugInfoParser::register("TIL Parser", TILDebugInfoParser); true diff --git a/rust/examples/minidump/src/lib.rs b/rust/examples/minidump/src/lib.rs index 9d8b4054..c899591b 100644 --- a/rust/examples/minidump/src/lib.rs +++ b/rust/examples/minidump/src/lib.rs @@ -21,7 +21,7 @@ impl Command for PrintMemoryInformationCommand { #[no_mangle] #[allow(non_snake_case)] pub extern "C" fn CorePluginInit() -> bool { - binaryninja::logger::init(LevelFilter::Trace).expect("failed to initialize logging"); + binaryninja::logger::init(LevelFilter::Trace); debug!("Registering minidump binary view type"); register_view_type("Minidump", "Minidump", view::MinidumpBinaryViewType::new); diff --git a/rust/examples/pdb-ng/src/lib.rs b/rust/examples/pdb-ng/src/lib.rs index e6a97be5..bc12caae 100644 --- a/rust/examples/pdb-ng/src/lib.rs +++ b/rust/examples/pdb-ng/src/lib.rs @@ -697,7 +697,7 @@ pub extern "C" fn PDBPluginInit() -> bool { } fn init_plugin() -> bool { - let _ = logger::init(LevelFilter::Debug); + logger::init(LevelFilter::Debug); DebugInfoParser::register("PDB", PDBParser {}); let settings = Settings::new(""); diff --git a/rust/examples/test_demangler/src/lib.rs b/rust/examples/test_demangler/src/lib.rs index eaa38dad..6735d5fb 100644 --- a/rust/examples/test_demangler/src/lib.rs +++ b/rust/examples/test_demangler/src/lib.rs @@ -57,7 +57,7 @@ impl Command for DemangleCommand { #[no_mangle] pub extern "C" fn CorePluginInit() -> bool { - let _ = logger::init(LevelFilter::Info); + logger::init(LevelFilter::Info); Demangler::register("Test", TestDemangler {}); command::register("Demangle Test", "Test", DemangleCommand {}); true diff --git a/rust/examples/workflow/src/lib.rs b/rust/examples/workflow/src/lib.rs index 3e295c51..47a8d2c8 100644 --- a/rust/examples/workflow/src/lib.rs +++ b/rust/examples/workflow/src/lib.rs @@ -5,7 +5,6 @@ use binaryninja::workflow::{Activity, AnalysisContext, Workflow}; use log::LevelFilter; const RUST_ACTIVITY_NAME: &'static str = "analysis.plugins.rustexample"; -// TODO: runOnce needs to be on... const RUST_ACTIVITY_CONFIG: &'static str = r#"{ "name": "analysis.plugins.rustexample", "title" : "Rust Example", @@ -56,7 +55,7 @@ fn example_activity(analysis_context: &AnalysisContext) { #[no_mangle] #[allow(non_snake_case)] pub extern "C" fn CorePluginInit() -> bool { - binaryninja::logger::init(LevelFilter::Debug).unwrap(); + binaryninja::logger::init(LevelFilter::Info); log::info!("Initialized the plugin"); -- cgit v1.3.1