Skip to content

Commit

Permalink
unwrap! more stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
MabezDev committed Oct 29, 2024
1 parent f014dd5 commit 0916d8a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
4 changes: 2 additions & 2 deletions esp-wifi/src/ble/os_adapter_esp32s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ pub(crate) fn create_ble_config() -> esp_bt_controller_config_t {
pub(crate) unsafe extern "C" fn interrupt_on(intr_num: i32) -> i32 {
trace!("interrupt_on {}", intr_num);
unwrap!(interrupt::enable(
Interrupt::try_from(intr_num as u16).unwrap(),
unwrap!(Interrupt::try_from(intr_num as u16)),
interrupt::Priority::Priority1,
));

Expand All @@ -307,7 +307,7 @@ pub(crate) unsafe extern "C" fn interrupt_off(intr_num: i32) -> i32 {
trace!("interrupt_off {}", intr_num);
interrupt::disable(
crate::hal::Cpu::ProCpu,
Interrupt::try_from(intr_num as u16).unwrap(),
unwrap!(Interrupt::try_from(intr_num as u16)),
);

0
Expand Down
10 changes: 5 additions & 5 deletions esp-wifi/src/compat/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ unsafe extern "C" fn strcat(destination: *mut u8, source: *const u8) -> *const u
unsafe extern "C" fn strcmp(str1: *const i8, str2: *const i8) -> i32 {
trace!("strcmp {:?} {:?}", str1, str2);

let s1 = core::ffi::CStr::from_ptr(str1).to_str().unwrap();
let s2 = core::ffi::CStr::from_ptr(str2).to_str().unwrap();
let s1 = unwrap!(core::ffi::CStr::from_ptr(str1).to_str());
let s2 = unwrap!(core::ffi::CStr::from_ptr(str2).to_str());

let x = s1.cmp(s2);

Expand Down Expand Up @@ -101,8 +101,8 @@ unsafe extern "C" fn strlcpy(dst: *mut u8, src: *const u8, size: usize) -> usize
unsafe extern "C" fn strstr(str1: *const i8, str2: *const i8) -> *const i8 {
trace!("strstr {:?} {:?}", str1, str2);

let s1 = core::ffi::CStr::from_ptr(str1).to_str().unwrap();
let s2 = core::ffi::CStr::from_ptr(str2).to_str().unwrap();
let s1 = unwrap!(core::ffi::CStr::from_ptr(str1).to_str());
let s2 = unwrap!(core::ffi::CStr::from_ptr(str2).to_str());

let idx = s1.find(s2);

Expand Down Expand Up @@ -146,7 +146,7 @@ unsafe extern "C" fn strdup(str: *const i8) -> *const u8 {

unsafe {
let s = core::ffi::CStr::from_ptr(str);
let s = s.to_str().unwrap();
let s = unwrap!(s.to_str());

let p = malloc(s.len() + 1);
core::ptr::copy_nonoverlapping(str, p as *mut i8, s.len() + 1);
Expand Down
4 changes: 2 additions & 2 deletions esp-wifi/src/timer/riscv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub(crate) fn setup_timer(mut alarm0: TimeBase) {

let cb: extern "C" fn() = unsafe { core::mem::transmute(handler as *const ()) };
alarm0.set_interrupt_handler(InterruptHandler::new(cb, interrupt::Priority::Priority1));
alarm0.start(TIMESLICE_FREQUENCY.into_duration()).unwrap();
unwrap!(alarm0.start(TIMESLICE_FREQUENCY.into_duration()));
critical_section::with(|cs| {
alarm0.enable_interrupt(true);
TIMER.borrow_ref_mut(cs).replace(alarm0);
Expand All @@ -39,7 +39,7 @@ pub(crate) fn setup_timer(mut alarm0: TimeBase) {
pub(crate) fn disable_timer() {
critical_section::with(|cs| {
unwrap!(TIMER.borrow_ref_mut(cs).as_mut()).enable_interrupt(false);
unwrap!(TIMER.borrow_ref_mut(cs).as_mut()).cancel().unwrap();
unwrap!(unwrap!(TIMER.borrow_ref_mut(cs).as_mut()).cancel());
});
}

Expand Down
4 changes: 2 additions & 2 deletions esp-wifi/src/timer/xtensa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub(crate) fn setup_timer(mut timer1: TimeBase) {
unsafe { core::mem::transmute::<*const (), extern "C" fn()>(handler as *const ()) },
interrupt::Priority::Priority2,
));
timer1.start(TIMESLICE_FREQUENCY.into_duration()).unwrap();
unwrap!(timer1.start(TIMESLICE_FREQUENCY.into_duration()));
critical_section::with(|cs| {
timer1.enable_interrupt(true);
TIMER.borrow_ref_mut(cs).replace(timer1);
Expand All @@ -36,7 +36,7 @@ pub(crate) fn setup_timer(mut timer1: TimeBase) {
pub(crate) fn disable_timer() {
critical_section::with(|cs| {
unwrap!(TIMER.borrow_ref_mut(cs).as_mut()).enable_interrupt(false);
unwrap!(TIMER.borrow_ref_mut(cs).as_mut()).cancel().unwrap();
unwrap!(unwrap!(TIMER.borrow_ref_mut(cs).as_mut()).cancel());
});
}

Expand Down
13 changes: 7 additions & 6 deletions esp-wifi/src/wifi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ pub struct AccessPointConfiguration {
impl Default for AccessPointConfiguration {
fn default() -> Self {
Self {
ssid: "iot-device".try_into().unwrap(),
ssid: unwrap!("iot-device".try_into()),
ssid_hidden: false,
channel: 1,
secondary_channel: None,
Expand Down Expand Up @@ -1658,11 +1658,11 @@ unsafe extern "C" fn recv_cb_ap(
pub(crate) static WIFI_TX_INFLIGHT: AtomicUsize = AtomicUsize::new(0);

fn decrement_inflight_counter() {
WIFI_TX_INFLIGHT
.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |x| {
unwrap!(
WIFI_TX_INFLIGHT.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |x| {
Some(x.saturating_sub(1))
})
.unwrap();
);
}

#[ram]
Expand Down Expand Up @@ -2461,8 +2461,9 @@ impl Sniffer {
pub(crate) fn new() -> Self {
// This shouldn't fail, since the way this is created, means that wifi will
// always be initialized.
esp_wifi_result!(unsafe { esp_wifi_set_promiscuous_rx_cb(Some(promiscuous_rx_cb)) })
.unwrap();
unwrap!(esp_wifi_result!(unsafe {
esp_wifi_set_promiscuous_rx_cb(Some(promiscuous_rx_cb))
}));
Self {
promiscuous_mode_enabled: AtomicBool::new(false),
}
Expand Down

0 comments on commit 0916d8a

Please sign in to comment.