mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-27 19:09:47 +03:00
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>
This commit is contained in:
committed by
Alex Rønne Petersen
parent
1655a666d5
commit
06cf86abeb
@@ -235,9 +235,7 @@ pub const BootServices = extern struct {
|
||||
InvalidParameter,
|
||||
};
|
||||
|
||||
pub const NumHandlesError = uefi.UnexpectedError || error{
|
||||
OutOfResources,
|
||||
};
|
||||
pub const NumHandlesError = uefi.UnexpectedError;
|
||||
|
||||
pub const LocateHandleError = uefi.UnexpectedError || error{
|
||||
BufferTooSmall,
|
||||
@@ -702,8 +700,17 @@ pub const BootServices = extern struct {
|
||||
&len,
|
||||
null,
|
||||
)) {
|
||||
.success => return @divExact(len, @sizeOf(Handle)),
|
||||
.out_of_resources => return error.OutOfResources,
|
||||
// If len is zero, it should return not_found, otherwise buffer_too_small.
|
||||
// This is because it can/should only return success when a valid buffer is
|
||||
// passed with a non zero size, which is not the case.
|
||||
// Thus this status is considered unreachable and will return error.Unexpected
|
||||
// .success => unreachable,
|
||||
.buffer_too_small => return @divExact(len, @sizeOf(uefi.Handle)),
|
||||
.not_found => return 0,
|
||||
// This function accounts for all possible causes of this error code
|
||||
// as per the most recent UEFI spec 2.10A, therefore this branch is
|
||||
// considered unreachable and will return error.Unexpected instead
|
||||
// .invalid_parameter => unreachable
|
||||
else => |status| return uefi.unexpectedStatus(status),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user