Skip to content

Commit aead334

Browse files
committed
uefi: Make IFR structs repr(C)
- Mark all packed structs as repr(C) - Derive Clone/Copy on IfrQuestionHeader to fix deriving Debug Fixes the following compiler errors: error: reference to packed field is unaligned error: `Debug` can't be derived on this `#[repr(packed)]` struct that does not derive `Copy` Signed-off-by: Tim Crawford <[email protected]>
1 parent fcdb04f commit aead334

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

crates/uefi/src/hii/ifr.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub struct HiiDate {
3838
}
3939

4040
#[derive(Clone, Copy, Debug, PartialEq)]
41-
#[repr(packed)] // Fails to have correct size with repr(C)
41+
#[repr(C, packed)] // Fails to have correct size with repr(C)
4242
pub struct HiiRef {
4343
pub QuestionId: QuestionId,
4444
pub FormId: FormId,
@@ -47,7 +47,7 @@ pub struct HiiRef {
4747
}
4848

4949
#[derive(Clone, Copy)]
50-
#[repr(packed)] // Fails to have correct size with repr(C)
50+
#[repr(C, packed)] // Fails to have correct size with repr(C)
5151
pub union IfrTypeValue {
5252
u8: u8,
5353
u16: u16,
@@ -133,8 +133,8 @@ pub const IFR_FLAG_RESET_REQUIRED: u8 = 0x10;
133133
pub const IFR_FLAG_RECONNECT_REQUIRED: u8 = 0x40;
134134
pub const IFR_FLAG_OPTIONS_ONLY: u8 = 0x80;
135135

136-
#[derive(Debug)]
137-
#[repr(packed)] // Has incorrect size if not packed
136+
#[derive(Clone, Copy, Debug)]
137+
#[repr(C, packed)] // Has incorrect size if not packed
138138
pub struct IfrQuestionHeader {
139139
pub Header: IfrStatementHeader,
140140
pub QuestionId: QuestionId,
@@ -310,7 +310,7 @@ impl IfrAction {
310310
}
311311

312312
#[derive(Debug)]
313-
#[repr(packed)] // Has incorrect size if not packed
313+
#[repr(C, packed)] // Has incorrect size if not packed
314314
pub struct IfrCheckbox {
315315
pub Header: IfrOpHeader,
316316
pub Question: IfrQuestionHeader,
@@ -326,7 +326,7 @@ pub struct IfrForm {
326326
}
327327

328328
#[derive(Debug)]
329-
#[repr(packed)] // Has incorrect size if not packed
329+
#[repr(C, packed)] // Has incorrect size if not packed
330330
pub struct IfrNumeric {
331331
pub Header: IfrOpHeader,
332332
pub Question: IfrQuestionHeader,
@@ -385,7 +385,7 @@ impl IfrRef {
385385
unsafe_field!(UnsafeIfrRef, DevicePath, *const u16);
386386
}
387387

388-
#[repr(packed)] // Has incorrect size if not packed
388+
#[repr(C, packed)] // Has incorrect size if not packed
389389
pub struct IfrSubtitle {
390390
pub Header: IfrOpHeader,
391391
pub Statement: IfrStatementHeader,

0 commit comments

Comments
 (0)