Skip to content

Commit

Permalink
unwrap less stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
MabezDev committed Oct 29, 2024
1 parent b126301 commit c845caa
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 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(
unwrap!(Interrupt::try_from(intr_num as u16)),
Interrupt::try_from(intr_num as u16).unwrap(),
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,
unwrap!(Interrupt::try_from(intr_num as u16)),
Interrupt::try_from(intr_num as u16).unwrap(),
);

0
Expand Down
11 changes: 6 additions & 5 deletions esp-wifi/src/compat/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ 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 = unwrap!(core::ffi::CStr::from_ptr(str1).to_str());
let s2 = unwrap!(core::ffi::CStr::from_ptr(str2).to_str());
// TODO: unwrap!() when defmt supports it
let s1 = core::ffi::CStr::from_ptr(str1).to_str().unwrap();
let s2 = core::ffi::CStr::from_ptr(str2).to_str().unwrap();

let x = s1.cmp(s2);

Expand Down Expand Up @@ -101,8 +102,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 = unwrap!(core::ffi::CStr::from_ptr(str1).to_str());
let s2 = unwrap!(core::ffi::CStr::from_ptr(str2).to_str());
let s1 = core::ffi::CStr::from_ptr(str1).to_str().unwrap();
let s2 = core::ffi::CStr::from_ptr(str2).to_str().unwrap();

let idx = s1.find(s2);

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

unsafe {
let s = core::ffi::CStr::from_ptr(str);
let s = unwrap!(s.to_str());
let s = s.to_str().unwrap(); // TODO when defmt supports it

let p = malloc(s.len() + 1);
core::ptr::copy_nonoverlapping(str, p as *mut i8, s.len() + 1);
Expand Down
1 change: 0 additions & 1 deletion examples/src/bin/wifi_esp_now.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use esp_println::println;
use esp_wifi::{
esp_now::{PeerInfo, BROADCAST_ADDRESS},
init,
EspWifiController,
};

#[entry]
Expand Down
7 changes: 2 additions & 5 deletions hil-test/tests/esp_wifi_floats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use esp_hal::{
rng::Rng,
timer::timg::TimerGroup,
};
use esp_wifi::{init, EspWifiInitFor};
use hil_test as _;

#[inline(never)]
Expand Down Expand Up @@ -101,8 +100,7 @@ mod tests {
#[timeout(3)]
fn fpu_stays_enabled_with_wifi(peripherals: Peripherals) {
let timg0 = TimerGroup::new(peripherals.TIMG0);
let _init = init(
EspWifiInitFor::Wifi,
let _init = esp_wifi::init(
timg0.timer1,
Rng::new(peripherals.RNG),
peripherals.RADIO_CLK,
Expand Down Expand Up @@ -138,8 +136,7 @@ mod tests {
unsafe { &mut *core::ptr::addr_of_mut!(APP_CORE_STACK) },
move || {
let timg0 = TimerGroup::new(peripherals.TIMG0);
let _init = init(
EspWifiInitFor::Wifi,
let _init = esp_wifi::init(
timg0.timer1,
Rng::new(peripherals.RNG),
peripherals.RADIO_CLK,
Expand Down

0 comments on commit c845caa

Please sign in to comment.