Skip to content

Commit 0733531

Browse files
committed
more work
1 parent 40394f2 commit 0733531

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

Diff for: lib/std/os/uefi/tables/boot_services.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ pub const BootServices = extern struct {
657657
return self.openProtocol(
658658
Protocol,
659659
handle,
660-
uefi.handle orelse return error.Unexpected,
660+
uefi.handle,
661661
null,
662662
.{ .by_handle_protocol = true },
663663
) catch |err| switch (err) {

Diff for: lib/std/os/uefi/tables/runtime_services.zig

+11-10
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ pub const RuntimeServices = extern struct {
245245
}
246246
}
247247

248+
/// Returns the length of the variable's data and its attributes.
248249
pub fn getVariableSize(
249250
self: *const RuntimeServices,
250251
name: [*:0]const u16,
@@ -276,7 +277,7 @@ pub const RuntimeServices = extern struct {
276277
name: [*:0]const u16,
277278
guid: *align(8) const Guid,
278279
buffer: []u8,
279-
) GetVariableError!struct { []u8, VariableAttributes } {
280+
) GetVariableError!?struct { []u8, VariableAttributes } {
280281
var attrs: VariableAttributes = undefined;
281282
var len = buffer.len;
282283

@@ -514,48 +515,48 @@ pub const RuntimeServices = extern struct {
514515
};
515516

516517
pub const VariableNameIterator = struct {
517-
pub const IterateVariableNameError = uefi.UnexpectedError || error{
518-
BufferTooSmall,
518+
pub const NextSizeError = uefi.UnexpectedError || error{
519519
DeviceError,
520520
Unsupported,
521521
};
522522

523-
pub const SizeOkError = uefi.UnexpectedError || error{
524-
DeviceError,
525-
Unsupported,
523+
pub const IterateVariableNameError = NextSizeError || error{
524+
BufferTooSmall,
525+
NotFound,
526526
};
527527

528528
services: *const RuntimeServices,
529529
buffer: []u16,
530530
guid: Guid,
531531

532-
pub fn sizeOk(self: *const VariableNameIterator) !bool {
532+
pub fn nextSize(self: *const VariableNameIterator) NextSizeError!?usize {
533533
var len: usize = 0;
534534
switch (self.services._getNextVariableName(
535535
&len,
536536
null,
537537
&self.guid,
538538
)) {
539539
.success, .buffer_too_small => return len,
540+
.not_found => return null,
540541
.device_error => return Error.DeviceError,
541542
.unsupported => return Error.Unsupported,
542543
else => |status| return uefi.unexpectedStatus(status),
543544
}
544545
}
545546

546-
/// Call `sizeOk` to ensure that `buffer` is large enough to hold the next
547+
/// Call `nextSize` to ensure that `buffer` is large enough to hold the next
547548
/// variable name.
548549
pub fn next(
549550
self: *VariableNameIterator,
550-
) IterateVariableNameError!?[:0]const u16 {
551+
) IterateVariableNameError![:0]const u16 {
551552
var len = self.buffer.len;
552553
switch (self.services._getNextVariableName(
553554
&len,
554555
@ptrCast(self.buffer.ptr),
555556
&self.guid,
556557
)) {
557558
.success => return self.buffer[0..len],
558-
.not_found => return null,
559+
.not_found => return Error.NotFound,
559560
.buffer_too_small => return Error.BufferTooSmall,
560561
.device_error => return Error.DeviceError,
561562
.unsupported => return Error.Unsupported,

0 commit comments

Comments
 (0)