authorgravatar for carmen@dotcarmen.devCarmen <carmen@dotcarmen.dev> 2025-04-02 22:58:17+02:00
committergravatar for mail@linusgroh.deLinus Groh <mail@linusgroh.de> 2025-04-04 12:42:28+01:00
log45afde2036fdacf5a5fc381acfad5982a4b84810
tree4b1f50225e6bb8d282ceab3dfb8538cfa5a99673
parent2112167f8c194271eac8536843d68c8aa72b487f

Payload -> @FieldType and use mem.sliceTo


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

lib/std/os/uefi/protocol/file.zig+5-7
...@@ -222,8 +222,8 @@ pub const File = extern struct {...@@ -222,8 +222,8 @@ pub const File = extern struct {
222 self: *const File,222 self: *const File,
223 comptime info: std.meta.Tag(Info),223 comptime info: std.meta.Tag(Info),
224 buffer: ?[]u8,224 buffer: ?[]u8,
225 ) GetInfoError!struct { usize, ?*std.meta.TagPayload(Info, info) } {225 ) GetInfoError!struct { usize, @FieldType(Info, @tagName(info)) } {
226 const InfoType = std.meta.TagPayload(Info, info);226 const InfoType = @FieldType(Info, @tagName(info));
227227
228 var len = if (buffer) |b| b.len else 0;228 var len = if (buffer) |b| b.len else 0;
229 switch (self._get_info(229 switch (self._get_info(
...@@ -245,17 +245,15 @@ pub const File = extern struct {...@@ -245,17 +245,15 @@ pub const File = extern struct {
245 pub fn setInfo(245 pub fn setInfo(
246 self: *File,246 self: *File,
247 comptime info: std.meta.Tag(Info),247 comptime info: std.meta.Tag(Info),
248 data: *const std.meta.TagPayload(Info, info),248 data: *const @FieldType(Info, @tagName(info)),
249 ) SetInfoError!void {249 ) SetInfoError!void {
250 const InfoType = std.meta.TagPayload(Info, info);250 const InfoType = @FieldType(Info, @tagName(info));
251251
252 var attached_str_len: usize = 0;
253 const attached_str: [*:0]const u16 = switch (info) {252 const attached_str: [*:0]const u16 = switch (info) {
254 .file => data.getFileName(),253 .file => data.getFileName(),
255 inline .file_system, .volume_label => data.getVolumeLabel(),254 inline .file_system, .volume_label => data.getVolumeLabel(),
256 };255 };
257256 const attached_str_len = std.mem.sliceTo(attached_str, 0).len;
258 while (attached_str[attached_str_len] != 0) : (attached_str_len += 1) {}
259257
260 // add the length (not +1 for sentinel) because `@sizeOf(InfoType)`258 // add the length (not +1 for sentinel) because `@sizeOf(InfoType)`
261 // already contains the first utf16 char259 // already contains the first utf16 char