Merge pull request #515 from betrusted-io/1.77.0-xous-warning-fixes

kernel: use addr_of!() and addr_of_mut!()
This commit is contained in:
bunnie 2024-03-23 11:52:49 +08:00 committed by GitHub
commit 72fda565cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 6 deletions

View file

@ -516,7 +516,7 @@ impl Process {
}
pub fn destroy(pid: PID) -> Result<(), xous_kernel::Error> {
let process_table = unsafe { &mut PROCESS_TABLE };
let process_table = unsafe { &mut *core::ptr::addr_of_mut!(PROCESS_TABLE) };
let pid_idx = pid.get() as usize - 1;
if pid_idx >= process_table.table.len() {
panic!("attempted to destroy PID that exceeds table index: {}", pid);
@ -597,7 +597,7 @@ impl core::fmt::Display for Thread {
pub fn set_current_pid(pid: PID) {
let pid_idx = (pid.get() - 1) as usize;
unsafe {
let pt = &mut PROCESS_TABLE;
let pt = &mut *core::ptr::addr_of_mut!(PROCESS_TABLE);
match pt.table.get(pid_idx) {
None | Some(false) => panic!("PID {} does not exist", pid),

View file

@ -93,7 +93,7 @@ impl MemoryManager {
{
#[cfg(baremetal)]
unsafe {
f(&mut MEMORY_MANAGER)
f(&mut *core::ptr::addr_of_mut!(MEMORY_MANAGER))
}
#[cfg(not(baremetal))]
@ -107,7 +107,7 @@ impl MemoryManager {
{
#[cfg(baremetal)]
unsafe {
f(&MEMORY_MANAGER)
f(&*core::ptr::addr_of!(MEMORY_MANAGER))
}
#[cfg(not(baremetal))]

View file

@ -314,7 +314,7 @@ impl SystemServices {
{
#[cfg(baremetal)]
unsafe {
f(&SYSTEM_SERVICES)
f(&*core::ptr::addr_of!(SYSTEM_SERVICES))
}
#[cfg(not(baremetal))]
SYSTEM_SERVICES.with(|ss| f(&ss.borrow()))
@ -326,7 +326,7 @@ impl SystemServices {
{
#[cfg(baremetal)]
unsafe {
f(&mut SYSTEM_SERVICES)
f(&mut *core::ptr::addr_of_mut!(SYSTEM_SERVICES))
}
#[cfg(not(baremetal))]