From c0278854502b67ba7812d4f61e0a978a2e30c412 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Buga?= Date: Tue, 10 Oct 2023 20:57:56 +0200 Subject: [PATCH] Avoid unwrap by using exact length buffer, simplify types --- esp-wifi/src/compat/work_queue.rs | 5 +---- esp-wifi/src/tasks.rs | 11 +++-------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/esp-wifi/src/compat/work_queue.rs b/esp-wifi/src/compat/work_queue.rs index c1d473ff..f6b9123a 100644 --- a/esp-wifi/src/compat/work_queue.rs +++ b/esp-wifi/src/compat/work_queue.rs @@ -31,10 +31,7 @@ pub fn queue_work( pub fn do_work() { unsafe { - let mut todo: [Option<( - extern "C" fn(*mut crate::binary::c_types::c_void), - *mut crate::binary::c_types::c_void, - )>; 10] = [None; 10]; + let mut todo = [None; 10]; critical_section::with(|_| { todo.iter_mut().for_each(|e| { diff --git a/esp-wifi/src/tasks.rs b/esp-wifi/src/tasks.rs index b1ba1ba9..45a7c6c7 100644 --- a/esp-wifi/src/tasks.rs +++ b/esp-wifi/src/tasks.rs @@ -34,13 +34,7 @@ pub extern "C" fn worker_task3() { pub extern "C" fn worker_task2() { loop { - let mut to_run: SimpleQueue< - ( - fn(*mut crate::binary::c_types::c_void), - *mut crate::binary::c_types::c_void, - ), - 10, - > = SimpleQueue::new(); + let mut to_run = SimpleQueue::<_, 20>::new(); critical_section::with(|_| unsafe { let current_timestamp = get_systimer_count(); @@ -52,7 +46,8 @@ pub extern "C" fn worker_task2() { debug!("timer is due.... {:?}", timer.ptimer); let fnctn: fn(*mut crate::binary::c_types::c_void) = core::mem::transmute(timer.timer_ptr); - unwrap!(to_run.enqueue((fnctn, timer.arg_ptr))); + + _ = to_run.enqueue((fnctn, timer.arg_ptr)); if timer.period != 0 { timer.expire = current_timestamp + timer.period;