From d37845197fe7f03fdf4aa02ffa35aa11d4c2b1c9 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Wed, 26 Apr 2023 14:29:29 +1000 Subject: [PATCH] embedded: Remove error handler Seems we no longer need an explicit error handler, remove it. I did not grok the reason (long thread link below) but just removed it and checked that the embedded crates still ran correctly. https://github.com/rust-lang/rust/issues/51540) --- bitcoin/embedded/src/main.rs | 12 ------------ hashes/embedded/src/main.rs | 11 ----------- 2 files changed, 23 deletions(-) diff --git a/bitcoin/embedded/src/main.rs b/bitcoin/embedded/src/main.rs index b3a89d35..8adbcf4b 100644 --- a/bitcoin/embedded/src/main.rs +++ b/bitcoin/embedded/src/main.rs @@ -8,7 +8,6 @@ extern crate bitcoin; use alloc::string::ToString; use alloc::vec; -use core::alloc::Layout; use core::panic::PanicInfo; use alloc_cortex_m::CortexMHeap; @@ -17,7 +16,6 @@ use bitcoin::{Address, Network, PrivateKey}; use bitcoin::secp256k1::ffi::types::AlignedType; use bitcoin::secp256k1::Secp256k1; -use cortex_m::asm; use cortex_m_rt::entry; use cortex_m_semihosting::{debug, hprintln}; @@ -57,16 +55,6 @@ fn main() -> ! { loop {} } -// define what happens in an Out Of Memory (OOM) condition -#[alloc_error_handler] -fn alloc_error(_layout: Layout) -> ! { - hprintln!("alloc error").unwrap(); - debug::exit(debug::EXIT_FAILURE); - asm::bkpt(); - - loop {} -} - #[inline(never)] #[panic_handler] fn panic(info: &PanicInfo) -> ! { diff --git a/hashes/embedded/src/main.rs b/hashes/embedded/src/main.rs index 98bb4bb3..a43e7106 100644 --- a/hashes/embedded/src/main.rs +++ b/hashes/embedded/src/main.rs @@ -7,8 +7,6 @@ extern crate bitcoin_hashes; #[cfg(feature = "alloc")] extern crate alloc; #[cfg(feature = "alloc")] use alloc_cortex_m::CortexMHeap; -#[cfg(feature = "alloc")] use core::alloc::Layout; -#[cfg(feature = "alloc")] use cortex_m::asm; #[cfg(feature = "alloc")] use alloc::string::ToString; use bitcoin_hashes::{sha256, Hash, HashEngine}; @@ -63,12 +61,3 @@ fn check_result(engine: sha256::HashEngine) { debug::exit(debug::EXIT_FAILURE); } } - -// define what happens in an Out Of Memory (OOM) condition -#[cfg(feature = "alloc")] -#[alloc_error_handler] -fn alloc_error(_layout: Layout) -> ! { - asm::bkpt(); - - loop {} -}