Skip to content

Commit d095403

Browse files
uefi: Remove non-protocol uses of unsafe_guid
The `unsafe_guid` macro is almost always used for creating protocols. There are three other uses though, for identifying file info types. Replace these with explicit impls of the `Identify` trait. Now that we have a `guid!` macro, this doesn't reduce the clarity of the code at all.
1 parent 1d0a081 commit d095403

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

Diff for: uefi/src/proto/media/file/info.rs

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use super::FileAttribute;
22
use crate::data_types::Align;
33
use crate::table::runtime::Time;
4-
use crate::{unsafe_guid, CStr16, Char16, Identify};
4+
use crate::{guid, CStr16, Char16, Guid, Identify};
55
use core::ffi::c_void;
66
use core::{mem, ptr};
77

@@ -142,7 +142,6 @@ pub enum FileInfoCreationError {
142142
/// attribute. Other changes must be carried out in a separate transaction.
143143
#[derive(Debug, Eq, PartialEq)]
144144
#[repr(C)]
145-
#[unsafe_guid("09576e92-6d3f-11d2-8e39-00a0c969723b")]
146145
pub struct FileInfo {
147146
size: u64,
148147
file_size: u64,
@@ -237,6 +236,10 @@ impl Align for FileInfo {
237236
}
238237
}
239238

239+
unsafe impl Identify for FileInfo {
240+
const GUID: Guid = guid!("09576e92-6d3f-11d2-8e39-00a0c969723b");
241+
}
242+
240243
impl InfoInternal for FileInfo {
241244
fn name_offset() -> usize {
242245
80
@@ -253,7 +256,6 @@ impl FileProtocolInfo for FileInfo {}
253256
/// this information structure. Consider using `FileSystemVolumeLabel` instead.
254257
#[derive(Debug, Eq, PartialEq)]
255258
#[repr(C)]
256-
#[unsafe_guid("09576e93-6d3f-11d2-8e39-00a0c969723b")]
257259
pub struct FileSystemInfo {
258260
size: u64,
259261
read_only: bool,
@@ -329,6 +331,10 @@ impl Align for FileSystemInfo {
329331
}
330332
}
331333

334+
unsafe impl Identify for FileSystemInfo {
335+
const GUID: Guid = guid!("09576e93-6d3f-11d2-8e39-00a0c969723b");
336+
}
337+
332338
impl InfoInternal for FileSystemInfo {
333339
fn name_offset() -> usize {
334340
36
@@ -342,7 +348,6 @@ impl FileProtocolInfo for FileSystemInfo {}
342348
/// May only be obtained on the root directory's file handle.
343349
#[derive(Debug, Eq, PartialEq)]
344350
#[repr(C)]
345-
#[unsafe_guid("db47d7d3-fe81-11d3-9a35-0090273fc14d")]
346351
pub struct FileSystemVolumeLabel {
347352
volume_label: [Char16],
348353
}
@@ -377,6 +382,10 @@ impl Align for FileSystemVolumeLabel {
377382
}
378383
}
379384

385+
unsafe impl Identify for FileSystemVolumeLabel {
386+
const GUID: Guid = guid!("db47d7d3-fe81-11d3-9a35-0090273fc14d");
387+
}
388+
380389
impl InfoInternal for FileSystemVolumeLabel {
381390
fn name_offset() -> usize {
382391
0

0 commit comments

Comments
 (0)