Skip to content

Commit

Permalink
UefiHidDxeV2: Remove mutable static shared reference
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
makubacki committed Oct 1, 2024
1 parent 0387f45 commit 69b4a00
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion HidPkg/UefiHidDxeV2/src/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 69b4a00

Please sign in to comment.