uefi: check_event: consume Event by reference

Cloning Events is inconvenient, so we make the life if devs a little
easier.
This commit is contained in:
Philipp Schuster 2025-12-01 21:16:33 +01:00
parent d2e2acf75b
commit 0413a7e0a7
5 changed files with 11 additions and 10 deletions

View file

@ -11,7 +11,8 @@ fn read_keyboard_events(input: &mut Input) -> Result {
println!("waiting for key press...");
// Pause until a keyboard event occurs.
let mut events = [input.wait_for_key_event().unwrap()];
let event = input.wait_for_key_event()?;
let mut events = [event];
boot::wait_for_event(&mut events).discard_errdata()?;
match input.read_key()? {

View file

@ -45,8 +45,7 @@ fn test_check_event() {
unsafe { boot::create_event(EventType::NOTIFY_WAIT, Tpl::CALLBACK, Some(callback), None) }
.unwrap();
let event_clone = unsafe { event.unsafe_clone() };
let is_signaled = boot::check_event(event_clone).unwrap();
let is_signaled = boot::check_event(&event).unwrap();
assert!(!is_signaled);
boot::close_event(event).unwrap();
@ -56,8 +55,8 @@ fn test_timer() {
let timer_event =
unsafe { boot::create_event_ex(EventType::TIMER, Tpl::CALLBACK, None, None, None) }
.unwrap();
let mut events = unsafe { [timer_event.unsafe_clone()] };
boot::set_timer(&timer_event, TimerTrigger::Relative(5_0 /*00 ns */)).unwrap();
let mut events = [unsafe { timer_event.unsafe_clone() }];
assert_eq!(boot::wait_for_event(&mut events).unwrap(), 0);
boot::close_event(timer_event).unwrap();
@ -89,7 +88,7 @@ fn test_callback_with_ctx() {
.expect("Failed to create event with context")
};
boot::check_event(event).expect("Failed to check event");
boot::check_event(&event).expect("Failed to check event");
// Check that `data` was updated inside the event callback.
assert_eq!(data, 456);

View file

@ -309,7 +309,7 @@ fn test_raw_disk_io2(handle: Handle) {
unsafe {
// Create the completion event
let mut event = boot::create_event(EventType::empty(), Tpl::NOTIFY, None, None)
let event = boot::create_event(EventType::empty(), Tpl::NOTIFY, None, None)
.expect("Failed to create disk I/O completion event");
// Initialise the task context
@ -333,8 +333,7 @@ fn test_raw_disk_io2(handle: Handle) {
.expect("Failed to initiate asynchronous disk I/O read");
// Wait for the transaction to complete
boot::wait_for_event(core::slice::from_mut(&mut event))
.expect("Failed to wait on completion event");
boot::wait_for_event(&mut [event]).expect("Failed to wait on completion event");
// Verify that the disk's MBR signature is correct
assert_eq!(task.token.transaction_status, Status::SUCCESS);