Update code for Rust 1.82.0
The `addr_of!` and `addr_of_mut!` macros are no longer unsafe.
Test: m out/soong/.intermediates/packages/modules/Virtualization/libs/libvmbase/libvmbase/android_arm64_armv8-a_cortex-a53_rlib_rlib-std/libvmbase.rlib
Bug: 369422063
Change-Id: I249fbf4752c7240acd096cda205c678c74baf4b1
diff --git a/libs/libvmbase/src/bionic.rs b/libs/libvmbase/src/bionic.rs
index 3c0cd6f..580b0cb 100644
--- a/libs/libvmbase/src/bionic.rs
+++ b/libs/libvmbase/src/bionic.rs
@@ -72,11 +72,10 @@
pub static mut ERRNO: c_int = 0;
#[no_mangle]
-#[allow(unused_unsafe)]
+// SAFETY: C functions which call this are only called from the main thread, not from exception
+// handlers.
unsafe extern "C" fn __errno() -> *mut c_int {
- // SAFETY: C functions which call this are only called from the main thread, not from exception
- // handlers.
- unsafe { addr_of_mut!(ERRNO) as *mut _ }
+ addr_of_mut!(ERRNO) as *mut _
}
fn set_errno(value: c_int) {
diff --git a/libs/libvmbase/src/layout.rs b/libs/libvmbase/src/layout.rs
index cf3a8fc..ad7a390 100644
--- a/libs/libvmbase/src/layout.rs
+++ b/libs/libvmbase/src/layout.rs
@@ -44,9 +44,7 @@
#[macro_export]
macro_rules! linker_addr {
($symbol:ident) => {{
- // SAFETY: We're just getting the address of an extern static symbol provided by the linker,
- // not dereferencing it.
- let addr = unsafe { addr_of!($crate::linker::$symbol) as usize };
+ let addr = addr_of!($crate::linker::$symbol) as usize;
VirtualAddress(addr)
}};
}