From 2b01430a351179c8f41271a9c8d0391193e95b3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Buga?= Date: Tue, 24 Oct 2023 19:20:35 +0200 Subject: [PATCH] Implement __assert_func --- esp-wifi/src/common_adapter/mod.rs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/esp-wifi/src/common_adapter/mod.rs b/esp-wifi/src/common_adapter/mod.rs index fedc2c53..2fddffd7 100644 --- a/esp-wifi/src/common_adapter/mod.rs +++ b/esp-wifi/src/common_adapter/mod.rs @@ -377,12 +377,23 @@ static mut WIFI_EVENT: esp_event_base_t = unsafe { &EVT }; // stuff needed by wpa-supplicant #[no_mangle] pub unsafe extern "C" fn __assert_func( - _file: *const u8, - _line: u32, - _func: *const u8, - _failed_expr: *const u8, + file: *const u8, + line: u32, + func: *const u8, + failed_expr: *const u8, ) { - todo!("__assert_func"); + let file = str_from_c(file); + let (func_pre, func) = if func.is_null() { + ("", "") + } else { + (", function: ", str_from_c(func)) + }; + let expr = str_from_c(failed_expr); + + panic!( + "assertion \"{}\" failed: file \"{}\", line {}{}{}", + expr, file, line, func_pre, func + ); } #[no_mangle]