From c7c10b161aeb8ab6650e6490ab88c270795aa8df Mon Sep 17 00:00:00 2001 From: Jonathan 'theJPster' Pallant Date: Tue, 2 Dec 2025 19:43:59 +0000 Subject: [PATCH 1/2] Be explicit about pointer casts Removes compiler warning added to nightly recently. People often accidentally cast function pointers to integers when they meant to call the function and cast the result, but they forgot the (). So because we actually want to cast a function pointer we have to be clear about that. --- examples/mps3-an536/src/bin/abt-exception-a32.rs | 2 +- examples/mps3-an536/src/bin/abt-exception-t32.rs | 2 +- examples/mps3-an536/src/bin/prefetch-exception-a32.rs | 4 ++-- examples/mps3-an536/src/bin/prefetch-exception-t32.rs | 4 ++-- examples/mps3-an536/src/bin/undef-exception-a32.rs | 4 ++-- examples/mps3-an536/src/bin/undef-exception-t32.rs | 4 ++-- examples/versatileab/src/bin/abt-exception-a32.rs | 2 +- examples/versatileab/src/bin/abt-exception-t32.rs | 2 +- examples/versatileab/src/bin/prefetch-exception-a32.rs | 4 ++-- examples/versatileab/src/bin/prefetch-exception-t32.rs | 4 ++-- examples/versatileab/src/bin/undef-exception-a32.rs | 4 ++-- examples/versatileab/src/bin/undef-exception-t32.rs | 4 ++-- 12 files changed, 20 insertions(+), 20 deletions(-) diff --git a/examples/mps3-an536/src/bin/abt-exception-a32.rs b/examples/mps3-an536/src/bin/abt-exception-a32.rs index bf430ce..804d679 100644 --- a/examples/mps3-an536/src/bin/abt-exception-a32.rs +++ b/examples/mps3-an536/src/bin/abt-exception-a32.rs @@ -88,7 +88,7 @@ unsafe fn data_abort_handler(addr: usize) -> usize { enable_alignment_check(); // note the fault isn't at the start of the function - let expect_fault_at = unaligned_from_a32 as usize + 8; + let expect_fault_at = unaligned_from_a32 as unsafe extern "C" fn() as usize + 8; if addr == expect_fault_at { println!("caught unaligned_from_a32"); diff --git a/examples/mps3-an536/src/bin/abt-exception-t32.rs b/examples/mps3-an536/src/bin/abt-exception-t32.rs index d2fc682..c399786 100644 --- a/examples/mps3-an536/src/bin/abt-exception-t32.rs +++ b/examples/mps3-an536/src/bin/abt-exception-t32.rs @@ -88,7 +88,7 @@ unsafe fn data_abort_handler(addr: usize) -> usize { enable_alignment_check(); // note the fault isn't at the start of the function - let expect_fault_at = unaligned_from_t32 as usize + 5; + let expect_fault_at = unaligned_from_t32 as unsafe extern "C" fn() as usize + 5; if addr == expect_fault_at { println!("caught unaligned_from_t32"); diff --git a/examples/mps3-an536/src/bin/prefetch-exception-a32.rs b/examples/mps3-an536/src/bin/prefetch-exception-a32.rs index a9e40e6..2f3a59d 100644 --- a/examples/mps3-an536/src/bin/prefetch-exception-a32.rs +++ b/examples/mps3-an536/src/bin/prefetch-exception-a32.rs @@ -63,12 +63,12 @@ unsafe fn prefetch_abort_handler(addr: usize) -> usize { let ifar = Ifar::read(); println!("IFAR (Faulting Address Register): {:?}", ifar); - if addr == bkpt_from_a32 as usize { + if addr == bkpt_from_a32 as unsafe extern "C" fn() as usize { println!("caught bkpt_from_a32"); } else { println!( "Bad fault address {:08x} is not {:08x}", - addr, bkpt_from_a32 as usize + addr, bkpt_from_a32 as unsafe extern "C" fn() as usize ); } diff --git a/examples/mps3-an536/src/bin/prefetch-exception-t32.rs b/examples/mps3-an536/src/bin/prefetch-exception-t32.rs index b5a4ccb..8c96baa 100644 --- a/examples/mps3-an536/src/bin/prefetch-exception-t32.rs +++ b/examples/mps3-an536/src/bin/prefetch-exception-t32.rs @@ -63,7 +63,7 @@ unsafe fn prefetch_abort_handler(addr: usize) -> usize { let ifar = Ifar::read(); println!("IFAR (Faulting Address Register): {:?}", ifar); - if (addr + 1) == bkpt_from_t32 as usize { + if (addr + 1) == bkpt_from_t32 as unsafe extern "C" fn() as usize { // note that thumb functions have their LSB set, despite always being a // multiple of two - that's how the CPU knows they are written in T32 // machine code. @@ -71,7 +71,7 @@ unsafe fn prefetch_abort_handler(addr: usize) -> usize { } else { println!( "Bad fault address {:08x} is not {:08x}", - addr, bkpt_from_t32 as usize + addr, bkpt_from_t32 as unsafe extern "C" fn() as usize ); } diff --git a/examples/mps3-an536/src/bin/undef-exception-a32.rs b/examples/mps3-an536/src/bin/undef-exception-a32.rs index 59c768f..e2bc17b 100644 --- a/examples/mps3-an536/src/bin/undef-exception-a32.rs +++ b/examples/mps3-an536/src/bin/undef-exception-a32.rs @@ -55,12 +55,12 @@ fn prefetch_abort_handler(_addr: usize) -> ! { unsafe fn undefined_handler(addr: usize) -> usize { println!("undefined abort occurred"); - if addr == udf_from_a32 as usize { + if addr == udf_from_a32 as unsafe extern "C" fn() as usize { println!("caught udf_from_a32"); } else { println!( "Bad fault address {:08x} is not {:08x}", - addr, udf_from_a32 as usize + addr, udf_from_a32 as unsafe extern "C" fn() as usize ); } diff --git a/examples/mps3-an536/src/bin/undef-exception-t32.rs b/examples/mps3-an536/src/bin/undef-exception-t32.rs index c6250ea..418b43c 100644 --- a/examples/mps3-an536/src/bin/undef-exception-t32.rs +++ b/examples/mps3-an536/src/bin/undef-exception-t32.rs @@ -55,7 +55,7 @@ fn prefetch_abort_handler(_addr: usize) -> ! { unsafe fn undefined_handler(addr: usize) -> usize { println!("undefined abort occurred"); - if (addr + 1) == udf_from_t32 as usize { + if (addr + 1) == udf_from_t32 as unsafe extern "C" fn() as usize { // note that thumb functions have their LSB set, despite always being a // multiple of two - that's how the CPU knows they are written in T32 // machine code. @@ -63,7 +63,7 @@ unsafe fn undefined_handler(addr: usize) -> usize { } else { println!( "Bad fault address {:08x} is not {:08x}", - addr, udf_from_t32 as usize + addr, udf_from_t32 as unsafe extern "C" fn() as usize ); } diff --git a/examples/versatileab/src/bin/abt-exception-a32.rs b/examples/versatileab/src/bin/abt-exception-a32.rs index e51d621..0745426 100644 --- a/examples/versatileab/src/bin/abt-exception-a32.rs +++ b/examples/versatileab/src/bin/abt-exception-a32.rs @@ -88,7 +88,7 @@ unsafe fn data_abort_handler(addr: usize) -> usize { enable_alignment_check(); // note the fault isn't at the start of the function - let expect_fault_at = unaligned_from_a32 as usize + 8; + let expect_fault_at = unaligned_from_a32 as unsafe extern "C" fn() as usize + 8; if addr == expect_fault_at { println!("caught unaligned_from_a32"); diff --git a/examples/versatileab/src/bin/abt-exception-t32.rs b/examples/versatileab/src/bin/abt-exception-t32.rs index e5c4472..ff263b5 100644 --- a/examples/versatileab/src/bin/abt-exception-t32.rs +++ b/examples/versatileab/src/bin/abt-exception-t32.rs @@ -88,7 +88,7 @@ unsafe fn data_abort_handler(addr: usize) -> usize { enable_alignment_check(); // note the fault isn't at the start of the function - let expect_fault_at = unaligned_from_t32 as usize + 3; + let expect_fault_at = unaligned_from_t32 as unsafe extern "C" fn() as usize + 3; if addr == expect_fault_at { println!("caught unaligned_from_t32"); diff --git a/examples/versatileab/src/bin/prefetch-exception-a32.rs b/examples/versatileab/src/bin/prefetch-exception-a32.rs index 5ca8e11..0dd67aa 100644 --- a/examples/versatileab/src/bin/prefetch-exception-a32.rs +++ b/examples/versatileab/src/bin/prefetch-exception-a32.rs @@ -68,12 +68,12 @@ unsafe fn prefetch_abort_handler(addr: usize) -> usize { let ifar = Ifar::read(); println!("IFAR (Faulting Address Register): {:?}", ifar); - if addr == bkpt_from_a32 as usize { + if addr == bkpt_from_a32 as unsafe extern "C" fn() as usize { println!("caught bkpt_from_a32"); } else { println!( "Bad fault address {:08x} is not {:08x}", - addr, bkpt_from_a32 as usize + addr, bkpt_from_a32 as unsafe extern "C" fn() as usize ); } } diff --git a/examples/versatileab/src/bin/prefetch-exception-t32.rs b/examples/versatileab/src/bin/prefetch-exception-t32.rs index 862490b..ab9631c 100644 --- a/examples/versatileab/src/bin/prefetch-exception-t32.rs +++ b/examples/versatileab/src/bin/prefetch-exception-t32.rs @@ -68,7 +68,7 @@ unsafe fn prefetch_abort_handler(addr: usize) -> usize { let ifar = Ifar::read(); println!("IFAR (Faulting Address Register): {:?}", ifar); - if (addr + 1) == bkpt_from_t32 as usize { + if (addr + 1) == bkpt_from_t32 as unsafe extern "C" fn() as usize { // note that thumb functions have their LSB set, despite always being a // multiple of two - that's how the CPU knows they are written in T32 // machine code. @@ -76,7 +76,7 @@ unsafe fn prefetch_abort_handler(addr: usize) -> usize { } else { println!( "Bad fault address {:08x} is not {:08x}", - addr, bkpt_from_t32 as usize + addr, bkpt_from_t32 as unsafe extern "C" fn() as usize ); } } diff --git a/examples/versatileab/src/bin/undef-exception-a32.rs b/examples/versatileab/src/bin/undef-exception-a32.rs index 0d94975..0b2a398 100644 --- a/examples/versatileab/src/bin/undef-exception-a32.rs +++ b/examples/versatileab/src/bin/undef-exception-a32.rs @@ -55,12 +55,12 @@ fn prefetch_abort_handler(_addr: usize) -> ! { unsafe fn undefined_handler(addr: usize) -> usize { println!("undefined abort occurred"); - if addr == udf_from_a32 as usize { + if addr == udf_from_a32 as unsafe extern "C" fn() as usize { println!("caught udf_from_a32"); } else { println!( "Bad fault address {:08x} is not {:08x}", - addr, udf_from_a32 as usize + addr, udf_from_a32 as unsafe extern "C" fn() as usize ); } diff --git a/examples/versatileab/src/bin/undef-exception-t32.rs b/examples/versatileab/src/bin/undef-exception-t32.rs index 7418cbd..ae0712a 100644 --- a/examples/versatileab/src/bin/undef-exception-t32.rs +++ b/examples/versatileab/src/bin/undef-exception-t32.rs @@ -55,7 +55,7 @@ fn prefetch_abort_handler(_addr: usize) -> ! { unsafe fn undefined_handler(addr: usize) -> usize { println!("undefined abort occurred"); - if (addr + 1) == udf_from_t32 as usize { + if (addr + 1) == udf_from_t32 as unsafe extern "C" fn() as usize { // note that thumb functions have their LSB set, despite always being a // multiple of two - that's how the CPU knows they are written in T32 // machine code. @@ -63,7 +63,7 @@ unsafe fn undefined_handler(addr: usize) -> usize { } else { println!( "Bad fault address {:08x} is not {:08x}", - addr, udf_from_t32 as usize + addr, udf_from_t32 as unsafe extern "C" fn() as usize ); } From 507791d979e735be0977a038fa3dcb14dd025260 Mon Sep 17 00:00:00 2001 From: Jonathan 'theJPster' Pallant Date: Tue, 2 Dec 2025 19:44:16 +0000 Subject: [PATCH 2/2] Bump nightly Rust compiler version for tests/examples --- examples/mps3-an536/rust-toolchain.toml | 2 +- examples/versatileab/rust-toolchain.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/mps3-an536/rust-toolchain.toml b/examples/mps3-an536/rust-toolchain.toml index cc61252..1b7c990 100644 --- a/examples/mps3-an536/rust-toolchain.toml +++ b/examples/mps3-an536/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "nightly-2025-10-29" +channel = "nightly-2025-12-01" targets = [ "armv8r-none-eabihf", ] diff --git a/examples/versatileab/rust-toolchain.toml b/examples/versatileab/rust-toolchain.toml index e016496..8468b4b 100644 --- a/examples/versatileab/rust-toolchain.toml +++ b/examples/versatileab/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "nightly-2025-10-29" +channel = "nightly-2025-12-01" targets = [ "armv7r-none-eabi", "armv7r-none-eabihf",