authorgravatar for entity@jsentity.devjust_some_entity <entity@jsentity.dev> 2026-01-27 23:09:51+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-01-27 23:09:51+01:00
log06cf86abeb3a062c6c3e21f4379c7fea9e6d71b6
treed012d7be5a6a7d0dcc7e33b6dd5549331ca504e7
parent1655a666d5695ac974e107233a90a75eebe5fc2f

Fix BootServices.locateHandleLen() (#30877)

Fixes https://codeberg.org/ziglang/zig/issues/30876 Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30877 Reviewed-by: linus <mail@linusgroh.de> Co-authored-by: just_some_entity <entity@jsentity.dev> Co-committed-by: just_some_entity <entity@jsentity.dev>

1 files changed, 12 insertions(+), 5 deletions(-)

lib/std/os/uefi/tables/boot_services.zig+12-5
...@@ -235,9 +235,7 @@ pub const BootServices = extern struct {...@@ -235,9 +235,7 @@ pub const BootServices = extern struct {
235 InvalidParameter,235 InvalidParameter,
236 };236 };
237237
238 pub const NumHandlesError = uefi.UnexpectedError || error{238 pub const NumHandlesError = uefi.UnexpectedError;
239 OutOfResources,
240 };
241239
242 pub const LocateHandleError = uefi.UnexpectedError || error{240 pub const LocateHandleError = uefi.UnexpectedError || error{
243 BufferTooSmall,241 BufferTooSmall,
...@@ -702,8 +700,17 @@ pub const BootServices = extern struct {...@@ -702,8 +700,17 @@ pub const BootServices = extern struct {
702 &len,700 &len,
703 null,701 null,
704 )) {702 )) {
705 .success => return @divExact(len, @sizeOf(Handle)),703 // If len is zero, it should return not_found, otherwise buffer_too_small.
706 .out_of_resources => return error.OutOfResources,704 // This is because it can/should only return success when a valid buffer is
705 // passed with a non zero size, which is not the case.
706 // Thus this status is considered unreachable and will return error.Unexpected
707 // .success => unreachable,
708 .buffer_too_small => return @divExact(len, @sizeOf(uefi.Handle)),
709 .not_found => return 0,
710 // This function accounts for all possible causes of this error code
711 // as per the most recent UEFI spec 2.10A, therefore this branch is
712 // considered unreachable and will return error.Unexpected instead
713 // .invalid_parameter => unreachable
707 else => |status| return uefi.unexpectedStatus(status),714 else => |status| return uefi.unexpectedStatus(status),
708 }715 }
709 }716 }