From 05e50e1f4a2549a13491e8bb865c3e6d2038f875 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Thu, 5 Aug 2021 19:19:47 +0200 Subject: [PATCH] time_driver: use regular fn ptr -> raw ptr casts --- embassy-nrf/src/time_driver.rs | 5 +---- embassy-stm32/src/time_driver.rs | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/embassy-nrf/src/time_driver.rs b/embassy-nrf/src/time_driver.rs index 7815427e..f3d07e98 100644 --- a/embassy-nrf/src/time_driver.rs +++ b/embassy-nrf/src/time_driver.rs @@ -208,10 +208,7 @@ impl State { critical_section::with(|cs| { let alarm = self.get_alarm(cs, alarm); - // safety: it's OK to transmute a fn pointer into a raw pointer - let callback_ptr: *const () = unsafe { mem::transmute(callback) }; - - alarm.callback.set(callback_ptr); + alarm.callback.set(callback as *const ()); alarm.ctx.set(ctx); }) } diff --git a/embassy-stm32/src/time_driver.rs b/embassy-stm32/src/time_driver.rs index 226e5e39..3ae4b1c4 100644 --- a/embassy-stm32/src/time_driver.rs +++ b/embassy-stm32/src/time_driver.rs @@ -232,10 +232,7 @@ impl State { critical_section::with(|cs| { let alarm = self.get_alarm(cs, alarm); - // safety: it's OK to transmute a fn pointer into a raw pointer - let callback_ptr: *const () = unsafe { mem::transmute(callback) }; - - alarm.callback.set(callback_ptr); + alarm.callback.set(callback as *const ()); alarm.ctx.set(ctx); }) }