diff options
author | Dario Nieuwenhuis <dirbaio@dirbaio.net> | 2021-02-26 01:08:04 +0100 |
---|---|---|
committer | Dario Nieuwenhuis <dirbaio@dirbaio.net> | 2021-02-26 01:10:17 +0100 |
commit | a1a0d87a14c047c8b2838ec2f8c62a5ca8875406 (patch) | |
tree | bba95bfbd3ba8e5c8651d0df0d238eb2d1dc88f2 | |
parent | 6cf4ada4e51f37b774f3b9000f2c75fd08cf46c3 (diff) | |
download | nrf-softdevice-a1a0d87a14c047c8b2838ec2f8c62a5ca8875406.zip |
Fix warnings. Closes #39
24 files changed, 83 insertions, 132 deletions
diff --git a/examples/src/bin/ble_bas_central.rs b/examples/src/bin/ble_bas_central.rs index d601cb8..9ee9a0b 100644 --- a/examples/src/bin/ble_bas_central.rs +++ b/examples/src/bin/ble_bas_central.rs @@ -10,11 +10,11 @@ use example_common::*; use core::mem; use cortex_m_rt::entry; use defmt::info; -use defmt::{panic, *}; +use defmt::*; use embassy::executor::{task, Executor}; use embassy::util::Forever; -use nrf_softdevice::ble::{central, gatt_client, Address, AddressType, Connection, Uuid}; +use nrf_softdevice::ble::{central, gatt_client, Address, AddressType}; use nrf_softdevice::raw; use nrf_softdevice::Softdevice; @@ -95,7 +95,7 @@ fn main() -> ! { ..Default::default() }; - let (sdp, p) = take_peripherals(); + let (sdp, _p) = take_peripherals(); let sd = Softdevice::enable(sdp, &config); let executor = EXECUTOR.put(Executor::new()); diff --git a/examples/src/bin/ble_bas_peripheral.rs b/examples/src/bin/ble_bas_peripheral.rs index 89c4621..462dfc9 100644 --- a/examples/src/bin/ble_bas_peripheral.rs +++ b/examples/src/bin/ble_bas_peripheral.rs @@ -10,10 +10,10 @@ use example_common::*; use core::mem; use cortex_m_rt::entry; use defmt::info; -use defmt::{panic, *}; +use defmt::*; -use nrf_softdevice::ble::{gatt_server, peripheral, Connection}; -use nrf_softdevice::{raw, RawError, Softdevice}; +use nrf_softdevice::ble::{gatt_server, peripheral}; +use nrf_softdevice::{raw, Softdevice}; use embassy::executor::{task, Executor}; use embassy::util::Forever; @@ -33,7 +33,7 @@ struct BatteryService { } #[task] -async fn bluetooth_task(sd: &'static Softdevice, config: peripheral::Config) { +async fn bluetooth_task(sd: &'static Softdevice) { let server: BatteryService = unwrap!(gatt_server::register(sd)); #[rustfmt::skip] let adv_data = &[ @@ -125,12 +125,12 @@ fn main() -> ! { ..Default::default() }; - let (sdp, p) = take_peripherals(); + let (sdp, _p) = take_peripherals(); let sd = Softdevice::enable(sdp, &config); let executor = EXECUTOR.put(Executor::new()); executor.run(|spawner| { unwrap!(spawner.spawn(softdevice_task(sd))); - unwrap!(spawner.spawn(bluetooth_task(sd, peripheral::Config::default()))); + unwrap!(spawner.spawn(bluetooth_task(sd))); }); } diff --git a/examples/src/bin/ble_l2cap_central.rs b/examples/src/bin/ble_l2cap_central.rs index 9ac6a86..ff30164 100644 --- a/examples/src/bin/ble_l2cap_central.rs +++ b/examples/src/bin/ble_l2cap_central.rs @@ -13,13 +13,12 @@ use core::ptr::NonNull; use core::slice; use cortex_m_rt::entry; use defmt::info; -use defmt::{panic, *}; +use defmt::*; use embassy::executor::{task, Executor}; use embassy::util::Forever; -use heapless::consts::*; use nrf_softdevice::ble::l2cap::Packet as _; -use nrf_softdevice::ble::{central, l2cap, Address, Connection, TxPower, Uuid}; +use nrf_softdevice::ble::{central, l2cap, Address, TxPower}; use nrf_softdevice::raw; use nrf_softdevice::Softdevice; @@ -171,7 +170,7 @@ fn main() -> ! { ..Default::default() }; - let (sdp, p) = take_peripherals(); + let (sdp, _p) = take_peripherals(); let sd = Softdevice::enable(sdp, &config); let executor = EXECUTOR.put(Executor::new()); diff --git a/examples/src/bin/ble_l2cap_peripheral.rs b/examples/src/bin/ble_l2cap_peripheral.rs index 3418cc7..871cb01 100644 --- a/examples/src/bin/ble_l2cap_peripheral.rs +++ b/examples/src/bin/ble_l2cap_peripheral.rs @@ -11,11 +11,11 @@ use example_common::*; use core::mem; use core::ptr::NonNull; use cortex_m_rt::entry; -use defmt::{panic, *}; +use defmt::*; use nrf_softdevice::ble; -use nrf_softdevice::ble::{l2cap, peripheral, Connection}; -use nrf_softdevice::{raw, RawError, Softdevice}; +use nrf_softdevice::ble::{l2cap, peripheral}; +use nrf_softdevice::{raw, Softdevice}; use embassy::executor::{task, Executor}; use embassy::util::Forever; @@ -64,8 +64,6 @@ async fn bluetooth_task(sd: &'static Softdevice) { let pkt = unwrap!(ch.rx().await); info!("rx: {:x}", pkt.0); } - - futures::future::pending::<()>().await; } } @@ -147,7 +145,7 @@ fn main() -> ! { ..Default::default() }; - let (sdp, p) = take_peripherals(); + let (sdp, _p) = take_peripherals(); let sd = Softdevice::enable(sdp, &config); let executor = EXECUTOR.put(Executor::new()); diff --git a/examples/src/bin/ble_peripheral_onoff.rs b/examples/src/bin/ble_peripheral_onoff.rs index 83686f4..d516991 100644 --- a/examples/src/bin/ble_peripheral_onoff.rs +++ b/examples/src/bin/ble_peripheral_onoff.rs @@ -18,8 +18,8 @@ use embassy_nrf::interrupt; use futures::pin_mut; use nrf52840_hal::gpio; -use nrf_softdevice::ble::{gatt_server, peripheral, Connection}; -use nrf_softdevice::{pac, raw, RawError, Softdevice}; +use nrf_softdevice::ble::{gatt_server, peripheral}; +use nrf_softdevice::{pac, raw, Softdevice}; static EXECUTOR: Forever<Executor> = Forever::new(); diff --git a/examples/src/bin/ble_scan.rs b/examples/src/bin/ble_scan.rs index 74e2d62..d49574d 100644 --- a/examples/src/bin/ble_scan.rs +++ b/examples/src/bin/ble_scan.rs @@ -10,11 +10,11 @@ use example_common::*; use core::mem; use core::slice; use cortex_m_rt::entry; -use defmt::{panic, *}; +use defmt::*; use embassy::executor::{task, Executor}; use embassy::util::Forever; -use nrf_softdevice::ble::{central, TxPower}; +use nrf_softdevice::ble::central; use nrf_softdevice::raw; use nrf_softdevice::Softdevice; @@ -106,7 +106,7 @@ fn main() -> ! { ..Default::default() }; - let (sdp, p) = take_peripherals(); + let (sdp, _p) = take_peripherals(); let sd = Softdevice::enable(sdp, &config); let executor = EXECUTOR.put(Executor::new()); diff --git a/examples/src/bin/flash.rs b/examples/src/bin/flash.rs index 1d765c7..84a71ab 100644 --- a/examples/src/bin/flash.rs +++ b/examples/src/bin/flash.rs @@ -8,7 +8,7 @@ mod example_common; use example_common::*; use cortex_m_rt::entry; -use defmt::{panic, *}; +use defmt::*; use embassy::executor::{task, Executor}; use embassy::flash::Flash as _; use embassy::util::Forever; @@ -39,7 +39,7 @@ async fn flash_task(sd: &'static Softdevice) { fn main() -> ! { info!("Hello World!"); - let (sdp, p) = take_peripherals(); + let (sdp, _p) = take_peripherals(); let sd = Softdevice::enable(sdp, &Default::default()); let executor = EXECUTOR.put(Executor::new()); diff --git a/examples/src/bin/interrupts.rs b/examples/src/bin/interrupts.rs index 55c896c..baeb3e8 100644 --- a/examples/src/bin/interrupts.rs +++ b/examples/src/bin/interrupts.rs @@ -8,7 +8,7 @@ mod example_common; use example_common::*; use cortex_m_rt::entry; -use defmt::{panic, *}; +use defmt::*; use embassy::executor::{task, Executor}; use embassy::util::Forever; @@ -23,7 +23,7 @@ async fn softdevice_task(sd: &'static Softdevice) { } #[task] -async fn interrupt_task(sd: &'static Softdevice) { +async fn interrupt_task(_sd: &'static Softdevice) { let enabled = interrupt::is_enabled(interrupt::SWI0_EGU0); info!("enabled: {:?}", enabled); @@ -89,7 +89,7 @@ fn SWI1_EGU1() { fn main() -> ! { info!("Hello World!"); - let (sdp, p) = take_peripherals(); + let (sdp, _p) = take_peripherals(); let sd = Softdevice::enable(sdp, &Default::default()); let executor = EXECUTOR.put(Executor::new()); diff --git a/examples/src/bin/rtic.rs b/examples/src/bin/rtic.rs index 7fd34b5..cf7be99 100644 --- a/examples/src/bin/rtic.rs +++ b/examples/src/bin/rtic.rs @@ -19,7 +19,7 @@ mod example_common; use example_common::*; use core::mem; -use defmt::{panic, *}; +use defmt::*; use embassy::executor::{task, Executor}; use embassy::util::Forever; use nrf52840_hal::pac::TIMER1; @@ -56,7 +56,7 @@ async fn bluetooth_task(sd: &'static Softdevice) { adv_data, scan_data, }; - let conn = unwrap!(peripheral::advertise(sd, adv, &config).await); + let _conn = unwrap!(peripheral::advertise(sd, adv, &config).await); info!("advertising done!"); } @@ -116,7 +116,7 @@ const APP: () = { ..Default::default() }; - let (sdp, p) = take_peripherals(); + let (sdp, _p) = take_peripherals(); // Softdevice enable must not be done in RTIC init // because RTIC runs init with interrupts disabled, and the diff --git a/examples/src/example_common.rs b/examples/src/example_common.rs index adbe86f..c73099d 100644 --- a/examples/src/example_common.rs +++ b/examples/src/example_common.rs @@ -18,7 +18,6 @@ static ALLOCATOR: CortexMHeap = CortexMHeap::empty(); #[alloc_error_handler] fn alloc_error(_layout: Layout) -> ! { panic!("Alloc error"); - loop {} } const HEAP_SIZE: usize = 32 * 1024; // in bytes diff --git a/nrf-softdevice-macro/src/lib.rs b/nrf-softdevice-macro/src/lib.rs index 063bc20..d2e4789 100644 --- a/nrf-softdevice-macro/src/lib.rs +++ b/nrf-softdevice-macro/src/lib.rs @@ -2,7 +2,6 @@ extern crate proc_macro; -use core::str::FromStr; use darling::FromMeta; use proc_macro::TokenStream; use proc_macro2::{Span, TokenStream as TokenStream2}; diff --git a/nrf-softdevice/src/ble/central.rs b/nrf-softdevice/src/ble/central.rs index b2aeda2..8318767 100644 --- a/nrf-softdevice/src/ble/central.rs +++ b/nrf-softdevice/src/ble/central.rs @@ -47,8 +47,8 @@ pub async fn connect( let d = OnDrop::new(|| { let ret = unsafe { raw::sd_ble_gap_connect_cancel() }; - if let Err(e) = RawError::convert(ret) { - warn!("sd_ble_gap_connect_cancel: {:?}", e); + if let Err(_e) = RawError::convert(ret) { + warn!("sd_ble_gap_connect_cancel: {:?}", _e); } }); @@ -173,8 +173,8 @@ where let _d = OnDrop::new(|| { let ret = unsafe { raw::sd_ble_gap_scan_stop() }; - if let Err(e) = RawError::convert(ret) { - warn!("sd_ble_gap_scan_stop: {:?}", e); + if let Err(_e) = RawError::convert(ret) { + warn!("sd_ble_gap_scan_stop: {:?}", _e); } }); diff --git a/nrf-softdevice/src/ble/common.rs b/nrf-softdevice/src/ble/common.rs index c14cd76..0ea81eb 100644 --- a/nrf-softdevice/src/ble/common.rs +++ b/nrf-softdevice/src/ble/common.rs @@ -1,4 +1,4 @@ -use crate::fmt::{panic, *}; +use crate::fmt::*; use crate::raw; pub(crate) unsafe fn on_evt(ble_evt: *const raw::ble_evt_t) { @@ -9,9 +9,9 @@ pub(crate) unsafe fn on_evt(ble_evt: *const raw::ble_evt_t) { } } -fn on_user_mem_request(ble_evt: *const raw::ble_evt_t) { +fn on_user_mem_request(_ble_evt: *const raw::ble_evt_t) { trace!("on_user_mem_request"); } -fn on_user_mem_release(ble_evt: *const raw::ble_evt_t) { +fn on_user_mem_release(_ble_evt: *const raw::ble_evt_t) { trace!("on_user_mem_release"); } diff --git a/nrf-softdevice/src/ble/connection.rs b/nrf-softdevice/src/ble/connection.rs index ba3125e..b75eb25 100644 --- a/nrf-softdevice/src/ble/connection.rs +++ b/nrf-softdevice/src/ble/connection.rs @@ -95,7 +95,7 @@ impl ConnectionState { ); let ibh = index_by_handle(conn_handle); - let index = unwrap!(ibh.get(), "bug: conn_handle has no index"); + let _index = unwrap!(ibh.get(), "bug: conn_handle has no index"); ibh.set(None); self.conn_handle = None; @@ -108,7 +108,7 @@ impl ConnectionState { #[cfg(feature = "ble-l2cap")] l2cap::portal(conn_handle).call(ble_evt); - trace!("conn {:?}: disconnected", index); + trace!("conn {:?}: disconnected", _index); } } diff --git a/nrf-softdevice/src/ble/gap.rs b/nrf-softdevice/src/ble/gap.rs index ff67348..d574591 100644 --- a/nrf-softdevice/src/ble/gap.rs +++ b/nrf-softdevice/src/ble/gap.rs @@ -4,7 +4,7 @@ use core::ptr; use crate::ble::*; use crate::fmt::{panic, *}; use crate::raw; -use crate::util::{get_union_field, BoundedLifetime}; +use crate::util::get_union_field; use crate::RawError; pub(crate) unsafe fn on_evt(ble_evt: *const raw::ble_evt_t) { @@ -41,15 +41,15 @@ pub(crate) unsafe fn on_evt(ble_evt: *const raw::ble_evt_t) { }); } raw::BLE_GAP_EVTS_BLE_GAP_EVT_CONN_PARAM_UPDATE => { - let conn_params = gap_evt.params.conn_param_update.conn_params; + let _conn_params = gap_evt.params.conn_param_update.conn_params; debug!( "on_conn_param_update conn_handle={:?} conn_sup_timeout={:?} max_conn_interval={:?} min_conn_interval={:?} slave_latency={:?}", gap_evt.conn_handle, - conn_params.conn_sup_timeout, - conn_params.max_conn_interval, - conn_params.min_conn_interval, - conn_params.slave_latency, + _conn_params.conn_sup_timeout, + _conn_params.max_conn_interval, + _conn_params.min_conn_interval, + _conn_params.slave_latency, ); } raw::BLE_GAP_EVTS_BLE_GAP_EVT_TIMEOUT => { @@ -92,32 +92,32 @@ pub(crate) unsafe fn on_evt(ble_evt: *const raw::ble_evt_t) { let ret = raw::sd_ble_gap_phy_update(conn_handle, &phys as *const raw::ble_gap_phys_t); - if let Err(err) = RawError::convert(ret) { - warn!("sd_ble_gap_phy_update err {:?}", err); + if let Err(_err) = RawError::convert(ret) { + warn!("sd_ble_gap_phy_update err {:?}", _err); } } raw::BLE_GAP_EVTS_BLE_GAP_EVT_PHY_UPDATE => { - let phy_update = gap_evt.params.phy_update; + let _phy_update = gap_evt.params.phy_update; trace!( "on_phy_update conn_handle={:?} status={:?} rx_phy={:?} tx_phy={:?}", gap_evt.conn_handle, - phy_update.status, - phy_update.rx_phy, - phy_update.tx_phy + _phy_update.status, + _phy_update.rx_phy, + _phy_update.tx_phy ); } #[cfg(any(feature = "s113", feature = "s132", feature = "s140"))] raw::BLE_GAP_EVTS_BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST => { - let peer_params = gap_evt.params.data_length_update_request.peer_params; + let _peer_params = gap_evt.params.data_length_update_request.peer_params; trace!( "on_data_length_update_request conn_handle={:?} max_rx_octets={:?} max_rx_time_us={:?} max_tx_octets={:?} max_tx_time_us={:?}", gap_evt.conn_handle, - peer_params.max_rx_octets, - peer_params.max_rx_time_us, - peer_params.max_tx_octets, - peer_params.max_tx_time_us, + _peer_params.max_rx_octets, + _peer_params.max_rx_time_us, + _peer_params.max_tx_octets, + _peer_params.max_tx_time_us, ); let conn_handle = gap_evt.conn_handle; @@ -151,8 +151,8 @@ pub(crate) unsafe fn do_data_length_update( ) { let mut dl_limitation = mem::zeroed(); let ret = raw::sd_ble_gap_data_length_update(conn_handle, params, &mut dl_limitation); - if let Err(err) = RawError::convert(ret) { - warn!("sd_ble_gap_data_length_update err {:?}", err); + if let Err(_err) = RawError::convert(ret) { + warn!("sd_ble_gap_data_length_update err {:?}", _err); if dl_limitation.tx_payload_limited_octets != 0 || dl_limitation.rx_payload_limited_octets != 0 diff --git a/nrf-softdevice/src/ble/gatt_client.rs b/nrf-softdevice/src/ble/gatt_client.rs index 3fc0bd8..2944066 100644 --- a/nrf-softdevice/src/ble/gatt_client.rs +++ b/nrf-softdevice/src/ble/gatt_client.rs @@ -5,7 +5,7 @@ use heapless::Vec; use num_enum::{FromPrimitive, IntoPrimitive}; use crate::ble::*; -use crate::fmt::{assert, assert_ne, panic, unreachable, *}; +use crate::fmt::{assert, assert_ne, panic, unreachable}; use crate::raw; use crate::util::{get_flexarray, get_union_field, Portal}; use crate::RawError; @@ -282,7 +282,7 @@ async fn discover_inner<T: Client>( let descs = { match discover_descriptors(conn, start_handle, end_handle).await { Ok(descs) => descs, - Err(DiscoverError::Gatt(AtterrAttributeNotFound)) => Vec::new(), + Err(DiscoverError::Gatt(GattError::AtterrAttributeNotFound)) => Vec::new(), Err(err) => return Err(err), } }; diff --git a/nrf-softdevice/src/ble/gatt_server.rs b/nrf-softdevice/src/ble/gatt_server.rs index 0004448..ccb17bb 100644 --- a/nrf-softdevice/src/ble/gatt_server.rs +++ b/nrf-softdevice/src/ble/gatt_server.rs @@ -4,7 +4,6 @@ //! In a connection any device can be server and client, and even both can be both at the same time. use core::mem; -use core::ptr; use crate::ble::*; use crate::fmt::{panic, *}; @@ -283,8 +282,8 @@ pub(crate) unsafe fn on_evt(ble_evt: *const raw::ble_evt_t) { ); let ret = { raw::sd_ble_gatts_exchange_mtu_reply(conn_handle, mtu) }; - if let Err(err) = RawError::convert(ret) { - warn!("sd_ble_gatts_exchange_mtu_reply err {:?}", err); + if let Err(_err) = RawError::convert(ret) { + warn!("sd_ble_gatts_exchange_mtu_reply err {:?}", _err); return; } diff --git a/nrf-softdevice/src/ble/l2cap.rs b/nrf-softdevice/src/ble/l2cap.rs index 3e1528e..29264a2 100644 --- a/nrf-softdevice/src/ble/l2cap.rs +++ b/nrf-softdevice/src/ble/l2cap.rs @@ -167,14 +167,12 @@ impl<P: Packet> L2cap<P> { // default is 1 if config.credits != 1 { - let ret = unsafe { - raw::sd_ble_l2cap_ch_flow_control( - conn_handle, - cid, - config.credits, - ptr::null_mut(), - ) - }; + let ret = raw::sd_ble_l2cap_ch_flow_control( + conn_handle, + cid, + config.credits, + ptr::null_mut(), + ); if let Err(err) = RawError::convert(ret) { warn!("sd_ble_l2cap_ch_flow_control err {:?}", err); return Err(err.into()); @@ -239,14 +237,12 @@ impl<P: Packet> L2cap<P> { // default is 1 if config.credits != 1 { - let ret = unsafe { - raw::sd_ble_l2cap_ch_flow_control( - conn_handle, - cid, - config.credits, - ptr::null_mut(), - ) - }; + let ret = raw::sd_ble_l2cap_ch_flow_control( + conn_handle, + cid, + config.credits, + ptr::null_mut(), + ); if let Err(err) = RawError::convert(ret) { warn!("sd_ble_l2cap_ch_flow_control err {:?}", err); return Some(Err(err.into())); @@ -266,8 +262,8 @@ impl<P: Packet> L2cap<P> { }; let ret = raw::sd_ble_l2cap_ch_setup(conn_handle, &mut cid, ¶ms); - if let Err(err) = RawError::convert(ret) { - warn!("sd_ble_l2cap_ch_setup err {:?}", err); + if let Err(_err) = RawError::convert(ret) { + warn!("sd_ble_l2cap_ch_setup err {:?}", _err); } None diff --git a/nrf-softdevice/src/ble/peripheral.rs b/nrf-softdevice/src/ble/peripheral.rs index 267dd00..8ea1842 100644 --- a/nrf-softdevice/src/ble/peripheral.rs +++ b/nrf-softdevice/src/ble/peripheral.rs @@ -141,8 +141,8 @@ pub async fn advertise( let d = OnDrop::new(|| { let ret = unsafe { raw::sd_ble_gap_adv_stop(ADV_HANDLE) }; - if let Err(e) = RawError::convert(ret) { - warn!("sd_ble_gap_adv_stop: {:?}", e); + if let Err(_e) = RawError::convert(ret) { + warn!("sd_ble_gap_adv_stop: {:?}", _e); } }); diff --git a/nrf-softdevice/src/flash.rs b/nrf-softdevice/src/flash.rs index 6f9aaad..46edda2 100644 --- a/nrf-softdevice/src/flash.rs +++ b/nrf-softdevice/src/flash.rs @@ -86,8 +86,8 @@ impl embassy::flash::Flash for Flash { let ret = unsafe { raw::sd_flash_write(address as _, words_ptr, words_len) }; let ret = match RawError::convert(ret) { Ok(()) => SIGNAL.wait().await, - Err(e) => { - warn!("sd_flash_write err {:?}", e); + Err(_e) => { + warn!("sd_flash_write err {:?}", _e); Err(FlashError::Failed) } }; @@ -109,8 +109,8 @@ impl embassy::flash::Flash for Flash { let ret = unsafe { raw::sd_flash_page_erase(page_number as u32) }; let ret = match RawError::convert(ret) { Ok(()) => SIGNAL.wait().await, - Err(e) => { - warn!("sd_flash_page_erase err {:?}", e); + Err(_e) => { + warn!("sd_flash_page_erase err {:?}", _e); Err(FlashError::Failed) } }; diff --git a/nrf-softdevice/src/fmt.rs b/nrf-softdevice/src/fmt.rs index 07df465..1abb329 100644 --- a/nrf-softdevice/src/fmt.rs +++ b/nrf-softdevice/src/fmt.rs @@ -73,7 +73,7 @@ macro_rules! unwrap { ($arg:expr$(,$msg:expr)*) => { match $crate::fmt::Try::into_result($arg) { ::core::result::Result::Ok(t) => t, - ::core::result::Result::Err(e) => { + ::core::result::Result::Err(_e) => { ::core::panic!($($msg,)*); } } diff --git a/nrf-softdevice/src/lib.rs b/nrf-softdevice/src/lib.rs index 50ceb56..dded76e 100644 --- a/nrf-softdevice/src/lib.rs +++ b/nrf-softdevice/src/lib.rs @@ -4,6 +4,7 @@ #![feature(type_alias_impl_trait)] #![feature(const_fn)] #![feature(cell_update)] +#![allow(incomplete_features)] pub(crate) mod util; diff --git a/nrf-softdevice/src/util/mod.rs b/nrf-softdevice/src/util/mod.rs index f13f0f2..b82c893 100644 --- a/nrf-softdevice/src/util/mod.rs +++ b/nrf-softdevice/src/util/mod.rs @@ -4,8 +4,6 @@ mod signal; pub use signal::*; mod portal; pub use portal::*; -mod waker_store; -pub use waker_store::*; mod drop_bomb; pub use drop_bomb::*; mod on_drop; @@ -36,21 +34,6 @@ pub(crate) unsafe fn get_flexarray<T>( core::slice::from_raw_parts(sanitized_ptr, count) } -/// Create a slice from a variable-length array in a BLE event. -/// -/// This function is a workaround for UB in __IncompleteArrayField -/// see https://github.com/rust-lang/rust-bindgen/issues/1892 -/// see https://github.com/rust-lang/unsafe-code-guidelines/issues/134 -pub(crate) unsafe fn get_flexarray2<T>( - orig_ptr: *const raw::ble_evt_t, - array: &[T; 0], - count: usize, -) -> &[T] { - let offs = array.as_ptr() as usize - orig_ptr as usize; - let sanitized_ptr = (orig_ptr as *const u8).add(offs) as *const T; - core::slice::from_raw_parts(sanitized_ptr, count) -} - /// Get a &T from a __BindgenUnionField<T> in a BLE event. /// /// This function is a workaround for UB in __BindgenUnionField diff --git a/nrf-softdevice/src/util/waker_store.rs b/nrf-softdevice/src/util/waker_store.rs deleted file mode 100644 index 0b2f09f..0000000 --- a/nrf-softdevice/src/util/waker_store.rs +++ /dev/null @@ -1,23 +0,0 @@ -use core::task::Waker; - -pub struct WakerStore { - waker: Option<Waker>, -} - -impl WakerStore { - pub const fn new() -> Self { - Self { waker: None } - } - - pub fn store(&mut self, w: &Waker) { - match self.waker { - Some(ref w2) if (w2.will_wake(w)) => {} - Some(_) => panic!("Waker overflow"), - None => self.waker = Some(w.clone()), - } - } - - pub fn wake(&mut self) { - self.waker.take().map(|w| w.wake()); - } -} |