authorgravatar for ybham6@gmail.comfifty-six <ybham6@gmail.com> 2022-01-16 01:44:15-05:00
committergravatar for ybham6@gmail.comfifty-six <ybham6@gmail.com> 2022-01-16 02:04:39-05:00
log4771ac298b0c692750524cb7e94eaf0b4343ce2b
tree42b74453b3af7bc3cac4c0db9e9b4583348ca1ea
parentdab4c63684ca951049fb8e8f6b2415857eb6652b

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.

7 files changed, 10 insertions(+), 24 deletions(-)

lib/std/os/uefi.zig-2
......@@ -98,7 +98,6 @@ pub const Time = extern struct {
9898
9999 /// 0 - 59
100100 second: u8,
101 _pad1: u8,
102101
103102 /// 0 - 999999999
104103 nanosecond: u32,
......@@ -115,7 +114,6 @@ pub const Time = extern struct {
115114 /// If true, the time is affected by daylight savings time.
116115 adjust_daylight: bool,
117116 },
118 _pad2: u8,
119117
120118 /// Time is to be interpreted as local time
121119 pub const unspecified_timezone: i16 = 0x7ff;
lib/std/os/uefi/protocols/absolute_pointer_protocol.zig+2-6
......@@ -40,9 +40,7 @@ pub const AbsolutePointerMode = extern struct {
4040 attributes: packed struct {
4141 supports_alt_active: bool,
4242 supports_pressure_as_z: bool,
43 _pad1: u6,
44 _pad2: u8,
45 _pad3: u16,
43 _pad: u30 = 0,
4644 },
4745};
4846
......@@ -53,8 +51,6 @@ pub const AbsolutePointerState = extern struct {
5351 active_buttons: packed struct {
5452 touch_active: bool,
5553 alt_active: bool,
56 _pad1: u6,
57 _pad2: u8,
58 _pad3: u16,
54 _pad: u30 = 0,
5955 },
6056};
lib/std/os/uefi/protocols/edid_override_protocol.zig+1-3
......@@ -26,7 +26,5 @@ pub const EdidOverrideProtocol = extern struct {
2626pub const EdidOverrideProtocolAttributes = packed struct {
2727 dont_override: bool,
2828 enable_hot_plug: bool,
29 _pad1: u6,
30 _pad2: u8,
31 _pad3: u16,
29 _pad: u30 = 0,
3230};
lib/std/os/uefi/protocols/hii.zig+2-2
......@@ -48,7 +48,7 @@ pub const NarrowGlyph = extern struct {
4848 attributes: packed struct {
4949 non_spacing: bool,
5050 wide: bool,
51 _pad: u6,
51 _pad: u6 = 0,
5252 },
5353 glyph_col_1: [19]u8,
5454};
......@@ -62,7 +62,7 @@ pub const WideGlyph = extern struct {
6262 },
6363 glyph_col_1: [19]u8,
6464 glyph_col_2: [19]u8,
65 _pad: [3]u8,
65 _pad: [3]u8 = [_]u8{0} ** 3,
6666};
6767
6868pub const HIIStringPackage = extern struct {
lib/std/os/uefi/protocols/simple_network_protocol.zig+2-6
......@@ -126,9 +126,7 @@ pub const SimpleNetworkReceiveFilter = packed struct {
126126 receive_broadcast: bool,
127127 receive_promiscuous: bool,
128128 receive_promiscuous_multicast: bool,
129 _pad1: u3 = undefined,
130 _pad2: u8 = undefined,
131 _pad3: u16 = undefined,
129 _pad: u27 = 0,
132130};
133131
134132pub const SimpleNetworkState = enum(u32) {
......@@ -171,7 +169,5 @@ pub const SimpleNetworkInterruptStatus = packed struct {
171169 transmit_interrupt: bool,
172170 command_interrupt: bool,
173171 software_interrupt: bool,
174 _pad1: u4,
175 _pad2: u8,
176 _pad3: u16,
172 _pad: u28 = 0,
177173};
lib/std/os/uefi/protocols/simple_text_input_ex_protocol.zig+2-2
......@@ -64,14 +64,14 @@ pub const KeyState = extern struct {
6464 left_logo_pressed: bool,
6565 menu_key_pressed: bool,
6666 sys_req_pressed: bool,
67 _pad1: u21,
67 _pad: u21 = 0,
6868 shift_state_valid: bool,
6969 },
7070 key_toggle_state: packed struct {
7171 scroll_lock_active: bool,
7272 num_lock_active: bool,
7373 caps_lock_active: bool,
74 _pad1: u3,
74 _pad: u3 = 0,
7575 key_state_exposed: bool,
7676 toggle_state_valid: bool,
7777 },
lib/std/os/uefi/tables/boot_services.zig+1-3
......@@ -239,9 +239,7 @@ pub const OpenProtocolAttributes = packed struct {
239239 by_child_controller: bool = false,
240240 by_driver: bool = false,
241241 exclusive: bool = false,
242 _pad1: u2 = undefined,
243 _pad2: u8 = undefined,
244 _pad3: u16 = undefined,
242 _pad: u26 = 0,
245243};
246244
247245pub const ProtocolInformationEntry = extern struct {