Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix static mut ref warnings in rust 1.83+ #288

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nrf-softdevice/src/ble/central.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ where
// has been dropped and the scanning has been stopped.
static mut BUF: [u8; BUF_LEN] = [0u8; BUF_LEN];
static mut BUF_DATA: raw::ble_data_t = raw::ble_data_t {
p_data: unsafe { BUF.as_mut_ptr() },
p_data: unsafe { (&mut *(&raw mut BUF)).as_mut_ptr() },
len: BUF_LEN as u16,
};

Expand Down
2 changes: 1 addition & 1 deletion nrf-softdevice/src/ble/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ pub(crate) fn with_state<T>(index: u8, f: impl FnOnce(&mut ConnectionState) -> T

fn allocate_index<T>(f: impl FnOnce(u8, &mut ConnectionState) -> T) -> Result<T, OutOfConnsError> {
unsafe {
for (i, s) in STATES.iter().enumerate() {
for (i, s) in (&*(&raw const STATES)).iter().enumerate() {
let state = &mut *s.get();
if state.refcount == 0 && !state.conn_handle.is_connected() {
return Ok(f(i as u8, state));
Expand Down
4 changes: 2 additions & 2 deletions nrf-softdevice/src/softdevice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ impl Softdevice {
};

unsafe {
let p = SOFTDEVICE.as_mut_ptr();
let p = (&mut *(&raw mut SOFTDEVICE)).as_mut_ptr();
p.write(sd);
&mut *p
}
Expand All @@ -298,7 +298,7 @@ impl Softdevice {
/// (a call to [`enable`] has returned without error) and no `&mut` references
/// to the softdevice are active
pub unsafe fn steal() -> &'static Softdevice {
&*SOFTDEVICE.as_ptr()
&*(&*(&raw const SOFTDEVICE)).as_ptr()
}

/// Runs the softdevice event handling loop.
Expand Down
Loading