Skip to content

Commit e55f796

Browse files
committed
uefi: return Result<Event> rather than Option<Event>
For all three functions, it is the normal / good case to be there. We can also see this in the edk2 implementations of the corresponding functions.
1 parent 075c47c commit e55f796

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

uefi/src/proto/console/pointer/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
//! Pointer device access.
44
5+
use crate::Error;
56
use crate::proto::unsafe_protocol;
67
use crate::{Event, Result, Status, StatusExt};
78
use uefi_raw::protocol::console::SimplePointerProtocol;
@@ -53,9 +54,8 @@ impl Pointer {
5354
/// for input from the pointer device
5455
///
5556
/// [`boot::wait_for_event`]: crate::boot::wait_for_event
56-
#[must_use]
57-
pub fn wait_for_input_event(&self) -> Option<Event> {
58-
Event::from_ptr(self.0.wait_for_input)
57+
pub fn wait_for_input_event(&self) -> Result<Event> {
58+
Event::from_ptr(self.0.wait_for_input).ok_or(Error::from(Status::UNSUPPORTED))
5959
}
6060

6161
/// Returns a reference to the pointer device information.

uefi/src/proto/console/text/input.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: MIT OR Apache-2.0
22

33
use crate::proto::unsafe_protocol;
4-
use crate::{Char16, Event, Result, Status, StatusExt};
4+
use crate::{Char16, Error, Event, Result, Status, StatusExt};
55
use core::mem::MaybeUninit;
66
use uefi_raw::protocol::console::{InputKey, SimpleTextInputProtocol};
77

@@ -84,9 +84,8 @@ impl Input {
8484
/// for a key to be available
8585
///
8686
/// [`boot::wait_for_event`]: crate::boot::wait_for_event
87-
#[must_use]
88-
pub fn wait_for_key_event(&self) -> Option<Event> {
89-
Event::from_ptr(self.0.wait_for_key)
87+
pub fn wait_for_key_event(&self) -> Result<Event> {
88+
Event::from_ptr(self.0.wait_for_key).ok_or(Error::from(Status::UNSUPPORTED))
9089
}
9190
}
9291

uefi/src/proto/network/snp.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ use core::ffi::c_void;
1616
use core::net::IpAddr;
1717
use core::ptr;
1818
use core::ptr::NonNull;
19+
use uefi::Error;
1920
use uefi_raw::protocol::network::snp::SimpleNetworkProtocol;
20-
use uefi_raw::{Boolean, IpAddress as EfiIpAddr, MacAddress as EfiMacAddr};
21+
use uefi_raw::{Boolean, IpAddress as EfiIpAddr, MacAddress as EfiMacAddr, Status};
2122

2223
pub use uefi_raw::protocol::network::snp::{
2324
InterruptStatus, NetworkMode, NetworkState, NetworkStatistics, ReceiveFlags,
@@ -269,9 +270,8 @@ impl SimpleNetwork {
269270
///
270271
/// On QEMU, this event seems to never fire; it is suggested to verify that your implementation
271272
/// of UEFI properly implements this event before using it.
272-
#[must_use]
273-
pub fn wait_for_packet_event(&self) -> Option<Event> {
274-
Event::from_ptr(self.0.wait_for_packet)
273+
pub fn wait_for_packet_event(&self) -> Result<Event> {
274+
Event::from_ptr(self.0.wait_for_packet).ok_or(Error::from(Status::UNSUPPORTED))
275275
}
276276

277277
/// Returns a reference to the Simple Network mode.

0 commit comments

Comments
 (0)