diff --git a/src/main.rs b/src/main.rs index 0767a477fc2a285aa130e5643d1db7a2fd07ff07..18b464619d618c7181364ad6494a464aff14316c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -333,17 +333,26 @@ fn check_user_presence(cid: ChannelID) -> Result<(), Ctap2StatusCode> { Ok(x) => x, Err(err) => panic!("Drivers were already taken when attempting to retrieve them"), }; - let buttons_driver = all_drivers.buttons.init_driver().unwrap(); - let _buttons_callback = buttons_driver.subscribe(&mut |_button_num, state| { + let buttons_driver = match all_drivers.buttons.init_driver() { + Ok(x) => x, + Err(err) => panic!("Couldn't init buttons subsystem"), + }; + let _buttons_callback = match buttons_driver.subscribe(&mut |_button_num, state| { match state { ButtonState::Pressed => button_touched.set(true), ButtonState::Released => (), }; - }).unwrap(); + }) { + Ok(x) => x, + Err(err) => panic!("Couldn't subscribe to button"), + }; let mut buttons = buttons_driver.buttons(); // At the moment, all buttons are accepted. You can customize your setup here. for mut button in &mut buttons { - button.enable_interrupt().unwrap(); + match button.enable_interrupt() { + Ok(_) => {}, + Err(_) => panic!("Couldn't enable interrupts"), + } } let mut keepalive_response = Ok(()); @@ -362,8 +371,14 @@ fn check_user_presence(cid: ChannelID) -> Result<(), Ctap2StatusCode> { let mut keepalive_callback = timer_context.with_callback(|_, _| { keepalive_expired.set(true); }); - let mut keepalive = keepalive_callback.init().unwrap(); - let keepalive_alarm = keepalive.set_alarm(KEEPALIVE_DELAY).unwrap(); + let mut keepalive = match keepalive_callback.init() { + Ok(x) => x, + Err(_) => panic!("Couldn't init callback!"), + }; + let keepalive_alarm = match keepalive.set_alarm(KEEPALIVE_DELAY) { + Ok(x) => x, + Err(_) => panic!("Couldn't set alarm"), + }; // Wait for a button touch or an alarm. usb_ctap_hid::yieldk_for(|| button_touched.get() || keepalive_expired.get()); @@ -398,7 +413,10 @@ fn check_user_presence(cid: ChannelID) -> Result<(), Ctap2StatusCode> { // Cleanup button callbacks. for mut button in &mut buttons { - button.disable_interrupt().unwrap(); + match button.disable_interrupt() { + Ok(_) => {}, + Err(_) => panic!("Couldn't disable interrupts"), + }; } // Returns whether the user was present.