From 69b4a001cd4671e64b48ac262e1eb96bb5f9b14d Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Tue, 1 Oct 2024 13:53:22 -0400 Subject: [PATCH] UefiHidDxeV2: Remove mutable static shared reference Use `addr_of!()` (raw pointer) to prevent a reference being created to the mutable static variable. ``` = note: this will be a hard error in the 2024 edition = note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior ``` Signed-off-by: Michael Kubacki --- HidPkg/UefiHidDxeV2/src/keyboard.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HidPkg/UefiHidDxeV2/src/keyboard.rs b/HidPkg/UefiHidDxeV2/src/keyboard.rs index 4772e43d88..fb0baf53be 100644 --- a/HidPkg/UefiHidDxeV2/src/keyboard.rs +++ b/HidPkg/UefiHidDxeV2/src/keyboard.rs @@ -1012,7 +1012,7 @@ mod test { keyboard_layout_ptr: *mut protocols::hii_database::KeyboardLayout, ) -> efi::Status { let mut keyboard_layout_buffer = vec![0u8; 4096]; - let buffer_size = keyboard_layout_buffer.pwrite(unsafe { &TEST_KEYBOARD_LAYOUT }, 0).unwrap(); + let buffer_size = keyboard_layout_buffer.pwrite(unsafe { ptr::addr_of!(TEST_KEYBOARD_LAYOUT) }, 0).unwrap(); keyboard_layout_buffer.resize(buffer_size, 0); unsafe { if keyboard_layout_length.read() < buffer_size as u16 {