Skip to content

Commit f7558fd

Browse files
committed
fix(menu): prevent masking of wait for event errors if closing the timer event fails
1 parent d1fd131 commit f7558fd

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/menu.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::entries::BootableEntry;
22
use crate::integrations::bootloader_interface::BootloaderInterface;
33
use crate::platform::timer::PlatformTimer;
44
use anyhow::{Context, Result, bail};
5-
use log::info;
5+
use log::{info, warn};
66
use std::time::Duration;
77
use uefi::ResultExt;
88
use uefi::boot::TimerTrigger;
@@ -66,7 +66,20 @@ fn read(input: &mut Input, timeout: &Duration) -> Result<MenuOperation> {
6666
// Close the timer event that we acquired.
6767
// We don't need to close the key event because it is owned globally.
6868
if let Some(timer_event) = events.into_iter().next() {
69-
uefi::boot::close_event(timer_event).context("unable to close timer event")?;
69+
// Store the result of the close event so we can determine if we can safely assert it.
70+
let close_event_result =
71+
uefi::boot::close_event(timer_event).context("unable to close timer event");
72+
if event_result.is_err()
73+
&& let Err(ref close_event_error) = close_event_result
74+
{
75+
// Log a warning if we failed to close the timer event.
76+
// This is done to ensure we don't mask the wait_for_event error.
77+
warn!("unable to close timer event: {}", close_event_error);
78+
} else {
79+
// If we reach here, we can safely assert that the close event succeeded without
80+
// masking the wait_for_event error.
81+
close_event_result?;
82+
}
7083
}
7184

7285
// Acquire the event that triggered.

0 commit comments

Comments
 (0)