Skip to content

Commit

Permalink
Avoid unwrap by using exact length buffer, simplify types
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Oct 10, 2023
1 parent a94996e commit c027885
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
5 changes: 1 addition & 4 deletions esp-wifi/src/compat/work_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down
11 changes: 3 additions & 8 deletions esp-wifi/src/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
Expand Down

0 comments on commit c027885

Please sign in to comment.