zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit b4c86c850d5fa6c0944549cd0209b333f9f6b004 (tree)
parent f186809caf3a14cbfbe6778f946c8597ebe7d561
Author: jsentity <jsentity@noreply.codeberg.org>
Date:   Mon, 26 Jan 2026 11:41:22 +0100

Fix std.uefi.protocol.DevicePath.next() and add utility function isEnd() (#30887)

Fix for https://codeberg.org/ziglang/zig/issues/30884 and https://codeberg.org/ziglang/zig/issues/30885

Co-authored-by: jsentity <jsentity@noreply.codeberg.org>
Co-committed-by: jsentity <jsentity@noreply.codeberg.org>

Diffstat:
Mlib/std/os/uefi/protocol/device_path.zig | 8+++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/lib/std/os/uefi/protocol/device_path.zig b/lib/std/os/uefi/protocol/device_path.zig @@ -26,12 +26,10 @@ pub const DevicePath = extern struct { /// Returns the next DevicePath node in the sequence, if any. pub fn next(self: *const DevicePath) ?*const DevicePath { + const subtype: uefi.DevicePath.End.Subtype = @enumFromInt(self.subtype); + if (self.type == .end and subtype == .end_entire) return null; const bytes: [*]const u8 = @ptrCast(self); - const next_node: *const DevicePath = @ptrCast(bytes + self.length); - if (next_node.type == .end and @as(uefi.DevicePath.End.Subtype, @enumFromInt(next_node.subtype)) == .end_entire) - return null; - - return next_node; + return @ptrCast(bytes + self.length); } /// Calculates the total length of the device path structure in bytes, including the end of device path node.