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 {
222222 self: *const File,
223223 comptime info: std.meta.Tag(Info),
224224 buffer: ?[]u8,
225 ) GetInfoError!struct { usize, ?*std.meta.TagPayload(Info, info) } {
226 const InfoType = std.meta.TagPayload(Info, info);
225 ) GetInfoError!struct { usize, @FieldType(Info, @tagName(info)) } {
226 const InfoType = @FieldType(Info, @tagName(info));
227227
228228 var len = if (buffer) |b| b.len else 0;
229229 switch (self._get_info(
......@@ -245,17 +245,15 @@ pub const File = extern struct {
245245 pub fn setInfo(
246246 self: *File,
247247 comptime info: std.meta.Tag(Info),
248 data: *const std.meta.TagPayload(Info, info),
248 data: *const @FieldType(Info, @tagName(info)),
249249 ) 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;
253252 const attached_str: [*:0]const u16 = switch (info) {
254253 .file => data.getFileName(),
255254 inline .file_system, .volume_label => data.getVolumeLabel(),
256255 };
257
258 while (attached_str[attached_str_len] != 0) : (attached_str_len += 1) {}
256 const attached_str_len = std.mem.sliceTo(attached_str, 0).len;
259257
260258 // add the length (not +1 for sentinel) because `@sizeOf(InfoType)`
261259 // already contains the first utf16 char