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 bf430ce2..804d679e 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 d2fc6823..c399786c 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 a9e40e68..2f3a59d8 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 b5a4ccbd..8c96baa1 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 59c768f6..e2bc17b1 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 c6250ea9..418b43c8 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 e51d621d..07454265 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 e5c4472b..ff263b53 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 5ca8e116..0dd67aab 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 862490b4..ab9631c2 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 0d949755..0b2a398a 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 7418cbd2..ae0712a2 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 cc612520..1b7c9907 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 e016496b..8468b4b2 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",