std/os/uefi: Simplify packed struct padding and default zero-initialize

Beyond adding default zero-initialization, this commit changes undefined
initialization to zero, as some cases reserved the padding and on other
cases, I've found some systems act strange when giving uninit instead of
zero even when it shouldn't be an issue, one example being
FileProtocol.Open's attributes, which *should* be ignored when not
creating a file, but ended up giving an unrelated error.
This commit is contained in:
fifty-six
2022-01-16 01:44:15 -05:00
parent dab4c63684
commit 4771ac298b
7 changed files with 10 additions and 24 deletions

View File

@@ -98,7 +98,6 @@ pub const Time = extern struct {
/// 0 - 59
second: u8,
_pad1: u8,
/// 0 - 999999999
nanosecond: u32,
@@ -115,7 +114,6 @@ pub const Time = extern struct {
/// If true, the time is affected by daylight savings time.
adjust_daylight: bool,
},
_pad2: u8,
/// Time is to be interpreted as local time
pub const unspecified_timezone: i16 = 0x7ff;

View File

@@ -40,9 +40,7 @@ pub const AbsolutePointerMode = extern struct {
attributes: packed struct {
supports_alt_active: bool,
supports_pressure_as_z: bool,
_pad1: u6,
_pad2: u8,
_pad3: u16,
_pad: u30 = 0,
},
};
@@ -53,8 +51,6 @@ pub const AbsolutePointerState = extern struct {
active_buttons: packed struct {
touch_active: bool,
alt_active: bool,
_pad1: u6,
_pad2: u8,
_pad3: u16,
_pad: u30 = 0,
},
};

View File

@@ -26,7 +26,5 @@ pub const EdidOverrideProtocol = extern struct {
pub const EdidOverrideProtocolAttributes = packed struct {
dont_override: bool,
enable_hot_plug: bool,
_pad1: u6,
_pad2: u8,
_pad3: u16,
_pad: u30 = 0,
};

View File

@@ -48,7 +48,7 @@ pub const NarrowGlyph = extern struct {
attributes: packed struct {
non_spacing: bool,
wide: bool,
_pad: u6,
_pad: u6 = 0,
},
glyph_col_1: [19]u8,
};
@@ -62,7 +62,7 @@ pub const WideGlyph = extern struct {
},
glyph_col_1: [19]u8,
glyph_col_2: [19]u8,
_pad: [3]u8,
_pad: [3]u8 = [_]u8{0} ** 3,
};
pub const HIIStringPackage = extern struct {

View File

@@ -126,9 +126,7 @@ pub const SimpleNetworkReceiveFilter = packed struct {
receive_broadcast: bool,
receive_promiscuous: bool,
receive_promiscuous_multicast: bool,
_pad1: u3 = undefined,
_pad2: u8 = undefined,
_pad3: u16 = undefined,
_pad: u27 = 0,
};
pub const SimpleNetworkState = enum(u32) {
@@ -171,7 +169,5 @@ pub const SimpleNetworkInterruptStatus = packed struct {
transmit_interrupt: bool,
command_interrupt: bool,
software_interrupt: bool,
_pad1: u4,
_pad2: u8,
_pad3: u16,
_pad: u28 = 0,
};

View File

@@ -64,14 +64,14 @@ pub const KeyState = extern struct {
left_logo_pressed: bool,
menu_key_pressed: bool,
sys_req_pressed: bool,
_pad1: u21,
_pad: u21 = 0,
shift_state_valid: bool,
},
key_toggle_state: packed struct {
scroll_lock_active: bool,
num_lock_active: bool,
caps_lock_active: bool,
_pad1: u3,
_pad: u3 = 0,
key_state_exposed: bool,
toggle_state_valid: bool,
},

View File

@@ -239,9 +239,7 @@ pub const OpenProtocolAttributes = packed struct {
by_child_controller: bool = false,
by_driver: bool = false,
exclusive: bool = false,
_pad1: u2 = undefined,
_pad2: u8 = undefined,
_pad3: u16 = undefined,
_pad: u26 = 0,
};
pub const ProtocolInformationEntry = extern struct {