Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0551959

Browse files
HadrienG2GabrielMajeri
authored andcommitted
Mark EFI status codes as must_use and check them
1 parent 47963af commit 0551959

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

‎src/error/status.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const HIGHEST_BIT_SET: usize = !((!0_usize) >> 1);
1111
/// to indicate whether an operation completed successfully.
1212
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
1313
#[repr(usize)]
14+
#[must_use]
1415
pub enum Status {
1516
/// The operation completed successfully.
1617
Success,

‎src/table/boot.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ impl BootServices {
101101
let mut entry_size = 0;
102102
let mut entry_version = 0;
103103

104-
(self.memory_map)(&mut map_size, 0, &mut map_key, &mut entry_size, &mut entry_version);
104+
let status = (self.memory_map)(&mut map_size, 0, &mut map_key, &mut entry_size, &mut entry_version);
105+
assert_eq!(status, Status::BufferTooSmall);
105106

106107
map_size * entry_size
107108
}
@@ -210,8 +211,7 @@ impl BootServices {
210211
///
211212
/// The time is in microseconds.
212213
pub fn stall(&self, time: usize) {
213-
// The spec says this cannot fail.
214-
(self.stall)(time);
214+
assert_eq!((self.stall)(time), Status::Success);
215215
}
216216

217217
/// Copies memory from source to destination. The buffers can overlap.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /