commit 45afde2036fdacf5a5fc381acfad5982a4b84810 (tree)
parent 2112167f8c194271eac8536843d68c8aa72b487f
Author: Carmen <carmen@dotcarmen.dev>
Date: Wed, 2 Apr 2025 22:58:17 +0200
Payload -> @FieldType and use mem.sliceTo
Diffstat:
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/lib/std/os/uefi/protocol/file.zig b/lib/std/os/uefi/protocol/file.zig
@@ -222,8 +222,8 @@ pub const File = extern struct {
self: *const File,
comptime info: std.meta.Tag(Info),
buffer: ?[]u8,
- ) GetInfoError!struct { usize, ?*std.meta.TagPayload(Info, info) } {
- const InfoType = std.meta.TagPayload(Info, info);
+ ) GetInfoError!struct { usize, @FieldType(Info, @tagName(info)) } {
+ const InfoType = @FieldType(Info, @tagName(info));
var len = if (buffer) |b| b.len else 0;
switch (self._get_info(
@@ -245,17 +245,15 @@ pub const File = extern struct {
pub fn setInfo(
self: *File,
comptime info: std.meta.Tag(Info),
- data: *const std.meta.TagPayload(Info, info),
+ data: *const @FieldType(Info, @tagName(info)),
) SetInfoError!void {
- const InfoType = std.meta.TagPayload(Info, info);
+ const InfoType = @FieldType(Info, @tagName(info));
- var attached_str_len: usize = 0;
const attached_str: [*:0]const u16 = switch (info) {
.file => data.getFileName(),
inline .file_system, .volume_label => data.getVolumeLabel(),
};
-
- while (attached_str[attached_str_len] != 0) : (attached_str_len += 1) {}
+ const attached_str_len = std.mem.sliceTo(attached_str, 0).len;
// add the length (not +1 for sentinel) because `@sizeOf(InfoType)`
// already contains the first utf16 char